Satay Module

Overview

The satay::satay module acts as the entry point for users to interact with vaults. The satay module is a friend module of satay::vault, and thus can access its mutating functions.

The ManagerAccount struct holds a manager's VaultInfo structs in a table keyed by vault_id, and controls the vault_id of the next vault.

struct ManagerAccount has key {    
    next_vault_id: u64,    
    vaults: Table<u64, VaultInfo>
}

The VaultInfo struct holds a vault's VaultCapability, providing access to mutating functions. The field is an Option such that the VaultCapability can be lent to strategies for operations.

struct VaultInfo has store {    
    // VaultCapability of the vault    
    // `Option` here is required to allow lending the capability object to strategies    
    vault_cap: Option<VaultCapability>
}

Manager Functions

initialize creates a new ManagerAccount for the signer. Access is restricted to only the Satay DAO address.

public entry fun initialize(
    manager: &signer
)

new_vault creates a new Vault for BaseCoin under the signer's ManagerAccount. Initializes management_fee and performance_fee.

public entry fun new_vault<BaseCoin>(
    manager: &signer, 
    seed: vector<u8>,
    management_fee: u64,
    performance_fee: u64
)

update_vault_fee sets vault.management_fee and vault.performance_fee for the vault referenced by (manager, vault_id).

public entry fun update_vault_fee(    
    manager: &signer,    
    vault_id: u64,    
    management_fee: u64,    
    performance_fee: u64
)

User Functions

deposit allows user to deposit amount of BaseCoin into the Vault referenced by the (manager_addr, vault_id) pair.

public entry fun deposit<BaseCoin>(
    user: &signer,
    manager_addr: address,
    vault_id: u64,
    amount: u64
)

withdraw allows user to withdraw amount of BaseCoin into the Vault referenced by the (manager_addr, vault_id) pair.

public entry fun withdraw<BaseCoin>(
    user: &signer,
    manager_addr: address,
    vault_id: u64,
    amount: u64
)

Strategy Functions

approve_strategy creates a VaultStrategy<StrategyType> resource on to operate on the Vault referenced by the (manager, vault_id) pair. debt_ratio indicates the percentage of BaseCoin the StrategyType can allocate at any given time.

public fun approve_strategy<StrategyType: drop>(    
    manager: &signer,    
    vault_id: u64,    
    position_coin_type: TypeInfo,    
    debt_ratio: u64
)

Returns the VaultCapability and VaultCapLock for StrategyType to perform operations on the Vault referenced by the (manager_addr, vault_id) pair. _witness guarantees that the caller is the module that defines StrategyType. VaultStrategy<StrategyType> must exist in the vault. Paired with a subsequent unlock_vault.

public fun lock_vault<StrategyType: drop>(    
    manager_addr: address,    
    vault_id: u64,    
    _witness: StrategyType
): (VaultCapability, VaultCapLock)

Unlocks the Vault referenced by the (manager_addr, vault_id) pair. Must be preceded by a call to lock_vault.

public fun unlock_vault<StrategyType: drop>(    
    manager_addr: address,    
    vault_capability: VaultCapability,    
    stop_handle: VaultCapLock
)

update_strategy_debt_ratio updates the the strategy.debt_ratio value of VaultStrategy<StrategyType> for the Vault referenced by (manager_addr, vault_id) .

public fun update_strategy_debt_ratio<StrategyType: drop>(    
    manager: &signer,    
    vault_id: u64,    
    debt_ratio: u64
): u64

update_strategy_max_report updates the the strategy.max_report_delay value of VaultStrategy<StrategyType> for the Vault referenced by (manager_addr, vault_id) .

public fun update_strategy_max_report_delay<StrategyType: drop>(    
    manager: &signer,    
    vault_id: u64,    
    max_report_delay: u64
)

update_strategy_credit_threshold updates the the strategy.credit_threshold value of VaultStrategy<StrategyType> for the Vault referenced by (manager_addr, vault_id) .

public fun update_strategy_credit_threshold<StrategyType: drop>(    
    manager: &signer,    
    vault_id: u64,    
    credit_threshold: u64
)

set_strategy_force_harvest_trigger_once sets the strategy.force_harvest_once to true on VaultStrategy<StrategyType> for the Vault referenced by (manager_addr, vault_id) .

public fun set_strategy_force_harvest_trigger_once<StrategyType: drop>(    
    manager: &signer,    
    vault_id: u64
)

Last updated