Token Unstake Smart Contract (1.0.0)
Download OpenAPI specification:Download
The Token Unstake Smart Contract handles all unbonding/unstaking logic for XKFI tokens. This contract was designed to keep the Energy Factory SC as simple as possible by separating the unlock/unbond functionality into a dedicated contract.
The Token Unstake contract provides:
- Token Claiming: Claim unlocked tokens after the unbonding period
- Unbonding Management: Track tokens that are in the unbonding process
- Penalty Application: Apply penalties based on the lock duration of newly unlocked tokens
The system maintains a record of tokens eligible for unlocking:
- Each entry includes the unbonding epoch
- Only tokens past their unbonding epoch can be claimed
- Penalty fees are calculated based on the lock duration
Claim Unlocked Tokens
Allows users to claim their unlocked tokens after the unbonding period has completed.
Process:
- System checks the user's list of tokens eligible for unlocking
- Only tokens past their unbonding epoch are processed
- A penalty fee is applied based on the lock duration
- Remaining tokens are sent to the user
Penalty Calculation: The penalty is calculated based on the original lock duration of the tokens being claimed. Longer lock periods result in higher penalties when unlocking early.
Important Notes:
- Only tokens that have completed the unbonding period will be sent
- If some tokens are still in the unbonding period, they remain in the contract
- The user can call this endpoint multiple times as tokens become available
Example Response (receipts):
{
"assetId": "KFI",
"assetType": "Fungible",
"from": "klv1qqqqqqqqqqqqqpgqnqtxpjzy8kmk58fvxuwlf4syg5mrldsec0nqd3cf0d",
"to": "klv1qqqqqqqqqqqqqpgq9696g7x76kwrrh02fahn4rpem4v595t8c0nqgxzpmu",
"type": 0,
"typeString": "Transfer",
"value": 60000000
},
{
"assetId": "XKFI-Y5SU/1",
"assetType": "SemiFungible",
"from": "klv1qqqqqqqqqqqqqpgqnqtxpjzy8kmk58fvxuwlf4syg5mrldsec0nqd3cf0d",
"to": "klv17e8zzgn73h6ehe3c6q9vlt77kuxk5euddmhymy5uhv2rhv0dc0nqlfp0ap",
"type": 0,
"typeString": "Transfer",
"value": 100000000
}
Request Body schema: application/jsonrequired
| scAddress required | string Token Unstake contract address |
| funcName required | string Value: "claimUnlockedTokens" |
| args | Array of strings No arguments required |
Responses
Request samples
- Payload
Content type
application/json
{- "scAddress": "klv1qqqqqqqqqqqqqpgqnqtxpjzy8kmk58fvxuwlf4syg5mrldsec0nqd3cf0d",
- "funcName": "claimUnlockedTokens",
- "args": [ ]
}Response samples
- 200
Content type
application/json
{- "data": {
- "returnData": [
- "string"
], - "returnCode": "string",
- "returnMessage": "string"
}, - "error": "string",
- "code": "string"
}