diff --git a/lib/sphinx b/lib/sphinx index 5fb24a8..97885f0 160000 --- a/lib/sphinx +++ b/lib/sphinx @@ -1 +1 @@ -Subproject commit 5fb24a825f46bd6ae0b5359fe0da1d2346126b09 +Subproject commit 97885f07476808154864abdc8ea961e6163054d0 diff --git a/package-lock.json b/package-lock.json index 94de5cf..b14bd5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.16", "license": "MIT", "dependencies": { - "@bananapus/core": "^0.0.23", + "@bananapus/core": "^0.0.24", "@bananapus/permission-ids": "^0.0.11", "@exhausted-pigeon/uniswap-v3-forge-quoter": "^1.0.1", "@openzeppelin/contracts": "^5.0.2", @@ -238,9 +238,9 @@ } }, "node_modules/@bananapus/core": { - "version": "0.0.23", - "resolved": "https://registry.npmjs.org/@bananapus/core/-/core-0.0.23.tgz", - "integrity": "sha512-VV/NeJHdzB1PxV32uNYDWA2n287ZUFCE9dmKga1LaSNOa8BP/kWe3NYhcfR9KcWpHxB7vJTT7erDNXiwYx21sQ==", + "version": "0.0.24", + "resolved": "https://registry.npmjs.org/@bananapus/core/-/core-0.0.24.tgz", + "integrity": "sha512-T2780FbyIT5fum6H6GNPZyYjK/Jb1oGagN1alkJgiRooHsBByJGqSZGmPzz1mND+RoBEqfZmG2weHHoLV+Z55Q==", "dependencies": { "@bananapus/permission-ids": "^0.0.11", "@chainlink/contracts": "^1.1.1", diff --git a/package.json b/package.json index 724a2c1..9f36aac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bananapus/buyback-hook", - "version": "0.0.16", + "version": "0.0.17", "license": "MIT", "repository": { "type": "git", @@ -18,7 +18,7 @@ "artifacts": "source ./.env && npx sphinx artifacts --org-id 'my-org-id' --project-name 'nana-buyback-hook-testnet'" }, "dependencies": { - "@bananapus/core": "^0.0.23", + "@bananapus/core": "^0.0.24", "@bananapus/permission-ids": "^0.0.11", "@exhausted-pigeon/uniswap-v3-forge-quoter": "^1.0.1", "@openzeppelin/contracts": "^5.0.2", @@ -28,4 +28,4 @@ "devDependencies": { "@sphinx-labs/plugins": "^0.33.0" } -} +} \ No newline at end of file diff --git a/src/JBBuybackHook.sol b/src/JBBuybackHook.sol index a7d3d98..126b5a1 100644 --- a/src/JBBuybackHook.sol +++ b/src/JBBuybackHook.sol @@ -352,7 +352,7 @@ contract JBBuybackHook is JBPermissioned, IJBBuybackHook { tokenCount: exactSwapAmountOut + partialMintTokenCount, beneficiary: address(context.beneficiary), memo: "", - useReservedRate: true + useReservedPercent: true }); } diff --git a/test/Fork.t.sol b/test/Fork.t.sol index 784d053..cdb4ef9 100644 --- a/test/Fork.t.sol +++ b/test/Fork.t.sol @@ -265,7 +265,7 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // * // // * @dev Should swap for both beneficiary and reserve (by burning/minting) // // */ -// // function test_swapIfQuoteBetter(uint256 _weight, uint256 _amountIn, uint256 _reservedRate) public { +// // function test_swapIfQuoteBetter(uint256 _weight, uint256 _amountIn, uint256 _reservedPercent) public { // // _amountIn = bound(_amountIn, 100, 100 ether); // // uint256 _amountOutQuoted = getAmountOut(pool, _amountIn, address(weth)); @@ -273,9 +273,9 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // // Reconfigure with a weight smaller than the price implied by the quote // // _weight = bound(_weight, 1, (_amountOutQuoted * 10 ** 18 / _amountIn) - 1); -// // _reservedRate = bound(_reservedRate, 0, 10_000); +// // _reservedPercent = bound(_reservedPercent, 0, 10_000); -// // _reconfigure(1, address(delegate), _weight, _reservedRate); +// // _reconfigure(1, address(delegate), _weight, _reservedPercent); // // uint256 _reservedBalanceBefore = jbController.reservedTokenBalanceOf(1); @@ -314,7 +314,7 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // // Check: token received by the beneficiary // // assertApproxEqAbs( // // jbx.balanceOf(beneficiary) - _balBeforePayment, -// // _amountOutQuoted - (_amountOutQuoted * _reservedRate / 10_000), +// // _amountOutQuoted - (_amountOutQuoted * _reservedPercent / 10_000), // // 1, // // "wrong balance" // // ); @@ -322,7 +322,7 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // // Check: token added to the reserve - 1 wei sensitivity for rounding errors // // assertApproxEqAbs( // // jbController.reservedTokenBalanceOf(1), -// // _reservedBalanceBefore + _amountOutQuoted * _reservedRate / 10_000, +// // _reservedBalanceBefore + _amountOutQuoted * _reservedPercent / 10_000, // // 1, // // "wrong reserve" // // ); @@ -468,13 +468,13 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // * // // * @dev Should swap for both beneficiary and reserve (by burning/minting) // // */ -// // function test_swapWhenQuoteNotProvidedInMetadata(uint256 _amountIn, uint256 _reservedRate) public { +// // function test_swapWhenQuoteNotProvidedInMetadata(uint256 _amountIn, uint256 _reservedPercent) public { // // _amountIn = bound(_amountIn, 10, 10 ether); -// // _reservedRate = bound(_reservedRate, 0, 10_000); +// // _reservedPercent = bound(_reservedPercent, 0, 10_000); // // uint256 _weight = 10 ether; -// // _reconfigure(1, address(delegate), _weight, _reservedRate); +// // _reconfigure(1, address(delegate), _weight, _reservedPercent); // // uint256 _reservedBalanceBefore = jbController.reservedTokenBalanceOf(1); @@ -511,18 +511,19 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // // 1 wei sensitivity for rounding errors // // if (_twap > _tokenCount) { // // // Path is picked based on twap, but the token received are the one quoted -// // assertApproxEqAbs(_tokenReceived, _quote - (_quote * _reservedRate) / 10_000, 1, "wrong swap"); +// // assertApproxEqAbs(_tokenReceived, _quote - (_quote * _reservedPercent) / 10_000, 1, "wrong swap"); // // assertApproxEqAbs( // // jbController.reservedTokenBalanceOf(1), -// // _reservedBalanceBefore + (_quote * _reservedRate) / 10_000, +// // _reservedBalanceBefore + (_quote * _reservedPercent) / 10_000, // // 1, // // "Reserve" // // ); // // } else { -// // assertApproxEqAbs(_tokenReceived, _tokenCount - (_tokenCount * _reservedRate) / 10_000, 1, "Wrong mint"); +// // assertApproxEqAbs(_tokenReceived, _tokenCount - (_tokenCount * _reservedPercent) / 10_000, 1, "Wrong +// mint"); // // assertApproxEqAbs( // // jbController.reservedTokenBalanceOf(1), -// // _reservedBalanceBefore + (_tokenCount * _reservedRate) / 10_000, +// // _reservedBalanceBefore + (_tokenCount * _reservedPercent) / 10_000, // // 1, // // "Reserve" // // ); @@ -676,7 +677,7 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // // ); // // } -// function _reconfigure(uint256 _projectId, address _delegate, uint256 _weight, uint256 _reservedRate) internal { +// function _reconfigure(uint256 _projectId, address _delegate, uint256 _weight, uint256 _reservedPercent) internal { // address _projectOwner = jbProjects.ownerOf(_projectId); // JBRuleset memory _fundingCycle = jbRulesets.currentOf(_projectId); @@ -696,7 +697,7 @@ contract TestJBBuybackHook_Fork is Test, UniswapV3ForgeQuoter { // metadata.useDataHookForPay = true; // metadata.dataHook = _delegate; -// metadata.reservedRate = _reservedRate; +// metadata.reservedPercent = _reservedPercent; // data.weight = _weight; // data.duration = 14 days; diff --git a/test/Unit.t.sol b/test/Unit.t.sol index e91d453..54b83f7 100644 --- a/test/Unit.t.sol +++ b/test/Unit.t.sol @@ -78,7 +78,7 @@ contract Test_BuybackHook_Unit is Test { rulesetId: 0, beneficiary: dude, weight: 69, - reservedRate: 0, + reservedPercent: 0, metadata: "" }); diff --git a/test/helpers/TestBaseWorkflowV3.sol b/test/helpers/TestBaseWorkflowV3.sol index a270f07..e70ad8c 100644 --- a/test/helpers/TestBaseWorkflowV3.sol +++ b/test/helpers/TestBaseWorkflowV3.sol @@ -63,7 +63,7 @@ contract TestBaseWorkflowV3 is Test { JBBuybackHook hook; uint256 projectId; - uint16 reservedRate = 4500; + uint16 reservedPercent = 4500; uint112 weight = 10 ether; // Minting 10 token per eth uint32 cardinality = 1000; uint256 twapDelta = 500; @@ -170,7 +170,7 @@ contract TestBaseWorkflowV3 is Test { // Ruleset metadata: use the hook for payments. metadata = JBRulesetMetadata({ - reservedRate: reservedRate, + reservedPercent: reservedPercent, redemptionRate: 5000, baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)), pausePay: false, @@ -210,7 +210,7 @@ contract TestBaseWorkflowV3 is Test { rulesetConfigurations[0].mustStartAtOrAfter = 0; rulesetConfigurations[0].duration = 6 days; rulesetConfigurations[0].weight = weight; - rulesetConfigurations[0].decayRate = 0; + rulesetConfigurations[0].decayPercent = 0; rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0)); rulesetConfigurations[0].metadata = metadata;