Address Contract Verified
Address
0xE4ddca21881baC219AF7F217703Db0475D2a9F02
Balance
0 ETH
Nonce
1
Code Size
3655 bytes
Creator
0x81328852...6bB7 at tx 0x433827b8...2998e1
Indexed Transactions
0
Contract Bytecode
3655 bytes
0x6080604052600436106100a05760003560e01c806348c314f41161006457806348c314f4146101a0578063516c731c146101b5578063b4f2e8b8146101d5578063c31c9c07146101f5578063ddca3f4314610215578063e4d0c7f01461023957600080fd5b8063022914a7146100ac578063089fe6aa146100f15780630eefdbad146101285780633fc8cef314610160578063469048401461018057600080fd5b366100a757005b600080fd5b3480156100b857600080fd5b506100dc6100c7366004610a35565b60006020819052908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156100fd57600080fd5b5060055461011490600160a01b900462ffffff1681565b60405162ffffff90911681526020016100e8565b34801561013457600080fd5b50600454610148906001600160a01b031681565b6040516001600160a01b0390911681526020016100e8565b34801561016c57600080fd5b50600554610148906001600160a01b031681565b34801561018c57600080fd5b50600354610148906001600160a01b031681565b6101b36101ae366004610a57565b610259565b005b3480156101c157600080fd5b506101b36101d0366004610a93565b610416565b3480156101e157600080fd5b506101b36101f0366004610acf565b610472565b34801561020157600080fd5b50600654610148906001600160a01b031681565b34801561022157600080fd5b5061022b60025481565b6040519081526020016100e8565b34801561024557600080fd5b506101b3610254366004610afb565b610573565b60015460011461029d5760405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b60448201526064015b60405180910390fd5b600260015560006102ad34610802565b9050600560009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156102ff57600080fd5b505af1158015610313573d6000803e3d6000fd5b505060065460055461033694506001600160a01b0390811693501690508361086e565b60065460408051610100810182526005546001600160a01b0380821683528881166020840152600160a01b90910462ffffff16928201929092528582166060820152600019608082015260a0810184905291169063414bf3899060c0810161039d866108ec565b815260006020909101526040516001600160e01b031960e084901b1681526103c89190600401610bba565b6020604051808303816000875af11580156103e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040b9190610c23565b505060018055505050565b3360009081526020819052604090205460ff166104645760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610294565b61046e828261091f565b5050565b3360009081526020819052604090205460ff166104c05760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610294565b6103e88211156105125760405162461bcd60e51b815260206004820152601c60248201527f6665652063616e206e6f74206265206d6f7265207468616e20313025000000006044820152606401610294565b6002829055600380546001600160a01b0319166001600160a01b0383169081179091556040805184815260208101929092527fc8242dc5446855370b781abbfc5d882af1d1a3cc29143216aba3558feb0ce925910160405180910390a15050565b6001546001146105b25760405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606401610294565b6002600155600480546040516368155ec160e01b81526001600160a01b0387811693820193909352336024820152306044820152606481018690529116906368155ec190608401600060405180830381600087803b15801561061357600080fd5b505af1158015610627573d6000803e3d6000fd5b505060065461064692506001600160a01b03878116925016600061086e565b600654610660906001600160a01b0386811691168561086e565b60065460408051610100810182526001600160a01b0387811682526005548082166020840152600160a01b900462ffffff16828401523060608301526080820185905260a0820187905260c08201869052600060e08301819052925163414bf38960e01b81529293169163414bf389916106dc91600401610bba565b6020604051808303816000875af11580156106fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071f9190610c23565b600554604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561076657600080fd5b505af115801561077a573d6000803e3d6000fd5b5050505061078781610802565b9050886001600160a01b03166344bc937b828a6000858c8c896040518863ffffffff1660e01b81526004016107c196959493929190610c3c565b6000604051808303818588803b1580156107da57600080fd5b505af11580156107ee573d6000803e3d6000fd5b505060018055505050505050505050505050565b600060025460001415801561082157506003546001600160a01b031615155b1561086a576000612710600254846108399190610cad565b6108439190610ce2565b60035490915061085c906001600160a01b03168261097c565b6108668184610cf6565b9250505b5090565b600060405163095ea7b360e01b81526001600160a01b03841660048201528260248201526000806044836000895af19150506108a9816109d2565b6108e65760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b6044820152606401610294565b50505050565b60006108f9606483610d0d565b61090490600a610e05565b61090f606484610ce2565b6109199190610cad565b92915050565b6001600160a01b03821660008181526020818152604091829020805460ff191685151590811790915591519182527ff74826f11048fa8ecf33e91132bf280f6582ed97548a84e426b56e98526b9316910160405180910390a25050565b600080600080600085875af19050806109cd5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610294565b505050565b60003d826109e457806000803e806000fd5b80602081146109fc578015610a0d5760009250610a12565b816000803e60005115159250610a12565b600192505b5050919050565b80356001600160a01b0381168114610a3057600080fd5b919050565b600060208284031215610a4757600080fd5b610a5082610a19565b9392505050565b600080600060608486031215610a6c57600080fd5b610a7584610a19565b9250610a8360208501610a19565b9150604084013590509250925092565b60008060408385031215610aa657600080fd5b610aaf83610a19565b915060208301358015158114610ac457600080fd5b809150509250929050565b60008060408385031215610ae257600080fd5b82359150610af260208401610a19565b90509250929050565b60008060008060008060008060e0898b031215610b1757600080fd5b610b2089610a19565b9750610b2e60208a01610a19565b9650604089013567ffffffffffffffff80821115610b4b57600080fd5b818b0191508b601f830112610b5f57600080fd5b813581811115610b6e57600080fd5b8c6020828501011115610b8057600080fd5b602083019850809750505050610b9860608a01610a19565b979a96995094979396956080850135955060a08501359460c001359350915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b600060208284031215610c3557600080fd5b5051919050565b6001600160a01b038781168252861660208201526040810185905260a06060820181905281018390526000838560c0840137600060c0858401015260c0601f19601f8601168301019050826080830152979650505050505050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615610cc757610cc7610c97565b500290565b634e487b7160e01b600052601260045260246000fd5b600082610cf157610cf1610ccc565b500490565b600082821015610d0857610d08610c97565b500390565b600082610d1c57610d1c610ccc565b500690565b600181815b80851115610d5c578160001904821115610d4257610d42610c97565b80851615610d4f57918102915b93841c9390800290610d26565b509250929050565b600082610d7357506001610919565b81610d8057506000610919565b8160018114610d965760028114610da057610dbc565b6001915050610919565b60ff841115610db157610db1610c97565b50506001821b610919565b5060208310610133831016604e8410600b8410161715610ddf575081810a610919565b610de98383610d21565b8060001904821115610dfd57610dfd610c97565b029392505050565b6000610a508383610d6456fea2646970667358221220c5c9b18db8d344057f9fe2bf09dbfb68a0cbc38e3887c2224466fc9f8455f32e64736f6c634300080a0033
Verified Source Code Full Match
Compiler: v0.8.10+commit.fc410830
EVM: london
Optimization: Yes (200 runs)
Owners.sol 22 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
abstract contract Owners {
event OwnerSet(address indexed owner, bool active);
mapping(address => bool) public owners;
modifier isOwner() {
require(owners[msg.sender], "Unauthorized");
_;
}
function _setOwner(address owner, bool active) internal virtual {
owners[owner] = active;
emit OwnerSet(owner, active);
}
function setOwner(address owner, bool active) external virtual isOwner {
_setOwner(owner, active);
}
}
TSAggregator.sol 48 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import { SafeTransferLib } from "../lib/SafeTransferLib.sol";
import { ReentrancyGuard } from "../lib/ReentrancyGuard.sol";
import { Owners } from "./Owners.sol";
import { TSAggregatorTokenTransferProxy } from './TSAggregatorTokenTransferProxy.sol';
abstract contract TSAggregator is Owners, ReentrancyGuard {
using SafeTransferLib for address;
event FeeSet(uint256 fee, address feeRecipient);
uint256 public fee;
address public feeRecipient;
TSAggregatorTokenTransferProxy public tokenTransferProxy;
constructor(address _tokenTransferProxy) {
_setOwner(msg.sender, true);
tokenTransferProxy = TSAggregatorTokenTransferProxy(_tokenTransferProxy);
}
// Needed for the swap router to be able to send back ETH
receive() external payable {}
function setFee(uint256 _fee, address _feeRecipient) external isOwner {
require(_fee <= 1000, "fee can not be more than 10%");
fee = _fee;
feeRecipient = _feeRecipient;
emit FeeSet(_fee, _feeRecipient);
}
function skimFee(uint256 amount) internal returns (uint256) {
if (fee != 0 && feeRecipient != address(0)) {
uint256 feeAmount = (amount * fee) / 10000;
feeRecipient.safeTransferETH(feeAmount);
amount -= feeAmount;
}
return amount;
}
// Parse amountOutMin treating the last 2 digits as an exponent
// So 15e4 = 150000. This allows for compressed memos on chains
// with limited space like Bitcoin
function _parseAmountOutMin(uint256 amount) internal pure returns (uint256) {
return amount / 100 * (10 ** (amount % 100));
}
}
ReentrancyGuard.sol 19 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
uint256 private locked = 1;
modifier nonReentrant() {
require(locked == 1, "REENTRANCY");
locked = 2;
_;
locked = 1;
}
}
SafeTransferLib.sol 138 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
library SafeTransferLib {
/*///////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool callStatus;
assembly {
// Transfer the ETH and store if it succeeded or not.
callStatus := call(gas(), to, amount, 0, 0, 0, 0)
}
require(callStatus, "ETH_TRANSFER_FAILED");
}
/*///////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
address token,
address from,
address to,
uint256 amount
) internal {
bool callStatus;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata to memory piece by piece:
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "from" argument.
mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.
// Call the token and store if it succeeded or not.
// We use 100 because the calldata length is 4 + 32 * 3.
callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)
}
require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED");
}
function safeTransfer(
address token,
address to,
uint256 amount
) internal {
bool callStatus;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata to memory piece by piece:
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.
// Call the token and store if it succeeded or not.
// We use 68 because the calldata length is 4 + 32 * 2.
callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)
}
require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FAILED");
}
function safeApprove(
address token,
address to,
uint256 amount
) internal {
bool callStatus;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata to memory piece by piece:
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.
// Call the token and store if it succeeded or not.
// We use 68 because the calldata length is 4 + 32 * 2.
callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)
}
require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED");
}
/*///////////////////////////////////////////////////////////////
INTERNAL HELPER LOGIC
//////////////////////////////////////////////////////////////*/
function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) {
assembly {
// Get how many bytes the call returned.
let returnDataSize := returndatasize()
// If the call reverted:
if iszero(callStatus) {
// Copy the revert message into memory.
returndatacopy(0, 0, returnDataSize)
// Revert with the same message.
revert(0, returnDataSize)
}
switch returnDataSize
case 32 {
// Copy the return data into memory.
returndatacopy(0, 0, returnDataSize)
// Set success to whether it returned true.
success := iszero(iszero(mload(0)))
}
case 0 {
// There was no return data.
success := 1
}
default {
// It returned some malformed input.
success := 0
}
}
}
}
IWETH9.sol 7 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
interface IWETH9 {
function deposit() external payable;
function withdraw(uint256) external;
}
TSAggregatorUniswapV3.sol 75 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import { SafeTransferLib } from "../lib/SafeTransferLib.sol";
import { IWETH9 } from "./interfaces/IWETH9.sol";
import { TSAggregator } from "./TSAggregator.sol";
import { IThorchainRouter } from "./interfaces/IThorchainRouter.sol";
import { IUniswapRouterV3 } from "./interfaces/IUniswapRouterV3.sol";
contract TSAggregatorUniswapV3 is TSAggregator {
using SafeTransferLib for address;
IWETH9 public weth;
uint24 public poolFee;
IUniswapRouterV3 public swapRouter;
constructor(
address _ttp, address _weth, address _swapRouter, uint24 _poolFee
) TSAggregator(_ttp) {
weth = IWETH9(_weth);
poolFee = _poolFee;
swapRouter = IUniswapRouterV3(_swapRouter);
}
function swapIn(
address tcRouter,
address tcVault,
string calldata tcMemo,
address token,
uint amount,
uint amountOutMin,
uint deadline
) public nonReentrant {
tokenTransferProxy.transferTokens(token, msg.sender, address(this), amount);
token.safeApprove(address(swapRouter), 0); // USDT quirk
token.safeApprove(address(swapRouter), amount);
uint amountOut = swapRouter.exactInputSingle(IUniswapRouterV3.ExactInputSingleParams({
tokenIn: token,
tokenOut: address(weth),
fee: poolFee,
recipient: address(this),
deadline: deadline,
amountIn: amount,
amountOutMinimum: amountOutMin,
sqrtPriceLimitX96: 0
}));
weth.withdraw(amountOut);
amountOut = skimFee(amountOut);
IThorchainRouter(tcRouter).depositWithExpiry{value: amountOut}(
payable(tcVault),
address(0), // ETH
amountOut,
tcMemo,
deadline
);
}
function swapOut(address token, address to, uint256 amountOutMin) public payable nonReentrant {
uint256 amount = skimFee(msg.value);
weth.deposit{value: amount}();
address(weth).safeApprove(address(swapRouter), amount);
swapRouter.exactInputSingle(IUniswapRouterV3.ExactInputSingleParams({
tokenIn: address(weth),
tokenOut: token,
fee: poolFee,
recipient: to,
deadline: type(uint).max,
amountIn: amount,
amountOutMinimum: _parseAmountOutMin(amountOutMin),
sqrtPriceLimitX96: 0
}));
}
}
IThorchainRouter.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
interface IThorchainRouter {
function depositWithExpiry(
address payable vault,
address asset,
uint amount,
string memory memo,
uint expiration
) external payable;
}
IUniswapRouterV3.sol 31 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
interface IUniswapRouterV3 {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
function exactInputSingle(
ExactInputSingleParams calldata params
) external returns (uint256 amountOut);
function exactInput(
ExactInputParams calldata params
) external returns (uint256 amountOut);
}
TSAggregatorTokenTransferProxy.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import { SafeTransferLib } from "../lib/SafeTransferLib.sol";
import { Owners } from "./Owners.sol";
contract TSAggregatorTokenTransferProxy is Owners {
using SafeTransferLib for address;
constructor() {
_setOwner(msg.sender, true);
}
function transferTokens(address token, address from, address to, uint256 amount) external isOwner {
require(from == tx.origin || _isContract(from), "Invalid from address");
token.safeTransferFrom(from, to, amount);
}
function _isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
Read Contract
fee 0xddca3f43 → uint256
feeRecipient 0x46904840 → address
owners 0x022914a7 → bool
poolFee 0x089fe6aa → uint24
swapRouter 0xc31c9c07 → address
tokenTransferProxy 0x0eefdbad → address
weth 0x3fc8cef3 → address
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
setFee 0xb4f2e8b8
uint256 _fee
address _feeRecipient
setOwner 0x516c731c
address owner
bool active
swapIn 0xe4d0c7f0
address tcRouter
address tcVault
string tcMemo
address token
uint256 amount
uint256 amountOutMin
uint256 deadline
swapOut 0x48c314f4
address token
address to
uint256 amountOutMin
Recent Transactions
No transactions found for this address