Skip to content

Commit

Permalink
update periphery (#424)
Browse files Browse the repository at this point in the history
* update periphery not working

* fix ur according to periphery update

* prettier

* fix issue during hardhat tests fixed in version 2.22.14

* change optimizer size

* change optimizer runs for manager only

* update again

* prettier

* update periphery again

* switch runs to 30000

---------

Co-authored-by: gretzke <[email protected]>
  • Loading branch information
dianakocsis and gretzke authored Dec 3, 2024
1 parent 5aefc7e commit a029362
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 215 deletions.
10 changes: 9 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ via_ir = true
solc_version = '0.8.26'
evm_version = "cancun"

optimizer_runs = 1_000_000
optimizer_runs = 44444444
fs_permissions = [{ access = "read", path = "./script/deployParameters/"}]

additional_compiler_profiles = [
{ name = "manager", via_ir = true, optimizer_runs = 30000 },
]

compilation_restrictions = [
{ paths = "lib/v4-periphery/src/PositionManager.sol", optimizer_runs = 30000 },
]

[fmt]
line_length = 120
quote_style = 'single'
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_COMPILER_SETTINGS = {
evmVersion: 'cancun',
optimizer: {
enabled: true,
runs: 1_000_000,
runs: 1,
},
metadata: {
bytecodeHash: 'none',
Expand Down
2 changes: 1 addition & 1 deletion lib/v4-periphery
Submodule v4-periphery updated 181 files
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"bignumber.js": "^9.0.0",
"chai": "^4.3.4",
"ethers": "^5.7.2",
"hardhat": "2.22.5",
"hardhat": "2.22.14",
"hardhat-typechain": "^0.3.5",
"mocha-chai-jest-snapshot": "^1.1.0",
"prettier": "^2.0.5",
Expand Down
60 changes: 40 additions & 20 deletions test/integration-tests/UniswapV4.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])
planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

const { usdcBalanceBefore, usdcBalanceAfter, wethBalanceBefore, wethBalanceAfter } = await executeRouter(
Expand All @@ -164,7 +165,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -192,7 +194,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -222,7 +225,8 @@ describe('Uniswap V4 Tests:', () => {
])
// take 1% of the output to alice, then settle and take the rest to the caller
v4Planner.addAction(Actions.TAKE_PORTION, [WETH.address, alice.address, ONE_PERCENT_BIPS])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -303,7 +307,8 @@ describe('Uniswap V4 Tests:', () => {
])
// take 1% of the output to alice, then settle and take the rest to the caller
v4Planner.addAction(Actions.TAKE_PORTION, [ETH_ADDRESS, alice.address, ONE_PERCENT_BIPS])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, ETH_ADDRESS])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [ETH_ADDRESS, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -338,7 +343,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -366,7 +372,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInUSDC,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -394,7 +401,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInDAI,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [daiContract.address, wethContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [daiContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [wethContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -423,7 +431,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [ETH_ADDRESS, usdcContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [ETH_ADDRESS, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [usdcContract.address, 0])
planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

const { usdcBalanceBefore, usdcBalanceAfter, ethBalanceBefore, ethBalanceAfter, gasSpent } = await executeRouter(
Expand Down Expand Up @@ -452,7 +461,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutUSDC,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, usdcContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [usdcContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -482,7 +492,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutDAI,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, daiContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [daiContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -512,7 +523,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [ETH_ADDRESS, usdcContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [ETH_ADDRESS, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [usdcContract.address, 0])
planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])
// sweep excess ETH leftover back to the caller!
planner.addCommand(CommandType.SWEEP, [ETH_ADDRESS, MSG_SENDER, 0])
Expand Down Expand Up @@ -544,7 +556,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [ETH_ADDRESS, currencyOut])
v4Planner.addAction(Actions.SETTLE_ALL, [ETH_ADDRESS, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [currencyOut, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])
// sweep excess ETH leftover back to the caller!
Expand Down Expand Up @@ -577,7 +590,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [ETH_ADDRESS, daiContract.address])
v4Planner.addAction(Actions.SETTLE_ALL, [ETH_ADDRESS, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [daiContract.address, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])
// sweep excess ETH leftover back to the caller!
Expand Down Expand Up @@ -612,7 +626,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, ETH_ADDRESS])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [ETH_ADDRESS, 0])
planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

const { usdcBalanceBefore, usdcBalanceAfter, ethBalanceBefore, ethBalanceAfter, gasSpent } = await executeRouter(
Expand Down Expand Up @@ -640,7 +655,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, ETH_ADDRESS])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [ETH_ADDRESS, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -669,7 +685,8 @@ describe('Uniswap V4 Tests:', () => {
amountOutMinimum: minAmountOutNative,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [currencyIn, ETH_ADDRESS])
v4Planner.addAction(Actions.SETTLE_ALL, [currencyIn, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [ETH_ADDRESS, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -698,7 +715,8 @@ describe('Uniswap V4 Tests:', () => {
hookData: '0x',
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, ETH_ADDRESS])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [ETH_ADDRESS, 0])
planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

const { usdcBalanceBefore, usdcBalanceAfter, ethBalanceBefore, ethBalanceAfter, gasSpent } = await executeRouter(
Expand Down Expand Up @@ -726,7 +744,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInUSDC,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [usdcContract.address, currencyOut])
v4Planner.addAction(Actions.SETTLE_ALL, [usdcContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [currencyOut, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down Expand Up @@ -755,7 +774,8 @@ describe('Uniswap V4 Tests:', () => {
amountInMaximum: maxAmountInDAI,
},
])
v4Planner.addAction(Actions.SETTLE_TAKE_PAIR, [daiContract.address, currencyOut])
v4Planner.addAction(Actions.SETTLE_ALL, [daiContract.address, MAX_UINT])
v4Planner.addAction(Actions.TAKE_ALL, [currencyOut, 0])

planner.addCommand(CommandType.V4_SWAP, [v4Planner.actions, v4Planner.params])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
encodeCollect,
encodeBurn,
encodeModifyLiquidities,
encodeInitializePool,
} from '../shared/encodeCall'
const { ethers } = hre
import { USDC_WETH, ETH_USDC } from '../shared/v4Helpers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
exports[`Check Ownership Gas gas: balance check ERC20 1`] = `
Object {
"calldataByteLength": 356,
"gasUsed": 37740,
"gasUsed": 37977,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@
exports[`Payments Gas Tests Individual Command Tests gas: SWEEP with ERC20 1`] = `
Object {
"calldataByteLength": 356,
"gasUsed": 37042,
"gasUsed": 37271,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: SWEEP_WITH_FEE 1`] = `
Object {
"calldataByteLength": 516,
"gasUsed": 65786,
"gasUsed": 66087,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: TRANSFER with ERC20 1`] = `
Object {
"calldataByteLength": 356,
"gasUsed": 36070,
"gasUsed": 36289,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: TRANSFER with ETH 1`] = `
Object {
"calldataByteLength": 356,
"gasUsed": 31635,
"gasUsed": 31842,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: UNWRAP_WETH 1`] = `
Object {
"calldataByteLength": 324,
"gasUsed": 44621,
"gasUsed": 44903,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: UNWRAP_WETH_WITH_FEE 1`] = `
Object {
"calldataByteLength": 644,
"gasUsed": 51108,
"gasUsed": 51466,
}
`;

exports[`Payments Gas Tests Individual Command Tests gas: WRAP_ETH 1`] = `
Object {
"calldataByteLength": 324,
"gasUsed": 53423,
"gasUsed": 53634,
}
`;
Loading

0 comments on commit a029362

Please sign in to comment.