-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/PRO-1038/pool-fee-rpc #4459
Changes from 12 commits
6fe6506
c3d5d82
c5dff7c
12bac95
61d9700
9e74b9c
7eeb324
2568183
4229b52
7c3c4ff
470a52d
3864f7e
a4a1a29
c46986d
d18d671
2ed5470
8c63160
10c25c6
ccc1415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
source: state-chain/custom-rpc/src/lib.rs | ||
assertion_line: 1591 | ||
expression: "serde_json::to_value(env).unwrap()" | ||
--- | ||
{"funding":{"minimum_funding_amount":0,"redemption_tax":0},"ingress_egress":{"egress_dust_limits":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":"0x7ffffffffffffffe"}},"egress_fees":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":null},"Polkadot":{"DOT":"0x7ffffffffffffffe"}},"ingress_fees":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":null},"Polkadot":{"DOT":"0x7ffffffffffffffe"}},"minimum_deposit_amounts":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffff","USDC":"0x7ffffffffffffffe"}},"witness_safety_margins":{"Bitcoin":3,"Ethereum":3,"Polkadot":null}},"pools":{"fees":{"Ethereum":{"FLIP":{"limit_order_fee_hundredth_pips":0,"quote_asset":{"asset":"USDC","chain":"Ethereum"},"range_order_fee_hundredth_pips":100}}}},"swapping":{"maximum_swap_amounts":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":null,"USDC":"0x7ffffffffffffffe"}},"network_fee_hundredth_pips":1000000}} | ||
{"funding":{"minimum_funding_amount":0,"redemption_tax":0},"ingress_egress":{"egress_dust_limits":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":"0x7ffffffffffffffe"}},"egress_fees":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":null},"Polkadot":{"DOT":"0x7ffffffffffffffe"}},"ingress_fees":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffffffffffffffffffff","USDC":null},"Polkadot":{"DOT":"0x7ffffffffffffffe"}},"minimum_deposit_amounts":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":"0xffffffffffffffff","USDC":"0x7ffffffffffffffe"}},"witness_safety_margins":{"Bitcoin":3,"Ethereum":3,"Polkadot":null}},"pools":{"fees":{"Ethereum":{"FLIP":{"limit_order_fee_hundredth_pips":0,"limit_order_total_fees_earned":{"one":"0x0","zero":"0x0"},"limit_total_swap_inputs":{"one":"0x0","zero":"0x0"},"quote_asset":{"asset":"USDC","chain":"Ethereum"},"range_order_fee_hundredth_pips":100,"range_order_total_fees_earned":{"one":"0x0","zero":"0x0"},"range_total_swap_inputs":{"one":"0x0","zero":"0x0"}}}}},"swapping":{"maximum_swap_amounts":{"Bitcoin":{"BTC":0},"Ethereum":{"ETH":0,"FLIP":null,"USDC":"0x7ffffffffffffffe"}},"network_fee_hundredth_pips":1000000}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
source: state-chain/custom-rpc/src/lib.rs | ||
assertion_line: 1457 | ||
expression: "serde_json::to_value(lp).unwrap()" | ||
--- | ||
{"balances":{"Bitcoin":{"BTC":"0x0"},"Ethereum":{"ETH":"0xffffffffffffffffffffffffffffffff","FLIP":"0x7fffffffffffffffffffffffffffffff"}},"flip_balance":"0x0","refund_addresses":{"Bitcoin":null,"Ethereum":"0x0101010101010101010101010101010101010101","Polkadot":"111111111111111111111111111111111HC1"},"role":"liquidity_provider"} | ||
{"balances":{"Bitcoin":{"BTC":"0x0"},"Ethereum":{"ETH":"0xffffffffffffffffffffffffffffffff","FLIP":"0x7fffffffffffffffffffffffffffffff"}},"earned_fees":{"Bitcoin":[{"amount":1000000,"asset":"BTC","chain":"Bitcoin"}]},"flip_balance":"0x0","refund_addresses":{"Bitcoin":null,"Ethereum":"0x0101010101010101010101010101010101010101","Polkadot":"111111111111111111111111111111111HC1"},"role":"liquidity_provider"} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1164,6 +1164,14 @@ pub struct PoolInfo { | |
/// The fee taken, when range orders are used, from swap inputs that contributes to liquidity | ||
/// provider earnings | ||
pub range_order_fee_hundredth_pips: u32, | ||
/// The total fees earned in this pool by range orders. | ||
pub range_order_total_fees_earned: SideMap<Amount>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about the return value here. Maybe something scalar would make more sense? Same for all the over new added fields. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we can use SideMap as you have here, and in the other PR of yours we will change it to PairMap (or whatever we call it). |
||
/// The total fees earned in this pool by limit orders. | ||
pub limit_order_total_fees_earned: SideMap<Amount>, | ||
/// The total amount of assets that have been bought by range orders in this pool. | ||
pub range_total_swap_inputs: SideMap<Amount>, | ||
/// The total amount of assets that have been bought by limit orders in this pool. | ||
pub limit_total_swap_inputs: SideMap<Amount>, | ||
} | ||
|
||
#[derive(Clone, Debug, Encode, Decode, TypeInfo, PartialEq, Eq, Serialize, Deserialize)] | ||
|
@@ -1520,6 +1528,7 @@ impl<T: Config> Pallet<T> { | |
.try_map(|(asset, collected_fees)| { | ||
AssetAmount::try_from(collected_fees).map_err(Into::into).and_then( | ||
|collected_fees| { | ||
T::LpBalance::record_fees(lp, collected_fees, asset); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlastairHolmes that's the place where I have to add record the fees for range orders, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry not sure how I could have missed that |
||
T::LpBalance::try_credit_account(lp, asset, collected_fees) | ||
.map(|()| collected_fees) | ||
}, | ||
|
@@ -1804,6 +1813,10 @@ impl<T: Config> Pallet<T> { | |
Ok(PoolInfo { | ||
limit_order_fee_hundredth_pips: pool.pool_state.limit_order_fee(), | ||
range_order_fee_hundredth_pips: pool.pool_state.range_order_fee(), | ||
range_order_total_fees_earned: pool.pool_state.range_order_total_fees_earned(), | ||
limit_order_total_fees_earned: pool.pool_state.limit_order_total_fees_earned(), | ||
range_total_swap_inputs: pool.pool_state.range_order_swap_inputs(), | ||
limit_total_swap_inputs: pool.pool_state.limit_order_swap_inputs(), | ||
}) | ||
} | ||
|
||
|
@@ -1953,11 +1966,9 @@ impl<T: Config> Pallet<T> { | |
amount_change: IncreaseOrDecrease<AssetAmount>, | ||
) -> DispatchResult { | ||
let collected_fees: AssetAmount = collected.fees.try_into()?; | ||
T::LpBalance::try_credit_account( | ||
lp, | ||
asset_pair.assets()[(!order.to_sold_side()).into()], | ||
collected_fees, | ||
)?; | ||
let asset = asset_pair.assets()[(!order.to_sold_side()).into()]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to add the recording of fees into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I do this. |
||
T::LpBalance::record_fees(lp, collected_fees, asset); | ||
T::LpBalance::try_credit_account(lp, asset, collected_fees)?; | ||
|
||
let bought_amount: AssetAmount = collected.bought_amount.try_into()?; | ||
T::LpBalance::try_credit_account( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ pub struct AuctionState { | |
pub struct LiquidityProviderInfo { | ||
pub refund_addresses: Vec<(ForeignChain, Option<ForeignChainAddress>)>, | ||
pub balances: Vec<(Asset, AssetAmount)>, | ||
pub earned_fees: BTreeMap<ForeignChain, Vec<(Asset, AssetAmount)>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the new any::AssetMap? |
||
} | ||
|
||
#[derive(Debug, Decode, Encode, TypeInfo)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we could use the AssetMap here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And use a StorageMap instead.