In this lesson we're adding a get_dy function, which computes the number of $crvUSD stablecoins received for dx, an input of the collateral token ($CRV).
In the process the lesson highlights some of the intricacies of working with integer arithmetic within smart contracts. A supplemental file TestMath.vy displayed in the video is included in the contracts directory.
Vyper contains additional advanced math functions. For further reading:
Arithmetic in Vyper uses the basic operators from Python. All arithmetic operators utilize safemath by default and revert on overflow.
x + yAdditionx - ySubtraction-xUnary minus/Negationx * yMultiplicationx / yInteger Divisionx ** yExponentiationx % yModulo
Vyper supports a decimal variable type that renders as fixed168x10 in the ABI.
This tutorial instead follows the convention of shifting 18 decimal places and rounding it off as a uint.