initialize() :
This function initializes the contract by setting the initialized variable to true and registering the contract with the _registerContract() function. The _registerContract() function takes in an array of addresses and the address of the contract, and stores the contract address in the registry. This allows the contract to be accessed and interacted with by other contracts. (autogenerated documentation)
deposit() :
This function allows a user to deposit collateral into a deposit box. It requires that the deposit box has been initialized, that the fees have been paid, and that the function is not reentrant. It checks that the collateral amount is greater than 0, and if the raw collateral is 0, it emits a NewDepositBox event. It then increments the collateral balances and emits a Deposit event. Finally, it transfers the collateral from the user to the contract. (autogenerated documentation)
requestWithdrawal() :
This function allows a user to request a withdrawal of their collateral from the deposit box. It requires that the user has already initialized the deposit box, has no pending withdrawal requests, and is not re-entering the function. The function then checks that the denominated collateral amount is greater than 0 and sets the withdrawal request amount and the request pass timestamp in the deposit box data. It then emits an event to notify that a withdrawal request has been made. The function then computes the final fees and checks that the fee-adjusted collateral is greater than or equal to the final fees. If so, it pays the final fees and requests an oracle price. (autogenerated documentation)
executeWithdrawal() :
This function allows a user to withdraw funds from a deposit box. It first checks to make sure that the withdrawal request is valid, then calculates the exchange rate between the deposit box's collateral currency and the denominated currency. It then checks to make sure that the amount to be withdrawn is not greater than the amount of collateral in the deposit box, and if it is, it adjusts the amount to be withdrawn to the amount of collateral in the deposit box. It then decrements the collateral balances and emits an event to signal that the withdrawal request has been executed. Finally, it transfers the withdrawn funds to the user's account. (autogenerated documentation)
cancelWithdrawal() :
This function allows a user to cancel a pending withdrawal request. It first checks to make sure that the user has a pending withdrawal request, and then emits an event to indicate that the request has been canceled. Finally, it resets the withdrawal request data in the deposit box associated with the user. (autogenerated documentation)
emergencyShutdown() :
This function is an external override that is used to shut down the system in an emergency. It is non-reentrant, meaning that it cannot be called more than once. It checks to see if the system is initialized before executing, and if so, it will shut down the system. (autogenerated documentation)
remargin() :
This function is an external override that is used to adjust the margins of a document. It is non-reentrant, meaning that it cannot be called more than once. The function does not have any code, so it is assumed that it is used to call other functions that will adjust the margins of the document. (autogenerated documentation)
getCollateral(address) :
This function is used to retrieve the collateral amount of a user from the DepositBox contract. It takes in an address of the user as an argument and returns the collateral amount as an unsigned fixed point number. The function works by first calling the _getFeeAdjustedCollateral() internal function which adjusts the collateral amount for any fees associated with it. It then returns the adjusted collateral amount. (autogenerated documentation)
totalDepositBoxCollateral() :
This function returns the total amount of collateral held in the deposit boxes of the contract. It works by first calling the _getFeeAdjustedCollateral() function, which adjusts the total collateral amount for any fees associated with the deposit boxes, and then returning the result of that function call. The rawTotalDepositBoxCollateral variable is used to store the total amount of collateral held in the deposit boxes. (autogenerated documentation)
_requestOraclePrice(uint256) :
This function is used to request the price of a certain asset from an oracle at a given time. It takes in a uint256 requestedTime parameter, which is used to specify the time at which the price should be requested. The function then calls the _getOracle() function to get an instance of the OracleInterface, and then calls the requestPrice() function on the oracle instance, passing in the priceIdentifier and requestedTime parameters. This will cause the oracle to query its data sources and return the requested price. (autogenerated documentation)
_incrementCollateralBalances() :
This function is used to increment the collateral balances of a DepositBoxData storage object and the total collateral balance of the contract. It takes in a DepositBoxData storage object and a collateral amount as parameters and returns the updated total collateral balance of the contract. The function works by first adding the collateral amount to the DepositBoxData storage object's rawCollateral balance and then adding the same amount to the contract's rawTotalDepositBoxCollateral balance. Finally, the updated total collateral balance of the contract is returned. (autogenerated documentation)
_decrementCollateralBalances() :
This function is used to decrement the collateral balances of a DepositBoxData storage object and the total collateral balance of the contract. It takes in a DepositBoxData storage object and a collateral amount as parameters. Internally, it calls the _removeCollateral function to subtract the collateral amount from the DepositBoxData storage object and the total collateral balance of the contract. It then returns the updated collateral amount. (autogenerated documentation)
_resetWithdrawalRequest() :
This function is used to reset the withdrawal request amount and request pass timestamp of a DepositBoxData storage object. It sets the withdrawal request amount to 0 and the request pass timestamp to 0. This function is used to reset the withdrawal request data when a withdrawal request is processed. (autogenerated documentation)
_depositBoxHasNoPendingWithdrawal(address) :
This function checks if a user has a pending withdrawal from their deposit box. It does this by checking the requestPassTimestamp of the user's deposit box. If the timestamp is equal to 0, then there is no pending withdrawal and the function returns true. Otherwise, the function throws an error. (autogenerated documentation)
_isInitialized() :
This function is an internal view function that checks if the contract has been initialized. It requires that the initialized variable is true, and if it is not, it will throw an error. This function is used to ensure that the contract is properly initialized before any other functions are called. (autogenerated documentation)
_getIdentifierWhitelist() :
This function is an internal view function that returns an instance of the IdentifierWhitelistInterface. It does this by using the finder contract to get the address of the IdentifierWhitelistInterface and then returning an instance of that interface. (autogenerated documentation)
_getOracle() :
This function is an internal view function that returns an OracleInterface. It uses the finder contract to get the address of the Oracle contract and then returns an OracleInterface instance. This allows the contract to interact with the Oracle contract and access its functions. (autogenerated documentation)
_getOraclePrice(uint256) :
This function is used to retrieve the price of a given asset from an oracle at a given time. It takes in a uint256 requestedTime parameter, which is used to specify the time at which the price should be retrieved. It then calls the _getOracle() function to retrieve the OracleInterface instance, and checks that the oracle has a price for the given asset at the requested time. If the oracle does have a price, the function retrieves the price as an int256 and checks that it is not negative. If it is negative, it sets the price to 0. Finally, the function returns the price as a FixedPoint.Unsigned instance. (autogenerated documentation)
_pfc() :
This function is an internal view function that returns the adjusted collateral amount for a given deposit box. It works by taking the raw total deposit box collateral as an input and using the _getFeeAdjustedCollateral() function to calculate the adjusted collateral amount. This adjusted collateral amount is then returned as a FixedPoint.Unsigned memory type. (autogenerated documentation)