igneous-labs / stake-pool-sdk

Socean Stake Pool Typescript SDK
stake-pool-sdk.vercel.app
MIT License
7 stars 3 forks source link

FEAT: calc* inverse methods #81

Closed sayantank closed 2 years ago

sayantank commented 2 years ago

closed #78

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
stake-pool-sdk ✅ Ready (Inspect) Visit Preview Apr 22, 2022 at 5:41AM (UTC)
sayantank commented 2 years ago

i think we might need to add one more step to the test, which is to call calcDeposit() / calcWithdrawal() on the lamportsStaked/totalDropletsToUnstake results returned by the inverse functions in order to make sure that the results >= the input dropletsToReceive/lamportsToReceive. Otherwise a user could get shortchanged and receive 1 or 2 fewer droplets/lamports than what was desired.

Here, we know that lamportsStaked returned by the inverse function will be lesser than the depositAmountLamports, so when we do calcDeposit with lamportsStaked we wouldn't get >= dropletsReceived right?

billythedummy commented 2 years ago

Here, we know that lamportsStaked returned by the inverse function will be lesser than the depositAmountLamports, so when we do calcDeposit with lamportsStaked we wouldn't get >= dropletsReceived right?

Yeah, actually nvm then, we probably dont need the additional checks