SetProtocol / set-protocol-v2

Set Protocol V2
118 stars 94 forks source link

Notional trade module adjustments post audit #256

Closed ckoopmann closed 1 year ago

ckoopmann commented 2 years ago

Code Review Processes

New Feature Review

Before submitting a pull request for new review, make sure the following is done:

README Checks

Code Checks

Broader Considerations

ckoopmann commented 2 years ago

Summary of Changes:

Adjust Interface for trade methods:

  1. Change trading parameters (token amounts) in relative terms (to the total set supply) rather than in absolute/notional amounts.
  2. Add methods to allow fixed-output-redemptions and fixed-input-mints (basically not fixing the fCash amount but the underlying / asset token instead) and rename existing methods to differentiate them.

Address issues raised in codearena audit:

  1. Add (configurable) gas limit in external function call to getDecodedID inside isWrappedFCash to avoid wasting excessive amounts of gas. (For example fallback method of cEth token wasted all of the gas leading to revertions)

  2. Reset allowances to zero after minting / redeeming to avoid leftover allowances. (and potential revertions on tokens which don't allow changing non-zero allowances such as USDT)

  3. Allow manager to disable automatic redemption of matured positions upon issuance / redemption to avoid persistent revertions in external calls from freezing user funds.

  4. Add _safeUint88 function to avoid silent overflows when downcasting uint256 fCash amounts to uint88 datatype expected by wrappedfCash

  5. Various smaller changes based on QA / gas optimization feedback from the audit contest. (typos, natspec comments etc)

Repo Cleanup:

Remove manual deployment of wFCashFactory etc. in integration tests and related imports etc.. Instead use factory instance deployed by the notional team.

ckoopmann commented 1 year ago

Replaced by: https://github.com/IndexCoop/index-protocol/pull/1