pie-dao / pools.piedao.org

pools-piedao-org-flax.vercel.app
Other
25 stars 27 forks source link

Feature/bcp swap #326

Closed jordaniza closed 2 years ago

jordaniza commented 2 years ago

The swap modal for DEFI+S/L => DEFI++ is now extended to multiple assets, whilst requiring a single buy token.

This means we can swap:

The swap modal is configured to add a flexible launcher and take a contract address. It can therefore be reused in several places as needed.

jordaniza commented 2 years ago

Some additional changes:

Outstanding issues:

jordaniza commented 2 years ago

@Alexintosh I updated the PR based on our discussion:

jordaniza commented 2 years ago

Based on comments I have added two further changes:

  1. Once the approveMax function has been called, we update the sellToken allowance:
      await approveMax(sellToken.address, spender);
      sellToken.allowance = ethers.constants.MaxUint256;

This prevents the issue whereby the user is waiting for approvals to update, straight after approving the contract.

  1. Add a transaction lifecycle hook isConfirmingTx which will cause the swap button to be disabled and render Swap in Progress... until the swap resolves. This at the very least gives visual feedback to the user that the swap is happening and prevents accidentally wasting gas on a double spend