fn name(env: soroban_sdk::Env) -> soroban_sdk::String
Repay borrowed tokens
fn repay(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: u128)
Seize pTokens from borrower to liquidator; only callable by peridottroller/peridottroller
fn seize(
env: soroban_sdk::Env,
borrower: soroban_sdk::Address,
liquidator: soroban_sdk::Address,
ptoken_amount: u128,
ctx: Option,
)
Borrow tokens against pToken collateral
fn borrow(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: u128)
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String
fn approve(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
amount: i128,
live_until_ledger: u32,
)
fn balance(env: soroban_sdk::Env, account: soroban_sdk::Address) -> i128
Deposit tokens into the vault and receive pTokens
fn deposit(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: u128)
Permissionless keepalive for global vault configuration and interest state. Account-health snapshots deliberately use a narrow TTL path to stay within Soroban's transaction footprint, so operators should call this periodically.
fn bump_ttl(env: soroban_sdk::Env)
fn decimals(env: soroban_sdk::Env) -> u32
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::MuxedAddress,
amount: i128,
)
Withdraw tokens using pTokens
fn withdraw(env: soroban_sdk::Env, user: soroban_sdk::Address, ptoken_amount: u128)
fn allowance(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
) -> i128
Read admin
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Repay the user's full post-accrual debt in a single call.
Avoids the dust left by repay(amount) when interest accrues between
simulation and execution: the repay cap is fixed pre-accrual, so a
user-supplied amount equal to the displayed debt always leaves a few
units behind. repay_max recomputes the debt after accrual and pays
exactly that, leaving the borrow at zero.
fn repay_max(env: soroban_sdk::Env, user: soroban_sdk::Address)
Admin: transfer admin to new address
fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Execute a flash loan to receiver. Receiver must return amount + fee within the callback.
fn flash_loan(
env: soroban_sdk::Env,
initiator: soroban_sdk::Address,
receiver: soroban_sdk::Address,
amount: u128,
data: soroban_sdk::Bytes,
)
Initialize the vault with underlying token, supply yearly rate, borrow yearly rate, and admin Rates are scaled by 1e6 (e.g., 10% = 100_000)
fn initialize(
env: soroban_sdk::Env,
token_address: soroban_sdk::Address,
supply_yearly_rate_scaled: u128,
borrow_yearly_rate_scaled: u128,
admin: soroban_sdk::Address,
)
fn accept_admin(env: soroban_sdk::Env)
fn total_supply(env: soroban_sdk::Env) -> i128
Admin: execute a staged upgrade once timelock has elapsed.
fn upgrade_wasm(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Admin-only recovery for missing core state after TTL expiry. Sets missing rate/index/time fields to safe defaults.
fn recover_state(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
supply_yearly_rate_scaled: u128,
borrow_yearly_rate_scaled: u128,
total_borrowed: u128,
)
Admin: set admin fee factor (0..=1e6)
fn set_admin_fee(env: soroban_sdk::Env, admin_fee_scaled: u128)
fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
owner: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
Admin: set borrow cap (0 disables)
fn set_borrow_cap(env: soroban_sdk::Env, cap: u128)
Admin: set supply cap (0 disables)
fn set_supply_cap(env: soroban_sdk::Env, cap: u128)
Admin: reduce reserves and transfer to admin
fn reduce_reserves(env: soroban_sdk::Env, amount: u128)
Repay on behalf during liquidation; only callable by peridottroller/peridottroller
fn repay_on_behalf(
env: soroban_sdk::Env,
liquidator: soroban_sdk::Address,
borrower: soroban_sdk::Address,
amount: u128,
)
Admin: update borrow yearly rate (scaled 1e6)
fn set_borrow_rate(env: soroban_sdk::Env, yearly_rate_scaled: u128)
Update interest based on elapsed time and current per-second rate
fn update_interest(env: soroban_sdk::Env)
Get user's balance in the vault in underlying terms (pTokens × exchange rate)
fn get_user_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u128
Repay debt tracked in a margin position namespace. Callable only by the configured margin controller.
fn repay_for_margin(
env: soroban_sdk::Env,
position_id: u64,
payer: soroban_sdk::Address,
amount: u128,
)
Borrow into a margin position namespace. Callable only by the configured margin controller.
fn borrow_for_margin(
env: soroban_sdk::Env,
position_id: u64,
receiver: soroban_sdk::Address,
amount: u128,
)
View: get boosted vault (if set)
fn get_boosted_vault(env: soroban_sdk::Env) -> Option
Get the exchange rate (pToken to underlying ratio) scaled by 1e6
fn get_exchange_rate(env: soroban_sdk::Env) -> u128
Get total pTokens issued
fn get_total_ptokens(env: soroban_sdk::Env) -> u128
Pull the specified amount of underlying from the boosted vault into idle cash. Call this before a large withdraw to pre-fund idle cash so the withdrawal transaction itself does not need to call the boosted vault (avoiding budget limits). Restricted to admin to prevent griefing: a permissionless version lets any caller force a full DeFindex redemption, disrupting yield for all depositors.
fn prepare_liquidity(env: soroban_sdk::Env, amount: u128)
Admin: reduce admin fees and transfer to admin
fn reduce_admin_fees(env: soroban_sdk::Env, amount: u128)
Admin: set boosted vault address (DeFindex).
fn set_boosted_vault(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
boosted_vault: soroban_sdk::Address,
)
Admin: update yearly interest rate (scaled 1e6). Applies after accruing with old rate.
fn set_interest_rate(env: soroban_sdk::Env, yearly_rate_scaled: u128)
Get user's pToken balance
fn get_ptoken_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u128
fn get_total_bad_debt(env: soroban_sdk::Env) -> u128
Get total borrowed outstanding
fn get_total_borrowed(env: soroban_sdk::Env) -> u128
Get total reserves
fn get_total_reserves(env: soroban_sdk::Env) -> u128
Admin: set flash loan fee (0..=1e6, applied to principal)
fn set_flash_loan_fee(env: soroban_sdk::Env, fee_scaled: u128)
Admin: set interest rate model address
fn set_interest_model(env: soroban_sdk::Env, model: soroban_sdk::Address)
Admin: set peridottroller address
fn set_peridottroller(env: soroban_sdk::Env, peridottroller: soroban_sdk::Address)
Admin: set reserve factor (0..=1e6)
fn set_reserve_factor(env: soroban_sdk::Env, reserve_factor_scaled: u128)
Admin: explicitly enable static-rate mode when no external model is used.
fn enable_static_rates(env: soroban_sdk::Env, admin: soroban_sdk::Address)
Get total amount deposited in the vault
fn get_total_deposited(env: soroban_sdk::Env) -> u128
Admin: move excess live cash into boosted vault to match target buffer.
fn rebalance_idle_cash(env: soroban_sdk::Env, admin: soroban_sdk::Address)
Permissionless TTL extension for per-user borrow state. Keepers can call this periodically for active borrowers.
fn bump_user_borrow_ttl(env: soroban_sdk::Env, user: soroban_sdk::Address)
Return (ptoken_balance, borrow_balance, exchange_rate, underlying_token) in one call. Peridottroller uses this in account-health loops to replace four cross-contract reads with one. Boosted markets use a fresh keeper-maintained NAV cache here; stale or missing cache state fails closed instead of synchronously loading a strategy footprint.
fn get_account_snapshot(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> (u128, u128, u128, soroban_sdk::Address)
Get total admin fees
fn get_total_admin_fees(env: soroban_sdk::Env) -> u128
Get total underlying
fn get_total_underlying(env: soroban_sdk::Env) -> u128
Get the underlying token address
fn get_underlying_token(env: soroban_sdk::Env) -> soroban_sdk::Address
Admin: stage a timelocked contract upgrade.
fn propose_upgrade_wasm(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
fn begin_margin_withdraw(
env: soroban_sdk::Env,
margin_controller: soroban_sdk::Address,
user: soroban_sdk::Address,
recipient: soroban_sdk::Address,
max_ptokens: u128,
)
Get collateral factor (scaled 1e6)
fn get_collateral_factor(env: soroban_sdk::Env) -> u128
fn get_margin_controller(env: soroban_sdk::Env) -> Option
Repay a margin position's full post-accrual debt with a fixed user-authorized maximum payment. Any overpay is refunded, avoiding exact-auth drift when interest changes between simulation and execution.
fn repay_full_for_margin(
env: soroban_sdk::Env,
position_id: u64,
payer: soroban_sdk::Address,
max_amount: u128,
) -> u128
Admin: set collateral factor (0..=1e6)
fn set_collateral_factor(env: soroban_sdk::Env, new_factor_scaled: u128)
Admin: set or clear margin controller address used for collateral lock checks.
fn set_margin_controller(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
margin_controller: Option,
)
Absorb remaining margin debt after collateral has been exhausted. Reserves absorb losses first; any remainder is explicitly recorded as bad debt and socialized through the exchange rate by reducing TotalBorrowed.
fn absorb_margin_bad_debt(env: soroban_sdk::Env, position_id: u64) -> u128
Permissionless TTL extension for position-scoped margin borrow state.
fn bump_margin_borrow_ttl(env: soroban_sdk::Env, position_id: u64)
View: preview flash-loan fee for amount using the same rounding as flash_loan.
fn preview_flash_loan_fee(env: soroban_sdk::Env, amount: u128) -> u128
Get available liquidity = total_underlying - total_borrowed
fn get_available_liquidity(env: soroban_sdk::Env) -> u128
View the persisted boosted-vault output-vector length.
fn get_boosted_asset_count(env: soroban_sdk::Env) -> Option
Get user's current borrow balance (principal adjusted by index)
fn get_user_borrow_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u128
Permissionless snapshot recovery is intentionally disabled: rebuilding without the historical borrow index can erase accrued interest.
fn recover_borrow_snapshot(env: soroban_sdk::Env, user: soroban_sdk::Address)
Permissionless snapshot recovery is intentionally disabled: rebuilding without the historical borrow index can erase accrued interest.
fn recover_margin_snapshot(env: soroban_sdk::Env, position_id: u64)
Admin migration/recovery for markets bound before BoostedAssetCount existed. The expected address prevents a stale operator command from configuring a replacement strategy accidentally.
fn set_boosted_asset_count(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
boosted_vault: soroban_sdk::Address,
asset_count: u32,
)
View: get target idle cash buffer in basis points.
fn get_idle_cash_buffer_bps(env: soroban_sdk::Env) -> u32
Borrow into a margin position namespace. Callable only by the configured margin controller.
fn init_margin_borrow_state(env: soroban_sdk::Env, position_id: u64)
Admin: set target idle cash buffer in basis points (0..=10_000).
fn set_idle_cash_buffer_bps(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
idle_cash_buffer_bps: u32,
)
Get current borrow balance for a margin position namespace.
fn get_margin_borrow_balance(env: soroban_sdk::Env, position_id: u64) -> u128
Get user's collateral value in underlying terms
fn get_user_collateral_value(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u128
Permissionless migration/keepalive path for user borrow state. Existing mirrors are canonical true principal; snapshots may include capitalized interest, so this path must not create a missing mirror.
fn migrate_borrow_state_batch(
env: soroban_sdk::Env,
users: soroban_sdk::Vec,
)
Permissionless migration/keepalive path for margin borrow state.
fn migrate_margin_state_batch(
env: soroban_sdk::Env,
position_ids: soroban_sdk::Vec,
)
Permissionless: refresh the cached boosted-underlying value from live DeFindex data. Call this at least every five minutes and after each rebalance. Account-health checks fail closed when the cache is stale so they never need to load DeFindex's full footprint inside a borrow transaction.
fn refresh_boosted_underlying(env: soroban_sdk::Env)
Admin recovery path for a missing/expired borrower snapshot. Intended for keeper-assisted repair after TTL expiry.
fn recover_user_borrow_snapshot(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
user: soroban_sdk::Address,
principal: u128,
interest_index: u128,
)
Admin-only migration for a legacy borrower whose debt snapshot exists but whose true-principal mirror was never written. The principal must be reconstructed from trusted historical accounting; snapshot principal is not a safe default because it may include capitalized interest.
fn recover_user_borrow_principal(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
user: soroban_sdk::Address,
principal: u128,
)
Admin recovery path for a missing/expired margin-position borrow snapshot.
fn recover_margin_borrow_snapshot(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
position_id: u64,
principal: u128,
interest_index: u128,
)
Borrow into a margin position namespace and send funds to the configured margin controller. This is used by controller-custodied margin positions.
fn borrow_for_margin_to_controller(
env: soroban_sdk::Env,
position_id: u64,
amount: u128,
)
Admin-only mirror recovery for legacy margin-position debt.
fn recover_margin_borrow_principal(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
position_id: u64,
principal: u128,
)