Redeeming Locks
Function Signatures
Redeem Single Lock
function redeemLock(uint256 lockId) externalRedeem Multiple Locks (Batch)
function redeemLocksForInitiative(
uint256 initiativeId,
uint256[] calldata lockIds
) externalParameters
| Parameter | Type | Description |
|---|---|---|
lockId | uint256 | The ERC721 token ID representing your lock position |
initiativeId | uint256 | The initiative ID (all locks must belong to this initiative) |
lockIds | uint256[] | Array of lock token IDs to redeem in batch |
TokenLock Data Structure
struct TokenLock {
uint256 initiativeId; // Which initiative this supports
uint256 tokenAmount; // Underlying tokens locked
uint256 lockDuration; // Duration in intervals
uint256 created; // Block timestamp of creation
bool withdrawn; // Redemption status
}Redemption Eligibility
- Redemption is allowed if the board is cancelled, the initiative is
Expired, or the lock itself has expired. - For
Accepted, the release timelock must have passed (acceptanceTimestamp + releaseLockDuration) unless the lock has already expired. - The lock must not be withdrawn, and the caller must own the NFT.
getInitiative(initiativeId)for state and timestamps.getTokenLock(lockId)for ownership/withdrawn status.releaseLockDuration()for timelock configuration.- ERC721Enumerable functions (
balanceOf,tokenOfOwnerByIndex) to enumerate lock token IDs by owner.
Validation & Errors
| Error | Condition | Solution |
|---|---|---|
Signals_TokenAlreadyRedeemed | Position already redeemed | Check lock.withdrawn status |
Signals_NotOwner | You don't own the NFT | Verify NFT ownership |
Signals_StillTimelocked | Release timelock not passed and lock not expired | Wait until acceptanceTimestamp + releaseLockDuration or lock expiry |
Signals_InvalidID | Lock does not belong to initiative | Ensure lock IDs match the initiative |
Related Functions
// Query functions
function getTokenLock(uint256 tokenId) external view returns (TokenLock memory)
function getInitiative(uint256 initiativeId) external view returns (Initiative memory)
function releaseLockDuration() external view returns (uint256)
function balanceOf(address owner) external view returns (uint256)
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256)
// Redemption
function redeemLock(uint256 lockId) external
function redeemLocksForInitiative(uint256 initiativeId, uint256[] calldata lockIds) external