Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
386 changes: 342 additions & 44 deletions packages/deepbook/sources/pool.move

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions packages/deepbook/sources/state/state.move
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,20 @@ public(package) fun history(self: &State): &History {
&self.history
}

/// Credit settled balances to an account by balance_manager_id.
/// Used to refund maker referral fees when orders expire during matching
/// (maker's BalanceManager is unavailable at that point).
public(package) fun credit_account_settled_balances(
self: &mut State,
balance_manager_id: ID,
balances: Balances,
ctx: &TxContext,
) {
self.update_account(balance_manager_id, ctx);
let account = &mut self.accounts[balance_manager_id];
account.add_settled_balances(balances);
}

// === Private Functions ===
/// Process fills for all makers. Update maker accounts and history.
fun process_fills(self: &mut State, fills: &mut vector<Fill>, ctx: &TxContext) {
Expand Down
21 changes: 21 additions & 0 deletions packages/deepbook/sources/vault/vault.move
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,27 @@ public(package) fun withdraw_deep_to_burn<BaseAsset, QuoteAsset>(
self.deep_balance.split(amount_to_burn)
}

public(package) fun withdraw_referral_fee_base<BaseAsset, QuoteAsset>(
self: &mut Vault<BaseAsset, QuoteAsset>,
amount: u64,
): Balance<BaseAsset> {
self.base_balance.split(amount)
}

public(package) fun withdraw_referral_fee_quote<BaseAsset, QuoteAsset>(
self: &mut Vault<BaseAsset, QuoteAsset>,
amount: u64,
): Balance<QuoteAsset> {
self.quote_balance.split(amount)
}

public(package) fun withdraw_referral_fee_deep<BaseAsset, QuoteAsset>(
self: &mut Vault<BaseAsset, QuoteAsset>,
amount: u64,
): Balance<DEEP> {
self.deep_balance.split(amount)
}

public(package) fun borrow_flashloan_base<BaseAsset, QuoteAsset>(
self: &mut Vault<BaseAsset, QuoteAsset>,
pool_id: ID,
Expand Down
Loading
Loading