Address Contract Verified
Address
0x0feF9c925540Af213e9513e534a653AC01DF61AD
Balance
0 ETH
Nonce
1
Code Size
8787 bytes
Creator
0x13Ac0CDd...01FC at tx 0x2c71fa17...2311c7
Indexed Transactions
0 (1 on-chain, 1.5% indexed)
Contract Bytecode
8787 bytes
0x6080604052600436106100e0575f3560e01c8063a10d09601161007e578063c646aee211610058578063c646aee214610293578063d51ba8f6146102cf578063f2fde38b146102eb578063f887ea4014610313576100e7565b8063a10d09601461021b578063a45ab62e14610243578063c0d786551461026b576100e7565b806354715e85116100ba57806354715e8514610177578063715018a6146101b357806379da58fc146101c95780638da5cb5b146101f1576100e7565b806301248d07146100eb57806314eaa43b146101135780633cdb97621461013b576100e7565b366100e757005b5f80fd5b3480156100f6575f80fd5b50610111600480360381019061010c9190611586565b61033d565b005b34801561011e575f80fd5b5061013960048036038101906101349190611720565b6103d4565b005b348015610146575f80fd5b50610161600480360381019061015c919061178c565b61058e565b60405161016e91906117f5565b60405180910390f35b348015610182575f80fd5b5061019d6004803603810190610198919061180e565b6105f1565b6040516101aa91906117f5565b60405180910390f35b3480156101be575f80fd5b506101c7610618565b005b3480156101d4575f80fd5b506101ef60048036038101906101ea9190611855565b61062b565b005b3480156101fc575f80fd5b506102056107ec565b60405161021291906118be565b60405180910390f35b348015610226575f80fd5b50610241600480360381019061023c9190611720565b610813565b005b34801561024e575f80fd5b50610269600480360381019061026491906118d7565b61095d565b005b348015610276575f80fd5b50610291600480360381019061028c9190611586565b610f27565b005b34801561029e575f80fd5b506102b960048036038101906102b49190611586565b611032565b6040516102c69190611971565b60405180910390f35b6102e960048036038101906102e4919061180e565b61104f565b005b3480156102f6575f80fd5b50610311600480360381019061030c9190611586565b61112f565b005b34801561031e575f80fd5b506103276111b3565b60405161033491906118be565b60405180910390f35b6103456111d8565b600160035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055507fb5a971e3a0967f24667868fe57eb95ea3b8ccc12e9a68c300804f85d21302274816040516103c991906118be565b60405180910390a150565b6103dc6111d8565b6103e461125f565b816004826040516103f591906119f6565b90815260200160405180910390205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20541015610480576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047790611a66565b60405180910390fd5b8160048260405161049191906119f6565b90815260200160405180910390205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546104e89190611ab1565b9250508190555061051a33838573ffffffffffffffffffffffffffffffffffffffff166112ae9092919063ffffffff16565b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fae1d1ec53cc389f413efa4343149dcd36b84da87cf0b1dec88a05ee10c521f328385604051610579929190611b1c565b60405180910390a361058961132d565b505050565b5f60048360405161059f91906119f6565b90815260200160405180910390205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f60058260405161060291906119f6565b9081526020016040518091039020549050919050565b6106206111d8565b6106295f611336565b565b6106336111d8565b61063b61125f565b8160058260405161064c91906119f6565b908152602001604051809103902054101561069c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069390611a66565b60405180910390fd5b816005826040516106ad91906119f6565b90815260200160405180910390205f8282546106c99190611ab1565b925050819055505f3373ffffffffffffffffffffffffffffffffffffffff16836040516106f590611b77565b5f6040518083038185875af1925050503d805f811461072f576040519150601f19603f3d011682016040523d82523d5f602084013e610734565b606091505b5050905080610778576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076f90611bd5565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fae1d1ec53cc389f413efa4343149dcd36b84da87cf0b1dec88a05ee10c521f3284866040516107d7929190611b1c565b60405180910390a3506107e861132d565b5050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f8211610855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084c90611c3d565b60405180910390fd5b6108823330848673ffffffffffffffffffffffffffffffffffffffff166113f7909392919063ffffffff16565b8160048260405161089391906119f6565b90815260200160405180910390205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546108ea9190611c5b565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fa348b54485f1d38cacb4b427a2dbc5bf2067cb3ba1024d6a4213a018939984848385604051610950929190611b1c565b60405180910390a3505050565b61096561125f565b5f73ffffffffffffffffffffffffffffffffffffffff1660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036109f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109eb90611cd8565b60405180910390fd5b60035f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610a9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9590611d40565b60405180910390fd5b82600482604051610aaf91906119f6565b90815260200160405180910390205f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20541015610b3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3190611a66565b60405180910390fd5b82600482604051610b4b91906119f6565b90815260200160405180910390205f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254610ba29190611ab1565b925050819055508373ffffffffffffffffffffffffffffffffffffffff1663095ea7b360025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b8152600401610c05929190611d5e565b6020604051808303815f875af1158015610c21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c459190611daf565b505f600267ffffffffffffffff811115610c6257610c616115fc565b5b604051908082528060200260200182016040528015610c905781602001602082028036833780820191505090505b50905084815f81518110610ca757610ca6611dda565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d4b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d6f9190611e1b565b81600181518110610d8357610d82611dda565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318cbafe586868530426040518663ffffffff1660e01b8152600401610e20959493929190611efd565b5f604051808303815f875af1158015610e3b573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610e63919061202d565b90505f8160018351610e759190611ab1565b81518110610e8657610e85611dda565b5b6020026020010151905080600585604051610ea191906119f6565b90815260200160405180910390205f828254610ebd9190611c5b565b925050819055508673ffffffffffffffffffffffffffffffffffffffff167f74692f099c12004d3377d298eaa020583924e38da5ab943f954630bdb7559928858884604051610f0e93929190612074565b60405180910390a2505050610f2161132d565b50505050565b610f2f6111d8565b60035f8273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610fb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610faf906120fa565b60405180910390fd5b8060025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc808160405161102791906118be565b60405180910390a150565b6003602052805f5260405f205f915054906101000a900460ff1681565b5f3411611091576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108890612162565b60405180910390fd5b346005826040516110a291906119f6565b90815260200160405180910390205f8282546110be9190611c5b565b925050819055505f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fa348b54485f1d38cacb4b427a2dbc5bf2067cb3ba1024d6a4213a018939984848334604051611124929190611b1c565b60405180910390a350565b6111376111d8565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036111a7575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161119e91906118be565b60405180910390fd5b6111b081611336565b50565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6111e0611479565b73ffffffffffffffffffffffffffffffffffffffff166111fe6107ec565b73ffffffffffffffffffffffffffffffffffffffff161461125d57611221611479565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161125491906118be565b60405180910390fd5b565b6002600154036112a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129b906121ca565b60405180910390fd5b6002600181905550565b611328838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040516024016112e1929190611d5e565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611480565b505050565b60018081905550565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611473848573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161142c939291906121e8565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611480565b50505050565b5f33905090565b5f8060205f8451602086015f885af18061149f576040513d5f823e3d81fd5b3d92505f519150505f82146114b85760018114156114d3565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b1561151557836040517f5274afe700000000000000000000000000000000000000000000000000000000815260040161150c91906118be565b60405180910390fd5b50505050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6115558261152c565b9050919050565b6115658161154b565b811461156f575f80fd5b50565b5f813590506115808161155c565b92915050565b5f6020828403121561159b5761159a611524565b5b5f6115a884828501611572565b91505092915050565b5f819050919050565b6115c3816115b1565b81146115cd575f80fd5b50565b5f813590506115de816115ba565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611632826115ec565b810181811067ffffffffffffffff82111715611651576116506115fc565b5b80604052505050565b5f61166361151b565b905061166f8282611629565b919050565b5f67ffffffffffffffff82111561168e5761168d6115fc565b5b611697826115ec565b9050602081019050919050565b828183375f83830152505050565b5f6116c46116bf84611674565b61165a565b9050828152602081018484840111156116e0576116df6115e8565b5b6116eb8482856116a4565b509392505050565b5f82601f830112611707576117066115e4565b5b81356117178482602086016116b2565b91505092915050565b5f805f6060848603121561173757611736611524565b5b5f61174486828701611572565b9350506020611755868287016115d0565b925050604084013567ffffffffffffffff81111561177657611775611528565b5b611782868287016116f3565b9150509250925092565b5f80604083850312156117a2576117a1611524565b5b5f83013567ffffffffffffffff8111156117bf576117be611528565b5b6117cb858286016116f3565b92505060206117dc85828601611572565b9150509250929050565b6117ef816115b1565b82525050565b5f6020820190506118085f8301846117e6565b92915050565b5f6020828403121561182357611822611524565b5b5f82013567ffffffffffffffff8111156118405761183f611528565b5b61184c848285016116f3565b91505092915050565b5f806040838503121561186b5761186a611524565b5b5f611878858286016115d0565b925050602083013567ffffffffffffffff81111561189957611898611528565b5b6118a5858286016116f3565b9150509250929050565b6118b88161154b565b82525050565b5f6020820190506118d15f8301846118af565b92915050565b5f805f80608085870312156118ef576118ee611524565b5b5f6118fc87828801611572565b945050602061190d878288016115d0565b935050604061191e878288016115d0565b925050606085013567ffffffffffffffff81111561193f5761193e611528565b5b61194b878288016116f3565b91505092959194509250565b5f8115159050919050565b61196b81611957565b82525050565b5f6020820190506119845f830184611962565b92915050565b5f81519050919050565b5f81905092915050565b5f5b838110156119bb5780820151818401526020810190506119a0565b5f8484015250505050565b5f6119d08261198a565b6119da8185611994565b93506119ea81856020860161199e565b80840191505092915050565b5f611a0182846119c6565b915081905092915050565b5f82825260208201905092915050565b7f496e73756666696369656e742062616c616e63650000000000000000000000005f82015250565b5f611a50601483611a0c565b9150611a5b82611a1c565b602082019050919050565b5f6020820190508181035f830152611a7d81611a44565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611abb826115b1565b9150611ac6836115b1565b9250828203905081811115611ade57611add611a84565b5b92915050565b5f611aee8261198a565b611af88185611a0c565b9350611b0881856020860161199e565b611b11816115ec565b840191505092915050565b5f6040820190508181035f830152611b348185611ae4565b9050611b4360208301846117e6565b9392505050565b5f81905092915050565b50565b5f611b625f83611b4a565b9150611b6d82611b54565b5f82019050919050565b5f611b8182611b57565b9150819050919050565b7f5472616e73666572206661696c656400000000000000000000000000000000005f82015250565b5f611bbf600f83611a0c565b9150611bca82611b8b565b602082019050919050565b5f6020820190508181035f830152611bec81611bb3565b9050919050565b7f416d6f756e74206d757374206265203e203000000000000000000000000000005f82015250565b5f611c27601283611a0c565b9150611c3282611bf3565b602082019050919050565b5f6020820190508181035f830152611c5481611c1b565b9050919050565b5f611c65826115b1565b9150611c70836115b1565b9250828201905080821115611c8857611c87611a84565b5b92915050565b7f526f75746572206e6f74207365740000000000000000000000000000000000005f82015250565b5f611cc2600e83611a0c565b9150611ccd82611c8e565b602082019050919050565b5f6020820190508181035f830152611cef81611cb6565b9050919050565b7f526f75746572206e6f7420616c6c6f77656400000000000000000000000000005f82015250565b5f611d2a601283611a0c565b9150611d3582611cf6565b602082019050919050565b5f6020820190508181035f830152611d5781611d1e565b9050919050565b5f604082019050611d715f8301856118af565b611d7e60208301846117e6565b9392505050565b611d8e81611957565b8114611d98575f80fd5b50565b5f81519050611da981611d85565b92915050565b5f60208284031215611dc457611dc3611524565b5b5f611dd184828501611d9b565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81519050611e158161155c565b92915050565b5f60208284031215611e3057611e2f611524565b5b5f611e3d84828501611e07565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b611e788161154b565b82525050565b5f611e898383611e6f565b60208301905092915050565b5f602082019050919050565b5f611eab82611e46565b611eb58185611e50565b9350611ec083611e60565b805f5b83811015611ef0578151611ed78882611e7e565b9750611ee283611e95565b925050600181019050611ec3565b5085935050505092915050565b5f60a082019050611f105f8301886117e6565b611f1d60208301876117e6565b8181036040830152611f2f8186611ea1565b9050611f3e60608301856118af565b611f4b60808301846117e6565b9695505050505050565b5f67ffffffffffffffff821115611f6f57611f6e6115fc565b5b602082029050602081019050919050565b5f80fd5b5f81519050611f92816115ba565b92915050565b5f611faa611fa584611f55565b61165a565b90508083825260208201905060208402830185811115611fcd57611fcc611f80565b5b835b81811015611ff65780611fe28882611f84565b845260208401935050602081019050611fcf565b5050509392505050565b5f82601f830112612014576120136115e4565b5b8151612024848260208601611f98565b91505092915050565b5f6020828403121561204257612041611524565b5b5f82015167ffffffffffffffff81111561205f5761205e611528565b5b61206b84828501612000565b91505092915050565b5f6060820190508181035f83015261208c8186611ae4565b905061209b60208301856117e6565b6120a860408301846117e6565b949350505050565b7f526f75746572206e6f742077686974656c6973746564000000000000000000005f82015250565b5f6120e4601683611a0c565b91506120ef826120b0565b602082019050919050565b5f6020820190508181035f830152612111816120d8565b9050919050565b7f4d7573742073656e64206e61746976652063757272656e6379000000000000005f82015250565b5f61214c601983611a0c565b915061215782612118565b602082019050919050565b5f6020820190508181035f83015261217981612140565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c005f82015250565b5f6121b4601f83611a0c565b91506121bf82612180565b602082019050919050565b5f6020820190508181035f8301526121e1816121a8565b9050919050565b5f6060820190506121fb5f8301866118af565b61220860208301856118af565b61221560408301846117e6565b94935050505056fea26469706673582212203bf22dc3bfb90ee4262aef48b9ca3f902729d169ae1482d6b4806d2b758bf61664736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: No
dupa.sol 116 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
interface IUniswapV2Router {
function swapExactTokensForETH(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function WETH() external pure returns (address);
}
contract DepositSwapWithdraw is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
constructor() Ownable(msg.sender) {}
address public router;
mapping(address => bool) public allowedRouters;
mapping(string => mapping(address => uint256)) private tokenBalances;
mapping(string => uint256) private nativeBalances;
event Deposited(string id, address indexed from, address indexed token, uint256 amount);
event Swapped(string id, address indexed token, uint256 tokenAmount, uint256 nativeReceived);
event Withdrew(string id, address indexed to, address indexed token, uint256 amount);
event RouterUpdated(address newRouter);
event RouterWhitelisted(address router);
function depositToken(address token, uint256 amount, string memory id) external {
require(amount > 0, "Amount must be > 0");
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
tokenBalances[id][token] += amount;
emit Deposited(id, msg.sender, token, amount);
}
function depositNative(string memory id) external payable {
require(msg.value > 0, "Must send native currency");
nativeBalances[id] += msg.value;
emit Deposited(id, msg.sender, address(0), msg.value);
}
function swapToNative(
address token,
uint256 amount,
uint256 minOut,
string memory id
) external nonReentrant {
require(router != address(0), "Router not set");
require(allowedRouters[router], "Router not allowed");
require(tokenBalances[id][token] >= amount, "Insufficient balance");
tokenBalances[id][token] -= amount;
IERC20(token).approve(router, amount);
address[] memory path = new address[](2);
path[0] = token;
path[1] = IUniswapV2Router(router).WETH();
uint[] memory amounts = IUniswapV2Router(router).swapExactTokensForETH(
amount,
minOut,
path,
address(this),
block.timestamp
);
uint256 received = amounts[amounts.length - 1];
nativeBalances[id] += received;
emit Swapped(id, token, amount, received);
}
function withdrawToken(address token, uint256 amount, string memory id) external onlyOwner nonReentrant {
require(tokenBalances[id][token] >= amount, "Insufficient balance");
tokenBalances[id][token] -= amount;
IERC20(token).safeTransfer(msg.sender, amount);
emit Withdrew(id, msg.sender, token, amount);
}
function withdrawNative(uint256 amount, string memory id) external onlyOwner nonReentrant {
require(nativeBalances[id] >= amount, "Insufficient balance");
nativeBalances[id] -= amount;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
emit Withdrew(id, msg.sender, address(0), amount);
}
function setRouter(address _router) external onlyOwner {
require(allowedRouters[_router], "Router not whitelisted");
router = _router;
emit RouterUpdated(_router);
}
function addRouterToWhitelist(address _router) external onlyOwner {
allowedRouters[_router] = true;
emit RouterWhitelisted(_router);
}
function getTokenBalance(string memory id, address token) external view returns (uint256) {
return tokenBalances[id][token];
}
function getNativeBalance(string memory id) external view returns (uint256) {
return nativeBalances[id];
}
receive() external payable {}
}
SafeERC20.sol 198 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
allowedRouters 0xc646aee2 → bool
getNativeBalance 0x54715e85 → uint256
getTokenBalance 0x3cdb9762 → uint256
owner 0x8da5cb5b → address
router 0xf887ea40 → address
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
addRouterToWhitelist 0x01248d07
address _router
depositNative 0xd51ba8f6
string id
depositToken 0xa10d0960
address token
uint256 amount
string id
renounceOwnership 0x715018a6
No parameters
setRouter 0xc0d78655
address _router
swapToNative 0xa45ab62e
address token
uint256 amount
uint256 minOut
string id
transferOwnership 0xf2fde38b
address newOwner
withdrawNative 0x79da58fc
uint256 amount
string id
withdrawToken 0x14eaa43b
address token
uint256 amount
string id
Recent Transactions
This address has 1 on-chain transactions, but only 1.5% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →