Satay Finance
  • Overview
    • Introduction
  • Our Three Pillars
    • Blocks
    • Strategies
    • Vaults
  • Technical Overview
    • Protocol Module
    • Wrapper Module (Legacy)
    • Asset Module
    • Vault Module
    • Base Strategy Module
    • Satay Module
  • Blocks
    • Echelon Block
    • Layerbank Block
    • MovePosition Block
  • Strategy Implementations
    • Leveraged Liquid Staking
    • Liquid Staking + LP Farming
    • Borrow Optimization
    • Echelon Simple
    • Layerbank Simple
    • MovePosition Simple
    • MovePosition Ticket
Powered by GitBook
On this page
  • Overview
  • Terminology
  • Packet
  • Strategy Module
  • Structs
  • MovePositionStrategy
  • Witness
  • Events
  • Error Codes
  • Public Functions
  • Internal Functions
  1. Strategy Implementations

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:

PreviousLayerbank SimpleNextMovePosition Ticket

Last updated 3 months ago

deposit_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, packet: vector<u8>, amount: u64): Deposits the strategy's base asset (Coin) directly into the strategy, using the internal function. Requires a .

vault_deposit_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, packet: vector<u8>, amount: u64): Deposits the strategy's base asset (Coin) from the vault into the strategy, using the internal function. Requires a .

withdraw_coin<CoinType>(account: &signer, strategy: Object<BaseStrategy>, packet: vector<u8>, amount: u64, max_loss: Option<u64>): Withdraws the strategy's base asset (Coin) directly from the strategy. Uses internal functions to withdraw strategy shares from signer's primary fungible stores and to redeem the strategy shares for the strategy's base asset (Coin). Requires a .

vault_withdraw_coin<CoinType>(account: &signer, request: &mut WithdrawalRequest, strategy: Object<BaseStrategy>, packet: vector<u8>, amount: u64, max_loss: Option<u64>): Coin<CoinType>: Withdraws the strategy's base asset (Coin) from a vault's strategy. Must be called with the vault's signer (typically via router). Uses vault's function in the satay::vault module to withdraw strategy shares from vault's primary fungible stores. Then uses to redeem the strategy shares for the strategy's base asset (Coin). Requires a .

vault_report<CoinType>(account: &signer, strategy: Object<BaseStrategy>): Reports strategy performance to the vault by calling the function in the satay::vault module.

market_withdraw_internal<CoinType>(strategy_ref: &MovePositionStrategy, packet: vector<u8>, amount: u64): Coin<CoinType>: Internal function for withdrawing Coin from market. Validates a packet using the internal function, then calls the function in moveposition_block::moveposition_block to redeem the shares for Coin.

market_deposit_internal<CoinType>(strategy: &MovePositionStrategy, packet: vector<u8>, coin: Coin<CoinType>): Internal function for depositing coins to market. Validates a packet using the internal function. First deposits the Coin to the strategy signer, , then calls the function in moveposition_block::moveposition_block to deposit the Coin into the market.

validate_ticket<CoinType>(packet: vector<u8>, amount: u64, operation: String): Helper function to validate a ticket for market operations. Takes in a which is validated against the CoinType, amount and operation.

process_withdrawal_internal<CoinType>(strategy: Object<BaseStrategy>, packet: vector<u8>, shares_asset: FungibleAsset, max_loss: Option<u64>): Coin<CoinType>: Internal function for processing withdrawals. Creates a withdrawal request with the provided shares and attempts base strategy withdrawal using the function in satay::base_strategy. If funds remain to be withdrawn, calculates needed amount and available collateral, then withdraws from market using . Finally completes the withdrawal with specified loss tolerance using the function in satay::base_strategy and returns the withdrawn Coin.

collateral_value=amount×collateral_balancetotal_shares\text{collateral\_value} = \frac{\text{amount} \times \text{collateral\_balance}}{\text{total\_shares}}collateral_value=total_sharesamount×collateral_balance​
deposit_internal
packet
deposit_internal
packet
prepare_withdrawal_internal
process_withdrawal_internal
packet
packet
process_withdrawal_internal
packet
validate_ticket
validate_ticket
market_withdraw_internal
withdraw
complete_withdrawal_coin
withdraw_strategy_shares
report
redeem
lend