Swapline
The Swapline is a more straightforward way to get synthetic tokens. It exists to keep the price of each of the synthetic tokens close to their original counterparts. Moreover, without it, amount of synthetic tokens in circulation would be smaller than debt, due to interest rate. The Swapline provides a simple way to counteract that.
#
Structure of Swapline- synthetic - address of a synthetic token
- collateral - address of a collateral token
- fee - percentage of every swap taken as a fee
- accumulated_fee - total amount of the fee. Can be withdrawn by admin
- balance - amount of tokens in reserve
- limit - limit of synthetic tokens that can be minted
- collateral_reserve - account where collateral tokens are deposited (different from both debt pool and vault counterparts)
- halted - swapline can be halted independently of rest of exchange (but halt of exchange affects it too)
- bump - seed used to ensure the generated address doesn't collide with any other existing one
#
Swapping tokensTokens can be swapped from collateral to synthetic as long as the total swapped amount is below the swapline limit. The appropriate function is defined here.
They can also be swapped back from synthetic to collateral, as long as there are enough tokens in collateral_reserve (balance). The method is defined here.
As both of these functions are so similar, they both take amount (u64) and the same struct:
- state - account with data of the program
- swapline - structure with data of the exchange
- synthetic - address of the synthetic token
- collateral - address of the collateral token
- user_collateral_account - user account with collateral tokens
- user_synthetic_account - user account with synthetic tokens
- assets_list - list of assets structured as this
- collateral_reserve - account with collateral tokens
- signer - owner of the user accounts with tokens
- exchange_authority - pubkey of the exchange program
- token_program - address of Solana's Token Program