0x0::balances
Balances
represents the three assets make up a pool: base, quote, and deep.
Whenever funds are moved, they are moved in the form of Balances
.
Balances
empty
new
reset
add_balances
add_base
add_quote
add_deep
base
quote
deep
Balances
struct Balances has copy, drop, store
empty
public(friend) fun empty(): balances::Balances
new
public(friend) fun new(base: u64, quote: u64, deep: u64): balances::Balances
public(package) fun new(base: u64, quote: u64, deep: u64): Balances {
Balances { base: base, quote: quote, deep: deep }
}
reset
public(friend) fun reset(balances: &mut balances::Balances): balances::Balances
public(package) fun reset(balances: &mut Balances): Balances {
let old = *balances;
balances.base = 0;
balances.quote = 0;
balances.deep = 0;
old
}
add_balances
public(friend) fun add_balances(balances: &mut balances::Balances, other: balances::Balances)
public(package) fun add_balances(balances: &mut Balances, other: Balances) {
balances.base = balances.base + other.base;
balances.quote = balances.quote + other.quote;
balances.deep = balances.deep + other.deep;
}
add_base
public(friend) fun add_base(balances: &mut balances::Balances, base: u64)
public(package) fun add_base(balances: &mut Balances, base: u64) {
balances.base = balances.base + base;
}
add_quote
public(friend) fun add_quote(balances: &mut balances::Balances, quote: u64)
public(package) fun add_quote(balances: &mut Balances, quote: u64) {
balances.quote = balances.quote + quote;
}
add_deep
public(friend) fun add_deep(balances: &mut balances::Balances, deep: u64)
public(package) fun add_deep(balances: &mut Balances, deep: u64) {
balances.deep = balances.deep + deep;
}
base
public(friend) fun base(balances: &balances::Balances): u64
quote
public(friend) fun quote(balances: &balances::Balances): u64
deep
public(friend) fun deep(balances: &balances::Balances): u64