Address Details
contract
0xAB7064715B7944110EF7138C0c55D3c4132BdFd5
- Contract Name
- CycleTrader
- Creator
- 0x5ca621–4f95fd at 0x4694da–7c3fb4
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 752,080 Transactions
- Transfers
- 811,481 Transfers
- Gas Used
- 391,847,396,768
- Last Balance Update
- 17866020
Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Code
Read Contract
Write Contract
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- CycleTrader
- Optimization enabled
- true
- Compiler version
- v0.6.12+commit.27d51765
- Optimization runs
- 200
- EVM Version
- istanbul
- Verified at
- 2021-12-18T07:12:12.755635Z
project:/contracts/CycleTrader.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import { ISwappaRouterV1 } from "./ISwappaRouterV1.sol"; import { SafeMath } from "./Libraries.sol"; import { IERC20 } from "./Interfaces.sol"; interface ChiToken { function freeFromUpTo(address from, uint256 value) external; } contract CycleTrader { ISwappaRouterV1 public immutable swappaRouter; ChiToken public immutable chiToken; using SafeMath for uint256; constructor(ISwappaRouterV1 swappa, ChiToken chi) public { swappaRouter = swappa; chiToken = chi; } receive() payable external {} modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 initialGas = 21000 + 16 * msg.data.length; uint256 gasSpent = initialGas + gasStart - gasleft(); uint256 freeUpValue = (gasSpent + 14154) / 41947; chiToken.freeFromUpTo(msg.sender, freeUpValue); } function trade( address[] calldata path, address[] calldata pairs, bytes[] calldata extras, uint256 inputAmount, uint256 minOutputAmount, uint deadline ) external payable discountCHI { if (deadline < block.timestamp) { // past deadline, do nothing return; } if (swappaRouter.getOutputAmount(path, pairs, extras, inputAmount) < minOutputAmount) { // money losing trade, do nothing return; } // take the input and approve for swappa router IERC20(path[0]).transferFrom(msg.sender, address(this), inputAmount); IERC20(path[0]).approve(address(swappaRouter), inputAmount); // run the swappa trade swappaRouter.swapExactInputForOutput( path, pairs, extras, inputAmount, minOutputAmount, // send the output of the trade to the message sender msg.sender, deadline ); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"swappa","internalType":"contract ISwappaRouterV1"},{"type":"address","name":"chi","internalType":"contract ChiToken"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ChiToken"}],"name":"chiToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ISwappaRouterV1"}],"name":"swappaRouter","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"trade","inputs":[{"type":"address[]","name":"path","internalType":"address[]"},{"type":"address[]","name":"pairs","internalType":"address[]"},{"type":"bytes[]","name":"extras","internalType":"bytes[]"},{"type":"uint256","name":"inputAmount","internalType":"uint256"},{"type":"uint256","name":"minOutputAmount","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60c060405234801561001057600080fd5b506040516108fb3803806108fb83398101604081905261002f9161004d565b6001600160601b0319606092831b8116608052911b1660a05261009e565b6000806040838503121561005f578182fd5b825161006a81610086565b602084015190925061007b81610086565b809150509250929050565b6001600160a01b038116811461009b57600080fd5b50565b60805160601c60a05160601c6108226100d960003980609b52806103d052508060e752806102595280610300528061044a52506108226000f3fe6080604052600436106100385760003560e01c80630c051135146100445780632dd9cbee1461006f578063fac994c2146100845761003f565b3661003f57005b600080fd5b34801561005057600080fd5b50610059610099565b60405161006691906107d8565b60405180910390f35b61008261007d3660046104f4565b6100bd565b005b34801561009057600080fd5b50610059610448565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005a9050428210156100cf5761039b565b60405162717a3560e91b815283906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e2f46a0090610128908e908e908e908e908e908e908e90600401610718565b60206040518083038186803b15801561014057600080fd5b505afa158015610154573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017891906105c2565b10156101835761039b565b8989600081811061019057fe5b90506020020160208101906101a591906104d2565b6001600160a01b03166323b872dd3330876040518463ffffffff1660e01b81526004016101d4939291906106db565b602060405180830381600087803b1580156101ee57600080fd5b505af1158015610202573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022691906105a2565b508989600081811061023457fe5b905060200201602081019061024991906104d2565b6001600160a01b031663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000866040518363ffffffff1660e01b81526004016102969291906106ff565b602060405180830381600087803b1580156102b057600080fd5b505af11580156102c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e891906105a2565b50604051630862d12f60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690630862d12f90610347908d908d908d908d908d908d908d908d9033908e90600401610769565b602060405180830381600087803b15801561036157600080fd5b505af1158015610375573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039991906105c2565b505b615208601036020160005a60405163079d229f60e01b815284840191909103915061a3db61374a830104906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063079d229f9061040790339085906004016106ff565b600060405180830381600087803b15801561042157600080fd5b505af1158015610435573d6000803e3d6000fd5b5050505050505050505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b80356001600160a01b038116811461048357600080fd5b92915050565b60008083601f84011261049a578182fd5b50813567ffffffffffffffff8111156104b1578182fd5b60208301915083602080830285010111156104cb57600080fd5b9250929050565b6000602082840312156104e3578081fd5b6104ed838361046c565b9392505050565b600080600080600080600080600060c08a8c031215610511578485fd5b893567ffffffffffffffff80821115610528578687fd5b6105348d838e01610489565b909b50995060208c013591508082111561054c578687fd5b6105588d838e01610489565b909950975060408c0135915080821115610570578687fd5b5061057d8c828d01610489565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b6000602082840312156105b3578081fd5b815180151581146104ed578182fd5b6000602082840312156105d3578081fd5b5051919050565b60008284526020808501945082825b85811015610617578183016001600160a01b03610606828561046c565b1688529683019691506001016105e9565b509495945050505050565b8183526020808401936000918085028201810184845b878110156106a457848303601f19018952813536889003601e1901811261065d578687fd5b8701803567ffffffffffffffff811115610675578788fd5b803603891315610683578788fd5b61069085828885016106b1565b9a86019a9450505090830190600101610638565b5090979650505050505050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b60006080825261072c60808301898b6105da565b828103602084015261073f81888a6105da565b90508281036040840152610754818688610622565b91505082606083015298975050505050505050565b600060e0825261077d60e083018c8e6105da565b8281036020840152610790818b8d6105da565b905082810360408401526107a581898b610622565b6060840197909752505060808101939093526001600160a01b039190911660a083015260c0909101529695505050505050565b6001600160a01b039190911681526020019056fea26469706673582212200123308271789fe61cedc8466b62126183849378417d1bccf91386e53336b3f564736f6c634300060c0033000000000000000000000000f35ed7156babf2541e032b3bb8625210316e283200000000000000000000000062a25e867f7853b362bbda8c0f400466a8063880
Deployed ByteCode
0x6080604052600436106100385760003560e01c80630c051135146100445780632dd9cbee1461006f578063fac994c2146100845761003f565b3661003f57005b600080fd5b34801561005057600080fd5b50610059610099565b60405161006691906107d8565b60405180910390f35b61008261007d3660046104f4565b6100bd565b005b34801561009057600080fd5b50610059610448565b7f00000000000000000000000062a25e867f7853b362bbda8c0f400466a806388081565b60005a9050428210156100cf5761039b565b60405162717a3560e91b815283906001600160a01b037f000000000000000000000000f35ed7156babf2541e032b3bb8625210316e2832169063e2f46a0090610128908e908e908e908e908e908e908e90600401610718565b60206040518083038186803b15801561014057600080fd5b505afa158015610154573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017891906105c2565b10156101835761039b565b8989600081811061019057fe5b90506020020160208101906101a591906104d2565b6001600160a01b03166323b872dd3330876040518463ffffffff1660e01b81526004016101d4939291906106db565b602060405180830381600087803b1580156101ee57600080fd5b505af1158015610202573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022691906105a2565b508989600081811061023457fe5b905060200201602081019061024991906104d2565b6001600160a01b031663095ea7b37f000000000000000000000000f35ed7156babf2541e032b3bb8625210316e2832866040518363ffffffff1660e01b81526004016102969291906106ff565b602060405180830381600087803b1580156102b057600080fd5b505af11580156102c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e891906105a2565b50604051630862d12f60e01b81526001600160a01b037f000000000000000000000000f35ed7156babf2541e032b3bb8625210316e28321690630862d12f90610347908d908d908d908d908d908d908d908d9033908e90600401610769565b602060405180830381600087803b15801561036157600080fd5b505af1158015610375573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039991906105c2565b505b615208601036020160005a60405163079d229f60e01b815284840191909103915061a3db61374a830104906001600160a01b037f00000000000000000000000062a25e867f7853b362bbda8c0f400466a8063880169063079d229f9061040790339085906004016106ff565b600060405180830381600087803b15801561042157600080fd5b505af1158015610435573d6000803e3d6000fd5b5050505050505050505050505050505050565b7f000000000000000000000000f35ed7156babf2541e032b3bb8625210316e283281565b80356001600160a01b038116811461048357600080fd5b92915050565b60008083601f84011261049a578182fd5b50813567ffffffffffffffff8111156104b1578182fd5b60208301915083602080830285010111156104cb57600080fd5b9250929050565b6000602082840312156104e3578081fd5b6104ed838361046c565b9392505050565b600080600080600080600080600060c08a8c031215610511578485fd5b893567ffffffffffffffff80821115610528578687fd5b6105348d838e01610489565b909b50995060208c013591508082111561054c578687fd5b6105588d838e01610489565b909950975060408c0135915080821115610570578687fd5b5061057d8c828d01610489565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b6000602082840312156105b3578081fd5b815180151581146104ed578182fd5b6000602082840312156105d3578081fd5b5051919050565b60008284526020808501945082825b85811015610617578183016001600160a01b03610606828561046c565b1688529683019691506001016105e9565b509495945050505050565b8183526020808401936000918085028201810184845b878110156106a457848303601f19018952813536889003601e1901811261065d578687fd5b8701803567ffffffffffffffff811115610675578788fd5b803603891315610683578788fd5b61069085828885016106b1565b9a86019a9450505090830190600101610638565b5090979650505050505050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b60006080825261072c60808301898b6105da565b828103602084015261073f81888a6105da565b90508281036040840152610754818688610622565b91505082606083015298975050505050505050565b600060e0825261077d60e083018c8e6105da565b8281036020840152610790818b8d6105da565b905082810360408401526107a581898b610622565b6060840197909752505060808101939093526001600160a01b039190911660a083015260c0909101529695505050505050565b6001600160a01b039190911681526020019056fea26469706673582212200123308271789fe61cedc8466b62126183849378417d1bccf91386e53336b3f564736f6c634300060c0033