services

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IService

type IService interface {
	// RetrieveTrades is used to get logs from the "OrderSettled" event preps market contract within given block range
	RetrieveTrades(fromBlock uint64, toBLock *uint64) ([]*models.Trade, error)

	// RetrieveTradesLimit is used to get all trades and their additional data from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveTradesLimit(limit uint64) ([]*models.Trade, error)

	// RetrieveOrders is used to get logs from the "OrderCommitted" event preps market contract within given block range
	RetrieveOrders(fromBlock uint64, toBLock *uint64) ([]*models.Order, error)

	// RetrieveOrdersLimit is used to get all orders and their additional data from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveOrdersLimit(limit uint64) ([]*models.Order, error)

	// RetrieveMarketUpdates is used to get logs from the "MarketUpdated" event preps market contract within given block
	// range
	RetrieveMarketUpdates(fromBlock uint64, toBLock *uint64) ([]*models.MarketUpdate, error)

	// RetrieveMarketUpdatesBig is used to get logs from the "MarketUpdated" event preps market contract within given block
	// range and return model with big.Int values
	RetrieveMarketUpdatesBig(fromBlock uint64, toBLock *uint64) ([]*models.MarketUpdateBig, error)

	// RetrieveMarketUpdatesLimit is used to get all market updates and their additional data from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveMarketUpdatesLimit(limit uint64) ([]*models.MarketUpdate, error)

	// RetrieveMarketUpdatesBigLimit is used to get logs from the "MarketUpdated" event preps market contract within given block
	// range and return the model with big.Int values
	RetrieveMarketUpdatesBigLimit(limit uint64) ([]*models.MarketUpdateBig, error)

	// RetrieveLiquidations is used to get logs from the "PositionLiquidated" event preps market contract within given block
	// range
	RetrieveLiquidations(fromBlock uint64, toBLock *uint64) ([]*models.Liquidation, error)

	// RetrieveLiquidationsLimit is used to get all liquidations and their additional data from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveLiquidationsLimit(limit uint64) ([]*models.Liquidation, error)

	// RetrieveAccountLiquidationsLimit is used to get all account liquidated events from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveAccountLiquidationsLimit(limit uint64) ([]*models.AccountLiquidated, error)

	// RetrieveUSDMintedLimit is used to get all `usdMinted` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveUSDMintedLimit(limit uint64) ([]*models.USDMinted, error)

	// RetrieveUSDBurnedLimit is used to get all `usdBurned` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveUSDBurnedLimit(limit uint64) ([]*models.USDBurned, error)

	// RetrieveDelegationUpdatedLimit is used to get all `DelegationUpdated` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveDelegationUpdatedLimit(limit uint64) ([]*models.DelegationUpdated, error)

	// RetrieveCollateralWithdrawnLimit is used to get all `Withdrawn` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveCollateralWithdrawnLimit(limit uint64) ([]*models.CollateralWithdrawn, error)

	// RetrieveCollateralDepositedLimit is used to get all `Deposited` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveCollateralDepositedLimit(limit uint64) ([]*models.CollateralDeposited, error)

	// RetrieveRewardClaimedLimit is used to get all `RewardClaimed` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveRewardClaimedLimit(limit uint64) ([]*models.RewardClaimed, error)

	// RetrieveRewardDistributedLimit is used to get all `RewardDistributed` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveRewardDistributedLimit(limit uint64) ([]*models.RewardDistributed, error)

	// RetrieveMarketUSDDepositedLimit is used to get all `MarketUSDDeposited` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveMarketUSDDepositedLimit(limit uint64) ([]*models.MarketUSDDeposited, error)

	// RetrieveMarketUSDWithdrawnLimit is used to get all `MarketUSDWithdrawn` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveMarketUSDWithdrawnLimit(limit uint64) ([]*models.MarketUSDWithdrawn, error)

	// RetrieveMarketRegistered is used to get all `MarketRegistered` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveMarketRegistered(limit uint64) ([]*models.MarketRegistered, error)

	// RetrievePoolCreated is used to get all `PoolCreated` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrievePoolCreated(limit uint64) ([]*models.PoolCreated, error)

	// RetrieveLiquidationsCore is used to get all `Liquidation` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveLiquidationsCore(limit uint64) ([]*models.CoreLiquidation, error)

	// RetrieveVaultLiquidationsCore is used to get all `VaultLiquidation` events from the Core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	RetrieveVaultLiquidationsCore(limit uint64) ([]*models.CoreVaultLiquidation, error)

	// GetPosition is used to get "Position" data struct from the latest block from the perps market with given data
	GetPosition(accountID *big.Int, marketID *big.Int) (*models.Position, error)

	// GetMarketMetadata is used to get market metadata by given market ID
	GetMarketMetadata(marketID *big.Int) (*models.MarketMetadata, error)

	// GetMarketSummary is used to get market summary by given market ID
	GetMarketSummary(marketID *big.Int) (*models.MarketSummary, error)

	// GetMarketIDs is used to get market IDs from the smart contract
	GetMarketIDs() ([]*big.Int, error)

	// GetFoundingRate is used to get current founding rate by given market ID
	GetFoundingRate(marketId *big.Int) (*big.Int, error)

	// GetAvailableMargin is used to get available margin for given account ID
	GetAvailableMargin(accountId *big.Int) (*big.Int, error)

	// GetLiquidationParameters is used to get liquidation params for given market ID
	GetLiquidationParameters(marketId *big.Int) (*models.LiquidationParameters, error)

	// GetFundingParameters is used to get funding params for given market ID
	GetFundingParameters(marketId *big.Int) (*models.FundingParameters, error)

	// GetAccountLastInteraction is used to get accounts last interaction for given account ID
	GetAccountLastInteraction(accountId *big.Int) (*big.Int, error)

	// GetAccountOwner is used to get accounts owner address for given account ID
	GetAccountOwner(accountId *big.Int) (string, error)

	// GetCollateralAmount is used to get accounts collateral amount for given market ID
	GetCollateralAmount(accountId *big.Int, marketId *big.Int) (*big.Int, error)

	// GetRequiredMaintenanceMargin is used to get required maintenance margin for given account ID
	GetRequiredMaintenanceMargin(accountId *big.Int) (*big.Int, error)

	// GetCollateralPrice is used to get collateral price for given block number and collateralType
	GetCollateralPrice(blockNumber *big.Int, collateralType common.Address) (*models.CollateralPrice, error)

	// GetVaultDebt is used to get vault debt for given pool ID and collateralType
	GetVaultDebt(poolID *big.Int, collateralType common.Address) (*big.Int, error)

	// GetVaultDebtHistorical is used to get vault debt for given pool ID, collateralType and block number
	GetVaultDebtHistorical(poolID *big.Int, collateralType common.Address, blockNumber *big.Int) (*big.Int, error)

	// GetVaultCollateral is used to get vault collateral for given pool ID and collateralType
	GetVaultCollateral(poolID *big.Int, collateralType common.Address) (amount *big.Int, value *big.Int, err error)

	// GetVaultCollateralHistorical is used to get vault collateral for given pool ID, collateralType and block number
	GetVaultCollateralHistorical(poolID *big.Int, collateralType common.Address, blockNumber *big.Int) (amount *big.Int, value *big.Int, err error)

	// GetPoolConfiguration is used to get MarketConfigurations array
	GetPoolConfiguration(poolID *big.Int) (*models.PoolConfiguration, error)

	// GetPoolName is used to get pool name from given PoolID
	GetPoolName(poolID *big.Int) (string, error)

	// GetAccountCollateralCore is used to get account collateral data for given account ID and collateral type
	GetAccountCollateralCore(accountId *big.Int, collateralType common.Address) (*models.AccountCollateral, error)

	// GetAccountAvailableCollateral is used to get account available collateral data for given account ID and collateral type
	GetAccountAvailableCollateral(accountId *big.Int, collateralType common.Address) (*big.Int, error)

	// GetCollateralConfigurations is used to get CollateralConfiguration data
	GetCollateralConfigurations(hideDisabled bool) ([]*models.CollateralConfiguration, error)

	// FormatAccount is used to get account, and it's additional data from the contract by given account id
	FormatAccount(id *big.Int) (*models.Account, error)

	// FormatAccounts is used to get all accounts and their additional data from the contract
	FormatAccounts() ([]*models.Account, error)

	// FormatAccountsLimit is used to get all accounts and their additional data from the contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	FormatAccountsLimit(limit uint64) ([]*models.Account, error)

	// FormatAccountCore is used to get all accounts and their additional data from the core contract with given block search
	// limit. For most public RPC providers the value for limit is 20 000 blocks
	FormatAccountCore(id *big.Int) (*models.Account, error)
}

IService is a service layer interface

func NewService

func NewService(
	rpc *ethclient.Client,
	conf *config.PerpsvConfig,
	core *core.Core,
	perps *perpsMarket.PerpsMarket,
) (IService, error)

NewService is used to get instance of Service

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is an implementation of IService interface

func (*Service) FormatAccount added in v0.1.2

func (s *Service) FormatAccount(id *big.Int) (*models.Account, error)

func (*Service) FormatAccountCore added in v0.11.0

func (s *Service) FormatAccountCore(id *big.Int) (*models.Account, error)

func (*Service) FormatAccounts added in v0.1.2

func (s *Service) FormatAccounts() ([]*models.Account, error)

func (*Service) FormatAccountsLimit added in v0.1.2

func (s *Service) FormatAccountsLimit(limit uint64) ([]*models.Account, error)

func (*Service) GetAccountAvailableCollateral added in v0.11.0

func (s *Service) GetAccountAvailableCollateral(accountId *big.Int, collateralType common.Address) (*big.Int, error)

func (*Service) GetAccountCollateralCore added in v0.11.0

func (s *Service) GetAccountCollateralCore(accountId *big.Int, collateralType common.Address) (*models.AccountCollateral, error)

func (*Service) GetAccountLastInteraction added in v0.1.21

func (s *Service) GetAccountLastInteraction(accountId *big.Int) (*big.Int, error)

func (*Service) GetAccountOwner added in v0.1.21

func (s *Service) GetAccountOwner(accountId *big.Int) (string, error)

func (*Service) GetAvailableMargin added in v0.1.15

func (s *Service) GetAvailableMargin(accountId *big.Int) (*big.Int, error)

func (*Service) GetCollateralAmount added in v0.3.0

func (s *Service) GetCollateralAmount(accountId *big.Int, marketId *big.Int) (*big.Int, error)

func (*Service) GetCollateralConfigurations added in v0.11.0

func (s *Service) GetCollateralConfigurations(hideDisabled bool) ([]*models.CollateralConfiguration, error)

func (*Service) GetCollateralPrice added in v0.3.10

func (s *Service) GetCollateralPrice(blockNumber *big.Int, collateralType common.Address) (*models.CollateralPrice, error)

func (*Service) GetFoundingRate added in v0.1.12

func (s *Service) GetFoundingRate(marketId *big.Int) (*big.Int, error)

func (*Service) GetFundingParameters added in v0.1.17

func (s *Service) GetFundingParameters(marketId *big.Int) (*models.FundingParameters, error)

func (*Service) GetLiquidationParameters added in v0.1.16

func (s *Service) GetLiquidationParameters(marketId *big.Int) (*models.LiquidationParameters, error)

func (*Service) GetMarketIDs added in v0.1.7

func (s *Service) GetMarketIDs() ([]*big.Int, error)

func (*Service) GetMarketMetadata added in v0.1.6

func (s *Service) GetMarketMetadata(marketID *big.Int) (*models.MarketMetadata, error)

func (*Service) GetMarketSummary added in v0.1.7

func (s *Service) GetMarketSummary(marketID *big.Int) (*models.MarketSummary, error)

func (*Service) GetPoolConfiguration added in v0.7.0

func (s *Service) GetPoolConfiguration(poolID *big.Int) (*models.PoolConfiguration, error)

func (*Service) GetPoolName added in v0.9.0

func (s *Service) GetPoolName(poolID *big.Int) (string, error)

func (*Service) GetPosition added in v0.0.2

func (s *Service) GetPosition(accountID *big.Int, marketID *big.Int) (*models.Position, error)

func (*Service) GetRequiredMaintenanceMargin added in v0.1.24

func (s *Service) GetRequiredMaintenanceMargin(accountId *big.Int) (*big.Int, error)

func (*Service) GetVaultCollateral added in v0.6.0

func (s *Service) GetVaultCollateral(poolID *big.Int, collateralType common.Address) (amount *big.Int, value *big.Int, err error)

func (*Service) GetVaultCollateralHistorical added in v0.10.0

func (s *Service) GetVaultCollateralHistorical(poolID *big.Int, collateralType common.Address, blockNumber *big.Int) (amount *big.Int, value *big.Int, err error)

func (*Service) GetVaultDebt added in v0.6.0

func (s *Service) GetVaultDebt(poolID *big.Int, collateralType common.Address) (*big.Int, error)

func (*Service) GetVaultDebtHistorical added in v0.10.0

func (s *Service) GetVaultDebtHistorical(poolID *big.Int, collateralType common.Address, blockNumber *big.Int) (*big.Int, error)

func (*Service) RetrieveAccountLiquidationsLimit added in v0.1.19

func (s *Service) RetrieveAccountLiquidationsLimit(limit uint64) ([]*models.AccountLiquidated, error)

func (*Service) RetrieveCollateralDepositedLimit added in v0.3.9

func (s *Service) RetrieveCollateralDepositedLimit(limit uint64) ([]*models.CollateralDeposited, error)

func (*Service) RetrieveCollateralWithdrawnLimit added in v0.3.9

func (s *Service) RetrieveCollateralWithdrawnLimit(limit uint64) ([]*models.CollateralWithdrawn, error)

func (*Service) RetrieveDelegationUpdatedLimit added in v0.3.8

func (s *Service) RetrieveDelegationUpdatedLimit(limit uint64) ([]*models.DelegationUpdated, error)

func (*Service) RetrieveLiquidations added in v0.1.3

func (s *Service) RetrieveLiquidations(fromBlock uint64, toBLock *uint64) ([]*models.Liquidation, error)

func (*Service) RetrieveLiquidationsCore added in v0.11.0

func (s *Service) RetrieveLiquidationsCore(limit uint64) ([]*models.CoreLiquidation, error)

func (*Service) RetrieveLiquidationsLimit added in v0.1.3

func (s *Service) RetrieveLiquidationsLimit(limit uint64) ([]*models.Liquidation, error)

func (*Service) RetrieveMarketRegistered added in v0.8.0

func (s *Service) RetrieveMarketRegistered(limit uint64) ([]*models.MarketRegistered, error)

func (*Service) RetrieveMarketUSDDepositedLimit added in v0.6.0

func (s *Service) RetrieveMarketUSDDepositedLimit(limit uint64) ([]*models.MarketUSDDeposited, error)

func (*Service) RetrieveMarketUSDWithdrawnLimit added in v0.6.0

func (s *Service) RetrieveMarketUSDWithdrawnLimit(limit uint64) ([]*models.MarketUSDWithdrawn, error)

func (*Service) RetrieveMarketUpdates added in v0.1.1

func (s *Service) RetrieveMarketUpdates(fromBlock uint64, toBLock *uint64) ([]*models.MarketUpdate, error)

func (*Service) RetrieveMarketUpdatesBig added in v0.1.8

func (s *Service) RetrieveMarketUpdatesBig(fromBlock uint64, toBLock *uint64) ([]*models.MarketUpdateBig, error)

func (*Service) RetrieveMarketUpdatesBigLimit added in v0.1.8

func (s *Service) RetrieveMarketUpdatesBigLimit(limit uint64) ([]*models.MarketUpdateBig, error)

func (*Service) RetrieveMarketUpdatesLimit added in v0.1.4

func (s *Service) RetrieveMarketUpdatesLimit(limit uint64) ([]*models.MarketUpdate, error)

func (*Service) RetrieveOrders added in v0.1.0

func (s *Service) RetrieveOrders(fromBlock uint64, toBLock *uint64) ([]*models.Order, error)

func (*Service) RetrieveOrdersLimit added in v0.1.4

func (s *Service) RetrieveOrdersLimit(limit uint64) ([]*models.Order, error)

func (*Service) RetrievePoolCreated added in v0.9.0

func (s *Service) RetrievePoolCreated(limit uint64) ([]*models.PoolCreated, error)

func (*Service) RetrieveRewardClaimedLimit added in v0.4.0

func (s *Service) RetrieveRewardClaimedLimit(limit uint64) ([]*models.RewardClaimed, error)

func (*Service) RetrieveRewardDistributedLimit added in v0.4.0

func (s *Service) RetrieveRewardDistributedLimit(limit uint64) ([]*models.RewardDistributed, error)

func (*Service) RetrieveTrades

func (s *Service) RetrieveTrades(fromBlock uint64, toBLock *uint64) ([]*models.Trade, error)

func (*Service) RetrieveTradesLimit added in v0.1.4

func (s *Service) RetrieveTradesLimit(limit uint64) ([]*models.Trade, error)

func (*Service) RetrieveUSDBurnedLimit added in v0.3.8

func (s *Service) RetrieveUSDBurnedLimit(limit uint64) ([]*models.USDBurned, error)

func (*Service) RetrieveUSDMintedLimit added in v0.3.7

func (s *Service) RetrieveUSDMintedLimit(limit uint64) ([]*models.USDMinted, error)

func (*Service) RetrieveVaultLiquidationsCore added in v0.11.0

func (s *Service) RetrieveVaultLiquidationsCore(limit uint64) ([]*models.CoreVaultLiquidation, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL