Increase the fee rate limit and log fee growth within the swap instruction (#104)

* Increase the fee rate limit and log fee growth within the swap instruction

* PR feedback

* log reward_growth

* remove .only

* only perform 1 log

* Revert "only perform 1 log"

This reverts commit 2ab6c5b6d2c3a29632d2285f6145231349720429.

* Revert "remove .only"

This reverts commit a39f15f6e55996155d00c26817966b22e6b26e95.

* Revert "log reward_growth"

This reverts commit f54e2060dde17c0ebb5cf5c30806c613088db165.

---------

Co-authored-by: Otto Cheung <otto@orca.so>
This commit is contained in:
Yutaro Mori 2023-08-22 20:35:13 -04:00 committed by GitHub
parent 7f7ee90b25
commit a574ae5922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,5 @@
use solana_program::msg;
use crate::{
errors::ErrorCode,
manager::{
@ -186,6 +188,15 @@ pub fn swap(
(amount_calculated, amount - amount_remaining)
};
let fee_growth = if a_to_b {
curr_fee_growth_global_input - whirlpool.fee_growth_global_a
} else {
curr_fee_growth_global_input - whirlpool.fee_growth_global_b
};
// Log delta in fee growth to track pool usage over time with off-chain analytics
msg!("fee_growth: {}", fee_growth);
Ok(PostSwapUpdate {
amount_a,
amount_b,

View File

@ -8,8 +8,8 @@ use super::{
// Fee rate is represented as hundredths of a basis point.
// Fee amount = total_amount * fee_rate / 1_000_000.
// Max fee rate supported is 1%.
pub const MAX_FEE_RATE: u16 = 10_000;
// Max fee rate supported is 3%.
pub const MAX_FEE_RATE: u16 = 30_000;
// Assuming that FEE_RATE is represented as hundredths of a basis point
// We want FEE_RATE_MUL_VALUE = 1/FEE_RATE_UNIT, so 1e6