mentorship2022 icon indicating copy to clipboard operation
mentorship2022 copied to clipboard

Multicall

Open alcueca opened this issue 2 years ago • 0 comments

Exercise name:        Multicall
Assignment #:         8
Track:                Smart contracts
Testing framework:    Foundry
Deployment framework: Foundry (forge create)
Node provider:        
Target network:       

Assignment summary

Building upon the AMM from the previous assignment, refactor it so that its function calls can be composed.

Instead of using transferFrom, set up state variables that track the AMM reserves, and at the beginning of each function compare the current balances from the cached reserve values, inferring how much the user transferred.

Inherit from Multicall.

Implement a function that only transfers tokens from the user.

Implement a function that allows any user to get tokens from the AMM if there is any discrepancy between cached reserves and actual balances, so that the balances and cached reserves match.

Off-chain, construct a transaction that transfers only X, sells a portion of it for Y, mints AMM tokens, and retrieves the surplus, if there is any.

Off-chain, construct a transaction that transfers AMM tokens, burns them, sells all X for Y, and returns only Y to the user.

Additional Details

Peripheral Goals

alcueca avatar May 02 '22 11:05 alcueca