API reference
All instructions of programs/squeeth. Accounts are listed in order. mut means writable, signer means it must sign.
init_market(funding_period: i64, twap_window: i64)
Creates the market, the power mint and the pool token account. Only the program upgrade authority.
| Account | Notes |
|---|---|
| payer | mut, signer, must be the upgrade authority |
| market | init, ["market"] |
| power_mint | init, ["power"], 9 decimals, authority = market |
| pool_tokens | init, ["pool_tokens"] |
| program, program_data | used to read the upgrade authority |
| token_program, system_program, rent |
Bounds: funding_period 60 to 7,776,000 seconds, twap_window 5 to 3,600 seconds, else BadParams.
open_vault()
| Account | Notes |
|---|---|
| owner | mut, signer |
| vault | init, ["vault", owner] |
| system_program |
deposit(lamports: u64)
Moves SOL from owner to the vault. Accounts: owner (mut, signer), vault (mut, owned by owner), system_program.
mint_power(amount: u64)
Reads the price, applies funding, adds amount to the debt, requires 150% or more, mints to owner_tokens.
| Account | Notes |
|---|---|
| owner | signer |
| market | mut |
| vault | mut, owned by owner |
| oracle | the |
| power_mint | mut |
| owner_tokens | mut, token account of the power mint |
| token_program |
burn_power(amount: u64)
Repays amount of debt by burning the owner's tokens. No price needed. Accounts: owner (signer), market (mut), vault (mut), power_mint (mut), owner_tokens (mut, authority = owner), token_program.
withdraw(lamports: u64)
Takes SOL out of the vault. If debt remains, reads the price, applies funding and requires 150% or more afterwards. Accounts: owner (mut, signer), market (mut), vault (mut), oracle.
liquidate(amount: u64)
Anyone. The vault must be under 150%. amount is at most half the debt (all of it at 0.001 token or less). Burns the liquidator's tokens, pays debt_value(amount) × 1.10 in SOL, capped at the collateral.
| Account | Notes |
|---|---|
| liquidator | mut, signer |
| market | mut |
| vault | mut, any owner |
| oracle | the |
| power_mint | mut |
| liquidator_tokens | mut, authority = liquidator |
| token_program |
open_lp(), add_liquidity(lamports: u64, max_tokens: u64), remove_liquidity(shares: u64)
open_lp creates ["lp", owner]. add_liquidity deposits SOL and up to max_tokens at the pool ratio (the first deposit sets it) and mints shares. remove_liquidity returns the share of both reserves.
buy(lamports_in: u64, min_out: u64), sell(tokens_in: u64, min_out: u64)
Constant product swap with a 0.3% fee against the pool. Refuses an empty pool (EmptyPool) and any output under min_out (Slippage).
| Account | Notes |
|---|---|
| trader | mut, signer |
| market | mut |
| trader_tokens | mut, token account of the power mint |
| pool_tokens | mut |
| token_program, system_program |
poke()
Anyone. Reads the price and applies funding. Accounts: market (mut), oracle.
init_test_oracle(), set_test_price(price_e8: i64, conf_e8: u64)
Local tests only. In the mainnet build they always fail with Disabled, and the price reader accepts only
Pyth.