OracleProviderRegistry.sol
OracleProviderRegistry
struct OracleProviderRegistry {
EnumerableSet.AddressSet _oracleProviders;
mapping(address => uint32) _minTakeProfitBPSs;
mapping(address => uint32) _maxTakeProfitBPSs;
mapping(address => uint8) _leverageLevels;
}
A registry for managing oracle providers.
Name | Type | Description |
---|---|---|
_oracleProviders | EnumerableSet.AddressSet | Set of registered oracle providers |
OracleProviderRegistryLib
Library for managing a registry of oracle providers.
register
function register(struct OracleProviderRegistry self, address oracleProvider, uint32 minTakeProfitBPS, uint32 maxTakeProfitBPS, uint8 leverageLevel) internal
Registers an oracle provider in the registry.
Throws an error with the code Errors.ALREADY_REGISTERED_ORACLE_PROVIDER
if the oracle provider is already registered.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. oracleProvider address The address of the oracle provider to register. minTakeProfitBPS uint32 The minimum take-profit basis points. maxTakeProfitBPS uint32 The maximum take-profit basis points. leverageLevel uint8 The leverage level of the oracle provider.
unregister
function unregister(struct OracleProviderRegistry self, address oracleProvider) internal
Unregisters an oracle provider from the registry.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. oracleProvider address The address of the oracle provider to unregister.
oracleProviders
function oracleProviders(struct OracleProviderRegistry self) internal view returns (address[])
Returns an array of all registered oracle providers.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. Return Values:
Name Type Description [0] address[] oracleProviders An array of addresses representing the registered oracle providers.
isRegistered
function isRegistered(struct OracleProviderRegistry self, address oracleProvider) internal view returns (bool)
Checks if an oracle provider is registered in the registry.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. oracleProvider address The address of the oracle provider to check. Return Values:
Name Type Description [0] bool bool Whether the oracle provider is registered.
getOracleProviderProperties
function getOracleProviderProperties(struct OracleProviderRegistry self, address oracleProvider) internal view returns (uint32 minTakeProfitBPS, uint32 maxTakeProfitBPS, uint8 leverageLevel)
Retrieves the properties of an oracle provider.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. oracleProvider address The address of the oracle provider. Return Values:
Name Type Description minTakeProfitBPS uint32 The minimum take-profit basis points. maxTakeProfitBPS uint32 The maximum take-profit basis points. leverageLevel uint8 The leverage level of the oracle provider.
setTakeProfitBPSRange
function setTakeProfitBPSRange(struct OracleProviderRegistry self, address oracleProvider, uint32 minTakeProfitBPS, uint32 maxTakeProfitBPS) internal
Sets the range for take-profit basis points for an oracle provider.
Parameters:
Name Type Description self struct OracleProviderRegistry The OracleProviderRegistry storage. oracleProvider address The address of the oracle provider. minTakeProfitBPS uint32 The minimum take-profit basis points. maxTakeProfitBPS uint32 The maximum take-profit basis points.
setLeverageLevel
function setLeverageLevel(struct OracleProviderRegistry self, address oracleProvider, uint8 leverageLevel) internal
Sets the leverage level of an oracle provider in the registry.
The leverage level must be either 0 or 1, and the max leverage must be x10 for level 0 or x20 for level 1.
Parameters:
Name Type Description self struct OracleProviderRegistry The storage reference to the OracleProviderRegistry. oracleProvider address The address of the oracle provider. leverageLevel uint8 The new leverage level to be set for the oracle provider.