Created
April 15, 2021 11:54
-
-
Save Taump/5469882f260bc60c62dbcbbe4cbc5dc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const my_share = inputRedeem * 10 ** reserve_asset_decimals / fund_state.shares_supply; | |
const reserve_amount = Math.floor(my_share * fund_balance?.[reserve_asset]); | |
const t1_amount = Math.floor(my_share * p1Balance); | |
const exchange = t1_amount && $get_exchange_result(obj); | |
const you_get_in_full_units = (reserve_amount - exchange.reserve_needed - (reserve_asset === "base" ? 4000 : 0)); | |
const you_get = you_get_in_full_units / 10 ** reserve_asset_decimals; | |
const fee_percent = (exchange.fee / you_get_in_full_units) * 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment