Address Contract Verified
Address
0x945229AF4d1fff9f51d1c8E9F62FE03bB4dB706c
Balance
0 ETH
Nonce
1
Code Size
3739 bytes
Creator
0xD7e24A49...3303 at tx 0xdf777cb2...0548c0
Indexed Transactions
0
Contract Bytecode
3739 bytes
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b14610152578063c804c39a14610167578063dd8c9c9d1461017a578063eb0d07f51461019a578063f2fde38b146101ad578063fc0c546a146101c0576100b4565b8063120aa877146100b957806339436b00146100e257806347fb23c1146101025780634cd488ab1461012257806358b4e4b414610137578063715018a61461014a575b600080fd5b6100cc6100c7366004610b84565b6101c8565b6040516100d99190610cfb565b60405180910390f35b6100f56100f0366004610bdb565b6101e8565b6040516100d99190610cc3565b610115610110366004610ab9565b61027e565b6040516100d99190610c7d565b610135610130366004610bb0565b610332565b005b610135610145366004610aec565b610455565b6101356104ea565b61015a610569565b6040516100d99190610c2c565b6101356101753660046109d2565b610578565b61018d610188366004610b6c565b610659565b6040516100d99190610d06565b6100cc6101a8366004610aec565b61066b565b6101356101bb3660046109b0565b6106c1565b61015a610777565b600360209081526000928352604080842090915290825290205460ff1681565b6060828203600101818167ffffffffffffffff8111801561020857600080fd5b50604051908082528060200260200182016040528015610232578160200160208202803683370190505b50905060005b8281101561027357858101600090815260026020526040902054825183908390811061026057fe5b6020908102919091010152600101610238565b509150505b92915050565b6060828203600101818167ffffffffffffffff8111801561029e57600080fd5b506040519080825280602002602001820160405280156102c8578160200160208202803683370190505b50905060005b828110156103285785810160009081526003602090815260408083206001600160a01b038b168452909152902054825160ff9091169083908390811061031057fe5b911515602092830291909101909101526001016102ce565b5095945050505050565b61033a610786565b6000546001600160a01b039081169116146103705760405162461bcd60e51b815260040161036790610d85565b60405180910390fd5b6000838152600260205260409020541561039c5760405162461bcd60e51b815260040161036790610de7565b6000838152600260205260409081902083905560015490516323b872dd60e01b81526001600160a01b03909116906323b872dd906103e290339030908690600401610c40565b602060405180830381600087803b1580156103fc57600080fd5b505af1158015610410573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104349190610b4c565b6104505760405162461bcd60e51b815260040161036790610dba565b505050565b60008381526003602090815260408083206001600160a01b038816845290915290205460ff161561048557600080fd5b6104918484848461066b565b6104ad5760405162461bcd60e51b815260040161036790610d55565b60008381526003602090815260408083206001600160a01b03881684529091529020805460ff191660011790556104e4848361078a565b50505050565b6104f2610786565b6000546001600160a01b0390811691161461051f5760405162461bcd60e51b815260040161036790610d85565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b600061058261090a565b60005b835181101561064e5783818151811061059a57fe5b602090810291909101810151805160009081526003835260408082206001600160a01b038a168352909352919091205490925060ff16156105da57600080fd5b6105f28583600001518460200151856040015161066b565b61060e5760405162461bcd60e51b815260040161036790610d55565b602080830151835160009081526003835260408082206001600160a01b038a16835290935291909120805460ff1916600190811790915593019201610585565b506104e4848361078a565b60026020526000908152604090205481565b6000808584604051602001610681929190610bfc565b6040516020818303038152906040528051906020012090506106b78360026000888152602001908152602001600020548361086d565b9695505050505050565b6106c9610786565b6000546001600160a01b039081169116146106f65760405162461bcd60e51b815260040161036790610d85565b6001600160a01b03811661071c5760405162461bcd60e51b815260040161036790610d0f565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031681565b3390565b8015610869577fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a82826040516107c1929190610c64565b60405180910390a160015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906107fb9085908590600401610c64565b602060405180830381600087803b15801561081557600080fd5b505af1158015610829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084d9190610b4c565b6108695760405162461bcd60e51b815260040161036790610dba565b5050565b600081815b85518110156108ff57600086828151811061088957fe5b602002602001015190508083116108ca5782816040516020016108ad929190610c1e565b6040516020818303038152906040528051906020012092506108f6565b80836040516020016108dd929190610c1e565b6040516020818303038152906040528051906020012092505b50600101610872565b509092149392505050565b60405180606001604052806000815260200160008152602001606081525090565b80356001600160a01b038116811461027857600080fd5b600082601f830112610952578081fd5b813561096561096082610e45565b610e1e565b81815291506020808301908481018184028601820187101561098657600080fd5b60005b848110156109a557813584529282019290820190600101610989565b505050505092915050565b6000602082840312156109c1578081fd5b6109cb838361092b565b9392505050565b600080604083850312156109e4578081fd5b6109ee848461092b565b915060208084013567ffffffffffffffff80821115610a0b578384fd5b81860187601f820112610a1c578485fd5b80359250610a2c61096084610e45565b83815284810190828601875b86811015610aa857813585016060818e03601f19011215610a5757898afd5b610a616060610e1e565b89820135815260408201358a820152606082013588811115610a81578b8cfd5b610a8f8f8c83860101610942565b6040830152508552509287019290870190600101610a38565b50979a909950975050505050505050565b600080600060608486031215610acd578081fd5b610ad7858561092b565b95602085013595506040909401359392505050565b60008060008060808587031215610b01578081fd5b610b0b868661092b565b93506020850135925060408501359150606085013567ffffffffffffffff811115610b34578182fd5b610b4087828801610942565b91505092959194509250565b600060208284031215610b5d578081fd5b815180151581146109cb578182fd5b600060208284031215610b7d578081fd5b5035919050565b60008060408385031215610b96578182fd5b82359150610ba7846020850161092b565b90509250929050565b600080600060608486031215610bc4578283fd5b505081359360208301359350604090920135919050565b60008060408385031215610bed578182fd5b50508035926020909101359150565b60609290921b6bffffffffffffffffffffffff19168252601482015260340190565b918252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015610cb7578351151583529284019291840191600101610c99565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015610cb757835183529284019291840191600101610cdf565b901515815260200190565b90815260200190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526016908201527524b731b7b93932b1ba1036b2b935b63290383937b7b360511b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526013908201527211549497d514905394d1915497d19052531151606a1b604082015260600190565b6020808252601a908201527f63616e6e6f742072657772697465206d65726b6c6520726f6f74000000000000604082015260600190565b60405181810167ffffffffffffffff81118282101715610e3d57600080fd5b604052919050565b600067ffffffffffffffff821115610e5b578081fd5b506020908102019056fea26469706673582212207bfecd172557e04b3fa1ca02f6222de305a95bc9008c6af1318f7340a20775ee64736f6c63430006080033
Verified Source Code Full Match
Compiler: v0.6.8+commit.0bbfe453
EVM: istanbul
Optimization: Yes (200 runs)
MerkleRedeem.sol 138 lines
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.6.8;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract MerkleRedeem is Ownable {
IERC20 public token;
event Claimed(address _claimant, uint256 _balance);
// Recorded weeks
mapping(uint => bytes32) public weekMerkleRoots;
mapping(uint => mapping(address => bool)) public claimed;
constructor(
address _token
) public {
token = IERC20(_token);
}
function disburse(
address _liquidityProvider,
uint _balance
)
private
{
if (_balance > 0) {
emit Claimed(_liquidityProvider, _balance);
require(token.transfer(_liquidityProvider, _balance), "ERR_TRANSFER_FAILED");
}
}
function claimWeek(
address _liquidityProvider,
uint _week,
uint _claimedBalance,
bytes32[] memory _merkleProof
)
public
{
require(!claimed[_week][_liquidityProvider]);
require(verifyClaim(_liquidityProvider, _week, _claimedBalance, _merkleProof), 'Incorrect merkle proof');
claimed[_week][_liquidityProvider] = true;
disburse(_liquidityProvider, _claimedBalance);
}
struct Claim {
uint week;
uint balance;
bytes32[] merkleProof;
}
function claimWeeks(
address _liquidityProvider,
Claim[] memory claims
)
public
{
uint totalBalance = 0;
Claim memory claim ;
for(uint i = 0; i < claims.length; i++) {
claim = claims[i];
require(!claimed[claim.week][_liquidityProvider]);
require(verifyClaim(_liquidityProvider, claim.week, claim.balance, claim.merkleProof), 'Incorrect merkle proof');
totalBalance += claim.balance;
claimed[claim.week][_liquidityProvider] = true;
}
disburse(_liquidityProvider, totalBalance);
}
function claimStatus(
address _liquidityProvider,
uint _begin,
uint _end
)
external
view
returns (bool[] memory)
{
uint size = 1 + _end - _begin;
bool[] memory arr = new bool[](size);
for(uint i = 0; i < size; i++) {
arr[i] = claimed[_begin + i][_liquidityProvider];
}
return arr;
}
function merkleRoots(
uint _begin,
uint _end
)
external
view
returns (bytes32[] memory)
{
uint size = 1 + _end - _begin;
bytes32[] memory arr = new bytes32[](size);
for(uint i = 0; i < size; i++) {
arr[i] = weekMerkleRoots[_begin + i];
}
return arr;
}
function verifyClaim(
address _liquidityProvider,
uint _week,
uint _claimedBalance,
bytes32[] memory _merkleProof
)
public
view
returns (bool valid)
{
bytes32 leaf = keccak256(abi.encodePacked(_liquidityProvider, _claimedBalance));
return MerkleProof.verify(_merkleProof, weekMerkleRoots[_week], leaf);
}
function seedAllocations(
uint _week,
bytes32 _merkleRoot,
uint _totalAllocation
)
external
onlyOwner
{
require(weekMerkleRoots[_week] == bytes32(0), "cannot rewrite merkle root");
weekMerkleRoots[_week] = _merkleRoot;
require(token.transferFrom(msg.sender, address(this), _totalAllocation), "ERR_TRANSFER_FAILED");
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/*
* @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 GSN 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 payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
Ownable.sol 68 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "../GSN/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.
*
* By default, the owner account will be the one that deploys the contract. 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.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = 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 {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
MerkleProof.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev These functions deal with verification of Merkle trees (hash trees),
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == root;
}
}
Read Contract
claimStatus 0x47fb23c1 → bool[]
claimed 0x120aa877 → bool
merkleRoots 0x39436b00 → bytes32[]
owner 0x8da5cb5b → address
token 0xfc0c546a → address
verifyClaim 0xeb0d07f5 → bool
weekMerkleRoots 0xdd8c9c9d → bytes32
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
claimWeek 0x58b4e4b4
address _liquidityProvider
uint256 _week
uint256 _claimedBalance
bytes32[] _merkleProof
claimWeeks 0x91c0737a
address _liquidityProvider
tuple[] claims
renounceOwnership 0x715018a6
No parameters
seedAllocations 0x4cd488ab
uint256 _week
bytes32 _merkleRoot
uint256 _totalAllocation
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address