fn admin(env: soroban_sdk::Env) -> soroban_sdk::Address
fn asset(env: soroban_sdk::Env) -> Result
Query the underlying asset balance for an address.
balance = caller_shares / total_shares × (supply_value - debt_value)
fn balance(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
) -> Result
Deposit underlying asset, execute leverage loop, mint shares.
Flow:
amount from from to the strategy contractfn deposit(
env: soroban_sdk::Env,
amount: i128,
from: soroban_sdk::Address,
) -> Result
Harvest BLND emissions, swap to underlying, re-leverage.
Callable only by the keeper. Claims from both supply and borrow emission sides, swaps BLND → underlying via Soroswap, then re-leverages proceeds. No new shares are minted — this increases per-share equity.
fn harvest(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
data: Option,
) -> Result<(), StrategyError>
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Current contract version (1 at deploy, bumped on each upgrade).
fn version(env: soroban_sdk::Env) -> u32
Get current strategy position details. Returns (total_equity, total_shares, b_tokens, d_tokens, b_rate, d_rate).
fn position(
env: soroban_sdk::Env,
) -> Result<(i128, i128, i128, i128, i128, i128), StrategyError>
Withdraw underlying by unwinding proportional leverage.
Flow:
tofn withdraw(
env: soroban_sdk::Env,
amount: i128,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
) -> Result
Rebalance: partial-unwind if HF is in the orange zone (HF < orange_hf),
restoring HF to orange_hf. Callable by anyone (permissionless — protects
the vault). Emits a rebalance event when loops are unwound.
fn rebalance(env: soroban_sdk::Env) -> Result<(), StrategyError>
fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Get the current keeper address.
fn get_keeper(env: soroban_sdk::Env) -> Result
Set a new keeper address (keeper self-rotation).
Gated by the current keeper. This is one of two ways to rotate the
keeper; see admin_set_keeper for the admin recovery path used when the
keeper key is lost or compromised.
fn set_keeper(
env: soroban_sdk::Env,
new_keeper: soroban_sdk::Address,
) -> Result<(), StrategyError>
The configured share token, or an error if not yet set.
fn share_token(env: soroban_sdk::Env) -> Result
The configured swap account, or an error if unset.
fn swap_account(env: soroban_sdk::Env) -> Result
Initialize the strategy with configuration.
init_args layout: [0] pool: Address — Blend pool [1] blend_token: Address — BLND token [2] router: Address — Soroswap router [3] reward_threshold: i128 — min BLND to trigger harvest [4] keeper: Address — authorized harvest caller [5] c_factor: i128 — collateral factor (1e7) [6] target_loops: u32 — number of leverage loops [7] min_hf: i128 — minimum health factor (1e7) [8] orange_hf: i128 — orange-zone threshold; partial unwind triggered below this (1e7) [9] admin: Address — authorized to upgrade the contract and set the share token
fn __constructor(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
init_args: soroban_sdk::Vec,
)
Keeper-gated: claim BLND emissions into the strategy and approve the swap account to pull them (if set) for an off-chain Broker swap. The BLND stays in the contract until pulled, so the on-chain Soroswap path remains a valid fallback. Returns the BLND balance available to swap.
fn harvest_claim(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
) -> Result
Get current health factor (1e7 scaled).
fn health_factor(env: soroban_sdk::Env) -> Result
Partial-unwind liquidation protection: unwind just enough loops to restore
HF to target_hf. Callable by the keeper, or by anyone when HF is already
in the orange zone. target_hf is floored at config.orange_hf to prevent
over-unwinding. Emits a rebalance event when loops are unwound.
fn partial_unwind(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
target_hf: i128,
) -> Result
Set the SEP-41 vault-share token (admin-gated, one-time wiring).
The token must already be deployed with this strategy as its minter.
Required before the first deposit. On a fresh deploy the token is the
per-user ledger from day one; for an upgraded legacy deployment, call
migrate_position per holder afterwards.
fn set_share_token(
env: soroban_sdk::Env,
token: soroban_sdk::Address,
) -> Result<(), StrategyError>
Admin recovery path to rotate the keeper (gated by the admin-sep admin).
Complements set_keeper: the keeper rotates itself in normal operation,
but if the keeper key is lost or compromised the admin can install a new
keeper here without the old keeper's cooperation.
fn admin_set_keeper(
env: soroban_sdk::Env,
new_keeper: soroban_sdk::Address,
) -> Result<(), StrategyError>
Keeper-gated: re-leverage harvested proceeds via the chosen route.
via_soroswap = true: swap the strategy's BLND → underlying on-chain
through Soroswap (mandatory non-zero amount_out_min), then re-leverage.via_soroswap = false (Broker): the keeper has already swapped off-chain
and transferred amount_in of underlying back to the strategy; re-leverage
it directly (asserted to be held). amount_out_min is ignored here.Emits a harvest_route event (route, amount_in, amount_out_min, realized)
for the keeper's A/B telemetry. Returns realized underlying re-leveraged.
fn harvest_reinvest(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
amount_in: i128,
via_soroswap: bool,
amount_out_min: i128,
) -> Result
Migrate a legacy VaultPos holder onto the share token: mint their
shares into the token and zero the legacy entry. Permissionless and
idempotent (it only moves a holder's own shares into their token
balance — no theft possible). Used once after upgrading a deployment
that predates the token; fresh deploys never need it.
fn migrate_position(
env: soroban_sdk::Env,
holder: soroban_sdk::Address,
) -> Result
Keeper-authorised, rate-limited auto-rebalance. Unwinds the minimal loops
to restore HF to orange_hf when HF has dropped into the orange zone.
Limited to once per REBALANCE_COOLDOWN_LEDGERS; emits a rebalance
event with before/after HF and loops unwound. Returns loops unwound.
fn rebalance_keeper(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result
Set the keeper-controlled account allowed to pull claimed BLND for an off-chain swap (admin-gated).
fn set_swap_account(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> Result<(), StrategyError>