Contract that controls the Gamma Protocol and the interaction of all sub contracts
-
notPartiallyPaused()
-
notFullyPaused()
-
onlyFullPauser()
-
onlyPartialPauser()
-
onlyAuthorized(address _sender, address _accountOwner)
-
onlyWhitelistedCallee(address _callee)
-
_isNotPartiallyPaused() (internal)
-
_isNotFullyPaused() (internal)
-
_isAuthorized(address _sender, address _accountOwner) (internal)
-
initialize(address _addressBook, address _owner) (external)
-
donate(address _asset, uint256 _amount) (external)
-
setSystemPartiallyPaused(bool _partiallyPaused) (external)
-
setSystemFullyPaused(bool _fullyPaused) (external)
-
setFullPauser(address _fullPauser) (external)
-
setPartialPauser(address _partialPauser) (external)
-
setCallRestriction(bool _isRestricted) (external)
-
setOperator(address _operator, bool _isOperator) (external)
-
refreshConfiguration() (external)
-
setNakedCap(address _collateral, uint256 _cap) (external)
-
operate(struct Actions.ActionArgs[] _actions) (external)
-
sync(address _owner, uint256 _vaultId) (external)
-
isOperator(address _owner, address _operator) (external)
-
getConfiguration() (external)
-
getProceed(address _owner, uint256 _vaultId) (external)
-
isLiquidatable(address _owner, uint256 _vaultId, uint256 _roundId) (external)
-
getPayout(address _otoken, uint256 _amount) (public)
-
isSettlementAllowed(address _otoken) (external)
-
canSettleAssets(address _underlying, address _strike, address _collateral, uint256 _expiry) (external)
-
getAccountVaultCounter(address _accountOwner) (external)
-
hasExpired(address _otoken) (external)
-
getVault(address _owner, uint256 _vaultId) (external)
-
getVaultWithDetails(address _owner, uint256 _vaultId) (public)
-
getNakedCap(address _asset) (external)
-
getNakedPoolBalance(address _asset) (external)
-
_runActions(struct Actions.ActionArgs[] _actions) (internal)
-
_verifyFinalState(address _owner, uint256 _vaultId) (internal)
-
_openVault(struct Actions.OpenVaultArgs _args) (internal)
-
_depositLong(struct Actions.DepositArgs _args) (internal)
-
_withdrawLong(struct Actions.WithdrawArgs _args) (internal)
-
_depositCollateral(struct Actions.DepositArgs _args) (internal)
-
_withdrawCollateral(struct Actions.WithdrawArgs _args) (internal)
-
_mintOtoken(struct Actions.MintArgs _args) (internal)
-
_burnOtoken(struct Actions.BurnArgs _args) (internal)
-
_redeem(struct Actions.RedeemArgs _args) (internal)
-
_settleVault(struct Actions.SettleVaultArgs _args) (internal)
-
_liquidate(struct Actions.LiquidateArgs _args) (internal)
-
_call(struct Actions.CallArgs _args) (internal)
-
_checkVaultId(address _accountOwner, uint256 _vaultId) (internal)
-
_isNotEmpty(address[] _array) (internal)
-
_isCalleeWhitelisted(address _callee) (internal)
-
_isLiquidatable(address _owner, uint256 _vaultId, uint256 _roundId) (internal)
-
_getOtokenDetails(address _otoken) (internal)
-
_canSettleAssets(address _underlying, address _strike, address _collateral, uint256 _expiry) (internal)
-
_refreshConfigInternal() (internal)
-
AccountOperatorUpdated(address accountOwner, address operator, bool isSet)
-
VaultOpened(address accountOwner, uint256 vaultId, uint256 vaultType)
-
LongOtokenDeposited(address otoken, address accountOwner, address from, uint256 vaultId, uint256 amount)
-
LongOtokenWithdrawed(address otoken, address AccountOwner, address to, uint256 vaultId, uint256 amount)
-
CollateralAssetDeposited(address asset, address accountOwner, address from, uint256 vaultId, uint256 amount)
-
CollateralAssetWithdrawed(address asset, address AccountOwner, address to, uint256 vaultId, uint256 amount)
-
ShortOtokenMinted(address otoken, address AccountOwner, address to, uint256 vaultId, uint256 amount)
-
ShortOtokenBurned(address otoken, address AccountOwner, address from, uint256 vaultId, uint256 amount)
-
Redeem(address otoken, address redeemer, address receiver, address collateralAsset, uint256 otokenBurned, uint256 payout)
-
VaultSettled(address accountOwner, address oTokenAddress, address to, uint256 payout, uint256 vaultId, uint256 vaultType)
-
VaultLiquidated(address liquidator, address receiver, address vaultOwner, uint256 auctionPrice, uint256 auctionStartingRound, uint256 collateralPayout, uint256 debtAmount, uint256 vaultId)
-
CallExecuted(address from, address to, bytes data)
-
FullPauserUpdated(address oldFullPauser, address newFullPauser)
-
PartialPauserUpdated(address oldPartialPauser, address newPartialPauser)
-
SystemPartiallyPaused(bool isPaused)
-
SystemFullyPaused(bool isPaused)
-
CallRestricted(bool isRestricted)
-
Donated(address donator, address asset, uint256 amount)
-
NakedCapUpdated(address collateral, uint256 cap)
modifier to check if the system is not partially paused, where only redeem and settleVault is allowed
modifier to check if the system is not fully paused, where no functionality is allowed
modifier to check if sender is the fullPauser address
modifier to check if the sender is the partialPauser address
modifier to check if the sender is the account owner or an approved account operator
-
_sender
: sender address -
_accountOwner
: account owner address
modifier to check if the called address is a whitelisted callee address
_callee
: called address
check if the system is not in a partiallyPaused state
check if the system is not in an fullyPaused state
check if the sender is an authorized operator
-
_sender
: msg.sender -
_accountOwner
: owner of a vault
initalize the deployed contract
-
_addressBook
: addressbook module -
_owner
: account owner address
send asset amount to margin pool
use donate() instead of direct transfer() to store the balance in assetBalance
-
_asset
: asset address -
_amount
: amount to donate to pool
allows the partialPauser to toggle the systemPartiallyPaused variable and partially pause or partially unpause the system
can only be called by the partialPauser
_partiallyPaused
: new boolean value to set systemPartiallyPaused to
allows the fullPauser to toggle the systemFullyPaused variable and fully pause or fully unpause the system
can only be called by the fullyPauser
_fullyPaused
: new boolean value to set systemFullyPaused to
allows the owner to set the fullPauser address
can only be called by the owner
_fullPauser
: new fullPauser address
allows the owner to set the partialPauser address
can only be called by the owner
_partialPauser
: new partialPauser address
allows the owner to toggle the restriction on whitelisted call actions and only allow whitelisted
call addresses or allow any arbitrary call addresses
can only be called by the owner
_isRestricted
: new call restriction state
allows a user to give or revoke privileges to an operator which can act on their behalf on their vaults
can only be updated by the vault owner
-
_operator
: operator that the sender wants to give privileges to or revoke them from -
_isOperator
: new boolean value that expresses if the sender is giving or revoking privileges for _operator
updates the configuration of the controller. can only be called by the owner
set cap amount for collateral asset used in naked margin
can only be called by owner
-
_collateral
: collateral asset address -
_cap
: cap amount, should be scaled by collateral asset decimals
execute a number of actions on specific vaults
can only be called when the system is not fully paused
_actions
: array of actions arguments
sync vault latest update timestamp
anyone can update the latest time the vault was touched by calling this function
vaultLatestUpdate will sync if the vault is well collateralized
-
_owner
: vault owner address -
_vaultId
: vault id
check if a specific address is an operator for an owner account
-
_owner
: account owner address -
_operator
: account operator address
- True if the _operator is an approved operator for the _owner account
returns the current controller configuration
-
the address of the whitelist module
-
the address of the oracle module
-
the address of the calculator module
-
the address of the pool module
return a vault's proceeds pre or post expiry, the amount of collateral that can be removed from a vault
-
_owner
: account owner of the vault -
_vaultId
: vaultId to return balances for
- amount of collateral that can be taken out
Function isLiquidatable(address _owner, uint256 _vaultId, uint256 _roundId) → bool, uint256, uint256 external
check if a vault is liquidatable in a specific round id
-
_owner
: vault owner address -
_vaultId
: vault id to check -
_roundId
: chainlink round id to check vault status at
- true if vault is undercollateralized, the price of 1 repaid otoken and the otoken collateral dust amount
get an oToken's payout/cash value after expiry, in the collateral asset
-
_otoken
: oToken address -
_amount
: amount of the oToken to calculate the payout for, always represented in 1e8
- amount of collateral to pay out
return if an expired oToken is ready to be settled, only true when price for underlying,
strike and collateral assets at this specific expiry is available in our Oracle module
_otoken
: oToken
Function canSettleAssets(address _underlying, address _strike, address _collateral, uint256 _expiry) → bool external
return if underlying, strike, collateral are all allowed to be settled
-
_underlying
: oToken underlying asset -
_strike
: oToken strike asset -
_collateral
: oToken collateral asset -
_expiry
: otoken expiry timestamp
- True if the oToken has expired AND all oracle prices at the expiry timestamp have been finalized, False if not
get the number of vaults for a specified account owner
_accountOwner
: account owner address
- number of vaults
check if an oToken has expired
_otoken
: oToken address
- True if the otoken has expired, False if not
return a specific vault
-
_owner
: account owner -
_vaultId
: vault id of vault to return
- Vault struct that corresponds to the _vaultId of _owner
Function getVaultWithDetails(address _owner, uint256 _vaultId) → struct MarginVault.Vault, uint256, uint256 public
return a specific vault
-
_owner
: account owner -
_vaultId
: vault id of vault to return
- Vault struct that corresponds to the _vaultId of _owner, vault type and the latest timestamp when the vault was updated
get cap amount for collateral asset
_asset
: collateral asset address
- cap amount
get amount of collateral deposited in all naked margin vaults
_asset
: collateral asset address
- naked pool balance
execute a variety of actions
for each action in the action array, execute the corresponding action, only one vault can be modified
for all actions except SettleVault, Redeem, and Call
_actions
: array of type Actions.ActionArgs[], which expresses which actions the user wants to execute
-
indicates if a vault has changed
-
the vault owner if a vault has changed
-
the vault Id if a vault has changed
verify the vault final state after executing all actions
-
_owner
: account owner address -
_vaultId
: vault id of the final vault
open a new vault inside an account
only the account owner or operator can open a vault, cannot be called when system is partiallyPaused or fullyPaused
_args
: OpenVaultArgs structure
deposit a long oToken into a vault
only the account owner or operator can deposit a long oToken, cannot be called when system is partiallyPaused or fullyPaused
_args
: DepositArgs structure
withdraw a long oToken from a vault
only the account owner or operator can withdraw a long oToken, cannot be called when system is partiallyPaused or fullyPaused
_args
: WithdrawArgs structure
deposit a collateral asset into a vault
only the account owner or operator can deposit collateral, cannot be called when system is partiallyPaused or fullyPaused
_args
: DepositArgs structure
withdraw a collateral asset from a vault
only the account owner or operator can withdraw collateral, cannot be called when system is partiallyPaused or fullyPaused
_args
: WithdrawArgs structure
mint short oTokens from a vault which creates an obligation that is recorded in the vault
only the account owner or operator can mint an oToken, cannot be called when system is partiallyPaused or fullyPaused
_args
: MintArgs structure
burn oTokens to reduce or remove the minted oToken obligation recorded in a vault
only the account owner or operator can burn an oToken, cannot be called when system is partiallyPaused or fullyPaused
_args
: MintArgs structure
redeem an oToken after expiry, receiving the payout of the oToken in the collateral asset
cannot be called when system is fullyPaused
_args
: RedeemArgs structure
settle a vault after expiry, removing the net proceeds/collateral after both long and short oToken payouts have settled
deletes a vault of vaultId after net proceeds/collateral is removed, cannot be called when system is fullyPaused
_args
: SettleVaultArgs structure
liquidate naked margin vault
can liquidate different vaults id in the same operate() call
_args
: liquidation action arguments struct
execute arbitrary calls
cannot be called when system is partiallyPaused or fullyPaused
_args
: Call action
check if a vault id is valid for a given account owner address
-
_accountOwner
: account owner address -
_vaultId
: vault id to check
- True if the _vaultId is valid, False if not
return if a callee address is whitelisted or not
_callee
: callee address
- True if callee address is whitelisted, False if not
Function _isLiquidatable(address _owner, uint256 _vaultId, uint256 _roundId) → struct MarginVault.Vault, bool, uint256, uint256 internal
check if a vault is liquidatable in a specific round id
-
_owner
: vault owner address -
_vaultId
: vault id to check -
_roundId
: chainlink round id to check vault status at
- vault struct, isLiquidatable, true if vault is undercollateralized, the price of 1 repaid otoken and the otoken collateral dust amount
get otoken detail, from both otoken versions
Function _canSettleAssets(address _underlying, address _strike, address _collateral, uint256 _expiry) → bool internal
return if an expired oToken is ready to be settled, only true when price for underlying,
strike and collateral assets at this specific expiry is available in our Oracle module
- True if the oToken has expired AND all oracle prices at the expiry timestamp have been finalized, False if not
updates the internal configuration of the controller
emits an event when an account operator is updated for a specific account owner
emits an event when a new vault is opened
Event LongOtokenDeposited(address otoken, address accountOwner, address from, uint256 vaultId, uint256 amount)
emits an event when a long oToken is deposited into a vault
Event LongOtokenWithdrawed(address otoken, address AccountOwner, address to, uint256 vaultId, uint256 amount)
emits an event when a long oToken is withdrawn from a vault
Event CollateralAssetDeposited(address asset, address accountOwner, address from, uint256 vaultId, uint256 amount)
emits an event when a collateral asset is deposited into a vault
Event CollateralAssetWithdrawed(address asset, address AccountOwner, address to, uint256 vaultId, uint256 amount)
emits an event when a collateral asset is withdrawn from a vault
Event ShortOtokenMinted(address otoken, address AccountOwner, address to, uint256 vaultId, uint256 amount)
emits an event when a short oToken is minted from a vault
Event ShortOtokenBurned(address otoken, address AccountOwner, address from, uint256 vaultId, uint256 amount)
emits an event when a short oToken is burned
Event Redeem(address otoken, address redeemer, address receiver, address collateralAsset, uint256 otokenBurned, uint256 payout)
emits an event when an oToken is redeemed
Event VaultSettled(address accountOwner, address oTokenAddress, address to, uint256 payout, uint256 vaultId, uint256 vaultType)
emits an event when a vault is settled
Event VaultLiquidated(address liquidator, address receiver, address vaultOwner, uint256 auctionPrice, uint256 auctionStartingRound, uint256 collateralPayout, uint256 debtAmount, uint256 vaultId)
emits an event when a vault is liquidated
emits an event when a call action is executed
emits an event when the fullPauser address changes
emits an event when the partialPauser address changes
emits an event when the system partial paused status changes
emits an event when the system fully paused status changes
emits an event when the call action restriction changes
emits an event when a donation transfer executed
emits an event when naked cap is updated