Opening a SAFE

Steps to open a SAFE and withdraw system coins

Import all the necessary dependencies:

>>> from web3 import Web3, HTTPProvider
>>> from pyflex import Address
>>> from pyflex.deployment import GfDeployment
>>> from pyflex.keys import register_keys
>>> from pyflex.numeric import Wad 

Connect to an Ethereum node:

>>> ETH_RPC_URL = "http://localhost:8545"
>>> web3 = Web3(HTTPProvider(endpoint_uri=ETH_RPC_URL, request_kwargs={"timeout": 60}))

Set your account and keystore file and then enter your keystore password:

>>> web3.eth.defaultAccount ='0xdD1693BD8E307eCfDbe51D246562fc4109f871f8'
>>> register_keys(web3, ['key_file=key.json'])
Password for key.json: 
>>>

Instantiate an Address object to use later. Then, initialize a GEB object:

>>> our_address = Address(web3.eth.defaultAccount)
>>> geb = GfDeployment.from_node(web3=web3)

Currently ETH-A is the only supported collateral:

>>> collateral = geb.collaterals['ETH-A']

Setup your approvals in order to join/exit collateral and system coins in and out of the system.

circle-info

These approve calls only need to be done once per address!

Set the amount of collateral to deposit and the amount of debt to withdraw:

deposit collateral and join it into the system:

Open a SAFE depositing the collateral and increasing your system coin balance in the SAFEEngine :

Check your coin balance in the SAFEEngine :

exit system coin in ERC20 form:

Last updated