bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 21쪽 중 14쪽
------------------------
* | Locking Duration (Days) | Claims (CARV) |
* | 15 | 25% |
* | 90 | 60% |
* | 150 | 100% |
* ----------------------------------------------------
* @notice after that, Burn the locking veCARV corresponding to the specified withdrawID
* @notice If the Locking Duration is less than 150 days, the remaining CARV will be:
* @notice 1. 50% enter the CARV foundation to maintain network operation.
* @notice 2. 50% will be burned, which makes CARV deflationary.
*
* @dev Emits `Claim`.
*
* @param withdrawID: The withdrawID that the user needs to claim CARV
*/
function claim(uint64 withdrawID) external;
/**
* @notice To claim CARV by withdrawIDs (Batch).
*
* @dev Emits `ClaimBatch`.
*
* @param withdrawIDs: The withdrawIDs that the user needs to claim CARV
*/
function claimBatch(uint64[] calldata withdrawIDs) external;
}
```
# CARV Vault
## **CARV Vault**
1. The Vault contract manages funds, distinguishing account permissions where each role can only call methods specific to its permissions.
2. Except for the foundation address, other addresses must be preset and cannot be changed afterward. The foundation can only operate assets within its designated permissions, ensuring the overall security of CARV Protocol funds.
The Vault contract includes the following account permissions:
* **Foundation Account:** Receives protocol-generated fees (e.g., from NFT redemptions or veCARV withdrawals) and acts as a buffer for fund exchanges (e.g., CARV/ETH exchanges required by the system). It also has the authority to initialize rewards accounts.
* **Rewards Account:** Pre-funded by the foundation, releasing funds strictly according to a curve (with a fixed daily release of veCARV Tokens, decreasing by 25% every six months). For details, refer to [Node Rewards](https://docs.carv.io/carv-protocol/verifier-node-explained/node-rewards).
### **Function Definitions & Explanations**
```Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;
interface IVault {
event FoundationWithdraw(address token, uint256 amount);
event RewardsDeposit(uint256 amount);
event RewardsWithdraw(address to, uint256 amount);
event ChangeFoundation(address newFoundation);
/**
* @notice Withdraw token by foundation: by specifying the token address and amount.
* @notice Foundation authorities can only withdraw token from their own accounts and cannot operate locked assets.
*
* @dev Emits `FoundationWithdraw`.
*
* @param token: address of withdraw token, nil address is the source token(like eth)
* @param amount: amount of withdraw token
*/
function foundationWithdraw(address token, uint256 amount) external;
/**
* @notice Rewards account Deposit, only foundation authority can operate
* @notice Deposit veCARV(CARV -> veCARV) for verification rewards
* @notice Define token release rules
*
* @dev Emits `RewardsDeposit`.
*/
function rewardsDeposit(uint256 amount) external;
/**
* @notice Called by ServiceProtocol contract, used to issue rewards to nodes or NFT holders.
* @notice Strictly follow the release rules and do not release beyond the rules.
*
* @dev Emits `RewardsWithdraw`.
*
* @param receiver: address to receive rewards
* @param amount: amount of rewards
*/
function rewardsWithdraw(address receiver, uint256 amount) external;
/**
* @notice Change the address of foundation.
* @notice can only be operated by foundation authority
*
* @dev Emits `ChangeFoundation`.
*
* @param newFoundation: address of new foundation.
*/
function changeFoundation(address newFoundation) external;
function startTimestamp() external view returns (uint256);
function totalRewardByDate(uint32 dateIndex) external pure returns (uint256);
}
```
# CARV NFT License
## CARV NFT License
1. Non-transferable ERC-721 (can be updated with governance).
2. Only syndicate funds can transfer NFT once and redistribute to their community.
3. A maximum of 100,000 tokens can be minted, with token IDs incrementing automatically.
4. Upon redemption, the token ID is permanently destroyed, and any unclaimed veCARV reverts to the foundation.
5. To redeem the NFT License, transfer the NFT to our predefined address. Redemption will be available 6 months after the TGE.
**Function Definitions & Explanations**
```Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
interface ICarvNft {
/**
* @notice This struct represents meta information bound to TokenID,
*
* `code`: code of this token entered by buyer
* `price`: price of this token paid by buyer
* `tier`: tier of this token
*/
struct MetaData {
string code;
uint64 price;
uint8 tier;
}
/**
* @notice mint {count} nft to {receiver}.
* @notice totalSupply 100,000
*
* @dev Auth: Only Owner.
*
* @param receiver: nft receiver
* @param count: how many nft to be minted to receiver
* @param meta: `MetaData` of this tokenID
*/
function mint(address receiver, uint256 count, MetaData calldata meta) external;
/**
* @notice mint {counts} nft to {receivers}.
* @notice call `mint`
*
* @dev Auth: Only Owner.
*
* @param receivers: array of receivers
* @param counts: array of counts
* @param metas: array of meta
*/
function mintBatch(address[] calldata receivers, uint256[] calldata counts, MetaData[] calldata metas) external;
/**
* @notice Set BaseURI of all the tokens
*
* @dev Auth: Only Owner.
*
* @param newBaseURI: newBaseURI
*/
function setBaseURI(string memory newBaseURI) external;
/**
* @notice Set TransferProhibitedUntil
* @notice When the time has not reached the `TransferProhibitedUntil`, ordinary tokens cannot be transferred.
*
* @dev Auth: Only Owner.
*
* @param newTransferProhibitedUntil: newTransferProhibitedUntil
*/
function setTransferProhibitedUntil(uint256 newTransferProhibitedUntil) external;
/**
* @notice Set RedeemAddress
* @notice When `transfer.to` is RedeemAddress, the token can be transferred under any circumstances
*
* @dev Auth: Only Owner.
*
* @param newRedeemAddress: newRedeemAddress
*/
function setRedeemAddress(address newRedeemAddress) external;
/**
* @notice Set TransferOnceWhitelist
* @notice Addresses in the whitelist can transfer tokens once before `TransferProhibitedUntil`
*
* @dev Auth: Only Owner.
*
* @param whitelist: whitelist
*/
function setTransferOnceWhitelist(address[] calldata whitelist) external;
}
```
# CARV Protocol Service
## CARV Protocol Service
* Utilizes a proxy contract.
* Manages system parameters separately through the Settings contract.
* The **VRF Manager contract** decouples random number generation logic from the core logic contracts, allowing for seamless upgrades.
* The contract itself does not store any funds; all assets are managed within the **Vault contract**, with specific roles assigned to manage funds through predefined actions.
* Implements the main logic of the CARV protocol.
### **Core Function Explanations**
[Trusted Execution Environment (TEE)](/carv-ecosystem/verifier-nodes/how-do-verifier-nodes-work/trusted-execution-environment-tee)
[Verifier Node](/carv-ecosystem/verifier-nodes/how-do-verifier-nodes-work/verifier-node)
[Attestation](/carv-ecosystem/verifier-nodes/how-do-verifier-nodes-work/attestation)
[Delegation](/carv-ecosystem/verifier-nodes/delegation)
[Rewards](/carv-ecosystem/verifier-nodes/how-do-verifier-nodes-work/rewards)
**Function Definitions & Explanations**
```Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
interface IProtocolService {
/**
* @notice This enum represents result of an attestation reported by verifier
*
* `Valid`: This attestation can be parsed successfully and is not malicious
* `Invalid`: This attestation cannot be parsed successfully
* `Malicious`: This attestation can be parsed successfully but is malicious
*/
enum AttestationResult {
Valid,
Invalid,
Malicious
}
/**
* @notice This struct represents information of a node
*
* `id`: The globally unique ID of the node. The node is automatically registered when
* it calls `nodeEnter` for the first time. Up to 65535 nodes can be registered.
* `listIndex`: The position of the node in the current `activeVrfNodeList`
* `active`: Is the node active?
* `lastConfirmDate`: The date on which reward was last confirmed.
* `missedVerifyCount`: The number of verifications the node currently misses
* `selfTotalRewards`: The total rewards of the node itself
* `selfClaimedRewards`: The rewards claimed by the node itself
* `delegationRewards`: The rewards of the node’s delegator
* `lastEnterTime`: The time when the node last called `nodeEnter` to go online
* `commissionRate`: rate of commission, which is given by NFT holders to the verifier node.(decimals: 4)
* `commissionRateLastModifyAt`: timestamp of last modifying commission rate
*/
struct NodeInfo {
uint16 id;
uint16 listIndex;
bool active;
uint32 lastConfirmDate;
uint64 missedVerifyCount;
int256 selfTotalRewards;
uint256 selfClaimedRewards;
uint256 delegationRewards;
uint256 lastEnterTime;
address claimer;
uint32 commissionRate; // decimals: 4
uint256 commissionRateLastModifyAt;
}
/**
* @notice This struct represents reward information of a CarvNft token
*
* `initialRewards`: When this tokenID is delegated to a node, the initial amount of delegator's rewards needs to be recorded.
* `totalRewards`: The amount of rewards this tokenID has been confirmed
* `claimedRewards`: The amount of rewards this tokenID has been claimed
*/
struct TokenRewardInfo {
uint256 initialRewards;
uint256 totalRewards;
uint256 claimedRewards;
}
/**
* @notice This struct represents staking information of a tee
*
* `valid`: Whether tee is currently valid, invalid tee cannot report attestation
* `staked`: tee’s current staked amount
* `lastReportAt`: The time when tee last reported attestation, used for unstake check
*/
struct TeeStakeInfo {
bool valid;
uint256 staked;
uint256 lastReportAt;
}
/**
* @notice This struct represents information of an attestation
*
* `reporter`: The address of the tee who reported this attestation
* `valid`: The number of votes that this attestation is considered valid (voted by the verifier node)
* `invalid`: The number of votes that this attestation is considered invalid (voted by the verifier node)
* `vrfChosenID`: ID of the currently randomly selected verification nodes
* `slashed`: Has this attestation been slashed?
* `deadline`: Deadline for collecting verification
*/
struct Attestation {
address reporter;
uint16 valid;
uint16 invalid;
uint16 malicious;
uint32 vrfChosenID;
bool slashed;
uint256 deadline;
}
/**
* @notice This struct represents information of an verification with signature
*
* `result`: result of this attestation
* `index`: index of this node in activeVrfNodeList
* `signer`: address of this node (sign the Data to call contract gasless)
* `v`: v of signature signed by signer
* `r`: r of signature signed by signer
* `s`: s of signature signed by signer
*/
struct VerificationInfo {
AttestationResult result;
uint16 index;
address signer;
uint8 v;
bytes32 r;
bytes32 s;
}
// admin
event UpdateVrfAddress(address vrf);
event UpdateSettingsAddress(address settings);
// tee
event TeeStake(address tee, uint256 amount);
event TeeUnstake(address tee, uint256 amount);
event TeeSlash(address tee, bytes32 attestationID, uint256 amount);
event ClaimMaliciousTeeRewards(address verifer, uint256 amount);
event TeeReportAttestations(address tee, bytes32[] attestationIDs, string[] attestationInfos, uint256 requestID);
event ConfirmVrfNodes(uint256 requestId, uint16[] vrfChosen, uint256 deadline);
// node
event NodeRegister(address node, uint16 id);
event NodeActivate(address node);
event NodeClear(address node);
event NodeSlash(address node, bytes32 attestationID, uint256 rewards);
event NodeModifyCommissionRate(address node, uint32 commissionRate);
event NodeSetClaimer(address node, address claimer);
event NodeClaim(address node, address claimer, uint256 rewards);
event NodeReportVerification(address node, bytes32 attestationID, AttestationResult result);
event NodeReportVerificationBatch(bytes32 attestationID, VerificationInfo[] infos);
// delegation
event Delegate(uint256 tokenID, address to);
event Redelegate(uint256 tokenID, address to);
event Undelegate(uint256 tokenID, address to);
event ClaimRewards(uint256 tokenID, uint256 rewards);
/*----------------------------------------------------------------------------------------------------------------*/
/**
* @notice update address of Settings contract.
*
* @dev Only admin role.
* @dev Emits `UpdateSettingsAddress`.
*
* @param settings_: address of Settings contract.
*/
function updateSettingsAddress(address settings_) external;
/**
* @notice update address of CarvVrf contract.
*
* @dev Only admin role.
* @dev Emits `UpdateVrfAddress`.
*
* @param carvVrf_: address of CarvVrf contract.
*/
function updateVrfAddress(address carvVrf_) external;
/**
* @notice Tee needs to stake CARVs before reporting attestation,
* @notice and CARVs will be converted to veCARVs stored in Vault.
* @notice which will be used to slash when tee proven to be evil.
*
* @dev Only tee role (granted by admin role).
* @dev Emits `TeeStake`.
*
* @param amount: amount of CARV tee plans to stake.
*/
function teeStake(uint256 amount) external;
/**
* @notice Tee withdraws staked veCARVs, rules are as follows:
* @notice 1. enough time has passed since the last attestation was submitted.
* @notice 2. veCARVs that have been slashed cannot be unstaked.
* @notice 3. unable to continue reporting attestation after unstaking.
*
* @dev Only tee role (granted by admin role).
* @dev Emits `TeeUnstake`.
*/
function teeUnstake() external;
/**
* @notice When the attestation reported by a tee is proven to be malicious,
* @notice anyone can initiate a teeSlash, which will slash the veCARVs staked by the tee.
* @notice Each malicious attestation can only be slashed once.
* @notice When the veCARVs staked by a tee are slashed below a threshold,
* @notice the tee will be forcibly restricted from continuing to report attestation.
*
* @dev Emits `TeeSlash`.
*
* @param attestationID: id of attestation which is proven malicious.
*/
function teeSlash(bytes32 attestationID) external;
/**
* @notice When an attestation reported by a tee is slashed,
* @notice verifiers that have reported verification for this attestation can claim the reward.
* @notice If a verifier have not reported verification of this attestation, it cannot claim the reward.
*
* @dev Emits `ClaimMaliciousTeeRewards`.
*
* @param attestationID: id of attestation which is slashed.
*/
function claimMaliciousTeeRewards(bytes32 attestationID) external;
/**
* @notice Tee reports attestations. The same attestation can only be reported once.
*
* @dev Only staked tee role.
* @dev Emits `TeeReportAttestations`.
* @dev A request to apply for VRF will be sent to chainlink.
* @dev After receiving the callback from chainlink, emits `ConfirmVrfNodes`.
*
* @param attestationInfos: attestations to be reported.
*/
function teeReportAttestations(string[] memory attestationInfos) external;
/**
* @notice In order to save costs more efficiently when selecting nodes in VRF,
* @notice we designed a data structure `activeVrfNodeList` for this purpose.
* @notice `activeVrfNodeList` stores up to 2000 active nodes with delegation weight,
* @notice and each time VRF will select from these nodes.
*
* @notice Nodes need to activate themselves by calling nodeEnter of the smart contract
* @notice To successfully activate a node, caller need to meet the following conditions:
* @notice 1. The caller needs to hold CarvNft, or be delegated by other holders
* @notice 2. If the current `activeVrfNodeList` is full, you need to choose a node
* @notice in the list with less delegation weight than yourself to replace it.
*
* @dev Emits `NodeActivate`.
* @dev If any node is kicked and replaced by your node. Emits `NodeClear`.
* @dev If any node calls nodeEnter for the first time. Emits `NodeRegister`.
*
* @param replacedNode: address of the node that needs to be replaced by your node
* only works when the `activeVrfNodeList` is full
*/
function nodeEnter(address replacedNode) external;
/**
* @notice Exits by node itself, and verification cannot be reported after exiting.
* @notice When a node exits, it will be punished based on missing counts during the online period.
*
* @dev Emits `NodeClear`.
*/
function nodeExit() external;
/**
* @notice Modify the commission rate of verifier node
*
* @dev Emits `NodeModifyCommissionRate`.
*
* @param commissionRate: rate of commission, which is given by NFT holders to the verifier node
*/
function nodeModifyCommissionRate(uint32 commissionRate) external;
/**
* @notice Similar to `nodeEnter`,
* @notice but the txn can be broadcast to the chain by other address after being authenticated by the node.
* @notice Compared with the `nodeEnter`, it is gasless for the verifier node.
* @notice following the eip-712.
*
* @dev Emits `NodeActivate`.
* @dev If any node is kicked and replaced by your node. Emits `NodeClear`.
* @dev If any node calls nodeEnter for the first time. Emits `NodeRegister`.
*
* @param replacedNode: address of the node that needs to be replaced by your node
* only works when the `activeVrfNodeList` is full
* @param expiredAt: transaction expiration time
* @param signer: address of verifier node ready to enter
*/
function nodeEnterWithSignature(
address replacedNode, uint256 expiredAt, address signer, uint8 v, bytes32 r, bytes32 s
) external;
/**
* @notice Similar to `nodeExit`,
* @notice but the txn can be broadcast to the chain by other address after being authenticated by the node.
* @notice Compared with the `nodeExit`, it is gasless for the verifier node.
* @notice following the eip-712.
*
* @dev Emits `NodeClear`.
*
* @param expiredAt: transaction expiration time
* @param signer: address of verifier node ready to exit
*/
function nodeExitWithSignature(
uint256 expiredAt, address signer, uint8 v, bytes32 r, bytes32 s
) external;
/**
* @notice Similar to `nodeModifyCommissionRate`,
* @notice but the txn can be broadcast to the chain by other address after being authenticated by the node.
* @notice Compared with the `nodeModifyCommissionRate`, it is gasless for the verifier node.
* @notice following the eip-712.
*
* @dev Emits `NodeModifyCommissionRate`.
*
* @param commissionRate: rate of commission, which is given by NFT holders to the verifier node
* @param expiredAt: transaction expiration time
* @param signer: address of verifier node
*/
function nodeModifyCommissionRateWithSignature(
uint32 commissionRate, uint256 expiredAt, address signer, uint8 v, bytes32 r, bytes32 s
) external;
/**
* @notice Specify the address that can claim rewards of this verifier node
* @notice it is gasless for the verifier node.
* @notice following the eip-712.
*
* @dev Emits `NodeSetClaimer`.
*
* @param claimer: address of whom can claim reward of this verifier
* @param expiredAt: transaction expiration time
* @param signer: address of verifier node
*/
function nodeSetRewardClaimerWithSignature(
address claimer, uint256 expiredAt, address signer, uint8 v, bytes32 r, bytes32 s
) external;
/**
* @notice Claim reward of node.
* @notice The reward for reporting verifications is divided into two parts: node's reward and delegators' reward
* @notice Only when the node is online for more than 6 hours/day will there be reward.
*
* @dev Emits `NodeClaim`.
*
* @param node: address of node to claim reward
*/
function nodeClaim(address node) external;
/**
* @notice Anyone can initiate a slash for a miss reporting of a node.
* @notice Each miss reporting of a node can only be slashed o프로젝트로 돌아가기