tradingstrategy-ai/frontend

Include expected minSharesQuantity in payment transaction

Closed this issue · 0 comments

Goal

As a Trading Strategy developer, I want a calculated minSharesQuantity to be included in blockchain payment transactions, to prevent MEV bot frontrunning.

Details

We currently include a value of 1 since this is a required field. The smart contract interprets this as 1 unit, or 1e-18 shares (effectively no minimum).

The correct value should be calculated based on the current share price, the amount of USDC the user is depositing, and a slippage tolerance.

When redeeming, we currently show a estimated value of USDC. We should do the same for deposits, showing the estimated number of shares that the user will receive.

image

Formula:

minSharesQuantity = USDC amount / share price * (1 - slippage tolerance)

…using a hard-coded slippage tolerance of 2%.

Acceptance criteria

  1. Deposit blockchain transactions include calculated minSharesQuantity based on the formula above
  2. Deposit UI includes estimated shares to be received, based on the formula above
    • question: should the estimate be calculated without slippage? or with a lower "average" expected slippage?