@gearbox-protocol/periphery-v3 1.7.0-next.85 → 1.7.0-next.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.10;
|
|
3
|
-
|
|
4
|
-
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
|
|
5
|
-
import {IDegenDistributorV3} from "../interfaces/IDegenDistributorV3.sol";
|
|
6
|
-
|
|
7
|
-
interface IDegenNFT {
|
|
8
|
-
function mint(address to, uint256 amount) external;
|
|
9
|
-
function burn(address from, uint256 amount) external;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
contract DegenDistributorV3 is IDegenDistributorV3 {
|
|
13
|
-
uint256 public constant version = 3_00;
|
|
14
|
-
|
|
15
|
-
/// @dev Emits each time when call not by treasury
|
|
16
|
-
error TreasuryOnlyException();
|
|
17
|
-
|
|
18
|
-
/// @dev Returns the token distributed by the contract
|
|
19
|
-
address public immutable override degenNFT;
|
|
20
|
-
|
|
21
|
-
/// @dev DAO Treasury address
|
|
22
|
-
address public immutable treasury;
|
|
23
|
-
|
|
24
|
-
/// @dev The current merkle root of total claimable balances
|
|
25
|
-
bytes32 public override merkleRoot;
|
|
26
|
-
|
|
27
|
-
/// @dev The mapping that stores amounts already claimed by users
|
|
28
|
-
mapping(address => uint256) public claimed;
|
|
29
|
-
|
|
30
|
-
modifier treasuryOnly() {
|
|
31
|
-
if (msg.sender != treasury) revert TreasuryOnlyException();
|
|
32
|
-
_;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
constructor(address degenNFT_, address treasury_) {
|
|
36
|
-
degenNFT = degenNFT_;
|
|
37
|
-
treasury = treasury_;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function updateMerkleRoot(bytes32 newRoot) external treasuryOnly {
|
|
41
|
-
bytes32 oldRoot = merkleRoot;
|
|
42
|
-
merkleRoot = newRoot;
|
|
43
|
-
emit RootUpdated(oldRoot, newRoot);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function claim(uint256 index, address account, uint256 totalAmount, bytes32[] calldata merkleProof)
|
|
47
|
-
external
|
|
48
|
-
override
|
|
49
|
-
{
|
|
50
|
-
require(claimed[account] < totalAmount, "MerkleDistributor: Nothing to claim");
|
|
51
|
-
|
|
52
|
-
bytes32 node = keccak256(abi.encodePacked(index, account, totalAmount));
|
|
53
|
-
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof.");
|
|
54
|
-
|
|
55
|
-
uint256 claimedAmount = totalAmount - claimed[account];
|
|
56
|
-
claimed[account] += claimedAmount;
|
|
57
|
-
IDegenNFT(degenNFT).mint(account, claimedAmount);
|
|
58
|
-
|
|
59
|
-
emit Claimed(account, claimedAmount);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.10;
|
|
3
|
-
|
|
4
|
-
interface IDegenDistributorEventsV3 {
|
|
5
|
-
/// @dev Emits when a user claims tokens
|
|
6
|
-
event Claimed(address indexed account, uint256 amount);
|
|
7
|
-
|
|
8
|
-
/// @dev Emits when the owner replaces the merkle root
|
|
9
|
-
event RootUpdated(bytes32 oldRoot, bytes32 indexed newRoot);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface IDegenDistributorV3 is IDegenDistributorEventsV3 {
|
|
13
|
-
// Returns the address of the token distributed by this contract.
|
|
14
|
-
function degenNFT() external view returns (address);
|
|
15
|
-
|
|
16
|
-
// Returns the merkle root of the merkle tree containing account balances available to claim.
|
|
17
|
-
function merkleRoot() external view returns (bytes32);
|
|
18
|
-
|
|
19
|
-
/// @dev Returns the total amount of token claimed by the user
|
|
20
|
-
function claimed(address user) external view returns (uint256);
|
|
21
|
-
|
|
22
|
-
// Claim the given amount of the token to the given address. Reverts if the inputs are invalid.
|
|
23
|
-
/// @dev Claims the remaining unclaimed amount of the token for the account. Reverts if the inputs are not a leaf in the tree
|
|
24
|
-
/// or the total claimed amount for the account is more than the leaf amount.
|
|
25
|
-
function claim(uint256 index, address account, uint256 totalAmount, bytes32[] calldata merkleProof) external;
|
|
26
|
-
}
|