Address Contract Verified
Address
0xD5060CA04EfC02c9EDC619F9047DF1e1CB382D01
Balance
0 ETH
Nonce
1
Code Size
5950 bytes
Creator
0xE30c6b39...032e at tx 0x7e147b8e...a22225
Indexed Transactions
0
Contract Bytecode
5950 bytes
0x608060408181526004918236101561001657600080fd5b600092833560e01c918263022914a714610e71575081630852817d14610e2057816308a199da14610d035781630d13b95314610be9578163162d493c14610ba35781631e1bff3f14610b205781631ff48c4914610af457816327a8d0d914610a595781632e394a94146109665781634109ce6c146108135781634626402b146107ea5781634dc10ea1146107c5578163516c731c1461073d57816353ba352c14610715578163644c5695146106ee5781636e91a94814610652578163730a1e38146105495781637dc0d1d01461052057816390170654146104f4578163932f3f66146104ce5781639ac2a011146104905781639e0320ca1461043b578163a8602fea146103e7578163ac21d47a146103be578163b37b50e3146102e1578163c37fb119146102b9578163d61175291461028457508063d6942c8b14610245578063dacd0737146101f1578063e6d7329d146101cb578063f5d36475146101ad5763fa5802941461018557600080fd5b346101a957816003193601126101a9576007549051602091821c63ffffffff168152f35b5080fd5b50346101a957816003193601126101a9576020906005549051908152f35b50346101a957816003193601126101a95760209060ff60075460801c1690519015158152f35b50346101a95760203660031901126101a95780610237610230926102419463ffffffff61021c610ec6565b168152600960205220825193848092611054565b0383610f03565b5191829182610fee565b0390f35b50346101a95760203660031901126101a95780610237610230926102419463ffffffff610270610ec6565b168152600a60205220825193848092611054565b919050346102b55760203660031901126102b55760ff6102ae9133855284602052842054166110ea565b3560055580f35b8280fd5b5050346101a957816003193601126101a95760209063ffffffff60075460601c169051908152f35b9050346102b557816003193601126102b5576102fb610ec6565b906024359263ffffffff808516938486036103ba5781903388528760205261032860ff858a2054166110ea565b169384018181116103a7571661270f190161036457505067ffffffff000000006007549260201b169167ffffffffffffffff1916171760075580f35b906020606492519162461bcd60e51b8352820152601b60248201527f536861726573206d7573742061646420757020746f20313030303000000000006044820152fd5b634e487b7160e01b875260118452602487fd5b8680fd5b5050346101a957816003193601126101a95760035490516001600160a01b039091168152602090f35b5050346101a95760203660031901126101a95761041860ff610407610eab565b9233855284602052842054166110ea565b60018060a01b03166bffffffffffffffffffffffff60a01b600854161760085580f35b9050346102b55760203660031901126102b55735908115158092036102b55760ff6104709133855284602052842054166110ea565b6007805460ff60881b191660889290921b60ff60881b1691909117905580f35b5050346101a95760203660031901126101a95760209160ff9082906001600160a01b036104bb610eab565b1681526001855220541690519015158152f35b5050346101a957816003193601126101a9576007548151911c63ffffffff168152602090f35b5050346101a95760203660031901126101a95780610237610230926102419463ffffffff61021c610ec6565b5050346101a957816003193601126101a95760025490516001600160a01b039091168152602090f35b9050346102b557826003193601126102b55760ff60075460801c16156105fa57826105aa9160018060a01b03600254168451808095819463a0e3440f60e01b8352820160609060208152600360208201526208aa8960eb1b60408201520190565b03915afa9081156105ee576105c7925083916105ca575b506111f7565b80f35b6105e691503d8085833e6105de8183610f03565b81019061113d565b9050386105c1565b505051903d90823e3d90fd5b6020608492519162461bcd60e51b8352820152602d60248201527f4d7573742063616c6c206469737472696275746554726561737572794578656360448201526c3aba37b91034b739ba32b0b21760991b6064820152fd5b9050346102b55760203660031901126102b55761066d610eab565b91338452600160205261068560ff82862054166110ea565b60ff60075460801c1661069c57836105c7846114df565b906020608492519162461bcd60e51b8352820152602660248201527f4d7573742063616c6c2064697374726962757465436f6d6d756e69747920696e60448201526539ba32b0b21760d11b6064820152fd5b5050346101a957816003193601126101a95760209060ff60075460881c1690519015158152f35b9050346102b557826003193601126102b5575490516001600160a01b03909116815260209150f35b5050346101a957806003193601126101a9577ff74826f11048fa8ecf33e91132bf280f6582ed97548a84e426b56e98526b9316602061077a610eab565b610782610fbc565b9033865285835261079860ff86882054166110ea565b6001600160a01b0316808652858352848620805460ff191660ff84151516179055935b519015158152a280f35b5050346101a957816003193601126101a95760209063ffffffff600754169051908152f35b5050346101a957816003193601126101a95760085490516001600160a01b039091168152602090f35b8383346101a95761082336610f41565b93909133845263ffffffff60209385855261084360ff84882054166110ea565b1684526009835283209184519167ffffffffffffffff8311610953575061086a835461101a565b601f8111610910575b5080601f83116001146108ae57508394829394926108a3575b50508160011b916000199060031b1c191617905580f35b01519050848061088c565b90601f198316958486528286209286905b8882106108f8575050836001959697106108df575b505050811b01905580f35b015160001960f88460031b161c191690558480806108d4565b806001859682949686015181550195019301906108bf565b838552818520601f840160051c810191838510610949575b601f0160051c01905b81811061093e5750610873565b858155600101610931565b9091508190610928565b634e487b7160e01b855260419052602484fd5b9050346102b557826003193601126102b55760ff60075460801c1615610a0057826109c79160018060a01b03600254168451808095819463a0e3440f60e01b8352820160609060208152600360208201526208aa8960eb1b60408201520190565b03915afa9081156105ee576105c7925083916109e4575b506114df565b6109f891503d8085833e6105de8183610f03565b9050386109de565b6020608492519162461bcd60e51b8352820152602e60248201527f4d7573742063616c6c2064697374726962757465436f6d6d756e69747945786560448201526d31baba37b91034b739ba32b0b21760911b6064820152fd5b9050346102b55760203660031901126102b557610a74610eab565b913384526001602052610a8c60ff82862054166110ea565b60ff60075460801c16610aa357836105c7846111f7565b906020608492519162461bcd60e51b8352820152602560248201527f4d7573742063616c6c2064697374726962757465547265617375727920696e736044820152643a32b0b21760d91b6064820152fd5b5050346101a95760203660031901126101a95780610237610230926102419463ffffffff610270610ec6565b5050346101a957806003193601126101a9577f278b09622564dd3991fe7744514513d64ea2c8ed2b2b9ec1150ad964fde80a996020610b5d610eab565b610b65610fbc565b90338652858352610b7b60ff86882054166110ea565b6001600160a01b031680865260018352848620805460ff191660ff84151516179055936107bb565b5050346101a95760203660031901126101a957610bc360ff610407610ec6565b6007805463ffffffff60601b191660609290921b63ffffffff60601b1691909117905580f35b8383346101a957610bf936610f41565b93909133845263ffffffff602093858552610c1960ff84882054166110ea565b168452600a835283209184519167ffffffffffffffff83116109535750610c40835461101a565b601f8111610cc0575b5080601f8311600114610c7857508394829394926108a35750508160011b916000199060031b1c191617905580f35b90601f198316958486528286209286905b888210610ca8575050836001959697106108df57505050811b01905580f35b80600185968294968601518155019501930190610c89565b838552818520601f840160051c810191838510610cf9575b601f0160051c01905b818110610cee5750610c49565b858155600101610ce1565b9091508190610cd8565b9050346102b55760209182600319360112610e1c57610d20610eab565b91338552848452610d3660ff83872054166110ea565b60018060a01b0380931692836bffffffffffffffffffffffff60a01b6003541617600355858183541691845187816044818663095ea7b360e01b988983528c8b8401528160248401525af18015610e1257916044939189969593610df5575b5084541686519788958694855284015260001960248401525af1908115610dec5750610dbf578280f35b81610dde92903d10610de5575b610dd68183610f03565b810190611125565b5038808280f35b503d610dcc565b513d85823e3d90fd5b610e0b90873d8911610de557610dd68183610f03565b5038610d95565b86513d85823e3d90fd5b8380fd5b5050346101a95760203660031901126101a95763ffffffff60401b610e43610ec6565b33845283602052610e5960ff84862054166110ea565b600754921b169063ffffffff60401b19161760075580f35b849084346102b55760203660031901126102b55760209260ff91906001600160a01b03610e9c610eab565b16815280855220541615158152f35b600435906001600160a01b0382168203610ec157565b600080fd5b6004359063ffffffff82168203610ec157565b67ffffffffffffffff8111610eed57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117610eed57604052565b67ffffffffffffffff8111610eed57601f01601f191660200190565b906040600319830112610ec15760043563ffffffff81168103610ec1579160243567ffffffffffffffff8111610ec15781602382011215610ec157806004013590610f8b82610f25565b92610f996040519485610f03565b82845260248383010111610ec15781600092602460209301838601378301015290565b602435908115158203610ec157565b60005b838110610fde5750506000910152565b8181015183820152602001610fce565b6040916020825261100e8151809281602086015260208686019101610fcb565b601f01601f1916010190565b90600182811c9216801561104a575b602083101461103457565b634e487b7160e01b600052602260045260246000fd5b91607f1691611029565b8054600093926110638261101a565b918282526020936001916001811690816000146110cb575060011461108a575b5050505050565b90939495506000929192528360002092846000945b8386106110b757505050500101903880808080611083565b80548587018301529401938590820161109f565b60ff19168685015250505090151560051b010191503880808080611083565b156110f157565b60405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606490fd5b90816020910312610ec157518015158103610ec15790565b9190604083820312610ec157825167ffffffffffffffff8111610ec15783019080601f83011215610ec15781519161117483610f25565b916111826040519384610f03565b83835260208483010111610ec1576020926111a291848085019101610fcb565b9201516001600160a01b0381168103610ec15790565b6001600160a01b03918216815291166020820152604081019190915260a0606082018190529092916111ec91840190611054565b916080600019910152565b90600654916000926114805760048054604080516370a0823160e01b815230818501526020949093919290916001600160a01b039182168686602481845afa958615611476578996611443575b5060055486106113f45760075463ffffffff948582168089029089820414891517156113e1576127109004978881039081116113e15760065560ff8260881c1660001461133e5750505080604483889354169360085416918a8751958694859363a9059cbb60e01b85528401528960248401525af180156113345796839261131294927f12fb68790bf96e8e0866b1d92968d5f195cefca1c631c800a1a5e1d7b80772419899611317575b505b600754831c1681526009865220908080519586958652850152830190611054565b0390a1565b61132d90883d8a11610de557610dd68183610f03565b50386112ef565b83513d89823e3d90fd5b858560039c97989c969394965416938c1c168652600989528a8620833b156103ba57869493929161138786928b8f51998a98899788966344bc937b60e01b8852169086016111b8565b03925af180156113d7579287927f12fb68790bf96e8e0866b1d92968d5f195cefca1c631c800a1a5e1d7b8077241979892611312956113c8575b50906112f1565b6113d190610ed9565b386113c1565b87513d84823e3d90fd5b634e487b7160e01b8c526011855260248cfd5b845162461bcd60e51b8152808301889052602360248201527f42616c616e63652069732062656c6f77206d696e696d756d2066656520616d6f6044820152621d5b9d60ea1b6064820152608490fd5b9095508681813d831161146f575b61145b8183610f03565b8101031261146b57519438611244565b8880fd5b503d611451565b85513d8b823e3d90fd5b60405162461bcd60e51b815260206004820152603160248201527f497427732074686520636f6d6d756e6974792773207475726e20746f2072656360448201527032b4bb32903234b9ba3934b13aba34b7b760791b6064820152608490fd5b6006549060009082156116aa5760018060a01b03908160045416936040948551936370a0823160e01b85523060048601526020948581602481865afa9081156116a0578791611673575b5083116116205780600354169063ffffffff948560075460601c168852600a8752888820833b1561146b57889493929161157b86928c51988997889687956344bc937b60e01b875216600486016111b8565b03925af18015611616576115e1575b506115d97f2a0d85dcd8643493024ad5bb803e92df710f15f0b462daf2cdba9b7ef18a07c793946006549260075460601c168652600a8452808620908080519586958652850152830190611054565b0390a1600655565b7f2a0d85dcd8643493024ad5bb803e92df710f15f0b462daf2cdba9b7ef18a07c79361160f6115d992610ed9565b935061158a565b85513d86823e3d90fd5b865162461bcd60e51b815260048101869052602660248201527f436f6d6d756e69747920646973747269627574696f6e20657863656564732062604482015265616c616e636560d01b6064820152608490fd5b90508581813d8311611699575b61168a8183610f03565b810103126103ba575138611529565b503d611680565b88513d89823e3d90fd5b60405162461bcd60e51b815260206004820152603060248201527f49742773207468652074726561737572792773207475726e20746f207265636560448201526f34bb32903234b9ba3934b13aba34b7b760811b6064820152608490fdfea2646970667358221220643708981cc607a868cc365e22a7ef06ef62959116418ffe93dee5ff398173eb64736f6c63430008160033
Verified Source Code Full Match
Compiler: v0.8.22+commit.4fc1097e
EVM: paris
Optimization: Yes (200 runs)
TSFeeDistributor_V2.sol 194 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
// -------------------
// Compatibility
// TC Router V4
// -------------------
import {Owners} from "../../lib/Owners.sol";
import {Executors} from "../../lib/Executors.sol";
import {SafeTransferLib} from "../../lib/SafeTransferLib.sol";
import {IERC20} from "../../interfaces/IERC20.sol";
import {IThorchainRouterV4} from "../../interfaces/IThorchainRouterV4.sol";
import {IOracleV1} from "../../interfaces/IOracleV1.sol";
contract TSFeeDistributor_V2 is Owners, Executors {
using SafeTransferLib for address;
IOracleV1 public oracle;
IThorchainRouterV4 public tcRouter;
IERC20 public feeAsset;
uint256 public minFeeAmount;
uint256 private _communityDistribution;
uint32 public treasuryBps;
uint32 public communityBps;
uint32 public treasuryIndex;
uint32 public communityIndex;
bool public publicMode;
bool public transferTreasury;
address public treasuryWallet;
mapping(uint32 => string) public memoTreasury;
mapping(uint32 => string) public memoCommunity;
event TreasuryDistribution(uint256 amount, string memo);
event CommunityDistribution(uint256 amount, string memo);
constructor(
address _oracleAddress,
address _tcRouterAddress,
address _feeAsset,
address _treasuryWallet
) {
treasuryBps = 2500;
communityBps = 7500;
_communityDistribution = 0;
oracle = IOracleV1(_oracleAddress);
tcRouter = IThorchainRouterV4(_tcRouterAddress);
feeAsset = IERC20(_feeAsset);
minFeeAmount = 0;
_feeAsset.safeApprove(_tcRouterAddress, 0);
_feeAsset.safeApprove(_tcRouterAddress, type(uint256).max);
publicMode = false;
transferTreasury = true;
treasuryWallet = _treasuryWallet;
_setOwner(msg.sender, true);
}
function setMinFeeAmount(uint256 amount) external isOwner {
minFeeAmount = amount;
}
function setTCRouter(address _tcRouterAddress) public isOwner {
tcRouter = IThorchainRouterV4(_tcRouterAddress);
feeAsset.approve(_tcRouterAddress, 0);
feeAsset.approve(_tcRouterAddress, type(uint256).max);
}
function setShares(uint32 treasury, uint32 community) external isOwner {
require(treasury + community == 10000, "Shares must add up to 10000");
treasuryBps = treasury;
communityBps = community;
}
function getMemoTreasury(uint32 id) external view returns (string memory) {
return memoTreasury[id];
}
function setMemoTreasury(uint32 id, string memory memo) external isOwner {
memoTreasury[id] = memo;
}
function setTreasuryIndex(uint32 index) external isOwner {
treasuryIndex = index;
}
function setTreasuryTransfer(bool _transferTreasury) external isOwner {
transferTreasury = _transferTreasury;
}
function getMemoCommunity(uint32 id) external view returns (string memory) {
return memoCommunity[id];
}
function setMemoCommunity(uint32 id, string memory memo) external isOwner {
memoCommunity[id] = memo;
}
function setCommunityIndex(uint32 index) external isOwner {
communityIndex = index;
}
function setTreasuryWallet(address _treasuryWallet) external isOwner {
treasuryWallet = _treasuryWallet;
}
// Protected version in case the oracle is down
function distributeTreasuryExecutor(
address inboundAddress
) external isExecutor {
require(!publicMode, "Must call distributeTreasury instead.");
_distributeTreasury(inboundAddress);
}
function distributeTreasury() external {
require(publicMode, "Must call distributeTreasuryExecutor instead.");
(, address inboundAddress) = oracle.getInboundAddress("ETH");
_distributeTreasury(inboundAddress);
}
function _distributeTreasury(address inboundAddress) internal {
require(
_communityDistribution == 0,
"It's the community's turn to receive distribution"
);
uint256 balance = feeAsset.balanceOf(address(this));
require(balance >= minFeeAmount, "Balance is below minimum fee amount");
uint256 treasuryAmount = (balance * treasuryBps) / 10000;
_communityDistribution = balance - treasuryAmount;
if (transferTreasury) {
feeAsset.transfer(treasuryWallet, treasuryAmount);
} else {
tcRouter.depositWithExpiry{value: 0}(
payable(inboundAddress),
address(feeAsset),
treasuryAmount,
memoTreasury[treasuryIndex],
type(uint256).max
);
}
emit TreasuryDistribution(treasuryAmount, memoTreasury[treasuryIndex]);
}
function distributeCommunityExecutor(
address inboundAddress
) external isExecutor {
require(!publicMode, "Must call distributeCommunity instead.");
_distributeCommunity(inboundAddress);
}
function distributeCommunity() external {
require(publicMode, "Must call distributeCommunityExecutor instead.");
(, address inboundAddress) = oracle.getInboundAddress("ETH");
_distributeCommunity(inboundAddress);
}
function _distributeCommunity(address inboundAddress) internal {
require(
_communityDistribution > 0,
"It's the treasury's turn to receive distribution"
);
require(
_communityDistribution <= feeAsset.balanceOf(address(this)),
"Community distribution exceeds balance"
);
tcRouter.depositWithExpiry{value: 0}(
payable(inboundAddress),
address(feeAsset),
_communityDistribution,
memoCommunity[communityIndex],
type(uint256).max
);
emit CommunityDistribution(
_communityDistribution,
memoCommunity[communityIndex]
);
_communityDistribution = 0;
}
}
IERC20.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IERC20 {
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(
address recipient,
uint256 amount
) external returns (bool);
function allowance(
address owner,
address spender
) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
}
IOracleV1.sol 15 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IOracleV1 {
function getRouterAddress() external view returns (address);
function getPoolsAPY(string memory chain) external view returns (uint64);
function getSaversAPY(string memory chain) external view returns (uint64);
// Updated to match the new return type of getInboundAddress in the TSOracle_V1 contract
function getInboundAddress(
string memory chain
) external view returns (bytes memory, address);
}
IThorchainRouterV4.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IThorchainRouterV4 {
function depositWithExpiry(
address payable vault,
address asset,
uint amount,
string memory memo,
uint expiration
) external payable;
}
Executors.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {Owners} from "./Owners.sol";
abstract contract Executors is Owners {
event ExecutorSet(address indexed executor, bool active);
mapping(address => bool) public executors;
modifier isExecutor() {
require(executors[msg.sender], "Unauthorized");
_;
}
function _setExecutor(address executor, bool active) internal virtual {
executors[executor] = active;
emit ExecutorSet(executor, active);
}
function setExecutor(address owner, bool active) external virtual isOwner {
_setExecutor(owner, active);
}
}
Owners.sol 22 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
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);
}
}
SafeTransferLib.sol 159 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
}
}
}
}
Read Contract
communityBps 0xfa580294 → uint32
communityIndex 0xc37fb119 → uint32
executors 0x9ac2a011 → bool
feeAsset 0x53ba352c → address
getMemoCommunity 0x1ff48c49 → string
getMemoTreasury 0x90170654 → string
memoCommunity 0xd6942c8b → string
memoTreasury 0xdacd0737 → string
minFeeAmount 0xf5d36475 → uint256
oracle 0x7dc0d1d0 → address
owners 0x022914a7 → bool
publicMode 0xe6d7329d → bool
tcRouter 0xac21d47a → address
transferTreasury 0x644c5695 → bool
treasuryBps 0x4dc10ea1 → uint32
treasuryIndex 0x932f3f66 → uint32
treasuryWallet 0x4626402b → address
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
distributeCommunity 0x2e394a94
No parameters
distributeCommunityExecutor 0x6e91a948
address inboundAddress
distributeTreasury 0x730a1e38
No parameters
distributeTreasuryExecutor 0x27a8d0d9
address inboundAddress
setCommunityIndex 0x162d493c
uint32 index
setExecutor 0x1e1bff3f
address owner
bool active
setMemoCommunity 0x0d13b953
uint32 id
string memo
setMemoTreasury 0x4109ce6c
uint32 id
string memo
setMinFeeAmount 0xd6117529
uint256 amount
setOwner 0x516c731c
address owner
bool active
setShares 0xb37b50e3
uint32 treasury
uint32 community
setTCRouter 0x08a199da
address _tcRouterAddress
setTreasuryIndex 0x0852817d
uint32 index
setTreasuryTransfer 0x9e0320ca
bool _transferTreasury
setTreasuryWallet 0xa8602fea
address _treasuryWallet
Recent Transactions
No transactions found for this address