Address Contract Partially Verified
Address
0x5ad6211CD3fdE39A9cECB5df6f380b8263d1e277
Balance
0.043890 ETH ($86.90)
Nonce
1
Code Size
8185 bytes
Creator
0x58B4B695...3503 at tx 0x20227dba...9558c6
Indexed Transactions
0
Contract Bytecode
8185 bytes
0x60806040526004361061012d5760003560e01c80639d22ae8c116100a5578063c45a015511610074578063d298460811610059578063d2984608146103d4578063d9caed1214610408578063f32a12ac1461042857600080fd5b8063c45a01551461035d578063ced67f0c1461039157600080fd5b80639d22ae8c146102e85780639dd8a81c14610308578063aa60e73314610328578063b081b4eb1461034857600080fd5b80633fc8cef3116100fc5780636e9821c2116100e15780636e9821c21461025b5780638da5cb5b1461029b5780638e9be9f4146102c857600080fd5b80633fc8cef31461020757806354a0af171461023b57600080fd5b80630a0879031461013957806313af403514610197578063225bf435146101b9578063248091c0146101e757600080fd5b3661013457005b600080fd5b34801561014557600080fd5b5061016d7f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe281565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156101a357600080fd5b506101b76101b23660046119d4565b610448565b005b3480156101c557600080fd5b506101d96101d43660046119f8565b610506565b60405190815260200161018e565b3480156101f357600080fd5b506101b7610202366004611a66565b610630565b34801561021357600080fd5b5061016d7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b34801561024757600080fd5b506101b7610256366004611b59565b6108a9565b34801561026757600080fd5b5061028b6102763660046119d4565b60016020526000908152604090205460ff1681565b604051901515815260200161018e565b3480156102a757600080fd5b5060005461016d9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156102d457600080fd5b506101b76102e3366004611a66565b610978565b3480156102f457600080fd5b506101b7610303366004611c44565b610ad8565b34801561031457600080fd5b506101b7610323366004611c7d565b610bb6565b34801561033457600080fd5b506101b7610343366004611d17565b610d48565b34801561035457600080fd5b506101b7610ea1565b34801561036957600080fd5b5061016d7f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac81565b34801561039d57600080fd5b5061016d6103ac3660046119d4565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156103e057600080fd5b5061016d7f0000000000000000000000008798249c2e607446efb7ad49ec89dd1865ff427281565b34801561041457600080fd5b506101b7610423366004611d30565b610f1c565b34801561043457600080fd5b506101b7610443366004611d7f565b610fb6565b60005473ffffffffffffffffffffffffffffffffffffffff163314610499576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917f167d3e9c1016ab80e58802ca9da10ce5c6a0f4debc46a2e7a2cd9e56899a4fb591a250565b3360009081526001602052604081205460ff1661054f576040517fcf1119ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105bb7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2857f0000000000000000000000008798249c2e607446efb7ad49ec89dd1865ff427261108a565b9050818110156105f7576040517f17d431f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518181527f4bd1bdc2f263261c65e1cf0d8f7908b6fbf4b4906bafb6a28e11aafdc86c326e9060200160405180910390a192915050565b3360009081526001602052604090205460ff16610679576040517fcf1119ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8781101561089e57600089898381811061069857610698611dad565b90506020020160208101906106ad91906119d4565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb828a8a868181106106de576106de611dad565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff909416600485015260200291909101356024830152506044016020604051808303816000875af1158015610757573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077b9190611ddc565b506040517f89afcb44000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8416906389afcb449060240160408051808303816000875af11580156107ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108109190611df9565b9150915087878581811061082657610826611dad565b90506020020135821080610851575085858581811061084757610847611dad565b9050602002013581105b15610888576040517f17d431f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050808061089690611e4c565b91505061067c565b505050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108fa576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008373ffffffffffffffffffffffffffffffffffffffff1683836040516109229190611e85565b60006040518083038185875af1925050503d806000811461095f576040519150601f19603f3d011682016040523d82523d6000602084013e610964565b606091505b505090508061097257600080fd5b50505050565b3360009081526001602052604090205460ff166109c1576040517fcf1119ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8781101561089e5760008989838181106109e0576109e0611dad565b90506020020160208101906109f591906119d4565b90506000888884818110610a0b57610a0b611dad565b9050602002016020810190610a2091906119d4565b905073ffffffffffffffffffffffffffffffffffffffff808216908316106000610a4a84846112de565b9050868686818110610a5e57610a5e611dad565b90506020020135610a89828b8b89818110610a7b57610a7b611dad565b905060200201358587611465565b1015610ac1576040517f17d431f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050508080610ad090611e4c565b9150506109c4565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b29576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82811660008181526002602090815260409182902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169486169485179055905192835290917f8357797ab855a0bad5103ea8bd2f21f986350e94d73f143ae114db8f0db5a93a91015b60405180910390a25050565b3360009081526001602052604090205460ff16610bff576040517fcf1119ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b85811015610d3f576000878783818110610c1e57610c1e611dad565b9050602002016020810190610c3391906119d4565b73ffffffffffffffffffffffffffffffffffffffff808216600090815260026020526040812054929350911615610c915773ffffffffffffffffffffffffffffffffffffffff80831660009081526002602052604090205416610cb3565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b9050848484818110610cc757610cc7611dad565b90506020020135610cf283838a8a88818110610ce557610ce5611dad565b905060200201353061108a565b1015610d2a576040517f17d431f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50508080610d3790611e4c565b915050610c02565b50505050505050565b3360009081526001602052604090205460ff16610d91576040517fcf1119ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000008798249c2e607446efb7ad49ec89dd1865ff427281166004830152602482018390527f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2169063a9059cbb906044016020604051808303816000875af1158015610e46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6a9190611ddc565b506040518181527f4bd1bdc2f263261c65e1cf0d8f7908b6fbf4b4906bafb6a28e11aafdc86c326e9060200160405180910390a150565b60405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216904790600081818185875af1925050503d8060008114610f17576040519150601f19603f3d011682016040523d82523d6000602084013e505050565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610f6d576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831615610f9457610f178383836117eb565b60008273ffffffffffffffffffffffffffffffffffffffff1682604051610922565b60005473ffffffffffffffffffffffffffffffffffffffff163314611007576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660008181526001602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001685151590811790915591519182527f878d105ed19c01e992a54459c2f04ba19432ac45600b42ce340d0342722074369101610baa565b60008061109786866112de565b90506110a48682866117eb565b6000808273ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156110f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111169190611ee3565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1610156112235761117a868383611960565b6040517f022c0d9f0000000000000000000000000000000000000000000000000000000081526000600482018190526024820183905273ffffffffffffffffffffffffffffffffffffffff88811660448401526080606484015260848301919091529195509084169063022c0d9f9060a401600060405180830381600087803b15801561120657600080fd5b505af115801561121a573d6000803e3d6000fd5b505050506112d3565b61122e868284611960565b6040517f022c0d9f0000000000000000000000000000000000000000000000000000000081526004810182905260006024820181905273ffffffffffffffffffffffffffffffffffffffff88811660448401526080606484015260848301919091529195509084169063022c0d9f9060a401600060405180830381600087803b1580156112ba57600080fd5b505af11580156112ce573d6000803e3d6000fd5b505050505b505050949350505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161061131d578385611320565b84845b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b16603482015291935091507f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac90604801604051602081830303815290604052805190602001206040516020016114269291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527fe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012095945050505050565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482018190526024820185905260009163a9059cbb906044016020604051808303816000875af11580156114db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ff9190611ddc565b506040517f89afcb44000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8816906389afcb449060240160408051808303816000875af1158015611570573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115949190611df9565b915091506000808873ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156115e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160a9190611ee3565b509150915086156116fc57611620868a856117eb565b61164b83826dffffffffffffffffffffffffffff16846dffffffffffffffffffffffffffff16611960565b6040517f022c0d9f0000000000000000000000000000000000000000000000000000000081526004810182905260006024820181905230604483015260806064830152608482015290955073ffffffffffffffffffffffffffffffffffffffff8a169063022c0d9f9060a401600060405180830381600087803b1580156116d157600080fd5b505af11580156116e5573d6000803e3d6000fd5b5050505083856116f59190611f33565b94506117df565b611707868a866117eb565b61173284836dffffffffffffffffffffffffffff16836dffffffffffffffffffffffffffff16611960565b6040517f022c0d9f0000000000000000000000000000000000000000000000000000000081526000600482018190526024820183905230604483015260806064830152608482015290955073ffffffffffffffffffffffffffffffffffffffff8a169063022c0d9f9060a401600060405180830381600087803b1580156117b857600080fd5b505af11580156117cc573d6000803e3d6000fd5b5050505082856117dc9190611f33565b94505b50505050949350505050565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052915160009283928716916118b29190611e85565b6000604051808303816000865af19150503d80600081146118ef576040519150601f19603f3d011682016040523d82523d6000602084013e6118f4565b606091505b509150915081158061192257508051158015906119225750808060200190518101906119209190611ddc565b155b15611959576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050565b60008061196f856103e5611f4b565b9050600061197d8483611f4b565b905060008261198e876103e8611f4b565b6119989190611f33565b90506119a48183611f88565b979650505050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146119d157600080fd5b50565b6000602082840312156119e657600080fd5b81356119f1816119af565b9392505050565b60008060408385031215611a0b57600080fd5b50508035926020909101359150565b60008083601f840112611a2c57600080fd5b50813567ffffffffffffffff811115611a4457600080fd5b6020830191508360208260051b8501011115611a5f57600080fd5b9250929050565b6000806000806000806000806080898b031215611a8257600080fd5b883567ffffffffffffffff80821115611a9a57600080fd5b611aa68c838d01611a1a565b909a50985060208b0135915080821115611abf57600080fd5b611acb8c838d01611a1a565b909850965060408b0135915080821115611ae457600080fd5b611af08c838d01611a1a565b909650945060608b0135915080821115611b0957600080fd5b50611b168b828c01611a1a565b999c989b5096995094979396929594505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080600060608486031215611b6e57600080fd5b8335611b79816119af565b925060208401359150604084013567ffffffffffffffff80821115611b9d57600080fd5b818601915086601f830112611bb157600080fd5b813581811115611bc357611bc3611b2a565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715611c0957611c09611b2a565b81604052828152896020848701011115611c2257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60008060408385031215611c5757600080fd5b8235611c62816119af565b91506020830135611c72816119af565b809150509250929050565b60008060008060008060608789031215611c9657600080fd5b863567ffffffffffffffff80821115611cae57600080fd5b611cba8a838b01611a1a565b90985096506020890135915080821115611cd357600080fd5b611cdf8a838b01611a1a565b90965094506040890135915080821115611cf857600080fd5b50611d0589828a01611a1a565b979a9699509497509295939492505050565b600060208284031215611d2957600080fd5b5035919050565b600080600060608486031215611d4557600080fd5b8335611d50816119af565b92506020840135611d60816119af565b929592945050506040919091013590565b80151581146119d157600080fd5b60008060408385031215611d9257600080fd5b8235611d9d816119af565b91506020830135611c7281611d71565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215611dee57600080fd5b81516119f181611d71565b60008060408385031215611e0c57600080fd5b505080516020909101519092909150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611e7e57611e7e611e1d565b5060010190565b6000825160005b81811015611ea65760208186018101518583015201611e8c565b81811115611eb5576000828501525b509190910192915050565b80516dffffffffffffffffffffffffffff81168114611ede57600080fd5b919050565b600080600060608486031215611ef857600080fd5b611f0184611ec0565b9250611f0f60208501611ec0565b9150604084015163ffffffff81168114611f2857600080fd5b809150509250925092565b60008219821115611f4657611f46611e1d565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611f8357611f83611e1d565b500290565b600082611fbe577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea26469706673582212206c4c5ffc8ccb8d59bb481dc2499e6e2dc87006543cab5f49cf51e0ee679d87cf64736f6c634300080a0033
Verified Source Code Partial Match
Compiler: v0.8.10+commit.fc410830
EVM: london
Optimization: Yes (99999 runs)
Auth.sol 45 lines
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
abstract contract Auth {
event SetOwner(address indexed owner);
event SetTrusted(address indexed user, bool isTrusted);
address public owner;
mapping(address => bool) public trusted;
error OnlyOwner();
error OnlyTrusted();
modifier onlyOwner() {
if (msg.sender != owner) revert OnlyOwner();
_;
}
modifier onlyTrusted() {
if (!trusted[msg.sender]) revert OnlyTrusted();
_;
}
constructor(address newOwner, address trustedUser) {
owner = newOwner;
trusted[trustedUser] = true;
emit SetOwner(owner);
emit SetTrusted(trustedUser, true);
}
function setOwner(address newOwner) external onlyOwner {
owner = newOwner;
emit SetOwner(newOwner);
}
function setTrusted(address user, bool isTrusted) external onlyOwner {
trusted[user] = isTrusted;
emit SetTrusted(user, isTrusted);
}
}
WethMaker.sol 88 lines
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import "./Unwindooor.sol";
/// @notice Contract for selling received tokens into weth. Deploy on secondary networks.
contract WethMaker is Unwindooor {
event SetBridge(address indexed token, address bridge);
address public immutable weth;
mapping(address => address) public bridges;
constructor(
address owner,
address user,
address factory,
address _weth
) Unwindooor(owner, user, factory) {
weth = _weth;
}
function setBridge(address token, address bridge) external onlyOwner {
bridges[token] = bridge;
emit SetBridge(token, bridge);
}
// Exchange token for weth or its bridge token (which gets converted into weth in subsequent transactions).
function buyWeth(
address[] calldata tokens,
uint256[] calldata amountsIn,
uint256[] calldata minimumOuts
) external onlyTrusted {
for (uint256 i = 0; i < tokens.length; i++) {
address tokenIn = tokens[i];
address outToken = bridges[tokenIn] == address(0) ? weth : bridges[tokenIn];
if (_swap(tokenIn, outToken, amountsIn[i], address(this)) < minimumOuts[i]) revert SlippageProtection();
}
}
function _swap(
address tokenIn,
address tokenOut,
uint256 amountIn,
address to
) internal returns (uint256 outAmount) {
IUniV2 pair = IUniV2(_pairFor(tokenIn, tokenOut));
_safeTransfer(tokenIn, address(pair), amountIn);
(uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
if (tokenIn < tokenOut) {
outAmount = _getAmountOut(amountIn, reserve0, reserve1);
pair.swap(0, outAmount, to, "");
} else {
outAmount = _getAmountOut(amountIn, reserve1, reserve0);
pair.swap(outAmount, 0, to, "");
}
}
// Allow the owner to withdraw the funds and bridge them to mainnet.
function withdraw(address token, address to, uint256 _value) onlyOwner external {
if (token != address(0)) {
_safeTransfer(token, to, _value);
} else {
(bool success, ) = to.call{value: _value}("");
require(success);
}
}
function doAction(address to, uint256 _value, bytes memory data) onlyOwner external {
(bool success, ) = to.call{value: _value}(data);
require(success);
}
receive() external payable {}
}
SushiMaker.sol 43 lines
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import "./WethMaker.sol";
/// @notice Contract for selling weth to sushi. Deploy on mainnet.
contract SushiMaker is WethMaker {
event Serve(uint256 amount);
address public immutable sushi;
address public immutable xSushi;
constructor(
address owner,
address user,
address factory,
address weth,
address _sushi,
address _xSushi
) WethMaker(owner, user, factory, weth) {
sushi = _sushi;
xSushi = _xSushi;
}
function buySushi(uint256 amountIn, uint256 minOutAmount) external onlyTrusted returns (uint256 amountOut) {
amountOut = _swap(weth, sushi, amountIn, xSushi);
if (amountOut < minOutAmount) revert SlippageProtection();
emit Serve(amountOut);
}
function sweep(uint256 amount) external onlyTrusted {
IERC20(sushi).transfer(xSushi, amount);
emit Serve(amount);
}
// In case we receive any unwrapped ethereum we can call this.
function wrapEth() external {
weth.call{value: address(this).balance}("");
}
}
Unwindooor.sol 112 lines
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import "./Auth.sol";
import "./interfaces/IUniV2.sol";
import "./interfaces/IUniV2Factory.sol";
/// @notice Contract for withdrawing LP positions.
/// @dev Calling unwindPairs() withdraws the LP position into one of the two tokens
contract Unwindooor is Auth {
error SlippageProtection();
error TransferFailed();
bytes4 private constant TRANSFER_SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
IUniV2Factory public immutable factory;
constructor(
address owner,
address user,
address factoryAddress
) Auth(owner, user) {
factory = IUniV2Factory(factoryAddress);
}
// We remove liquidity and sell tokensB[i] for tokensA[i].
function unwindPairs(
address[] calldata tokensA,
address[] calldata tokensB,
uint256[] calldata amounts,
uint256[] calldata minimumOuts
) external onlyTrusted {
for (uint256 i = 0; i < tokensA.length; i++) {
address tokenA = tokensA[i];
address tokenB = tokensB[i];
bool keepToken0 = tokenA < tokenB;
address pair = _pairFor(tokenA, tokenB);
if (_unwindPair(IUniV2(pair), amounts[i], keepToken0, tokenB) < minimumOuts[i]) revert SlippageProtection();
}
}
// Burn liquidity and sell one of the tokens for the other.
function _unwindPair(
IUniV2 pair,
uint256 amount,
bool keepToken0,
address tokenToSell
) private returns (uint256 amountOut) {
pair.transfer(address(pair), amount);
(uint256 amount0, uint256 amount1) = pair.burn(address(this));
(uint112 reserve0, uint112 reserve1,) = pair.getReserves();
if (keepToken0) {
_safeTransfer(tokenToSell, address(pair), amount1);
amountOut = _getAmountOut(amount1, uint256(reserve1), uint256(reserve0));
pair.swap(amountOut, 0, address(this), "");
amountOut += amount0;
} else {
_safeTransfer(tokenToSell, address(pair), amount0);
amountOut = _getAmountOut(amount0, uint256(reserve0), uint256(reserve1));
pair.swap(0, amountOut, address(this), "");
amountOut += amount1;
}
}
// In case we don't want to sell one of the tokens for the other.
function burnPairs(
IUniV2[] calldata lpTokens,
uint256[] calldata amounts,
uint256[] calldata minimumOut0,
uint256[] calldata minimumOut1
) external onlyTrusted {
for (uint256 i = 0; i < lpTokens.length; i++) {
IUniV2 pair = lpTokens[i];
pair.transfer(address(pair), amounts[i]);
(uint256 amount0, uint256 amount1) = pair.burn(address(this));
if (amount0 < minimumOut0[i] || amount1 < minimumOut1[i]) revert SlippageProtection();
}
}
function _getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) internal pure returns (uint256) {
uint256 amountInWithFee = amountIn * 997;
uint256 numerator = amountInWithFee * reserveOut;
uint256 denominator = reserveIn * 1000 + amountInWithFee;
return numerator / denominator;
}
function _safeTransfer(address token, address to, uint value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(TRANSFER_SELECTOR, to, value));
if (!success || (data.length != 0 && !abi.decode(data, (bool)))) revert TransferFailed();
}
function _pairFor(address tokenA, address tokenB) internal view returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint160(uint256(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'e18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303' // init code hash
)))));
}
}
IERC20.sol 7 lines
// SPDX-License-Identifier: GPL-3.0-or-later
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address addy) external view returns (uint256);
}
IUniV2.sol 12 lines
// SPDX-License-Identifier: GPL-3.0-or-later
import "./IERC20.sol";
interface IUniV2 is IERC20 {
function totalSupply() external view returns (uint256);
function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function token0() external view returns (address);
function token1() external view returns (address);
}
IUniV2Factory.sol 5 lines
// SPDX-License-Identifier: GPL-3.0-or-later
interface IUniV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address);
}
Read Contract
bridges 0xced67f0c → address
factory 0xc45a0155 → address
owner 0x8da5cb5b → address
sushi 0x0a087903 → address
trusted 0x6e9821c2 → bool
weth 0x3fc8cef3 → address
xSushi 0xd2984608 → address
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
burnPairs 0x248091c0
address[] lpTokens
uint256[] amounts
uint256[] minimumOut0
uint256[] minimumOut1
buySushi 0x225bf435
uint256 amountIn
uint256 minOutAmount
returns: uint256
buyWeth 0x9dd8a81c
address[] tokens
uint256[] amountsIn
uint256[] minimumOuts
doAction 0x54a0af17
address to
uint256 _value
bytes data
setBridge 0x9d22ae8c
address token
address bridge
setOwner 0x13af4035
address newOwner
setTrusted 0xf32a12ac
address user
bool isTrusted
sweep 0xaa60e733
uint256 amount
unwindPairs 0x8e9be9f4
address[] tokensA
address[] tokensB
uint256[] amounts
uint256[] minimumOuts
withdraw 0xd9caed12
address token
address to
uint256 _value
wrapEth 0xb081b4eb
No parameters
Token Balances (5)
View Transfers →Recent Transactions
No transactions found for this address