liabtc-mint-endpoint
Location:
xlink-dao/contracts/liabtc/liabtc-mint-endpoint.clar
Façade for xlink-staking contract designed to handle the lifecycle of the LiaBTC rebasing token (mint, burn and rebase operations).
The liabtc-mint-endpoint contract acts as single aBTC staker within the xlink-staking contract. It serves as an abstraction layer, simplifying interactions between LiaBTC users and the liquid staking pool management provided by the xlink-staking contract, also known as XLink Staking Manager.
Mint
The mint operation consists of two main actions:
User transfers
aBTCto be staked in the liquid staking pool.User receives
LiaBTCtokens in exchange at a 1:1 ratio (1aBTC= 1LiaBTC).
When a user mints LiaBTC, the underlying aBTC is transferred to the Staking Manager, which stores the funds, tracks the liquid staking status (including shares and stake balances) and emits an event.
Burn
The burn operation (or unstake) allows users to withdraw their aBTC from the liquid staking pool in exchange for burning LiaBTC tokens at a 1:1 ratio. These operations are managed by the liabtc-mint-registry and involve a waiting period between the burn request and the final withdrawal of aBTC.
Request
User initiates the request to unstake a specific amount of aBTC. During this step:
That same amount of
LiaBTCtokens are burned from the user wallet.A burn request is created in the registry with a unique
request-idand aPENDINGstatus.The
aBTCare sent from the Staking Manager to the registry, which will hold the funds until the request is either finalized or revoked.
Finalize
Once the burn-delay period (typically 1,000 Bitcoin blocks) has passed, the user or any other principal can finalize the request. On finalization:
The corresponding
aBTCis transferred from the registry to the requester, completing the unstaking process.The request status is updated to
FINALIZED.
Revoke
Burn requests can be revoked by the requester at any time before it is finalized. When revoke:
The corresponding
aBTCis returned to the user.A
mintoperation is executed in the same transaction, restoring the user's original amount ofLiaBTC.The request status is updated to
REVOKED.
Rebase
This contract manages the LiaBTC token reserve through the rebase public function. Mint and burn operations perfom a rebase every time they are executed. However, rebase can be called permissionlessly by any principal.
The rebasing mechanism is implemented via the "shares" concept. The LiaBTC reserve reperesents the value in aBTC of the staking shares held by the liabtc-mint-endpoint, as tracked by the XLink Staking Manager contract.
The staking shares held by the liabtc-mint-endpoint are adjusted whenever users mint or burn LiaBTC. Over time, the value of these shares in aBTC grows as accrued staking rewards are reinvested, increasing the reserve.
For a detailed overview of the LiaBTC liquid token, refer to the token-liabtc contract documentation.
Features
Public
rebase
rebaseUpdates the LiaBTC token reserve by recalculating its value in aBTC based on the staking shares held by the liabtc-mint-endpoint contract.
mint
mintMints LiaBTC to the caller (defined as sender within the contract) in exchange for aBTC at a 1:1 ratio. The provided aBTC is staked in the XLink Staking Manager by the liabtc-mint-endpoint on behalf of the user.
The message and signature-packs parameters serve as inputs to the xlink-staking::stake function. They are part of the XLink liquid staking pool's reward accrual mechanism, which operates permissionlessly and relies on validators.
Parameters
amount
uint
message
{ token: principal, accrued-rewards: uint, update-block: uint }
signature-packs
list 100 { signer: principal, message-hash: (buff 32), signature: (buff 65) }
request-burn
request-burnInitiates the burn procedure for a certain amount of LiaBTC. Several actions are performed:
LiaBTCamount is burned from the user wallet.The same amount of
aBTCis unstaked from thexlink-stakingcontract and transferred to theliabtc-mint-endpoint, which then transfers it to theliabtc-mint-registry, where it is held until finalization or revocation.A request with
PENDINGstatus is created on the registry.
As with mint, the message and signature-packs parameters serve as inputs to the xlink-staking::unstake function.
Parameters
amount
uint
message
{ token: principal, accrued-rewards: uint, update-block: uint }
signature-packs
list 100 { signer: principal, message-hash: (buff 32), signature: (buff 65) }
revoke-burn
revoke-burnRevokes a burn request. Only the requester (requested-by field of the request) can call this function. The registry returns the funds back to user as in finalize-request, with the key difference that the mint function is invoked (with the user as sender) to restake the aBTC and mint the LiaBTC back to the user. Request status is updated to REVOKED.
Parameters
request-id
uint
message
{ token: principal, accrued-rewards: uint, update-block: uint }
signature-packs
list 100 { signer: principal, message-hash: (buff 32), signature: (buff 65) }
finalize-burn
finalize-burnFinalizes a burn request by transferring the aBTC from the registry to the user (requested-by field of the request). Request is set as FINALIZED. This function is permissionless and can be called by any user, even those who did not initiate the burn request.
Parameters
request-id
uint
finalize-burn-many
finalize-burn-manyFinalizes requests in bulk.
Parameters
request-ids
list 1000 uint
Governance
The following functions are guarded by the is-dao-or-extension function. This implies that only the LISA DAO or an enabled extension can use these features.
set-use-whitelist
set-use-whitelistSets the use-whitelist variable.
Parameters
new-use
bool
set-whitelisted
set-whitelistedAssigns the whitelist status of a user. Modifies the whitelisted map.
Parameters
user
principal
new-whitelisted
bool
set-whitelisted-many
set-whitelisted-manyAssigns the whitelist status of users in bulk.
Parameters
users
list 1000 principal
new-whitelisted
list 1000 bool
set-mint-paused
set-mint-pausedSets the mint-paused variable.
Parameters
new-paused
bool
set-burn-paused
set-burn-pausedSets the burn-paused variable.
Parameters
new-paused
bool
set-burn-delay
set-burn-delaySets the burn-delay variable.
Parameters
new-delay
uint
Supporting features
is-dao-or-extension
is-dao-or-extensionStandard protocol function to check whether the contract-caller is an enabled extension within the DAO or the tx-sender is the DAO itself (proposal execution scenario). The enabled extension check is delegated to the LISA's executor-dao contract.
is-whitelisted-or-mint-for-all
is-whitelisted-or-mint-for-allChecks if a given principal is eligible for minting under the current whitelist settings. If the whitelist is active, returns false if the user is not whitelisted. Returns true in all other cases.
Parameters
user
principal
validate-mint
validate-mintxlink-staking::validate-stake façade for handling aBTC staking. Within the contract, this function is solely called by the mint function. Throws if mint is paused or the sender is not whitelisted (when applicable).
Parameters
amount
uint
validate-request-burn
validate-request-burnxlink-staking::validate-unstake façade for handling aBTC unstaking. Within the contract, this function is solely called by the request-burn function. Throws if burn is paused.
Parameters
amount
uint
validate-revoke-burn
validate-revoke-burnPerforms revoke burn validations and returns the corresponding request details. Within the contract, this function is solely called by the revoke-burn function. Validations encompass: burn is not paused, request exists, request has PENDING status and sender matches the requested-by field on the burn request (only the requester can revoke).
Parameters
request-id
uint
validate-finalize-burn
validate-finalize-burnPerforms finalize burn validations and returns the corresponding request details. Within the contract, this function is solely called by the finalize-burn function. Validations encompass: burn is not paused, request exists, request has PENDING status and the burn-delay period has been completed.
Parameters
request-id
uint
Getters
is-mint-paused
is-mint-pausedReturns the mint-paused variable.
is-burn-paused
is-burn-pausedReturns the burn-paused variable.
is-not-mint-paused-or-fail
is-not-mint-paused-or-failThrows with err-paused if mint is paused, returns (ok true) otherwise.
is-not-burn-paused-or-fail
is-not-burn-paused-or-failThrows with err-paused if burn is paused, returns (ok true) otherwise.
get-burn-request-or-fail
get-burn-request-or-failReturns a burn request stored in the liabtc-mint-registry's burn-request map. If entry doesn't exist, throws.
Parameters
request-id
uint
get-burn-request-or-fail-many
get-burn-request-or-fail-manyReturns a list of burn requests stored in the liabtc-mint-registry. If any of the entries doesn't exist, throws.
Parameters
request-ids
list 1000 uint
get-burn-delay
get-burn-delayReturns the burn-delay variable.
get-current-bitcoin-block
get-current-bitcoin-blockGetter for testing purposes. If mainnet, returns the burn-block-height.
Storage
mint-paused
mint-pausedVariable
bool
Indicates the operational status for the mint (stake) operations.
burn-paused
burn-pausedVariable
bool
Indicates the operational status for the burn (unstake) operations.
burn-delay
burn-delayVariable
uint
Indicates the waiting period for a burn request, measured in Bitcoin blocks (burn chain). It represents the time users must wait between initiating burn request and being able to finalize it.
use-whitelist
use-whitelistVariable
bool
Indicates whether the whitelist mechanism is currently active. The whitelist applies to mint (stake) operations but not to burn (unstake) ones.
whitelisted
whitelistedMap
principal bool
Maintains a mapping of users (principal) to their whitelist status (bool).
Relevant constants
PENDING
PENDINGbuff 1
0x00
Burn request pending status. When created, burn requests start with this status.
FINALIZED
FINALIZEDbuff 1
0x01
Burn request finalize status.
REVOKED
REVOKEDbuff 1
0x02
Burn request revoked status.
Contract calls
xlink-staking: Interactions with the Staking Manager are present in the contract's core opertions. It is called during every mint or burn operation to handle the corresponding stake or unstake actions. Additionally, the Staking Manager is essential to perfom theLiaBTCrebase by retrieving the value ofaBTCheld by theliabtc-mint-endpointas a staker within the protocol.liabtc-mint-registry: The registry is called to manage burn requests and handle funds during the burning/unstaking process.token-liabtc: This contract is called to perform three essential actions: rebase, mint and burn.'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-abtc: As the underlying token that backsLiaBTC, this contract is called for transfers and to specify the token being staked in the Staking Manager.'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lisa-dao: This contract is exclusively called by theis-dao-or-extensionfunction for authorizing governance operations.
Errors
err-unauthorised
(err u1000)
err-paused
(err u7001)
err-request-pending
(err u7006)
err-request-finalized-or-revoked
(err u7007)
err-not-whitelisted
(err u7008)
Last updated