SAFE Manager
A central hub for all SAFEs
Smart contract code: GebSafeManager
1. Summary
The SAFE Manager is an abstraction around the SAFEEngine
that allows anyone to easily manage their GEB positions.
2. Contract Variables & Functions
Variables
safeEngine
- the address of theSAFEEngine
safei
- auto incrementing noncecdps[safeId: uint256]
- mapping between SAFE ids and SAFEcdpList[safeId: uint256]
- double linked list indicating the previous and next SAFE ids of a provided SAFEownsCDP[cdpId: uint256]
- indicates the owner of a SAFEcollateralTypes[cdpId: uint256]
- the collateral type backing the SAFE with idsafeId
firstSAFEID[owner: address]
- the firstsafeId
of an ownerlastSAFEID[owner: address]
- the lastsafeId
or an ownersafeCount[owner: address]
- the amount of SAFEs and address hassafeCan[owner: address
,safeId: uint256
,allowedAddr: address]
- whether an address is allowed to interact with a SAFEhandlerCan[safeHandler: address
,allowedAddr: address]
- whether an address is allowed to interact with a SAFE's handler
Data Structures
List
- a struct containing the previous and the next SAFE ids of a specific SAFE. Contains:prev
- the previous SAFE idnext
- the next SAFE id
Functions
allowSAFE(safe: uint256
,usr: address
,ok: uint256)
- allow an address to interact with a SAFE with a specific idallowHandler(usr: address
,ok: uint256)
- allow an address to interact with a SAFE handleropenSAFE(collateralType: bytes32
,usr: address)
- create a new SAFE id and handlertransferSAFEOwnership(safe: uint256
,dst: address)
- transfer a SAFE to another addressmodifySAFECollateralization(safe: uint256
,deltaCollateral: int256
,deltaDebt:
int256)
- add/remove collateral to and from a SAFE or generate/repay debttransferCollateral(safe: uint256
,dst: address
,wad: uint256)
- transfer collateral from a SAFE to another addresstransferInternalCoins(safe: uint256
,dst: address
,rad: uint256)
- transferSAFEEngine.coinBalance
system coins between addressesquitSystem(safe: uint256
,dst: address)
- migrate the SAFE to a destination addressenterSystem(safe: address
,src: uint256)
- import a SAFE to the handler owned by an addressmoveSAFE(safeSrc: uint256
,safeDst: uint256)
- move a position between SAFE handlersprotectSAFE(safe: uint256
,liquidationEngine: address
,saviour: address)
- choose aSAFESaviour
for a SAFE
Events
AllowSAFE
- emitted whenallowSafe
is called. Contains:sender
- themsg.sender
safe
- the SAFE idusr
- the address of the user that is allowed/forbidden from managing the SAFEok
- whether theusr
is allowed or not to manage the SAFE
AllowHandler
- emitted whenallowHandler
is called. Contains:sender
- themsg.sender
usr
- the handlerok
- whether it is allowed or not
TransferSAFEOwnership
- emitted whentransferSAFEOwnership
is called. Contains:sender
- themsg.sender
safe
- the SAFE iddst
- the new owner
OpenSAFE
- emitted when a new SAFE is created usingopenSAFE
. Contains:sender
- themsg.sender
own
- the SAFE ownersafe
- SAFE id
ModifySAFECollateralization
- emitted whenmodifySAFECollateralization
is called. Contains:sender
- themsg.sender
safe
- the SAFE iddeltaCollateral
- the amount of collateral to add/removedeltaDebt
- the amount of debt to repay/withdraw
TransferCollateral
- emitted whentransferCollateral
is called. Contains:sender
- themsg.sender
safe
- the SAFE iddst
- the destination SAFE idwad
- amount of collateral to transfer
TransferInternalCoins
- emitted whentransferInternalCoins
is called. Contains:sender
- themsg.sender
safe
- the SAFE iddst
- destination for internal coinsrad
- amount of internal coins to transfer
QuitSystem
- emitted whenquitSystem
is called. Contains:sender
- themsg.sender
safe
- the SAFE iddst
- the destination handler for the SAFE
EnterSystem
- emitted whenenterSystem
is called. Contains:sender
- themsg.sender
src
- the source handler for the SAFEsafe
- the SAFE id
MoveSAFE
- emitted whenmoveSAFE
is called. Contains:safe
- the SAFE idsafeSrc
- the source ID that has the current handler controlling the SAFEsafeDst
- the destination SAFE id that has the handler which will control thesafe
from now on
ProtectSAFE
- emitted whenprotectSAFE
is called. Contains:sender
- themsg.sender
safe
- the SAFE idliquidationEngine
- theLiquidationEngine
wheresaviour
is and that can liquidatesafe
saviour
- the saviour that will protect the SAFE
3. Risks
When openSAFE
is executed, a new safeHandler
is created and a safeId
is assigned to it for a specific owner
. If the user calls CollateralJoin.join
to add collateral to the safeHandler
immediately after the SAFE creation transaction is mined, there is a chance that a chain reorg occurs. This would result in the user losing the ownership of the safeHandler
and therefore lose their collateral. Users can avoid this issue when using proxy actions.
Last updated