In this exercise, you'll learn how to repay DAI debt by interacting with Vat and DaiJoin contracts directly.
The starter code for this exercise is provided in foundry/src/exercises/Repay.sol
Solution is in foundry/src/solutions/Repay.sol
Hint: notes/code/DssProxyActions.sol
function repay(uint256 amt) external auth {
// Write your code here
}- Transfer DAI from the caller, approve, and join it into the Vat via
DaiJoin. - Calculate the debt to repay using
Math.calcDebtToRepay. - Call
vat.frobto wipe debt (zerodink, negativedart). - Refund any excess DAI remaining in the Vat back to the caller.
function repayAll() external auth {
// Write your code here
}- Calculate the exact DAI amount needed using
Math.calcDaiToRepayAll. - Transfer DAI from the caller, approve, and join it into the Vat via
DaiJoin. - Get the urn's
art(total debt units) and callvat.frobwith negativedartequal to-art.
forge test --fork-url $FORK_URL --match-path test/Repay.t.sol -vvv