Skip to content

Commit

Permalink
works with core
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Jul 18, 2024
1 parent 297dfef commit 65687b5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
24 changes: 17 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bananapus/buyback-hook",
"version": "0.0.13",
"version": "0.0.14",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -18,7 +18,7 @@
"artifacts": "source ./.env && npx sphinx artifacts --org-id 'cltepuu9u0003j58rjtbd0hvu' --project-name 'nana-buyback-hook-testnet'"
},
"dependencies": {
"@bananapus/core": "^0.0.20",
"@bananapus/core": "^0.0.21",
"@bananapus/permission-ids": "^0.0.10",
"@exhausted-pigeon/uniswap-v3-forge-quoter": "^1.0.1",
"@openzeppelin/contracts": "^5.0.2",
Expand Down
16 changes: 8 additions & 8 deletions test/Unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract Test_BuybackHook_Unit is Test {
uint256 weight,
uint256 swapOutCount,
uint256 amountIn,
uint256 decimals
uint8 decimals
)
public
{
Expand All @@ -156,7 +156,7 @@ contract Test_BuybackHook_Unit is Test {
amountIn = bound(amountIn, 1, beforePayRecordedContext.amount.value);

// The terminal token decimals.
decimals = bound(decimals, 1, 18);
decimals = uint8(bound(decimals, 1, 18));

// Calculate the number of project tokens that a direct payment of `amountIn` terminal tokens would yield.
uint256 tokenCount = mulDiv(amountIn, weight, 10 ** decimals);
Expand Down Expand Up @@ -633,15 +633,15 @@ contract Test_BuybackHook_Unit is Test {

/// @notice Test the `afterPayRecordedWith` function by swapping ERC-20 tokens for project tokens, ensuring that the
/// right number of project tokens are burned from the hook and minted to the beneficiary.
function test_afterPayRecordedWith_swapERC20(uint256 tokenCount, uint256 twapQuote, uint256 decimals) public {
function test_afterPayRecordedWith_swapERC20(uint256 tokenCount, uint256 twapQuote, uint8 decimals) public {
// Account for MSB as sign when casting to int256 later.
uint256 intMax = type(uint256).max / 2;

// Bound to avoid overflow and ensure that the swap quote exceeds the mint quote.
tokenCount = bound(tokenCount, 2, intMax - 1);
twapQuote = bound(twapQuote, tokenCount, intMax);

decimals = bound(decimals, 1, 18);
decimals = uint8(bound(decimals, 1, 18));

// Set up the context with the amount of ERC-20 tokens to swap and other information.
afterPayRecordedContext.amount =
Expand Down Expand Up @@ -819,7 +819,7 @@ contract Test_BuybackHook_Unit is Test {
function test_afterPayRecordedWith_ERC20SwapRevertWithoutQuote(
uint256 tokenCount,
uint256 weight,
uint256 decimals,
uint8 decimals,
uint256 extraMint
)
public
Expand All @@ -837,7 +837,7 @@ contract Test_BuybackHook_Unit is Test {
extraMint = bound(extraMint, 2, type(uint128).max);

// The number of decimals that the terminal token uses.
decimals = bound(decimals, 1, 18);
decimals = uint8(bound(decimals, 1, 18));

// Set up the context with the amount of ERC-20 tokens to use and other information.
afterPayRecordedContext.amount =
Expand Down Expand Up @@ -987,7 +987,7 @@ contract Test_BuybackHook_Unit is Test {
function test_afterPayRecordedWith_ETHSwapRevertWithoutQuote(
uint256 tokenCount,
uint256 weight,
uint256 decimals,
uint8 decimals,
uint256 extraMint
)
public
Expand All @@ -1005,7 +1005,7 @@ contract Test_BuybackHook_Unit is Test {
extraMint = bound(extraMint, 2, type(uint128).max);

// The number of decimals that the terminal token uses.
decimals = bound(decimals, 1, 18);
decimals = uint8(bound(decimals, 1, 18));

// Set up the context with the amount of ETH to use and other information.
afterPayRecordedContext.amount =
Expand Down
6 changes: 3 additions & 3 deletions test/helpers/TestBaseWorkflowV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ contract TestBaseWorkflowV3 is Test {
JBBuybackHook hook;

uint256 projectId;
uint256 reservedRate = 4500;
uint256 weight = 10 ether; // Minting 10 token per eth
uint16 reservedRate = 4500;
uint112 weight = 10 ether; // Minting 10 token per eth
uint32 cardinality = 1000;
uint256 twapDelta = 500;

Expand Down Expand Up @@ -197,7 +197,7 @@ contract TestBaseWorkflowV3 is Test {
JBCurrencyAmount[] memory surplusAllowances = new JBCurrencyAmount[](1);
payoutLimits[0] = JBCurrencyAmount({amount: 2 ether, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
surplusAllowances[0] =
JBCurrencyAmount({amount: type(uint232).max, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
JBCurrencyAmount({amount: type(uint224).max, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
fundAccessLimitGroups[0] = JBFundAccessLimitGroup({
terminal: address(jbMultiTerminal),
token: JBConstants.NATIVE_TOKEN,
Expand Down
4 changes: 2 additions & 2 deletions test/mock/MockSplitHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ contract MockSplitHook is ERC165, IJBSplitHook {
address(this),
1,
2,
JBTokenAmount(address(this), 1 ether, 10 ** 18, 0),
JBTokenAmount(address(this), 1 ether, 10 ** 18, 0),
JBTokenAmount({token: address(this), value: 1 ether, decimals: 18, currency: 0}),
JBTokenAmount({token: address(this), value: 1 ether, decimals: 18, currency: 0}),
1,
1,
address(this),
Expand Down

0 comments on commit 65687b5

Please sign in to comment.