Get admin address.
fn get_admin(env: soroban_sdk::Env) -> Result
Extend contract TTL. Public.
fn extend_ttl(env: soroban_sdk::Env)
Initialize the contract. Can only be called once.
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
oracle_registry: soroban_sdk::Address,
accounting_token: soroban_sdk::Address,
) -> Result<(), PositionError>
Compute the NAV for an account.
NOTE: This function is designed for off-chain simulation (simulateTransaction) only. Calling it as a real on-chain transaction will exceed the 100M instruction budget for realistic adapter × pool configurations. This is acceptable for NAV reporting use cases.
Account-agnostic: any address can be queried without prior registration. Returns zero NAV for accounts with no positions — NOT an error.
Per-adapter error isolation: if one adapter panics or returns an error, the remaining adapters are still queried and their results are included in the NAV.
fn compute_nav(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> Result
Get the adapter address for a protocol.
fn get_adapter(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::Symbol,
) -> Result
Accept a pending admin proposal (step 2 of two-step transfer).
Must be called by the pending_admin address.
fn accept_admin(env: soroban_sdk::Env) -> Result<(), PositionError>
Get a specific position by index.
fn get_position(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
index: u32,
) -> Result
Get all positions for an account.
fn get_positions(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> soroban_sdk::Vec
Propose a new admin (step 1 of two-step transfer). Admin only. (MEDIUM-01)
Writes pending_admin without overwriting the current admin.
The new admin must call accept_admin() to complete the transfer.
fn propose_admin(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
) -> Result<(), PositionError>
fn remove_adapter(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::Symbol,
) -> Result<(), PositionError>
Remove a position by index. Admin only. Uses swap-with-last.
fn remove_position(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
index: u32,
) -> Result<(), PositionError>
Get all registered adapter protocol IDs.
fn get_all_adapters(env: soroban_sdk::Env) -> soroban_sdk::Vec
Register an adapter for a protocol. Admin only.
fn register_adapter(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::Symbol,
adapter: soroban_sdk::Address,
) -> Result<(), PositionError>
Register a position for an account. Admin only.
position_id is protocol-specific (e.g., pool address for Blend).
fn register_position(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
protocol_id: soroban_sdk::Symbol,
position_id: soroban_sdk::Symbol,
) -> Result
Get the number of positions for an account.
fn get_position_count(env: soroban_sdk::Env, account: soroban_sdk::Address) -> u32
Compute NAV for a single specific adapter, identified by protocol_id.
This is the budget-safe alternative to compute_nav() when an adapter contains
many pools. Instead of looping all adapters in one transaction, call this function
once per adapter — each call stays within the CPU budget.
Returns the same NAVResult structure as compute_nav() but scoped to only the
specified adapter's positions.
Errors:
fn compute_nav_adapter(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
protocol_id: soroban_sdk::Symbol,
) -> Result
Get oracle registry address.
fn get_oracle_registry(
env: soroban_sdk::Env,
) -> Result
Set oracle registry. Admin only.
fn set_oracle_registry(
env: soroban_sdk::Env,
oracle_registry: soroban_sdk::Address,
) -> Result<(), PositionError>
Set accounting token. Admin only.
fn set_accounting_token(
env: soroban_sdk::Env,
token: soroban_sdk::Address,
) -> Result<(), PositionError>
Batch-register multiple token positions for DirectHoldings.
fn register_tokens_batch(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
protocol_id: soroban_sdk::Symbol,
position_ids: soroban_sdk::Vec,
) -> Result
fn execute_adapter_update(env: soroban_sdk::Env) -> Result<(), PositionError>
fn propose_adapter_update(
env: soroban_sdk::Env,
protocol_id: soroban_sdk::Symbol,
new_addr: soroban_sdk::Address,
) -> Result<(), PositionError>