Skip to content
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

calculate fair price for lp token #1140

Merged
merged 2 commits into from Jun 29, 2021
Merged

calculate fair price for lp token #1140

merged 2 commits into from Jun 29, 2021

Conversation

wangjj9219
Copy link
Member

@wangjj9219 wangjj9219 commented Jun 28, 2021

according to https://blog.alphafinance.io/fair-lp-token-pricing/ , the fair price is determined by the external feed price(both token_0 and token_1) and the invariant(pool_0 * pool_1) of the liquidity pool to prevent the manipulatable attack .

@wangjj9219 wangjj9219 marked this pull request as ready for review June 28, 2021 12:06
@@ -219,3 +217,40 @@ impl<T: Config> PriceProvider<CurrencyId> for Pallet<T> {
<Pallet<T>>::deposit_event(Event::UnlockPrice(currency_id));
}
}

/// https://en.wikipedia.org/wiki/Integer_square_root
fn integer_sqrt(n: U256) -> U256 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add TODO to use paritytech/parity-common#554 once it is available

@wangjj9219
Copy link
Member Author

@qwer951123 @RomeroYang @StrawberryFlavor need to update sdk and front end

@wangjj9219 wangjj9219 merged commit a0690e0 into master Jun 29, 2021
@wangjj9219 wangjj9219 deleted the use-fair-price-for-lp branch June 29, 2021 01:57
syan095 pushed a commit that referenced this pull request Jun 29, 2021
* origin/master:
  Improve collator selection (#1139)
  calculate fair price for lp token (#1140)
  Update to use to relay chain block number (#1141)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants