Dai and Collateral Redemption during Emergency Shutdown
Level: Intermediate
Estimated Time: 60minutes
Description
This guide describes how users can interact with the Maker protocol through proxy contracts to redeem Dai and any excess collateral if the Maker system has entered into emergency shutdown. We will define the setup process, including proxy contract setup, followed by seth calls to; redeem collateral as a Dai Holder, and free excess collateral as a Vault Owner.
Learning Objectives
To redeem Dai and/or excess collateral in the event of Emergency Shutdown
Table of Contents
Setup Process
Installation
Contract Address Setup
Dai Holders to Redeem Collateral
Check user Dai holdings
Approve a Proxy
Create Calldata
Execute Calldata using the MYPROXY Contract
Call cashETH or cashGEM functions
Using cashETH
Define calldata for our function
Execute cashETHcalldata
Alternative from step (6), Using cashGEM
Define calldata for our function
Call execute in MYPROXY
Vault Owners to Redeem Excess Collateral
Vault Holder State
Redeeming ETH using the freeETH function
2.1. Set Call Data
2.2 Execute this calldata
Redeeming ETH using the freeGEM function
3.1 Set Calldata
3.2 Execute this calldata
Conclusion
Setup process
1. Installation
In order to interface with the Ethereum blockchain, the user needs to install seth, a command line tool as part of the Dapp.Tools toolset. We also provide further installation information here. Once the user has installed and configured [seth](<https://dapp.tools/>)
correctly to use the main Ethereum network and the address which holds their MKR, they can query contract balances, approvals and transfers.
2. Contract Address Setup
The user will require the following contract addresses, shown below as mainnet addresses. Rest of mainnet or testnet addresses are accessible at changelog.makerdao.com which can be verified on Etherscan. Similarly, additional information on the commands described below can be found in the End contract and the Proxy_Actions_End contract. These should be setup in the following manner and pasted into the terminal line by line:
Dai holders to Redeem Collateral
There are two functions to be called in order to retrieve the end collateral. The first step is pack
and the second step is cashETH
or cashGem
depending on the leftover amount of each collateral type in the system.
Depositing Dai tokens into the system can be done using the PROXY_ACTIONS_END
contract library and the pack
function. This function efficiently bundles together three parameters, including three parameters; the Dai(join)
adapter, the end
contract and the amount of Dai tokens you wish to redeem for allowed collateral in one go.
1. Check user Dai holdings
The user can check their Dai Token balance and subsequently save it in the wad
variable so that it can be later used in the proxy function.
2. Approve a Proxy
The user needs to approve MYPROXY
in order to withdraw Dai from their wallet by using the following function.
3. Create Calldata
Next it is necessary to bundle together the function definitions and parameters that the user needs to execute. This is done by preparing a function call to MYPROXY
, defined as calldata.
4. Execute calldata using the MYPROXY
contract
MYPROXY
contractThe user is able to call the execute
function and utilize the PROXY_ACTIONS_END.pack()
function within the environment of MYPROXY
. This approves the proxy to take Dai tokens from the user's wallet into the proxy address and deposits it into the end
contract, where a proportionate amount of collateral can later be claimed. Once the DAI is packed, it cannot be unpacked.
5. Call cashETH
or cashGEM
functions
cashETH
or cashGEM
functionsUsers will be able to withdraw collateral depending on the collateral that is in the VAT at the time of shutdown. For example 1 Dai will be able to claim a portion of ETH and BAT (and any other accepted collateral) which when combined will be approximately worth 1 USD. This process is completed by calling cashETH
or cashGEM
.
6. Using cashETH
cashETH
The following function cashETH
is referenced as part of the calldata
function and should be referenced here.
7. Define calldata for our function
Next, we again define the calldata for our function by bundling together the cashETH
parameters shown above.
8. Execute cashETHcalldata
cashETHcalldata
Finally, executing the cashETHcalldata
in the execute
function of the user's MYPROXY
contract will redeem ETH for DAI, and place this ETH into the user's ETH wallet.
9. Alternative from step (6), Using cashGEM
cashGEM
It is also possible to use the cashGEM
function in order to redeem different collateral types. In the below example we are referencing gemJoin as it relates to BAT.
10. Define calldata for our function
Similarly, as done in step (7), the user needs to define the calldata to interact with cashGEM
11. Call execute in MYPROXY
MYPROXY
Finally, executing the cashBATcalldata
in the execute
function of the user's MYPROXY
contract will redeem BAT for DAI, and place this BAT into the user's ETH wallet.
Vault Owners to Redeem Excess Collateral
Likewise, a vault owner can use the freeETH
or freeGEM
proxy actions function to retrieve any excess collateral they may have locked in the system.
1. Vault Holder State
There are some constraints for vault holders to be aware of. For example, if a user’s Vault is under-collateralised then they will not have any excess collateral to claim. Likewise, if the user’s Vault is currently in a flip auction at the time of emergency shutdown, it will be necessary for the Vault holder to cancel the auction by calling skip(ilk, id)
before calling free__()
.
Similarly, these functions have been completed using Maker proxy contract calls. There may be other scenarios in which 3rd party front ends such as InstaDApp have their own proxies, which will require users to exit from their proxy in order to use the below.
2. Redeeming ETH using the freeETH
function
freeETH
function2.1. Set calldata
Depending on how many vaults the user has, it will be necessary to repeat this process for each vault ID.
2.2. Execute this calldata
Executing the MYPROXY
contract will redeem ETH and place it into the users address.
3. Redeeming ETH using the freeGEM
function
freeGEM
function3.1. Set calldata
Depending on how many vaults the user has, it will be necessary to repeat this process for each vault ID.
3.2. Execute this calldata
Executing the MYPROXY
contract will redeem BAT (or other collateral types) and place them into the users address.
Conclusion
The above outlines how to redeem Dai and excess Vault collateral using the command line.
In summary, we showed how to check your Dai holdings, how to approve a proxy to withdraw Dai from your wallet and then to use cashETH/GEM
functions to withdraw collateral into the user’s ETH wallet using the MYPROXY
contract . For Vault owners, we showed how to redeem collateral by using the MYPROXY
contract and the freeGEM
function.
In the event of emergency shutdown we envision that it will still be possible to sell Dai on the open market as well as by making use of economically incentivized redemption keepers to meet market needs for both Dai owners and Vaults holders.
Last updated