Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.02 KB

File metadata and controls

35 lines (24 loc) · 1.02 KB

DAI / USDS Swap Exercise

In this exercise, you'll learn how to swap between DAI and USDS using the DaiUsds converter contract.

The starter code for this exercise is provided in foundry/src/exercises/DaiUsds.sol

Solution is in foundry/src/solutions/DaiUsds.sol

Task 1 - Swap DAI to USDS

function swapDaiToUsds(uint256 amt) external {
    // Write your code here
}
  • Transfer DAI from the caller and approve the DaiUsds converter.
  • Call daiUsds.daiToUsds to convert DAI to USDS for the caller.

Task 2 - Swap USDS to DAI

function swapUsdsToDai(uint256 amt) external {
    // Write your code here
}
  • Transfer USDS from the caller and approve the DaiUsds converter.
  • Call daiUsds.usdsToDai to convert USDS to DAI for the caller.

Test

forge test --fork-url $FORK_URL --match-path test/DaiUsds.t.sol -vvv