Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7939

Creating a single sided vault, using float for calculating ratio

$
0
0

When making a single sided vault, aka deposit X get Y. is it safe to just use a float to get the ratio?

right now I just calculate the ratio with like so:

(x_underlying_token_account_amount as f64) / (y_lp_mint_supply as f64)

Meaning you get more x per y as underlying increases compared to the lp_mint supply.

I let people deposit and withdraw based on that ratio. Ive played around with more precise libraries to get precise number etc, but they all give me the same number as the method above.

I feel like its safe to assume that with single sided vaults this is a safe approach to getting the ratio for deposits and withdrawals but I would love to get some input from a pro


Viewing all articles
Browse latest Browse all 7939

Trending Articles