Initializes the contract with the necessary configuration parameters.
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.init_argsThe init_args vector must contain the following, in order:
blend_pool_address: Address - The address of the Blend pool where assets are deposited.blend_token: Address - The address of the reward token (e.g., BLND) issued by the Blend pool.soroswap_router: Address - The address of the Soroswap AMM router for asset swaps.reward_threshold: i128 - The minimum reward amount that triggers reinvestment.keeper: Address - The address of the account that will be allowed to do harvest.This function:
reserve_id from the Blend pool for the given asset.claim_ids for the asset bTokens.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.
e: Env - The execution environment.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.
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.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.
e: Env - The execution environment.from: Address - The address initiating the harvest (must be the keeper).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.
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.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.
e: Env - The execution environment.from: Address - The address for which the balance is being queried.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.
e: Env - The execution environment.new_keeper: Address - The new keeper address to set.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.
e: Env - The execution environment.Result<Address, StrategyError> - The current keeper address or an error.fn get_keeper(env: soroban_sdk::Env) -> Result