MovePosition Simple

Overview

The moveposition_simple::strategy module implements a lending strategy for the MovePosition protocol. It manages lending positions using packets (serialized tickets) for position validation and state management.

Terminology

Packet

A signed binary packet containing a serialized ticket that authorizes the deposit. The packet is verified using Hocket and must contain valid ticket data

Strategy Module

Structs

MovePositionStrategy

Core strategy struct storing vault and authorization references.

struct MovePositionStrategy has key {
    vault: Object<Vault>, // used to deposit/withdraw funds to/from 
    auth_ref: AuthRef     // used to retrieve strategy signer for depositing assets
}

Witness

Internal witness type for strategy creation.

struct Witness has drop {}

Events

  • StrategyCreated: Event emitted when a new strategy is created.

Error Codes

  • EINVALID_AMOUNT: Invalid amount specified

  • EINSUFFICIENT_BALANCE: Insufficient balance to perform the operation

  • EVAULT_MISMATCH: Invalid vault specified

  • EWITHDRAWAL_ACCOUNT_MISMATCH: Invalid withdrawal account specified

  • ECANNOT_EXCEED_DEBT: Cannot exceed the strategy debt

Public Functions

  • create<CoinType>(account: &signer, vault: Object<Vault>, debt_limit: u64): Creates a new instance of the strategy for the specified vault. Only callable by governance account.

  • tend_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, packet: vector<u8>): Deposits idle coins into the MovePosition market.

Internal Functions

  • borrow_strategy(strategy: Object<BaseStrategy>): &MovePositionStrategy: Returns a reference to the strategy data.

  • deposit_internal<CoinType>(strategy: &MovePositionStrategy, packet: vector<u8>, coin: Coin<CoinType>): FungibleAsset: Internal function for Coin deposits.

  • prepare_withdrawal_internal(account: &signer, strategy: Object<BaseStrategy>, amount: u64): FungibleAsset: Internal function for preparing withdrawals. Withdraws and returns strategy shares from the signers account.

  • get_collateral_for_shares<CoinType>(strategy_ref: &MovePositionStrategy, amount: u64): u64: Calculates collateral value for given amount of shares. Retrieves the collateral balance and total shares to calculate the collateral value for a given amount using the function below:

collateral_value=amount×collateral_balancetotal_shares\text{collateral\_value} = \frac{\text{amount} \times \text{collateral\_balance}}{\text{total\_shares}}

Last updated