Contract 188cacf8f830a043f187721235281e47018960d60d3e3794541578983662dfcf

← Back to Index 📥 Download WASM

Meta

rssdkver 23.1.0#7456be9d91fe1f4cb070fc2732bac78244ce6c3f
rsver 1.91.0

Instances

  • CBBY53VYJSMAWCBZZ7BHJZ5XSZNJUS4ZE6Q4RN7TKZGHPYHMEE467W7Y

Interface

Deposits tokens into the fee vault for a specific reserve. Requires the signer to sign the transaction if the signer is set.

Arguments

  • user - The address of the user making the deposit
  • amount - The amount of tokens to deposit

Returns

  • i128 - The number of shares minted for the user

Panics

  • InvalidAmount - If the amount is less than or equal to 0
  • InvalidBTokensMinted - If the amount of bTokens minted is less than or equal to 0
  • InvalidSharesMinted - If the amount of shares minted is less than or equal to 0
  • BalanceError - If the user does not have enough tokens
fn deposit(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: i128) -> i128

Get the vault's fee configuration

Returns

  • Fee - The fee configuration for the vault
fn get_fee(env: soroban_sdk::Env) -> Fee

ADMIN ONLY Sets the Fee mode for the fee vault

Arguments

  • e - The environment object
  • rate_type - The rate type the vault will use
  • 0 = take rate (admin earns a percentage of the vault's earnings)
  • 1 = capped rate (vault earns at most the APR cap, with any additional returns going to the admin)
  • 2 = fixed rate (vault always earns the fixed rate, with the admin either supplementing or earning the difference)
  • rate - The rate value, with 7 decimals (e.g. 1000000 for 10%)

Panics

  • InvalidFeeRate - If the value is not within 0 and 1_000_0000
  • InvalidFeeRateType - If the rate type is not 0, 1, or 2
fn set_fee(env: soroban_sdk::Env, rate_type: u32, rate: u32)

Withdraws tokens from the fee vault for a specific reserve. If the input amount is greater than the user's underlying balance, the user's full balance will be withdrawn. Requires the signer to sign the transaction if the signer is set.

Arguments

  • user - The address of the user making the withdrawal
  • amount - The amount of tokens to withdraw

Returns

  • i128 - The number of shares burnt

Panics

  • InvalidAmount - If the amount is less than or equal to 0
  • InvalidBTokensBurnt - If the amount of bTokens burnt is less than or equal to 0
  • InsufficientReserves - If the pool doesn't have enough reserves to complete the withdrawal
fn withdraw(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: i128) -> i128

Get the vault's admin

Returns

  • Address - The admin address for the vault
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Get the vault data

Returns

  • VaultData - The vault data
fn get_vault(env: soroban_sdk::Env) -> VaultData

ADMIN ONLY Sets the admin address for the fee vault. Requires a signature from both the current admin and the new admin address.

Arguments

  • e - The environment object
  • admin - The new admin address to set
fn set_admin(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Get the vault's blend pool it deposits into and the asset it supports.

Returns

  • (Address, Address) - (The blend pool address, the asset address)
fn get_config(env: soroban_sdk::Env) -> (soroban_sdk::Address, soroban_sdk::Address)

Fetch a user's position in shares

Arguments

  • user - The address of the user

Returns

  • i128 - The user's position in shares, or the user has no shares
fn get_shares(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Get the vault's signer

Returns

  • Option<Address> - The signer address for the vault, or None if no signer is set
fn get_signer(env: soroban_sdk::Env) -> Option

ADMIN ONLY Sets the signer for the fee vault. This address is required to sign all user deposits into the fee vault. Requires a signature from both the current admin and the new signer address.

Passing None as the signer will remove the signer requirement for deposits.

Arguments

  • signer - The new signer address to set
fn set_signer(env: soroban_sdk::Env, signer: Option)

Fetch a user's rewards for a specific token. Does not update the user's rewards.

If the current claimable rewards is needed, it is recommended to simulate a claim call to get the current claimable rewards.

Arguments

  • user - The address of the user
  • token - The address of the reward token

Returns

  • Option<UserRewards> - The user's rewards for the token, or None
fn get_rewards(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> Option

ADMIN ONLY Sets rewards to be distributed to the fee vault depositors. The full reward_amount will be transferred to the vault to be distributed to the users until the expiration timestamp.

Arguments

  • token - The address of the reward token
  • reward_amount - The amount of rewards to distribute
  • expiration - The timestamp when the rewards expire

Panics

  • InvalidRewardConfig - If the reward token cannot be changed, or if a valid reward period cannot be started
  • BalanceError - If the admin does not have enough tokens to set the rewards
fn set_rewards(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    reward_amount: i128,
    expiration: u64,
)

Fetch a user's position in bTokens

Arguments

  • user - The address of the user

Returns

  • i128 - The user's position in bTokens, or 0 if they have no bTokens
fn get_b_tokens(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Initialize the contract

Arguments

  • admin - The admin address
  • pool - The blend pool address the vault will deposit into
  • asset - The asset address of the reserve the vault will support
  • rate_type - The rate type the vault will use
  • 0 = take rate (admin earns a percentage of the vault's earnings)
  • 1 = capped rate (vault earns at most the APR cap, with any additional returns going to the admin)
  • 2 = fixed rate (vault always earns the fixed rate, with the admin either supplementing or earning the difference)
  • rate - The rate value, with 7 decimals (e.g. 1000000 for 10%)
  • signer- The signer address if the vault is permissioned, None otherwise

Panics

  • InvalidFeeRate - If the value is not within 0 and 1_000_0000
  • InvalidFeeRateType - If the rate type is not 0, 1, or 2
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    pool: soroban_sdk::Address,
    asset: soroban_sdk::Address,
    rate_type: u32,
    rate: u32,
    signer: Option,
)

ADMIN ONLY Deposit tokens into the vault's admin balance

Arguments

  • amount - The amount of tokens to deposit

Returns

  • i128 - The number of b_tokens minted

Panics

  • InvalidAmount - If the amount is less than or equal to 0
  • InvalidBTokensMinted - If the amount of bTokens minted is less than or equal to 0
  • BalanceError - If the user does not have enough tokens
fn admin_deposit(env: soroban_sdk::Env, amount: i128) -> i128

Claims rewards for the user from the fee vault.

Arguments

  • user - The address of the user claiming rewards
  • reward_token - The address of the reward token to claim
  • to - The address to send the claimed rewards to

Returns

  • i128 - The amount of rewards claimed

Panics

  • NoRewardsConfigured - If no rewards are configured for the token
fn claim_rewards(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    to: soroban_sdk::Address,
) -> i128

ADMIN ONLY Withdraw tokens from the vault's admin balance

Arguments

  • amount - The amount of underlying tokens to withdraw

Returns

  • i128 - The number of b_tokens burnt

Panics

  • InvalidAmount - If the amount is less than or equal to 0
  • BalanceError - If the user does not have enough shares to withdraw the amount
  • InvalidBTokensBurnt - If the amount of bTokens burnt is less than or equal to 0
fn admin_withdraw(env: soroban_sdk::Env, amount: i128) -> i128

ADMIN ONLY Claims emissions for the given reserves from the pool. This is a passthrough function that invokes the pool's "claim" function as the contract. More details can be found here: https://github.com/blend-capital/blend-contracts/blob/v1.0.0/pool/src/contract.rs#L192

Arguments

  • reserve_token_ids - The ids of the reserves to claiming emissions for
  • to - The address to send the emissions to

Returns

  • i128 - The amount of blnd tokens claimed
fn claim_emissions(
    env: soroban_sdk::Env,
    reserve_token_ids: soroban_sdk::Vec,
    to: soroban_sdk::Address,
) -> i128

Get the reward data for a specific token

Arguments

  • token - The address of the reward token

Returns

  • Option<RewardData> - The reward data for the token, or None if no data exists
fn get_reward_data(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
) -> Option

Get the current reward token for the fee vault

Returns

  • Option<Address> - The address of the reward token, or None if no reward token is set
fn get_reward_token(env: soroban_sdk::Env) -> Option

ADMIN ONLY Upgrades the contract to use new WASM bytecode. This allows the contract to be updated with new functionality while preserving its state and address.

Arguments

  • new_wasm_hash - The hash of the new WASM bytecode to upgrade to

Panics

  • Only the admin can call this function
fn upgrade_contract(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

NOT INTENDED FOR CONTRACT USE

Get the vault summary, which includes the pool, asset, admin, signer, fee, vault data, rewards, and estimated APR for vault suppliers. Intended for use by dApps looking to fetch display data.

Returns

  • VaultSummary - The summary of the vault
fn get_vault_summary(env: soroban_sdk::Env) -> VaultSummary

Fetch a user's position in underlying tokens

Arguments

  • user - The address of the user

Returns

  • i128 - The user's position in underlying tokens, or 0 if they have no shares
fn get_underlying_tokens(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Fetch the admin balance in underlying tokens

Returns

  • i128 - The admin's accrued fees in underlying tokens, or 0 if the reserve does not exist
fn get_underlying_admin_balance(env: soroban_sdk::Env) -> i128

Imports

WebAssembly Text (WAT) ▶