UNPKG

@mean-finance/dca-v2-core

Version:

Core smart contracts of DCA v2 by mean.finance

1,192 lines (1,191 loc) 27.3 kB
{ "_format": "hh-sol-artifact-1", "contractName": "DCAHubSwapHandler", "sourceName": "contracts/DCAHub/DCAHubSwapHandler.sol", "abi": [ { "inputs": [], "name": "HighFee", "type": "error" }, { "inputs": [], "name": "HighPlatformFeeRatio", "type": "error" }, { "inputs": [], "name": "InvalidAllowedTokensInput", "type": "error" }, { "inputs": [], "name": "InvalidFee", "type": "error" }, { "inputs": [], "name": "InvalidInterval", "type": "error" }, { "inputs": [], "name": "InvalidMask", "type": "error" }, { "inputs": [], "name": "InvalidPairs", "type": "error" }, { "inputs": [], "name": "InvalidTokens", "type": "error" }, { "inputs": [], "name": "LiquidityNotReturned", "type": "error" }, { "inputs": [], "name": "NoSwapsToExecute", "type": "error" }, { "inputs": [], "name": "UnallowedToken", "type": "error" }, { "inputs": [], "name": "ZeroAddress", "type": "error" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "contract ITokenPriceOracle", "name": "oracle", "type": "address" } ], "name": "OracleSet", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address", "name": "account", "type": "address" } ], "name": "Paused", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint16", "name": "platformFeeRatio", "type": "uint16" } ], "name": "PlatformFeeRatioSet", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } ], "name": "RoleAdminChanged", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } ], "name": "RoleGranted", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } ], "name": "RoleRevoked", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint32", "name": "feeSet", "type": "uint32" } ], "name": "SwapFeeSet", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint32[]", "name": "swapIntervals", "type": "uint32[]" } ], "name": "SwapIntervalsAllowed", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint32[]", "name": "swapIntervals", "type": "uint32[]" } ], "name": "SwapIntervalsForbidden", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": true, "internalType": "address", "name": "rewardRecipient", "type": "address" }, { "indexed": true, "internalType": "address", "name": "callbackHandler", "type": "address" }, { "components": [ { "components": [ { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "reward", "type": "uint256" }, { "internalType": "uint256", "name": "toProvide", "type": "uint256" }, { "internalType": "uint256", "name": "platformFee", "type": "uint256" } ], "internalType": "struct IDCAHubSwapHandler.TokenInSwap[]", "name": "tokens", "type": "tuple[]" }, { "components": [ { "internalType": "address", "name": "tokenA", "type": "address" }, { "internalType": "address", "name": "tokenB", "type": "address" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenA", "type": "uint256" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioAToB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioBToA", "type": "uint256" }, { "internalType": "bytes1", "name": "intervalsInSwap", "type": "bytes1" } ], "internalType": "struct IDCAHubSwapHandler.PairInSwap[]", "name": "pairs", "type": "tuple[]" } ], "indexed": false, "internalType": "struct IDCAHubSwapHandler.SwapInfo", "name": "swapInformation", "type": "tuple" }, { "indexed": false, "internalType": "uint256[]", "name": "borrowed", "type": "uint256[]" }, { "indexed": false, "internalType": "uint32", "name": "fee", "type": "uint32" } ], "name": "Swapped", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address[]", "name": "tokens", "type": "address[]" }, { "indexed": false, "internalType": "bool[]", "name": "allowed", "type": "bool[]" } ], "name": "TokensAllowedUpdated", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address", "name": "account", "type": "address" } ], "name": "Unpaused", "type": "event" }, { "inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "IMMEDIATE_ROLE", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "MAX_FEE", "outputs": [ { "internalType": "uint32", "name": "", "type": "uint32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "MAX_PLATFORM_FEE_RATIO", "outputs": [ { "internalType": "uint16", "name": "", "type": "uint16" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "PLATFORM_WITHDRAW_ROLE", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "PRIVILEGED_SWAPPER_ROLE", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "TIME_LOCKED_ROLE", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }, { "internalType": "bytes1", "name": "", "type": "bytes1" }, { "internalType": "uint32", "name": "", "type": "uint32" } ], "name": "accumRatio", "outputs": [ { "internalType": "uint256", "name": "accumRatioAToB", "type": "uint256" }, { "internalType": "uint256", "name": "accumRatioBToA", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" } ], "name": "activeSwapIntervals", "outputs": [ { "internalType": "bytes1", "name": "", "type": "bytes1" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint32[]", "name": "_swapIntervals", "type": "uint32[]" } ], "name": "addSwapIntervalsToAllowedList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "allowedSwapIntervals", "outputs": [ { "internalType": "bytes1", "name": "", "type": "bytes1" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "allowedTokens", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address[]", "name": "_tokens", "type": "address[]" }, { "components": [ { "internalType": "uint8", "name": "indexTokenA", "type": "uint8" }, { "internalType": "uint8", "name": "indexTokenB", "type": "uint8" } ], "internalType": "struct IDCAHubSwapHandler.PairIndexes[]", "name": "_pairs", "type": "tuple[]" }, { "internalType": "bool", "name": "_calculatePrivilegedAvailability", "type": "bool" }, { "internalType": "bytes", "name": "_oracleData", "type": "bytes" } ], "name": "getNextSwapInfo", "outputs": [ { "components": [ { "components": [ { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "reward", "type": "uint256" }, { "internalType": "uint256", "name": "toProvide", "type": "uint256" }, { "internalType": "uint256", "name": "platformFee", "type": "uint256" } ], "internalType": "struct IDCAHubSwapHandler.TokenInSwap[]", "name": "tokens", "type": "tuple[]" }, { "components": [ { "internalType": "address", "name": "tokenA", "type": "address" }, { "internalType": "address", "name": "tokenB", "type": "address" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenA", "type": "uint256" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioAToB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioBToA", "type": "uint256" }, { "internalType": "bytes1", "name": "intervalsInSwap", "type": "bytes1" } ], "internalType": "struct IDCAHubSwapHandler.PairInSwap[]", "name": "pairs", "type": "tuple[]" } ], "internalType": "struct IDCAHubSwapHandler.SwapInfo", "name": "_swapInformation", "type": "tuple" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "role", "type": "bytes32" } ], "name": "getRoleAdmin", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" } ], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" } ], "name": "hasRole", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "oracle", "outputs": [ { "internalType": "contract ITokenPriceOracle", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "paused", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "platformBalance", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "platformFeeRatio", "outputs": [ { "internalType": "uint16", "name": "", "type": "uint16" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint32[]", "name": "_swapIntervals", "type": "uint32[]" } ], "name": "removeSwapIntervalsFromAllowedList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" } ], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" } ], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address[]", "name": "_tokens", "type": "address[]" }, { "internalType": "bool[]", "name": "_allowed", "type": "bool[]" } ], "name": "setAllowedTokens", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "contract ITokenPriceOracle", "name": "_oracle", "type": "address" } ], "name": "setOracle", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint16", "name": "_platformFeeRatio", "type": "uint16" } ], "name": "setPlatformFeeRatio", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint32", "name": "_swapFee", "type": "uint32" } ], "name": "setSwapFee", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" } ], "name": "supportsInterface", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address[]", "name": "_tokens", "type": "address[]" }, { "components": [ { "internalType": "uint8", "name": "indexTokenA", "type": "uint8" }, { "internalType": "uint8", "name": "indexTokenB", "type": "uint8" } ], "internalType": "struct IDCAHubSwapHandler.PairIndexes[]", "name": "_pairsToSwap", "type": "tuple[]" }, { "internalType": "address", "name": "_rewardRecipient", "type": "address" }, { "internalType": "address", "name": "_callbackHandler", "type": "address" }, { "internalType": "uint256[]", "name": "_borrow", "type": "uint256[]" }, { "internalType": "bytes", "name": "_callbackData", "type": "bytes" }, { "internalType": "bytes", "name": "_oracleData", "type": "bytes" } ], "name": "swap", "outputs": [ { "components": [ { "components": [ { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "reward", "type": "uint256" }, { "internalType": "uint256", "name": "toProvide", "type": "uint256" }, { "internalType": "uint256", "name": "platformFee", "type": "uint256" } ], "internalType": "struct IDCAHubSwapHandler.TokenInSwap[]", "name": "tokens", "type": "tuple[]" }, { "components": [ { "internalType": "address", "name": "tokenA", "type": "address" }, { "internalType": "address", "name": "tokenB", "type": "address" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenA", "type": "uint256" }, { "internalType": "uint256", "name": "totalAmountToSwapTokenB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioAToB", "type": "uint256" }, { "internalType": "uint256", "name": "ratioBToA", "type": "uint256" }, { "internalType": "bytes1", "name": "intervalsInSwap", "type": "bytes1" } ], "internalType": "struct IDCAHubSwapHandler.PairInSwap[]", "name": "pairs", "type": "tuple[]" } ], "internalType": "struct IDCAHubSwapHandler.SwapInfo", "name": "_swapInformation", "type": "tuple" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }, { "internalType": "bytes1", "name": "", "type": "bytes1" }, { "internalType": "uint32", "name": "", "type": "uint32" } ], "name": "swapAmountDelta", "outputs": [ { "internalType": "uint128", "name": "swapDeltaAToB", "type": "uint128" }, { "internalType": "uint128", "name": "swapDeltaBToA", "type": "uint128" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }, { "internalType": "bytes1", "name": "", "type": "bytes1" } ], "name": "swapData", "outputs": [ { "internalType": "uint32", "name": "performedSwaps", "type": "uint32" }, { "internalType": "uint224", "name": "nextAmountToSwapAToB", "type": "uint224" }, { "internalType": "uint32", "name": "lastSwappedAt", "type": "uint32" }, { "internalType": "uint224", "name": "nextAmountToSwapBToA", "type": "uint224" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "swapFee", "outputs": [ { "internalType": "uint32", "name": "", "type": "uint32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "tokenMagnitude", "outputs": [ { "internalType": "uint120", "name": "", "type": "uint120" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ], "bytecode": "0x", "deployedBytecode": "0x", "linkReferences": {}, "deployedLinkReferences": {} }