Fujicracy / fuji-v2

Cross-chain money market aggregator
https://fuji-v2-frontend.vercel.app
15 stars 10 forks source link

Allowance for debt asset #363

Closed brozorec closed 1 year ago

brozorec commented 1 year ago

Context

Currently, the allowance modal handles only the collateral asset that works when we deposit. It breaks when we want to pay back.

TODOs

ferostabio commented 1 year ago

@brozorec doing this I realized that even if I removed the infinite limit switch, the modal's text is all about it

<Typography mt="1rem">
  To avoid having to reapprove for subsequent transactions, you could enable infinite approval.
</Typography>

<Typography mt="1rem">
  Otherwise, only the exact amount for this transaction will be allowed to be transfered from your wallet.
</Typography>
ferostabio commented 1 year ago

@brozorec we also need to decide what to do with

set(
  produce((s: BorrowState) => {
    if (s.collateral.allowance.value) {
      // optimistic: we assume transaction will success and update allowance according to that
      s.collateral.allowance.value -= parseFloat(s.collateral.input)
    }
  })
)

That code has been commented out, but we need to deal with it.

brozorec commented 1 year ago

@ferostar

doing this I realized that even if I removed the infinite limit switch, the modal's text is all about it

Let's rewrite it as follows: "Approve the router contract [ADDRESS](with an etherscan link) to use [XXX] from your wallet."

we also need to decide what to do with

I suggest we remove it and when the tx on the src chain gets confirmed, we re-fetch the allowance. Wdyt?