Skip to content

Commit

Permalink
Make UniV3 VIP generic (to better support forks)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncancmt committed Apr 25, 2024
1 parent 75cf385 commit a16a1e3
Show file tree
Hide file tree
Showing 12 changed files with 548 additions and 435 deletions.
33 changes: 11 additions & 22 deletions chain_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
},
"etherscanApi": "https://api-sepolia.etherscan.io/api",
"uniV3": {
"factory": "0x0227628f3F023bb0B980b67D528571c95c6DaC1c",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x0227628f3F023bb0B980b67D528571c95c6DaC1c"
},
"makerPsm": {
"dai": "0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6"
Expand Down Expand Up @@ -54,8 +53,7 @@
},
"etherscanApi": "https://api.etherscan.io/api",
"uniV3": {
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
},
"makerPsm": {
"dai": "0x6B175474E89094C44Da98b954EedeAC495271d0F"
Expand Down Expand Up @@ -85,8 +83,7 @@
},
"etherscanApi": "https://api.polygonscan.com/api",
"uniV3": {
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -116,8 +113,7 @@
},
"etherscanApi": "https://api.basescan.org/api",
"uniV3": {
"factory": "0x33128a8fC17869897dcE68Ed026d694621f6FDfD",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x33128a8fC17869897dcE68Ed026d694621f6FDfD"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -147,8 +143,7 @@
},
"etherscanApi": "https://api-sepolia.basescan.org/api",
"uniV3": {
"factory": "0x0000000000000000000000000000000000000000",
"initHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
"factory": "0x0000000000000000000000000000000000000000"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -178,8 +173,7 @@
},
"etherscanApi": "https://api-optimistic.etherscan.io/api",
"uniV3": {
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -209,8 +203,7 @@
},
"etherscanApi": "https://api-sepolia-optimism.etherscan.io/api",
"uniV3": {
"factory": "0x0000000000000000000000000000000000000000",
"initHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
"factory": "0x0000000000000000000000000000000000000000"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -240,8 +233,7 @@
},
"etherscanApi": "https://api.arbiscan.io/api",
"uniV3": {
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -271,8 +263,7 @@
},
"etherscanApi": "https://api-sepolia.arbiscan.io/api",
"uniV3": {
"factory": "0x0000000000000000000000000000000000000000",
"initHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
"factory": "0x0000000000000000000000000000000000000000"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -302,8 +293,7 @@
},
"etherscanApi": "https://api.bscscan.com/api",
"uniV3": {
"factory": "0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down Expand Up @@ -333,8 +323,7 @@
},
"etherscanApi": "https://api.snowtrace.io/api",
"uniV3": {
"factory": "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD",
"initHash": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54"
"factory": "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD"
},
"makerPsm": {
"dai": "0x0000000000000000000000000000000000000000"
Expand Down
2 changes: 1 addition & 1 deletion sh/common_deploy_settler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nonce="$(cast abi-decode "$nonce_sig" "$(cast call --rpc-url "$rpc_url" "$safe_a
declare -r -i nonce

declare constructor_args
constructor_args="$(cast abi-encode 'constructor(address,bytes32,address)' "$(get_config uniV3.factory)" "$(get_config uniV3.initHash)" "$(get_config makerPsm.dai)")"
constructor_args="$(cast abi-encode 'constructor(address,address)' "$(get_config uniV3.factory)" "$(get_config makerPsm.dai)")"
declare -r constructor_args

declare initcode
Expand Down
2 changes: 1 addition & 1 deletion sh/deploy_new_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ declare -r upgrade_safe

# encode constructor arguments for Settler
declare constructor_args
constructor_args="$(cast abi-encode 'constructor(address,bytes32,address)' "$(get_config uniV3.factory)" "$(get_config uniV3.initHash)" "$(get_config makerPsm.dai)")"
constructor_args="$(cast abi-encode 'constructor(address,address)' "$(get_config uniV3.factory)" "$(get_config makerPsm.dai)")"
declare -r constructor_args

# set minimum gas price to (mostly for Arbitrum and BNB)
Expand Down
10 changes: 5 additions & 5 deletions src/Settler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ contract Settler is
// When you change this, you must make corresponding changes to
// `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set
// `constructor_args`.
constructor(address uniFactory, bytes32 poolInitCodeHash, address dai)
constructor(address uniFactory, address dai)
Permit2Payment()
Basic()
OtcOrderSettlement()
UniswapV3(uniFactory, poolInitCodeHash)
UniswapV3(uniFactory)
UniswapV2()
MakerPSM(dai)
CurveTricrypto()
Expand Down Expand Up @@ -174,7 +174,7 @@ contract Settler is
bytes memory sig
) = abi.decode(data, (address, uint256, bytes, ISignatureTransfer.PermitTransferFrom, bytes));

sellTokenForTokenToUniswapV3VIP(recipient, path, amountOutMin, permit, sig);
sellToUniswapV3VIP(recipient, path, amountOutMin, permit, sig);
}

function _curveTricryptoVIP(bytes calldata data) internal DANGEROUS_freeMemory {
Expand Down Expand Up @@ -296,7 +296,7 @@ contract Settler is
bytes memory path,
ISignatureTransfer.PermitTransferFrom memory permit
) = abi.decode(data, (address, uint256, bytes, ISignatureTransfer.PermitTransferFrom));
sellTokenForTokenToUniswapV3MetaTxn(recipient, path, amountOutMin, msgSender, permit, sig);
sellToUniswapV3MetaTxn(recipient, path, amountOutMin, msgSender, permit, sig);
}

function _metaTxnCurveTricryptoVIP(bytes calldata data, address msgSender, bytes calldata sig)
Expand Down Expand Up @@ -367,7 +367,7 @@ contract Settler is
(address recipient, uint256 bips, uint256 amountOutMin, bytes memory path) =
abi.decode(data, (address, uint256, uint256, bytes));

sellTokenForTokenToUniswapV3(recipient, path, bips, amountOutMin);
sellToUniswapV3(recipient, path, bips, amountOutMin);
} else if (action == ISettlerActions.UNISWAPV2.selector) {
(address recipient, address sellToken, address pool, uint8 swapInfo, uint256 bips, uint256 amountOutMin) =
abi.decode(data, (address, address, address, uint8, uint256, uint256));
Expand Down
4 changes: 2 additions & 2 deletions src/core/Permit2Payment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ abstract contract Permit2PaymentBase is AllowanceHolderContext, SettlerAbstract
bytes memory data,
uint32 selector,
function (bytes calldata) internal returns (bytes memory) callback
) internal override returns (bytes memory) {
) internal returns (bytes memory) {
TransientStorage.setOperatorAndCallback(target, selector, callback);
(bool success, bytes memory returndata) = target.call{value: value}(data);
success.maybeRevert(returndata);
Expand All @@ -215,7 +215,7 @@ abstract contract Permit2PaymentBase is AllowanceHolderContext, SettlerAbstract
bytes memory data,
uint32 selector,
function (bytes calldata) internal returns (bytes memory) callback
) internal override returns (bytes memory) {
) internal returns (bytes memory) {
TransientStorage.setCallback(selector, callback);
(bool success, bytes memory returndata) = target.call{value: value}(data);
success.maybeRevert(returndata);
Expand Down
16 changes: 0 additions & 16 deletions src/core/Permit2PaymentAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,13 @@ abstract contract Permit2PaymentAbstract is AbstractContext {
bytes memory sig
) internal virtual;

function _setOperatorAndCall(
address payable target,
uint256 value,
bytes memory data,
uint32 selector,
function (bytes calldata) internal returns (bytes memory) callback
) internal virtual returns (bytes memory);

function _setOperatorAndCall(
address target,
bytes memory data,
uint32 selector,
function (bytes calldata) internal returns (bytes memory) callback
) internal virtual returns (bytes memory);

function _setCallbackAndCall(
address payable target,
uint256 value,
bytes memory data,
uint32 selector,
function (bytes calldata) internal returns (bytes memory) callback
) internal virtual returns (bytes memory);

function _setCallbackAndCall(
address target,
bytes memory data,
Expand Down
Loading

0 comments on commit a16a1e3

Please sign in to comment.