Skip to content

Instantly share code, notes, and snippets.

@Taump
Created April 15, 2021 11:54
Show Gist options
  • Save Taump/5469882f260bc60c62dbcbbe4cbc5dc1 to your computer and use it in GitHub Desktop.
Save Taump/5469882f260bc60c62dbcbbe4cbc5dc1 to your computer and use it in GitHub Desktop.
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