Global Settlement Guide
The following are examples of how you can use geb.js to facilitate the Global Settlement process and redeem your collateral which is locked in your own Safes or directly exchange system coins with collateral.
Example Flow for Global Settlement Using GEB.js
These scripts can help you go throught the steps described on the Global Settlement page.
We first need to setup geb.js and ethers.js:
import { ethers } from 'ethers'
import { Geb, utils } from 'geb.js'
const provider = new ethers.providers.JsonRpcProvider(
'http://kovan.infura.io/v3/<API KEY>'
)
const wallet = new ethers.Wallet('0xdefiisawesome...', provider)
const geb = new Geb('kovan', provider)Before continuing, we need to make sure that Global Settlement was triggered by checking the shutdown timestamp:
const shutdownTime = await geb.contracts.globalSettlement.shutdownTime()
const hasGlobalSettlementStarted = shutdownTime.gt(0)Withdraw Excess Collateral
After settlement starts, each collateral needs to be frozen (Step 2). This needs to be done only once for every collateral type.
Since a SAFE is supposed to be over-collateralized, its owner can already withdraw excess collateral. The following script assumes that the SAFE is owned by a proxy contract. It also uses the Global Settlement Proxy Actions to pack and atomically execute multiple transactions at once.
This fulfills step 3 and step 5 from the Global Settlement process.
Set the Final COL/COIN Exchange Rates
This part of the process consists in determining an exchange rate between the system coins that are still in circulation and each individual collateral type accepted by the system. The system needs to account for all Safes (I), terminate all ongoing collateral auctions (II) and remove all system surplus (III).
This needs to be done only once for the whole system. These steps can be taken care of by the settlement keeper bot or by anyone who is willing to pay the gas costs associated with these transactions.
Finally, the cash price for each collateral can be set with the following steps:
Redeem Collateral Against System Coins
At this stage, any system coin holder can exchange their coins against a fixed basket of collateral. This is a 2 step process that consists in locking and preparing system coins and then claiming a share of a specific collateral type.
Last updated
Was this helpful?