TrustBonding.sol
The TrustBonding contract is the primary smart contract for bonding/staking of TRUST tokens within the Intuition protocol. Responsible for managing emissions of new TRUST tokens for various stakeholders, including atom creators, triple creators, and other participants in the ecosystem.
Wrapped Trust (wTRUST)β
The TrustBonding contract requires users to wrap their TRUST tokens into Wrapped TRUST (wTRUST) before locking them in the voting escrow. This wrapping process is handled by the WrappedTrust contract, which allows users to deposit TRUST tokens and receive an equivalent amount of wTRUST tokens.
Voting Escrow (veTRUST)β
The TrustBonding contract inherits from the popular Voting Escrow mechanism, allowing users to lock their TRUST tokens for a specified period in exchange for veTRUST tokens. veTRUST determines a user's share of rewards and their voting power in governance, where veTRUST holders can veto proposals.
The voting escrow mechanism is implemented using the VotingEscrow contract, which provides functions for creating locks, increasing lock amounts, and extending lock durations.
Originated from Curve Finance's veCRV model, originally written in Vyper, the Voting Escrow contract has been adapted to Solidity for use in the Intuition protocol and forked from the Stargate DAO's implementation.
Smart Contract Writesβ
While TrustBonding is paused, the lock and deposit functions below (create_lock, increase_amount, increase_unlock_time, increase_amount_and_time, deposit_for and withdraw_and_create_lock) and claimRewards revert. withdraw keeps working, so a pause never traps locked tokens.
Creating Locksβ
Users can create a new lock by calling the create_lock function, specifying the amount of Wrapped TRUST tokens to lock and the unlock time. _unlock_time is an absolute Unix timestamp, not a duration. The contract rounds it down to a whole week, and the result must be within the minimum and maximum lock periods (at most 2 years ahead).
function create_lock(uint256 _value, uint256 _unlock_time) external nonReentrant onlyUserOrWhitelist notUnlocked {
// Lock creation logic
}
Increasing Lock Amountβ
Users can increase the amount of Wrapped TRUST tokens in an existing lock by calling the increase_amount function.
function increase_amount(uint256 _value) external nonReentrant onlyUserOrWhitelist notUnlocked {
// Lock amount increase logic
}
Increasing Lock Durationβ
Users can extend the duration of an existing lock by calling the increase_unlock_time function with a new, later unlock timestamp (rounded down to a whole week).
function increase_unlock_time(uint256 _unlock_time) external nonReentrant onlyUserOrWhitelist notUnlocked {
// Lock duration extension logic
}
Increase Amount and Durationβ
Users can simultaneously increase the amount of Wrapped TRUST tokens and extend the duration of an existing lock by calling the increase_amount_and_time function.
function increase_amount_and_time(uint256 _value, uint256 _unlock_time) external nonReentrant onlyUserOrWhitelist notUnlocked {
// Lock amount and duration increase logic
}
Withdrawβ
Once the lock period has expired, users can withdraw their locked Wrapped TRUST tokens by calling the withdraw function. Any address, including a contract that is not whitelisted, can withdraw its own expired lock.
function withdraw() external nonReentrant {
// Withdrawal logic
}
Smart Contract Readsβ
Balance Ofβ
The balanceOf function returns the voting power of a specific address at a given timestamp.
function balanceOf(address _addr) external view returns (uint256) {
// Balance calculation logic
}
Balance Of At Timestampβ
The balanceOfAtT function returns the voting power of a specific address at a given timestamp. (balanceOfAt(address, uint256) takes a block number instead.)
function balanceOfAtT(address _addr, uint256 _t) external view returns (uint256) {
// Balance calculation logic
}
Total Supplyβ
The totalSupply function returns the total voting power in the system at a given timestamp.
function totalSupply() external view returns (uint256) {
// Total supply calculation logic
}
Total Supply At Timestampβ
The totalSupplyAtT function returns the total voting power in the system at a given timestamp.
function totalSupplyAtT(uint256 t) external view returns (uint256) {
// Total supply calculation logic
}
Eventsβ
Rewards Claimedβ
The RewardsClaimed event is emitted when a user claims their rewards.
event RewardsClaimed(address indexed user, address indexed recipient, uint256 amount);
Additional Resourcesβ
For more detailed information on the MultiVault contract and its functions, please refer to the Intuition Smart Contract V2 repository.