Echelon Simple
Overview
The echelon_simple::strategy
module implements a simple lending strategy for the Echelon protocol. It allows deposits and withdrawals of both Coin
and FungibleAsset
types, and manages lending positions in Echelon markets.
Strategy Module
Structs
Witness
Internal witness type for strategy creation.
EchelonStrategy
Core strategy struct storing vault and market references.
Events
StrategyCreated: Event emitted when a new strategy is created.
Error Codes
ENOT_AUTHORIZED
: Not authorized to perform the operationEINVALID_AMOUNT
: Invalid amount specifiedEINSUFFICIENT_BALANCE
: Insufficient balance to perform the operationEINVALID_ASSET_METADATA
: Invalid asset metadataEUNSUPPORTED_ASSET_TYPE
: Unsupported asset typeEINVALID_ASSET_TYPE
: Invalid asset typeEVAULT_MISMATCH
: Invalid vault specifiedEWITHDRAWAL_ACCOUNT_MISMATCH
: Invalid withdrawal account specifiedECANNOT_EXCEED_DEBT
: Cannot exceed the strategy debt
Public Functions
Strategy Creation and Management
create(account: &signer, vault: Object<Vault>, market: Object<Market>, debt_limit: u64)
: Creates a new instance of the strategy for the specified vault. Only callable by governance account.
Direct Deposit Functions
deposit_fa(account: &signer, strategy: Object<BaseStrategy>, amount: u64)
: Withdraws the strategy's base asset (FungibleAsset) from signer's primary store and deposits this directly into the strategy. The minted strategy shares are deposited into the signer's primary fungible store.deposit_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, amount: u64)
: Withdraws the strategy's base asset (Coin) from signer's primary store and deposits this directly into the strategy. The minted strategy shares are deposited into the signer's primary fungible store.
Vault Deposit Functions
vault_deposit_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, amount: u64)
: Deposits the strategy's base asset (Coin) from the vault into the strategy. Must be called with the vault's signer (typically via router). The minted strategy shares are deposited into the vault's primary fungible store.vault_deposit_fa(account: &signer, strategy: Object<BaseStrategy>, amount: u64)
: Deposits the strategy's base asset (FungibleAsset) from the vault into the strategy. Must be called with the vault's signer (typically via router). The minted strategy shares are deposited into the vault's primary fungible store.
Direct Withdrawal Functions
withdraw_fa(account: &signer, strategy: Object<BaseStrategy>, amount: u64, max_loss: Option<u64>)
: Withdraws the strategy's base asset (FungibleAsset) directly from the strategy by redeeming the specified amount of strategy shares from the signer's primary fungible store.withdraw_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, amount: u64, max_loss: Option<u64>)
: Withdraws the strategy's base asset (Coin) directly from the strategy by redeeming the specified amount of strategy shares from the signer's primary fungible store.
Vault Withdrawal Functions
Strategy Operations
tend_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>)
: Tends the strategy's position by depositing idle Coin into the market.tend_fa(account: &signer, strategy: Object<BaseStrategy>)
: Tends the strategy's position by depositing idle FungibleAsset into the market.
Getters
get_market(strategy: Object<BaseStrategy>): Object<Market>
: Returns the market associated with the strategy.
Internal Functions
borrow_strategy(strategy: Object<BaseStrategy>): &EchelonStrategy
: Returns a reference to the strategy data.deposit_coin_internal<CoinType>(strategy: &EchelonStrategy, coin: Coin<CoinType>): FungibleAsset
: Internal function for Coin deposits. Mints and returns strategy shares.deposit_fa_internal(strategy: &EchelonStrategy, asset: FungibleAsset): FungibleAsset
: Internal function for FungibleAsset deposits. Mints and returns strategy shares.
Last updated