Contract 39ade914159ace3fbeafb0c4cf60497bd0dbb83932832bb21102f6e41a0ed70c

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.6#0c47dcfa187069d241f11fb082730f667b55e802
rsver 1.85.0

Instances

  • CAHXQWU2HB74PIBT2BUIPYUZXMGZJEQUCNMQLEZR4OMNXMCEHYNEUWZQ

Interface

Initializes the contract with the necessary configuration parameters.

Arguments

  • e - The execution environment, provided automatically when the contract is invoked.
  • asset - The address of the asset managed by the contract.
  • init_args - A vector of initialization arguments required for configuration.

Parameters in init_args

The init_args vector must contain the following, in order:

  1. blend_pool_address: Address - The address of the Blend pool where assets are deposited.
  2. blend_token: Address - The address of the reward token (e.g., BLND) issued by the Blend pool.
  3. soroswap_router: Address - The address of the Soroswap AMM router for asset swaps.
  4. reward_threshold: i128 - The minimum reward amount that triggers reinvestment.
  5. keeper: Address - The address of the account that will be allowed to do harvest.

Behavior

This function:

  • Fetches the reserve_id from the Blend pool for the given asset.
  • Calculates claim_ids for the asset bTokens.
  • Stores all paramete
fn __constructor(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Address,
    init_args: soroban_sdk::Vec,
)

Retrieves the asset address from the contract's stored configuration.

This function extends the contract's TTL and returns the asset address stored in the configuration. It returns a Result<Address, StrategyError> where Ok contains the asset address and Err indicates an error.

Arguments

  • e: Env - The execution environment.

Returns

  • Result<Address, StrategyError> - The asset address or an error.
fn asset(env: soroban_sdk::Env) -> Result

Deposits a specified amount of the underlying asset into the strategy.

This function transfers the specified amount of the underlying asset from the from address to the strategy contract, supplies it to the Blend pool, and mints shares representing the deposited amount.

Arguments

  • e: Env - The execution environment.
  • amount: i128 - The amount of the underlying asset to deposit.
  • from: Address - The address from which the asset is being transferred.

Returns

  • Result<i128, StrategyError> - The underlying balance of the vault (caller) after the deposit or an error.
fn deposit(
    env: soroban_sdk::Env,
    amount: i128,
    from: soroban_sdk::Address,
) -> Result

Harvests rewards from the Blend pool and reinvests them into the strategy.

This function claims rewards from the Blend pool and reinvests them if the balance exceeds the reward threshold. It also emits a harvest event upon completion.

To comply with the Strategy Crate, this function requires a from argument, which is not strictly necessary in this context. However, the function enforces that the caller (keeper) provides their own address for authorization.

Arguments

  • e: Env - The execution environment.
  • from: Address - The address initiating the harvest (must be the keeper).

Returns

  • Result<(), StrategyError> - Returns Ok(()) on success or a StrategyError on failure.
fn harvest(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    data: Option,
) -> Result<(), StrategyError>

Withdraws a specified amount of the underlying asset from the strategy.

This function transfers the specified amount of the underlying asset from the strategy contract to the to address, burns the corresponding bTokens, and updates the reserves.

Arguments

  • e: Env - The execution environment.
  • amount: i128 - The amount of the underlying asset to withdraw.
  • from: Address - The address from which the asset is being withdrawn.
  • to: Address - The address to which the asset is being transferred.

Returns

  • Result<i128, StrategyError> - The remaining balance of the vault (caller) after the withdrawal or an error.
fn withdraw(
    env: soroban_sdk::Env,
    amount: i128,
    from: soroban_sdk::Address,
    to: soroban_sdk::Address,
) -> Result

Returns the balance of the underlying asset for a given address.

This function calculates the balance of the underlying asset for the specified 'from' address by converting the 'from' shares to the underlying asset amount.

Arguments

  • e: Env - The execution environment.
  • from: Address - The address for which the balance is being queried.

Returns

  • Result<i128, StrategyError> - The balance of the underlying asset or an error.
fn balance(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
) -> Result

Sets a new keeper address for the strategy.

This function updates the keeper address stored in the contract's storage. Only the current keeper can authorize this change.

Arguments

  • e: Env - The execution environment.
  • new_keeper: Address - The new keeper address to set.

Returns

  • Result<(), StrategyError> - An empty result or an error.
fn set_keeper(
    env: soroban_sdk::Env,
    new_keeper: soroban_sdk::Address,
) -> Result<(), StrategyError>

Returns the current keeper address.

Arguments

  • e: Env - The execution environment.

Returns

  • Result<Address, StrategyError> - The current keeper address or an error.
fn get_keeper(env: soroban_sdk::Env) -> Result

Imports

WebAssembly Text (WAT) ▶