stSTX: Stacking DAO Core
Stacking DAO Core is the main entry point for all user-related actions such as depositing and withdrawing STX, or looking up a withdrawal NFT position of a user. The stSTX/STX ratio is read from the data contract (see Reading the ratio).
The contract can be found here: https://explorer.hiro.so/txid/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.stacking-dao-core-stx-v2?chain=mainnet
Integrations
For wallets, CEXes and other protocols who want to integrate the Stacking DAO deposit/withdrawal logic, there are four important methods to take into account:
Deposit
The deposit method can be initiated using the deposit method on the SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.stacking-dao-core-stx-v2 contract.
This contract expects the following parameters:
stx-amount- a positive integer value for the uSTX (micro-STX, 10^6) amount you want to stack and getstSTXin return for. For example, passing1000000will stack 1 STX.min-shares-out- a positive integer for the minimum amount ofstSTX(in micro-stSTX) you are willing to receive. The transaction reverts if fewer shares would be minted, protecting you against an unexpected ratio change (slippage protection). Compute it from the current ratio (see Reading the ratio below); pass a value slightly below the expected output, or0to accept any amount.
Initiate Withdrawal
When withdrawing, users can follow a two-step process. See https://docs.stackingdao.com/stackingdao/the-stacking-dao-app/withdrawing-stx for more information.
The initialisation of a withdrawal can be called using init-withdraw and expects the following parameters:
ststx-amount- a positive integer value for the ustSTX (micro-stSTX, 10^6) amount you want to unstack and getSTXin return for. For example, passing1000000will unstack 1 stSTX.
When this call succeeds, the user will receive an NFT that represents their unstacking position and indicates the amount of STX they should receive after a given PoX cycle ends (this is always principal + yield).
Withdrawal
Finally, once the PoX cycle ends after a given init-withdrawal call (but always before the last 288 blocks of a given cycle), the STX principal + yield can be withdrawn from Stacking DAO.
The withdrawal can be called using withdraw and expects the following parameters:
nft-id- the ID of the NFT that was minted in theinit-withdrawmethod previously.
After the withdrawal succeeds, the STX principal and yield amounts will be returned to the transaction sender's wallet.
Instant Withdrawal
Instant withdrawal lets you withdraw your STX immediately using idle liquidity from the protocol, if idle liquidity is available. A 1% fee applies to Instant Unstack.
The instant withdrawal can be called using withdraw-idle and expects the following parameters:
ststx-amount- a positive integer value for the ustSTX (micro-stSTX, 10^6) amount you want to unstack and getSTXin return for. For example, passing1000000will unstack 1 stSTX.
Reading the ratio
The stSTX/STX exchange rate is read from the data contract at SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.data-stx-v2, using the get-stx-per-ststx read-only method. It returns the amount of micro-STX backing one stSTX (10^6 based), and is what you should use to size min-shares-out.
The data contract can be found here: https://explorer.hiro.so/txid/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.data-stx-v2?chain=mainnet