Module 0xdee9::custodian_v2
- Struct
Account
- Resource
AccountCap
- Resource
Custodian
- Constants
- Function
mint_account_cap
- Function
create_child_account_cap
- Function
delete_account_cap
- Function
account_owner
- Function
account_balance
- Function
new
- Function
withdraw_asset
- Function
increase_user_available_balance
- Function
decrease_user_available_balance
- Function
increase_user_locked_balance
- Function
decrease_user_locked_balance
- Function
lock_balance
- Function
unlock_balance
- Function
account_available_balance
- Function
account_locked_balance
- Function
borrow_mut_account_balance
use 0x2::balance;
use 0x2::coin;
use 0x2::object;
use 0x2::table;
use 0x2::tx_context;
Struct Account
struct Account<T> has store
Fields
Resource AccountCap
Capability granting permission to access an entry in Custodian.account_balances. Calling mint_account_cap creates an "admin account cap" such that id == owner with the permission to both access funds and create new AccountCaps. Calling create_child_account_cap creates a "child account cap" such that id != owner that can access funds, but cannot create new AccountCaps.
struct AccountCap has store, key
Fields
Resource Custodian
struct Custodian<T> has store, key
Fields
Constants
const EAdminAccountCapRequired: u64 = 2;
Function mint_account_cap
Create an admin AccountCap that can be used across all DeepBook pools, and has the permission to create new AccountCaps that can access the same source of funds
public(friend) fun mint_account_cap(ctx: &mut tx_context::TxContext): custodian_v2::AccountCap
Implementation
Function create_child_account_cap
Create a "child account cap" such that id != owner that can access funds, but cannot create new AccountCaps.
public fun create_child_account_cap(admin_account_cap: &custodian_v2::AccountCap, ctx: &mut tx_context::TxContext): custodian_v2::AccountCap
Implementation
Function delete_account_cap
Destroy the given account_cap object
public fun delete_account_cap(account_cap: custodian_v2::AccountCap)
Implementation
Function account_owner
Return the owner of an AccountCap
public fun account_owner(account_cap: &custodian_v2::AccountCap): address
Implementation
Function account_balance
public(friend) fun account_balance<Asset>(custodian: &custodian_v2::Custodian<Asset>, owner: address): (u64, u64)
Implementation
Function new
public(friend) fun new<T>(ctx: &mut tx_context::TxContext): custodian_v2::Custodian<T>
Implementation
Function withdraw_asset
public(friend) fun withdraw_asset<Asset>(custodian: &mut custodian_v2::Custodian<Asset>, quantity: u64, account_cap: &custodian_v2::AccountCap, ctx: &mut tx_context::TxContext): coin::Coin<Asset>
Implementation
Function increase_user_available_balance
public(friend) fun increase_user_available_balance<T>(custodian: &mut custodian_v2::Custodian<T>, owner: address, quantity: balance::Balance<T>)
Implementation
Function decrease_user_available_balance
public(friend) fun decrease_user_available_balance<T>(custodian: &mut custodian_v2::Custodian<T>, account_cap: &custodian_v2::AccountCap, quantity: u64): balance::Balance<T>
Implementation
Function increase_user_locked_balance
public(friend) fun increase_user_locked_balance<T>(custodian: &mut custodian_v2::Custodian<T>, account_cap: &custodian_v2::AccountCap, quantity: balance::Balance<T>)
Implementation
Function decrease_user_locked_balance
public(friend) fun decrease_user_locked_balance<T>(custodian: &mut custodian_v2::Custodian<T>, owner: address, quantity: u64): balance::Balance<T>
Implementation
Function lock_balance
Move quantity from the unlocked balance of user to the locked balance of user
public(friend) fun lock_balance<T>(custodian: &mut custodian_v2::Custodian<T>, account_cap: &custodian_v2::AccountCap, quantity: u64)
Implementation
Function unlock_balance
Move quantity from the locked balance of user to the unlocked balance of user
public(friend) fun unlock_balance<T>(custodian: &mut custodian_v2::Custodian<T>, owner: address, quantity: u64)
Implementation
Function account_available_balance
public(friend) fun account_available_balance<T>(custodian: &custodian_v2::Custodian<T>, owner: address): u64
Implementation
Function account_locked_balance
public(friend) fun account_locked_balance<T>(custodian: &custodian_v2::Custodian<T>, owner: address): u64
Implementation
Function borrow_mut_account_balance
fun borrow_mut_account_balance<T>(custodian: &mut custodian_v2::Custodian<T>, owner: address): &mut custodian_v2::Account<T>