Skip to content

Redeeming Locks

Function Signatures

Redeem Single Lock

function redeemLock(uint256 lockId) external

Redeem Multiple Locks (Batch)

function redeemLocksForInitiative(
    uint256 initiativeId,
    uint256[] calldata lockIds
) external

Parameters

ParameterTypeDescription
lockIduint256The ERC721 token ID representing your lock position
initiativeIduint256The initiative ID (all locks must belong to this initiative)
lockIdsuint256[]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.
Useful queries:
  • 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

ErrorConditionSolution
Signals_TokenAlreadyRedeemedPosition already redeemedCheck lock.withdrawn status
Signals_NotOwnerYou don't own the NFTVerify NFT ownership
Signals_StillTimelockedRelease timelock not passed and lock not expiredWait until acceptanceTimestamp + releaseLockDuration or lock expiry
Signals_InvalidIDLock does not belong to initiativeEnsure 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