Skip to content

Commit

Permalink
Merge pull request #31 from cowprotocol/include-fees
Browse files Browse the repository at this point in the history
Include fees + File for checking final ETH slippage for single tx hash
  • Loading branch information
harisang authored Aug 23, 2024
2 parents e14cbcf + 852b699 commit 15cf06d
Show file tree
Hide file tree
Showing 8 changed files with 1,047 additions and 2 deletions.
389 changes: 389 additions & 0 deletions contracts/gpv2_settlement_abi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,389 @@
"""Contract ABI of the CoW Protocol settlement contract
"""

gpv2_settlement_abi = [
{
"inputs": [
{
"internalType": "contract GPv2Authentication",
"name": "authenticator_",
"type": "address",
},
{"internalType": "contract IVault", "name": "vault_", "type": "address"},
],
"stateMutability": "nonpayable",
"type": "constructor",
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "target",
"type": "address",
},
{
"indexed": False,
"internalType": "uint256",
"name": "value",
"type": "uint256",
},
{
"indexed": False,
"internalType": "bytes4",
"name": "selector",
"type": "bytes4",
},
],
"name": "Interaction",
"type": "event",
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "owner",
"type": "address",
},
{
"indexed": False,
"internalType": "bytes",
"name": "orderUid",
"type": "bytes",
},
],
"name": "OrderInvalidated",
"type": "event",
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "owner",
"type": "address",
},
{
"indexed": False,
"internalType": "bytes",
"name": "orderUid",
"type": "bytes",
},
{
"indexed": False,
"internalType": "bool",
"name": "signed",
"type": "bool",
},
],
"name": "PreSignature",
"type": "event",
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "solver",
"type": "address",
}
],
"name": "Settlement",
"type": "event",
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "owner",
"type": "address",
},
{
"indexed": False,
"internalType": "contract IERC20",
"name": "sellToken",
"type": "address",
},
{
"indexed": False,
"internalType": "contract IERC20",
"name": "buyToken",
"type": "address",
},
{
"indexed": False,
"internalType": "uint256",
"name": "sellAmount",
"type": "uint256",
},
{
"indexed": False,
"internalType": "uint256",
"name": "buyAmount",
"type": "uint256",
},
{
"indexed": False,
"internalType": "uint256",
"name": "feeAmount",
"type": "uint256",
},
{
"indexed": False,
"internalType": "bytes",
"name": "orderUid",
"type": "bytes",
},
],
"name": "Trade",
"type": "event",
},
{
"inputs": [],
"name": "authenticator",
"outputs": [
{
"internalType": "contract GPv2Authentication",
"name": "",
"type": "address",
}
],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "domainSeparator",
"outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [{"internalType": "bytes", "name": "", "type": "bytes"}],
"name": "filledAmount",
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [{"internalType": "bytes[]", "name": "orderUids", "type": "bytes[]"}],
"name": "freeFilledAmountStorage",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [{"internalType": "bytes[]", "name": "orderUids", "type": "bytes[]"}],
"name": "freePreSignatureStorage",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [
{"internalType": "uint256", "name": "offset", "type": "uint256"},
{"internalType": "uint256", "name": "length", "type": "uint256"},
],
"name": "getStorageAt",
"outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [{"internalType": "bytes", "name": "orderUid", "type": "bytes"}],
"name": "invalidateOrder",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [{"internalType": "bytes", "name": "", "type": "bytes"}],
"name": "preSignature",
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [
{"internalType": "bytes", "name": "orderUid", "type": "bytes"},
{"internalType": "bool", "name": "signed", "type": "bool"},
],
"name": "setPreSignature",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [
{
"internalType": "contract IERC20[]",
"name": "tokens",
"type": "address[]",
},
{
"internalType": "uint256[]",
"name": "clearingPrices",
"type": "uint256[]",
},
{
"components": [
{
"internalType": "uint256",
"name": "sellTokenIndex",
"type": "uint256",
},
{
"internalType": "uint256",
"name": "buyTokenIndex",
"type": "uint256",
},
{"internalType": "address", "name": "receiver", "type": "address"},
{
"internalType": "uint256",
"name": "sellAmount",
"type": "uint256",
},
{"internalType": "uint256", "name": "buyAmount", "type": "uint256"},
{"internalType": "uint32", "name": "validTo", "type": "uint32"},
{"internalType": "bytes32", "name": "appData", "type": "bytes32"},
{"internalType": "uint256", "name": "feeAmount", "type": "uint256"},
{"internalType": "uint256", "name": "flags", "type": "uint256"},
{
"internalType": "uint256",
"name": "executedAmount",
"type": "uint256",
},
{"internalType": "bytes", "name": "signature", "type": "bytes"},
],
"internalType": "struct GPv2Trade.Data[]",
"name": "trades",
"type": "tuple[]",
},
{
"components": [
{"internalType": "address", "name": "target", "type": "address"},
{"internalType": "uint256", "name": "value", "type": "uint256"},
{"internalType": "bytes", "name": "callData", "type": "bytes"},
],
"internalType": "struct GPv2Interaction.Data[][3]",
"name": "interactions",
"type": "tuple[][3]",
},
],
"name": "settle",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [
{"internalType": "address", "name": "targetContract", "type": "address"},
{"internalType": "bytes", "name": "calldataPayload", "type": "bytes"},
],
"name": "simulateDelegatecall",
"outputs": [{"internalType": "bytes", "name": "response", "type": "bytes"}],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [
{"internalType": "address", "name": "targetContract", "type": "address"},
{"internalType": "bytes", "name": "calldataPayload", "type": "bytes"},
],
"name": "simulateDelegatecallInternal",
"outputs": [{"internalType": "bytes", "name": "response", "type": "bytes"}],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [
{
"components": [
{"internalType": "bytes32", "name": "poolId", "type": "bytes32"},
{
"internalType": "uint256",
"name": "assetInIndex",
"type": "uint256",
},
{
"internalType": "uint256",
"name": "assetOutIndex",
"type": "uint256",
},
{"internalType": "uint256", "name": "amount", "type": "uint256"},
{"internalType": "bytes", "name": "userData", "type": "bytes"},
],
"internalType": "struct IVault.BatchSwapStep[]",
"name": "swaps",
"type": "tuple[]",
},
{
"internalType": "contract IERC20[]",
"name": "tokens",
"type": "address[]",
},
{
"components": [
{
"internalType": "uint256",
"name": "sellTokenIndex",
"type": "uint256",
},
{
"internalType": "uint256",
"name": "buyTokenIndex",
"type": "uint256",
},
{"internalType": "address", "name": "receiver", "type": "address"},
{
"internalType": "uint256",
"name": "sellAmount",
"type": "uint256",
},
{"internalType": "uint256", "name": "buyAmount", "type": "uint256"},
{"internalType": "uint32", "name": "validTo", "type": "uint32"},
{"internalType": "bytes32", "name": "appData", "type": "bytes32"},
{"internalType": "uint256", "name": "feeAmount", "type": "uint256"},
{"internalType": "uint256", "name": "flags", "type": "uint256"},
{
"internalType": "uint256",
"name": "executedAmount",
"type": "uint256",
},
{"internalType": "bytes", "name": "signature", "type": "bytes"},
],
"internalType": "struct GPv2Trade.Data",
"name": "trade",
"type": "tuple",
},
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
},
{
"inputs": [],
"name": "vault",
"outputs": [{"internalType": "contract IVault", "name": "", "type": "address"}],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "vaultRelayer",
"outputs": [
{"internalType": "contract GPv2VaultRelayer", "name": "", "type": "address"}
],
"stateMutability": "view",
"type": "function",
},
{"stateMutability": "payable", "type": "receive"},
]
2 changes: 2 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"0x83F20F44975D03b1b09e64809B757c47f942BEeA"
)

REQUEST_TIMEOUT = 5

# Time limit, currently set to 1 full day, after which Coingecko Token List is re-fetched (in seconds)
COINGECKO_TOKEN_LIST_RELOAD_TIME = 86400

Expand Down
Empty file added src/fees/__init__.py
Empty file.
Loading

0 comments on commit 15cf06d

Please sign in to comment.