-
Maker For Beginners 7
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
Lecture1.6
-
Lecture1.7
-
-
Maker For Advanced 7
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
Lecture2.7
-
-
Maker Quiz 1
-
Quiz3.1
-
Dai Module
The origin of DAI was initially created to represent any token that has a core system considering equal in value to the internal debt unit. The DAI module contains the dAI token contract and all of the adapters.
The DAI contract is the user-facing ERC20 contract that maintains the accounting for external DAI balances and most functions are standard for the token with the changing supply but it also features the ability the ability to issue approvals for transfers that are based on signed messages.
Join consists of three smart contracts and one of which is the DaiJoin contract. Each Join contract is created specifically to allow the given token type to be joined to the vat. Because of this, each join has different logic to account for the different types of tokens in the system. The DaiJoin contract allows users to withdraw their Dai from the system into the standardized ERC20 token. Most functions are standard for the token that has a changing supply but it also has features like issuing approvals for transfers based on the signed messages. For the most part, dai.sol functions as a simple ERC20 token. These tokens have been heavily documented in our courses and you can revise the previous lessons.
The transfers from the Dai contract works differently than it does with the generic transfer From function. The Dai contract allows for unlimited approval and if the user approves an address for a maximum unit value, the address will have unlimited approval until it is told otherwise. The permit function allows end-users to sign a message which can be relayed by another party to submit an approval and it can be useful for applications where the end-user won’t have to hold ETH. In order to use the functionality, a user’s address has to sign a message with the holder, spender, and expiry, as well as the allowed amount and this, can then be submitted to Permit to update the users’ approval.
The unlimited allowance is an uncommon practice but this could be something used as a trick by users that have malicious contracts that give access to their Dai. This is concerning and ungradable contracts practices where the contract could appear innocent until upgraded to a malicious contract.
DAI is susceptible to the known ERC20 race condition but should not be an issue with unlimited approval so the users using the approval for a specific amount have to be aware of this issue and use caution when authorizing other contracts to perform the transfer on their behalf. The Dai token provides off-chain approval which means that the owner of an ETH address can sign permission which allows another ETH address to take care of the execution of the transfer but with no allowance.