Open aaronmgdr opened 5 months ago
@aaronmgdr There's no way of fetching the bucket sizes at the moment via the SDK but one way you could achieve a similar slippage check is by calculating the effective price based on the quote from getAmountOut
and then comparing that to oracleMedianRate
in the same way you are currently doing. I think in that way you probably wouldn't need the second check on X% of the bucket since any potential slippage due to that will be reflected in the first check.
Also it's important for you to set the minAmountOut
parameter anyways after getting a quote since otherwise the trade can be frontrun. By looking at the command in the CLI it seems that if people don't provide --forAtLeast
it would probably be due to not knowing the exchange rate rather than wanting to force a trade at any execution price.
thanks for the reply!
The old Exchange Contracts had a
getBuyAndSellBuckets
view method.when minReceiveAmount of the token was 0, we had been using this to give warnings if a trade/swap would significantly move the price (see code block below).
The questions
Is there an equivalent method on Broker or way you would handle something similar.
since with mentoSDK im fetching a quoted
minAmountOut
, do i suspect i dont even need to worry about "dangerous" swaps