liabtc-mint-endpoint
Last updated
Last updated
Location: xlink-dao/contracts/liabtc/liabtc-mint-endpoint.clar
Façade for 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 contract. It serves as an abstraction layer, simplifying interactions between LiaBTC
users and the liquid staking pool management provided by the contract, also known as XLink Staking Manager.
The mint operation consists of two main actions:
User transfers aBTC
to be staked in the liquid staking pool.
User receives LiaBTC
tokens in exchange at a 1:1 ratio (1 aBTC
= 1 LiaBTC
).
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.
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 and involve a waiting period between the burn request and the final withdrawal of aBTC
.
User initiates the request to unstake a specific amount of aBTC
. During this step:
That same amount of LiaBTC
tokens are burned from the user wallet.
A burn request is created in the registry with a unique request-id
and a status.
The aBTC
are sent from the Staking Manager to the registry, which will hold the funds until the request is either finalized or revoked.
The corresponding aBTC
is transferred from the registry to the requester, completing the unstaking process.
Burn requests can be revoked by the requester at any time before it is finalized. When revoke:
The corresponding aBTC
is returned to the user.
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.
rebase
Updates the LiaBTC
token reserve by recalculating its value in aBTC
based on the staking shares held by the liabtc-mint-endpoint
contract.
mint
Mints 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.
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
Initiates the burn procedure for a certain amount of LiaBTC
. Several actions are performed:
LiaBTC
amount is burned from the user wallet.
A request with PENDING
status is created on the registry.
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
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
Finalizes 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
Finalizes requests in bulk.
Parameters
request-ids
list 1000 uint
set-use-whitelist
Parameters
new-use
bool
set-whitelisted
Parameters
user
principal
new-whitelisted
bool
set-whitelisted-many
Assigns the whitelist status of users in bulk.
Parameters
users
list 1000 principal
new-whitelisted
list 1000 bool
set-mint-paused
Parameters
new-paused
bool
set-burn-paused
Parameters
new-paused
bool
set-burn-delay
Parameters
new-delay
uint
is-dao-or-extension
Standard 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
Checks 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
Parameters
amount
uint
validate-request-burn
Parameters
amount
uint
validate-revoke-burn
Parameters
request-id
uint
validate-finalize-burn
Parameters
request-id
uint
is-mint-paused
is-burn-paused
is-not-mint-paused-or-fail
Throws with err-paused
if mint is paused, returns (ok true)
otherwise.
is-not-burn-paused-or-fail
Throws with err-paused
if burn is paused, returns (ok true)
otherwise.
get-burn-request-or-fail
Returns 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
Returns 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-current-bitcoin-block
Getter for testing purposes. If mainnet, returns the burn-block-height
.
mint-paused
Variable
bool
Indicates the operational status for the mint (stake) operations.
burn-paused
Variable
bool
Indicates the operational status for the burn (unstake) operations.
burn-delay
Variable
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
Variable
bool
Indicates whether the whitelist mechanism is currently active. The whitelist applies to mint (stake) operations but not to burn (unstake) ones.
whitelisted
Map
principal bool
Maintains a mapping of users (principal
) to their whitelist status (bool
).
PENDING
buff 1
0x00
Burn request pending status. When created, burn requests start with this status.
FINALIZED
buff 1
0x01
Burn request finalize status.
REVOKED
buff 1
0x02
Burn request revoked status.
'SP2XD7417HGPRTREMKF748VNEQPDRR0RMANB7X1NK.token-abtc
: As the underlying token that backs LiaBTC
, this contract is called for transfers and to specify the token being staked in the Staking Manager.
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)
Once the period (typically 1,000 Bitcoin blocks) has passed, the user or any other principal can finalize the request. On finalization:
The request status is updated to .
A operation is executed in the same transaction, restoring the user's original amount of LiaBTC
.
The request status is updated to .
This contract manages the LiaBTC
token reserve through the public function. Mint and burn operations perfom a rebase every time they are executed. However, rebase
can be called permissionlessly by any principal.
For a detailed overview of the LiaBTC
liquid token, refer to the contract documentation.
The message
and signature-packs
parameters serve as inputs to the function. They are part of the XLink liquid staking pool's reward accrual mechanism, which operates permissionlessly and relies on validators.
The same amount of aBTC
is unstaked from the xlink-staking
contract and transferred to the liabtc-mint-endpoint
, which then transfers it to the , where it is held until finalization or revocation.
As with , the message
and signature-packs
parameters serve as inputs to the function.
Revokes 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 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
.
The following functions are guarded by the function. This implies that only the LISA DAO or an enabled extension can use these features.
Sets the variable.
Assigns the whitelist status of a user. Modifies the map.
Sets the variable.
Sets the variable.
Sets the variable.
xlink-staking::validate-stake
façade for handling aBTC
staking. Within the contract, this function is solely called by the function. Throws if mint is paused or the sender
is not whitelisted (when applicable).
xlink-staking::validate-unstake
façade for handling aBTC
unstaking. Within the contract, this function is solely called by the function. Throws if burn is paused.
Performs revoke burn validations and returns the corresponding request details. Within the contract, this function is solely called by the 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).
Performs finalize burn validations and returns the corresponding request details. Within the contract, this function is solely called by the function. Validations encompass: burn is not paused, request exists, request has PENDING
status and the period has been completed.
Returns the variable.
Returns the variable.
Returns the variable.
: 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 the LiaBTC
rebase by retrieving the value of aBTC
held by the liabtc-mint-endpoint
as a staker within the protocol.
: The registry is called to manage burn requests and handle funds during the burning/unstaking process.
: This contract is called to perform three essential actions: rebase, mint and burn.
'SM26NBC8SFHNW4P1Y4DFH27974P56WN86C92HPEHH.lisa-dao
: This contract is exclusively called by the function for authorizing governance operations.