Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Requesting web app source or peer review of cross-project pool swap calculations #2

@grctest

Description

@grctest

Hey,

I've come across your XBTS app UX, the pool portal is excellent!

I'm primarily interested in the code regarding swapping pool assets, if you could share the code for the app I'd greatly appreciate it!

In the mean time though, can you comment on the calculations used for pool swaps?

I've replicated the reference web wallet pool swap calculations in the astro UI: https://github.com/BTS-CM/astro-ui/blob/842a0450a8940a708278795189e486aa0dab82ac/src/components/PoolForm.jsx#L433

So now the astro UI & the reference wallet output the same amount, for example:
BTWTY.BTSEOSLP
1000 EOS -> 137299.30838 BTS
1000 BTS -> 5.1891 EOS

But the xbts pool swap calculations come out to:
1000 EOS -> min 96326.75762 BTS , price 138.12808 (1000 * price = 138128.08 BTS)
1000 BTS -> min 5.0746 EOS, price 0.0052 (1000 * price = 5.2 EOS)

So I can get how you calculate the price:

((eos balance + swapped eos) / pre swap bts) => (2576.1895 + 1000)/493972.17812 = 138.1280769 (same as yours)

and

((bts balance + sapped bts) / pre swap eos) => 1 / ((493972.17812 + 100000) / 2576.1895) = 0.0043 (same as yours)

So perhaps you've got a more accurate price calculation than astro and the ref ui?

But how are you then getting the min price? I'd greatly appreciate open sourcing of this chunk of code & any peer review of the astro code & ref wallet code, if your xbts app pool swap calculations are more accurate?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions