Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- FoundersTreasury
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 1000
- EVM Version
- paris
- Verified at
- 2023-08-05T05:40:19.978641Z
Constructor Arguments
000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000001e18ed1bfca02e59a43de32c60ac0fd4923b64b5000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000055bc3149557373ac8fe90a652d20789cb874503c000000000000000000000000000000000000000000000000000000000000001f000000000000000000000000db5bf456e97f0dfba490e1335a03bc8fe7c3a683000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000009355361c9ba7efdcfcda49a2cdf3beccd3630938000000000000000000000000000000000000000000000000000000000000001b
contracts/FoundersTreasury.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract FoundersTreasury {
struct Founder {
address addr;
uint8 sharePercent;
}
Founder[] private founders;
constructor(Founder[] memory _founders) {
for (uint256 i = 0; i < _founders.length; ++i) {
founders.push(_founders[i]);
}
}
function distribute(address[] calldata tokenAddresses) public {
uint256 balance = address(this).balance;
uint256 balanceRemaining = balance;
uint256 foundersCount = founders.length;
for (uint256 i = foundersCount - 1; ; --i) {
if (balanceRemaining == 0) break;
Founder memory founder = founders[i];
uint256 coinsPerAddress = i == 0
? balanceRemaining
: (balance * founder.sharePercent) / 100;
payable(founder.addr).transfer(coinsPerAddress);
balanceRemaining -= coinsPerAddress;
if (i == 0) break;
}
for (uint256 j = 0; j < tokenAddresses.length; j++) {
address tokenAddress = tokenAddresses[j];
balanceRemaining = balance = IERC20(tokenAddress).balanceOf(
address(this)
);
for (uint256 i = foundersCount - 1; ; --i) {
if (balanceRemaining == 0) break;
Founder memory founder = founders[i];
uint256 tokensPerAddress = i == 0
? balanceRemaining
: (balance * founder.sharePercent) / 100;
IERC20(tokenAddress).transfer(founder.addr, tokensPerAddress);
balanceRemaining -= tokensPerAddress;
if (i == 0) break;
}
}
}
receive() external payable {}
}
/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` 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 amount) external returns (bool);
}
Compiler Settings
{"viaIR":true,"remappings":[],"optimizer":{"runs":1000,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"paris","compilationTarget":{"contracts/FoundersTreasury.sol":"FoundersTreasury"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"tuple[]","name":"_founders","internalType":"struct FoundersTreasury.Founder[]","components":[{"type":"address","name":"addr","internalType":"address"},{"type":"uint8","name":"sharePercent","internalType":"uint8"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"distribute","inputs":[{"type":"address[]","name":"tokenAddresses","internalType":"address[]"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x604060808152346101a6576106898038038061001a816101c0565b928339810160209182818303126101a65780516001600160401b03918282116101a657019180601f840112156101a6578251828111610132576005926100638683861b016101c0565b94868087858152019360061b820101938085116101a65792908701925b84841061015657505050505060005b8251811015610148578381831b840101516000546801000000000000000081101561013257600181018060005581101561011c576000805285600020019060018060a01b038151168254918760ff60a01b91015160a01b169160018060a81b0319161717905560001981146101065760010161008f565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b84516104a390816101e68239f35b88848203126101a6578851898101818110858211176101ab578a5284516001600160a01b03811681036101a65781528885015160ff811681036101a6578982015282529288019290870190610080565b600080fd5b60246000634e487b7160e01b81526041600452fd5b6040519190601f01601f191682016001600160401b038111838210176101325760405256fe608060405260048036101561001d575b50361561001b57600080fd5b005b600090813560e01c636138889b14610035575061000f565b3461035e576020908160031936011261035a5780359167ffffffffffffffff9182841161035657366023850112156103565783810135928311610356573660248460051b8601011161035657845447946000198201918211939086856103435788908885995b6102aa575b505090919293949596505b8681106100b6578780f35b60248160051b8301013573ffffffffffffffffffffffffffffffffffffffff908181168091036102a657604051907f70a0823100000000000000000000000000000000000000000000000000000000825230888301528582602481845afa91821561029b578b92610268575b50818961025557808c9189915b61015e575b505050505050600019811461014b576001016100ab565b602488601187634e487b7160e01b835252fd5b61017061016a83610392565b50610414565b8215938415610237578a8d60448a86955b51169160405194859384927fa9059cbb0000000000000000000000000000000000000000000000000000000084528301528660248301528a5af18015610229576101ee575b506101d091610362565b916101e7576101df8291610385565b908d9261012f565b8c91610134565b8a81813d8311610222575b61020381836103dc565b8101031261021e57518015150361021a57386101c6565b8e80fd5b8f80fd5b503d6101f9565b508f604051903d90823e3d90fd5b8a8d60448a606461024e60ff86890151168d61045a565b0495610181565b60248c60118b634e487b7160e01b835252fd5b9091508581813d8311610294575b61028081836103dc565b8101031261029057519038610122565b8a80fd5b503d610276565b6040513d8d823e3d90fd5b8980fd5b73ffffffffffffffffffffffffffffffffffffffff838080808e6102d061016a82610392565b9061032857869586915b511682821561031f575bf115610314576102f391610362565b98801561030f57906103068a9392610385565b9990919261009b565b6100a0565b6040513d85823e3d90fd5b506108fc6102e4565b606461033a60ff8d840151168a61045a565b049586916102da565b602489601187634e487b7160e01b835252fd5b8480fd5b8280fd5b5080fd5b9190820391821161036f57565b634e487b7160e01b600052601160045260246000fd5b801561036f576000190190565b9060009182548110156103c8578280527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563019190565b602483634e487b7160e01b81526032600452fd5b90601f8019910116810190811067ffffffffffffffff8211176103fe57604052565b634e487b7160e01b600052604160045260246000fd5b906040516040810181811067ffffffffffffffff8211176103fe57604052915473ffffffffffffffffffffffffffffffffffffffff8116835260a01c60ff166020830152565b8181029291811591840414171561036f5756fea264697066735822122033c31461921e60c26b22569dfc9c062a0ff2e8bdccefbdf41f1d7cab675e48e564736f6c63430008120033000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000001e18ed1bfca02e59a43de32c60ac0fd4923b64b5000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000055bc3149557373ac8fe90a652d20789cb874503c000000000000000000000000000000000000000000000000000000000000001f000000000000000000000000db5bf456e97f0dfba490e1335a03bc8fe7c3a683000000000000000000000000000000000000000000000000000000000000001b0000000000000000000000009355361c9ba7efdcfcda49a2cdf3beccd3630938000000000000000000000000000000000000000000000000000000000000001b
Deployed ByteCode
0x608060405260048036101561001d575b50361561001b57600080fd5b005b600090813560e01c636138889b14610035575061000f565b3461035e576020908160031936011261035a5780359167ffffffffffffffff9182841161035657366023850112156103565783810135928311610356573660248460051b8601011161035657845447946000198201918211939086856103435788908885995b6102aa575b505090919293949596505b8681106100b6578780f35b60248160051b8301013573ffffffffffffffffffffffffffffffffffffffff908181168091036102a657604051907f70a0823100000000000000000000000000000000000000000000000000000000825230888301528582602481845afa91821561029b578b92610268575b50818961025557808c9189915b61015e575b505050505050600019811461014b576001016100ab565b602488601187634e487b7160e01b835252fd5b61017061016a83610392565b50610414565b8215938415610237578a8d60448a86955b51169160405194859384927fa9059cbb0000000000000000000000000000000000000000000000000000000084528301528660248301528a5af18015610229576101ee575b506101d091610362565b916101e7576101df8291610385565b908d9261012f565b8c91610134565b8a81813d8311610222575b61020381836103dc565b8101031261021e57518015150361021a57386101c6565b8e80fd5b8f80fd5b503d6101f9565b508f604051903d90823e3d90fd5b8a8d60448a606461024e60ff86890151168d61045a565b0495610181565b60248c60118b634e487b7160e01b835252fd5b9091508581813d8311610294575b61028081836103dc565b8101031261029057519038610122565b8a80fd5b503d610276565b6040513d8d823e3d90fd5b8980fd5b73ffffffffffffffffffffffffffffffffffffffff838080808e6102d061016a82610392565b9061032857869586915b511682821561031f575bf115610314576102f391610362565b98801561030f57906103068a9392610385565b9990919261009b565b6100a0565b6040513d85823e3d90fd5b506108fc6102e4565b606461033a60ff8d840151168a61045a565b049586916102da565b602489601187634e487b7160e01b835252fd5b8480fd5b8280fd5b5080fd5b9190820391821161036f57565b634e487b7160e01b600052601160045260246000fd5b801561036f576000190190565b9060009182548110156103c8578280527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563019190565b602483634e487b7160e01b81526032600452fd5b90601f8019910116810190811067ffffffffffffffff8211176103fe57604052565b634e487b7160e01b600052604160045260246000fd5b906040516040810181811067ffffffffffffffff8211176103fe57604052915473ffffffffffffffffffffffffffffffffffffffff8116835260a01c60ff166020830152565b8181029291811591840414171561036f5756fea264697066735822122033c31461921e60c26b22569dfc9c062a0ff2e8bdccefbdf41f1d7cab675e48e564736f6c63430008120033