Address Contract Partially Verified
Address
0xD19d7B48670654d4e6aFAcd1ed8F160235ec931b
Balance
0 ETH
Nonce
1
Code Size
2087 bytes
Creator
0x5a46c3A5...A892 at tx 0x4717ae7d...2fd977
Indexed Transactions
0
Contract Bytecode
2087 bytes
0x608060405234801561000f575f80fd5b5060043610610055575f3560e01c80631e83409a1461005957806328de3c9b1461007f5780635827b250146100ad578063d4abe717146100b7578063f7c618c1146100d7575b5f80fd5b61006c610067366004610637565b610101565b6040519081526020015b60405180910390f35b61009261008d36600461065d565b61011e565b60408051938452602084019290925290820152606001610076565b6100b561014f565b005b6100ca6100c5366004610674565b61015a565b60405161007691906106e3565b5f546100e9906001600160a01b031681565b6040516001600160a01b039091168152602001610076565b5f8054610118906001600160a01b0316834261021b565b92915050565b6002818154811061012d575f80fd5b5f91825260209091206003909102018054600182015460029092015490925083565b61015833610364565b565b60608167ffffffffffffffff81111561017557610175610726565b60405190808252806020026020018201604052801561019e578160200160208202803683370190505b505f80549192506001600160a01b039091169042905b84811015610212576101ed838787848181106101d2576101d261073a565b90506020020160208101906101e79190610637565b8461021b565b8482815181106101ff576101ff61073a565b60209081029190910101526001016101b4565b50505092915050565b5f6001600160a01b03841661023157505f61035d565b5f61023b84610399565b60028101549091505f03610252575f91505061035d565b5f8160010180548060200260200160405190810160405280929190818152602001828054801561029f57602002820191905f5260205f20905b81548152602001906001019080831161028b575b505050505090505f5b8151811015610348578181815181106102c3576102c361073a565b60200260200101515f0315610340578181815181106102e4576102e461073a565b60200260200101518510610348575f8360010182815481106103085761030861073a565b905f5260205f2001819055508260020181815481106103295761032961073a565b905f5260205f2001548461033d9190610762565b93505b6001016102a8565b50821561035a5761035a868685610542565b50505b9392505050565b5f546001600160a01b031615610378575f80fd5b5f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381165f9081526001602052604090206002810154158015906103c557506001810154155b1561053d575f816002015f815481106103e0576103e061073a565b905f5260205f2001549050816002018054806103fe576103fe610775565b600190038181905f5260205f20015f905590555f6002835f0154815481106104285761042861073a565b905f5260205f2090600302016040518060600160405290815f82015481526020016001820154815260200160028201548152505090505f81604001518361046f9190610789565b825190915080156104805780610482565b425b90505f5b83604001518110156104e557856001018185602001516104a691906107a8565b6104b09084610762565b8154600181810184555f9384526020808520909201929092556002890180548084018255908452922090910184905501610486565b50600183604001516104f791906107bf565b61050190836107a8565b61050b90856107bf565b60028601805461051d906001906107bf565b8154811061052d5761052d61073a565b5f91825260209091200155505050505b919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790525f906105969085906105fe565b905080515f14806105b65750808060200190518101906105b691906107d2565b6105f85760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640160405180910390fd5b50505050565b60605f808351602085015f875af13d604051925080835260208301815f823e808201604052828061062d578282fd5b5050505092915050565b5f60208284031215610647575f80fd5b81356001600160a01b038116811461035d575f80fd5b5f6020828403121561066d575f80fd5b5035919050565b5f8060208385031215610685575f80fd5b823567ffffffffffffffff8082111561069c575f80fd5b818501915085601f8301126106af575f80fd5b8135818111156106bd575f80fd5b8660208260051b85010111156106d1575f80fd5b60209290920196919550909350505050565b602080825282518282018190525f9190848201906040850190845b8181101561071a578351835292840192918401916001016106fe565b50909695505050505050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156101185761011861074e565b634e487b7160e01b5f52603160045260245ffd5b5f826107a357634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176101185761011861074e565b818103818111156101185761011861074e565b5f602082840312156107e2575f80fd5b8151801515811461035d575f80fdfea2646970667358221220bece21bb945350dff4a86bfd7940404f3a8a8ee77a469ce3445b201b8dff16ba64736f6c63430008180033
Verified Source Code Partial Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: Yes (200 runs)
VestingContract.sol 133 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IVestingContract.sol";
interface IERC20 {
function transfer(address recipient, uint256 amount) external returns (bool);
}
contract VestingContract is IVestingContract {
struct VestingInfo {
uint256 startingFrom;
uint256 interval;
uint256 tranches;
}
struct VestingInput {
VestingInfo info;
address[] owners;
uint256[] amounts;
}
struct Vesting {
uint256 infoIndex;
uint256[] timestamps;
uint256[] amounts;
}
uint256 private constant ONE_HUNDRED = 1e18;
address public rewardToken;
mapping(address => Vesting) private vestingOf;
VestingInfo[] public infos;
constructor(VestingInput[] memory inputs) {
for(uint256 i = 0; i < inputs.length; i++) {
VestingInput memory input = inputs[i];
uint256 infoIndex = infos.length;
infos.push(input.info);
for(uint256 z = 0; z < input.owners.length; z++) {
Vesting storage vesting = vestingOf[input.owners[z]];
vesting.infoIndex = infoIndex;
vesting.amounts.push(input.amounts[z]);
}
}
}
function completeInitialization() external override {
_setRewardToken(msg.sender);
}
function claim(address owner) external returns (uint256 amount) {
return _claim(rewardToken, owner, block.timestamp);
}
function claimBatch(address[] calldata owners) external returns (uint256[] memory amounts) {
amounts = new uint256[](owners.length);
address token = rewardToken;
uint256 blockTimestamp = block.timestamp;
for(uint256 i = 0; i < owners.length; i++) {
amounts[i] = _claim(token, owners[i], blockTimestamp);
}
}
function _claim(address token, address owner, uint256 blockTimestamp) private returns(uint256 amount) {
if(token == address(0)) {
return 0;
}
Vesting storage vesting = _prepareVesting(owner);
if(vesting.amounts.length == 0) {
return 0;
}
uint256[] memory timestamps = vesting.timestamps;
for(uint256 i = 0; i < timestamps.length; i++) {
if(timestamps[i] == 0) {
continue;
}
if(blockTimestamp < timestamps[i]) {
break;
}
vesting.timestamps[i] = 0;
amount += vesting.amounts[i];
}
if(amount != 0) {
_safeTransfer(token, owner, amount);
}
}
function _prepareVesting(address owner) private returns(Vesting storage vesting) {
vesting = vestingOf[owner];
if(vesting.amounts.length > 0 && vesting.timestamps.length == 0) {
uint256 amount = vesting.amounts[0];
vesting.amounts.pop();
VestingInfo memory info = infos[vesting.infoIndex];
uint256 splittedAmount = amount / info.tranches;
uint256 startingFrom = info.startingFrom;
startingFrom = startingFrom == 0 ? block.timestamp : startingFrom;
for(uint256 i = 0; i < info.tranches; i++) {
vesting.timestamps.push(startingFrom + (info.interval * i));
vesting.amounts.push(splittedAmount);
}
vesting.amounts[vesting.amounts.length - 1] = (amount - (splittedAmount * (info.tranches - 1)));
}
}
function _setRewardToken(address token) private {
require(rewardToken == address(0));
rewardToken = token;
}
function _safeTransfer(address erc20TokenAddress, address to, uint256 value) private {
bytes memory returnData = _call(erc20TokenAddress, abi.encodeWithSelector(IERC20(erc20TokenAddress).transfer.selector, to, value));
require(returnData.length == 0 || abi.decode(returnData, (bool)), 'TRANSFER_FAILED');
}
function _call(address location, bytes memory payload) private returns(bytes memory returnData) {
assembly {
let result := call(gas(), location, 0, add(payload, 0x20), mload(payload), 0, 0)
let size := returndatasize()
returnData := mload(0x40)
mstore(returnData, size)
let returnDataPayloadStart := add(returnData, 0x20)
returndatacopy(returnDataPayloadStart, 0, size)
mstore(0x40, add(returnDataPayloadStart, size))
switch result case 0 {revert(returnDataPayloadStart, size)}
}
}
}
IVestingContract.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IVestingContract {
function completeInitialization() external;
}
Read Contract
infos 0x28de3c9b → uint256, uint256, uint256
rewardToken 0xf7c618c1 → address
Write Contract 3 functions
These functions modify contract state and require a wallet transaction to execute.
claim 0x1e83409a
address owner
returns: uint256
claimBatch 0xd4abe717
address[] owners
returns: uint256[]
completeInitialization 0x5827b250
No parameters
Recent Transactions
No transactions found for this address