Skip to main content

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.

NameTypeDescription
_oracleProvidersEnumerableSet.AddressSetSet 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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
    oracleProvideraddressThe address of the oracle provider to register.
    minTakeProfitBPSuint32The minimum take-profit basis points.
    maxTakeProfitBPSuint32The maximum take-profit basis points.
    leverageLeveluint8The leverage level of the oracle provider.

unregister

function unregister(struct OracleProviderRegistry self, address oracleProvider) internal

Unregisters an oracle provider from the registry.

  • Parameters:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
    oracleProvideraddressThe 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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
  • Return Values:

    NameTypeDescription
    [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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
    oracleProvideraddressThe address of the oracle provider to check.
  • Return Values:

    NameTypeDescription
    [0]boolbool 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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
    oracleProvideraddressThe address of the oracle provider.
  • Return Values:

    NameTypeDescription
    minTakeProfitBPSuint32The minimum take-profit basis points.
    maxTakeProfitBPSuint32The maximum take-profit basis points.
    leverageLeveluint8The 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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe OracleProviderRegistry storage.
    oracleProvideraddressThe address of the oracle provider.
    minTakeProfitBPSuint32The minimum take-profit basis points.
    maxTakeProfitBPSuint32The 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:

    NameTypeDescription
    selfstruct OracleProviderRegistryThe storage reference to the OracleProviderRegistry.
    oracleProvideraddressThe address of the oracle provider.
    leverageLeveluint8The new leverage level to be set for the oracle provider.