Documentation ¶
Index ¶
- type Account
- type AccountLiquidated
- type CollateralDeposited
- type CollateralPrice
- type CollateralWithdrawn
- type DelegationUpdated
- type FundingParameters
- type Liquidation
- type LiquidationParameters
- type MarketConfiguration
- type MarketMetadata
- type MarketSummary
- type MarketUSDDeposited
- type MarketUSDWithdrawn
- type MarketUpdate
- type MarketUpdateBig
- type Order
- type Permission
- type PermissionChanged
- type PoolConfiguration
- type Position
- type PriceFeedID
- type RewardClaimed
- type RewardDistributed
- type Trade
- type USDBurned
- type USDMinted
- type UserPermissions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶ added in v0.1.2
type Account struct { ID *big.Int Permissions []*UserPermissions Owner common.Address LastInteraction uint64 }
Account is a struct for account model
- ID is an account NFT id
- Permissions is a slice of UserPermissions struct with granted permissions data
- Owner is a contract owner address
- LastInteraction is a unix timestamp for last accounts contract interaction
func FormatAccount ¶ added in v0.1.2
func FormatAccount( id *big.Int, owner common.Address, lastInteraction uint64, permissions []perpsMarket.IAccountModuleAccountPermissions, ) *Account
FormatAccount is used to get account from given data
type AccountLiquidated ¶ added in v0.1.19
AccountLiquidated is a struct for `AccountLiquidated` event
- ID is an account NFT id
- Reward is a liquidation reward transferred to caller
- FullLiquidated is a filed for define is account fully liquidated or not
type CollateralDeposited ¶ added in v0.3.9
type CollateralDeposited struct { AccountId *big.Int CollateralType common.Address TokenAmount *big.Int Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
CollateralDeposited is a `Deposited` Core smart-contract event struct
func GetCollateralDepositedFromEvent ¶ added in v0.3.9
func GetCollateralDepositedFromEvent(event *core.CoreDeposited, time uint64) *CollateralDeposited
GetCollateralDepositedFromEvent is used to get CollateralDeposited struct from given contract event
type CollateralPrice ¶ added in v0.3.10
CollateralPrice is a collateral price data struct
type CollateralWithdrawn ¶ added in v0.3.9
type CollateralWithdrawn struct { AccountId *big.Int CollateralType common.Address TokenAmount *big.Int Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
CollateralWithdrawn is a `Withdrawn` Core smart-contract event struct
func GetCollateralWithdrawnFromEvent ¶ added in v0.3.9
func GetCollateralWithdrawnFromEvent(event *core.CoreWithdrawn, time uint64) *CollateralWithdrawn
GetCollateralWithdrawnFromEvent is used to get CollateralWithdrawn struct from given contract event
type DelegationUpdated ¶ added in v0.3.8
type DelegationUpdated struct { AccountId *big.Int PoolId *big.Int CollateralType common.Address Amount *big.Int Leverage *big.Int Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
DelegationUpdated is a `DelegationUpdated` Core smart-contract event struct
func GetDelegationUpdatedFromEvent ¶ added in v0.3.8
func GetDelegationUpdatedFromEvent(event *core.CoreDelegationUpdated, time uint64) *DelegationUpdated
GetDelegationUpdatedFromEvent is used to get DelegationUpdated struct from given contract event
type FundingParameters ¶ added in v0.1.17
func GetFundingParameters ¶ added in v0.1.17
func GetFundingParameters(resp struct { SkewScale *big.Int MaxFundingVelocity *big.Int }) *FundingParameters
type Liquidation ¶ added in v0.1.3
type Liquidation struct { MarketID uint64 AccountID *big.Int AmountLiquidated *big.Int CurrentPositionSize *big.Int BlockNumber uint64 BlockTimestamp uint64 }
Liquidation is a position liquidation model
- MarketID: ID of the market used for the order.
- AccountID: ID of the account used for the order.
- AmountLiquidated: amount liquidated.
- CurrentPositionSize: position size after liquidation.
- BlockNumber: Block number where the order was committed.
- BlockTimestamp: Timestamp of the block where the order was committed.
func GetLiquidationFromEvent ¶ added in v0.1.3
func GetLiquidationFromEvent(event *perpsMarket.PerpsMarketPositionLiquidated, time uint64) *Liquidation
GetLiquidationFromEvent is used to get Liquidation struct from given contract event
type LiquidationParameters ¶ added in v0.1.16
type MarketConfiguration ¶ added in v0.7.0
func GetMarketConfigurationFromContractData ¶ added in v0.7.0
func GetMarketConfigurationFromContractData(config core.MarketConfigurationData) *MarketConfiguration
type MarketMetadata ¶ added in v0.1.6
MarketMetadata is a market metadata model
- MarketID is a market ID value
- Name is a market name value
- Symbol is a market symbol value for example 'ETH'
func GetMarketMetadataFromContractResponse ¶ added in v0.1.6
func GetMarketMetadataFromContractResponse(id *big.Int, name string, symbol string) *MarketMetadata
GetMarketMetadataFromContractResponse is used to get MarketMetadata model from given values
type MarketSummary ¶ added in v0.1.7
type MarketSummary struct { MarketID *big.Int Skew *big.Int Size *big.Int MaxOpenInterest *big.Int CurrentFundingRate *big.Int CurrentFundingVelocity *big.Int IndexPrice *big.Int BlockTimestamp uint64 }
MarketSummary is a market summary data struct
- MarketID - Represents the ID of the market
- Skew - Represents the skew of the market
- Size - Represents the size of the market
- MaxOpenInterest - Represents the maximum open interest of the market
- CurrentFundingRate - Represents the current funding rate of the market
- CurrentFundingVelocity - Represents the current funding velocity of the market
- IndexPrice - Represents the index price of the market
- BlockTimestamp: Timestamp of the block at which the market data was fetched.
func GetMarketSummaryFromContractModel ¶ added in v0.1.7
func GetMarketSummaryFromContractModel(summary perpsMarket.IPerpsMarketModuleMarketSummary, marketID *big.Int, time uint64) *MarketSummary
GetMarketSummaryFromContractModel is used to get MarketSummary from contract data struct
type MarketUSDDeposited ¶ added in v0.6.0
type MarketUSDDeposited struct { MarketId *big.Int Target common.Address Amount *big.Int Market common.Address CreditCapacity *big.Int NetIssuance *big.Int DepositedCollateralValue *big.Int ReportedDebt *big.Int BlockNumber uint64 BlockTimestamp uint64 TransactionHash string }
func GetMarketUSDDepositedFromEvent ¶ added in v0.6.0
func GetMarketUSDDepositedFromEvent(event *core.CoreMarketUsdDeposited, time uint64) *MarketUSDDeposited
type MarketUSDWithdrawn ¶ added in v0.6.0
type MarketUSDWithdrawn struct { MarketId *big.Int Target common.Address Amount *big.Int Market common.Address CreditCapacity *big.Int NetIssuance *big.Int DepositedCollateralValue *big.Int ReportedDebt *big.Int BlockNumber uint64 BlockTimestamp uint64 TransactionHash string }
func GetMarketUSDWithdrawnFromEvent ¶ added in v0.6.0
func GetMarketUSDWithdrawnFromEvent(event *core.CoreMarketUsdWithdrawn, time uint64) *MarketUSDWithdrawn
type MarketUpdate ¶ added in v0.1.1
type MarketUpdate struct { MarketID uint64 Price uint64 Skew int64 Size uint64 SizeDelta int64 CurrentFundingRate int64 CurrentFundingVelocity int64 BlockNumber uint64 BlockTimestamp uint64 TransactionHash string }
MarketUpdate
- MarketID: ID of the market.
- Price: Price at the time of the event.
- Skew: Market skew at the time of the event. Positive values indicate more longs.
- Size: Size of the entire market after settlement.
- SizeDelta: Change in market size during the update.
- CurrentFundingRate: Current funding rate of the market.
- CurrentFundingVelocity: Current rate of change of the funding rate.
- BlockNumber: Block number at which the market data was fetched.
- BlockTimestamp: Timestamp of the block at which the market data was fetched.
- TransactionHash: Hash of the transaction where the market update occurred.
func GetMarketUpdateFromEvent ¶ added in v0.1.1
func GetMarketUpdateFromEvent(event *perpsMarket.PerpsMarketMarketUpdated, time uint64) *MarketUpdate
GetMarketUpdateFromEvent is used to get MarketUpdate struct from given event and block timestamp
type MarketUpdateBig ¶ added in v0.1.8
type MarketUpdateBig struct { MarketID *big.Int Price *big.Int Skew *big.Int Size *big.Int SizeDelta *big.Int CurrentFundingRate *big.Int CurrentFundingVelocity *big.Int BlockNumber uint64 BlockTimestamp uint64 TransactionHash string }
MarketUpdateBig is a MarketUpdate model struct with big.Int value types to return data as it is received from the contract
- MarketID: ID of the market.
- Price: Price at the time of the event.
- Skew: Market skew at the time of the event. Positive values indicate more longs.
- Size: Size of the entire market after settlement.
- SizeDelta: Change in market size during the update.
- CurrentFundingRate: Current funding rate of the market.
- CurrentFundingVelocity: Current rate of change of the funding rate.
- BlockNumber: Block number at which the market data was fetched.
- BlockTimestamp: Timestamp of the block at which the market data was fetched.
- TransactionHash: Hash of the transaction where the market update occurred.
func GetMarketUpdateBigFromEvent ¶ added in v0.1.8
func GetMarketUpdateBigFromEvent(event *perpsMarket.PerpsMarketMarketUpdated, time uint64) *MarketUpdateBig
GetMarketUpdateBigFromEvent is used to get MarketUpdateBig model from given event and block timestamp
type Order ¶ added in v0.1.0
type Order struct { MarketID uint64 AccountID *big.Int OrderType uint8 SizeDelta *big.Int AcceptablePrice *big.Int SettlementTime uint64 ExpirationTime uint64 TrackingCode [32]byte Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
Order is an order event model
- MarketID: ID of the market used for the order.
- AccountID: ID of the account used for the order.
- OrderType: Represents the transaction type (0 at the time of writing).
- SizeDelta: Requested change in size of the order.
- AcceptablePrice: Maximum or minimum accepted price to settle the order.
- SettlementTime: Time at which the order can be settled.
- ExpirationTime: Time at which the order expired.
- TrackingCode: Optional code for integrator tracking purposes.
- Sender: Address of the sender of the order.
- BlockNumber: Block number where the order was committed.
- BlockTimestamp: Timestamp of the block where the order was committed.
func GetOrderFromEvent ¶ added in v0.1.0
func GetOrderFromEvent(event *perpsMarket.PerpsMarketOrderCommitted, time uint64) *Order
GetOrderFromEvent is used to get Order struct from given event and block timestamp
type Permission ¶ added in v0.1.2
type Permission int
Permission is a permission enum
const ( ADMIN Permission = iota WITHDRAW DELEGATE MINT REWARDS PERPS_MODIFY_COLLATERAL PERPS_COMMIT_ASYNC_ORDER )
func PermissionFromString ¶ added in v0.1.2
func PermissionFromString(s string) (Permission, error)
PermissionFromString is used to get Permission from string value mapped in permissionsS
func (Permission) String ¶ added in v0.1.2
func (p Permission) String() string
String is used to return Permission string value
type PermissionChanged ¶ added in v0.1.19
type PermissionChanged struct { AccountID *big.Int User common.Address Permission Permission }
PermissionChanged is a struct for `PermissionRevoked` and `PermissionGranted` contract events
type PoolConfiguration ¶ added in v0.7.0
type PoolConfiguration struct {
MarketConfigurations []*MarketConfiguration
}
func GetPoolConfigurationFromContractData ¶ added in v0.7.0
func GetPoolConfigurationFromContractData(configs []core.MarketConfigurationData) *PoolConfiguration
type Position ¶ added in v0.0.2
type Position struct { TotalPnl *big.Int AccruedFunding *big.Int PositionSize *big.Int BlockNumber uint64 BlockTimestamp uint64 }
Position
- TotalPnl: Represents the total profit and loss for the position.
- AccruedFunding: Represents the accrued funding for the position.
- PositionSize: Represents the size of the position.
- BlockNumber: Represents the block number at which the position data was fetched.
- BlockTimestamp: Represents the timestamp of the block at which the position data was fetched.
func GetPositionFromContract ¶ added in v0.0.2
GetPositionFromContract is used to get Position struct from given contract data struct and block values
type PriceFeedID ¶ added in v0.1.26
type PriceFeedID int
PriceFeedID is a permission enum
const ( UNKNOWN PriceFeedID = iota ETH BTC LINK OP SNX )
func GetPriceFeedIDFromMarketID ¶ added in v0.1.26
func GetPriceFeedIDFromMarketID(id *big.Int) PriceFeedID
GetPriceFeedIDFromMarketID is used to get PriceFeedID from given market id value
func (PriceFeedID) String ¶ added in v0.1.26
func (p PriceFeedID) String() string
String is used to return PriceFeedID string value
type RewardClaimed ¶ added in v0.4.0
type RewardClaimed struct { AccountId *big.Int PoolId *big.Int CollateralType common.Address Distributor common.Address Amount *big.Int BlockNumber uint64 BlockTimestamp uint64 }
func GetRewardClaimedFromEvent ¶ added in v0.4.0
func GetRewardClaimedFromEvent(event *core.CoreRewardsClaimed, time uint64) *RewardClaimed
type RewardDistributed ¶ added in v0.4.0
type RewardDistributed struct { PoolId *big.Int CollateralType common.Address Distributor common.Address Amount *big.Int Start *big.Int Duration *big.Int BlockNumber uint64 BlockTimestamp uint64 }
func GetRewardDistributedFromEvent ¶ added in v0.4.0
func GetRewardDistributedFromEvent(event *core.CoreRewardsDistributed, time uint64) *RewardDistributed
type Trade ¶
type Trade struct { MarketID uint64 AccountID *big.Int FillPrice *big.Int PnL *big.Int AccruedFunding *big.Int SizeDelta *big.Int NewSize *big.Int TotalFees *big.Int ReferralFees *big.Int CollectedFees *big.Int SettlementReward *big.Int TrackingCode [32]byte Settler common.Address BlockNumber uint64 BlockTimestamp uint64 TransactionHash string }
Trade is a trade event model
- MarketID - ID of the market used for the trade
- AccountID - ID of the account used for the trade
- FillPrice - Price at which the order was settled
- PnL - PL of the previous closed position
- AccruedFunding - Accrued funding of the previous closed position
- SizeDelta - Size delta from the order
- NewSize - New size of the position after settlement
- TotalFees - Amount of fees collected by the protocol
- ReferralFees - Amount of fees collected by the referrer
- CollectedFees - Amount of fees collected by the fee collector
- SettlementReward - Amount of fees collected by the settler
- TrackingCode - Optional code for integrator tracking purposes
- Settler - Address of the settler of the order
- BlockNumber - Block number where the trade was settled.
- BlockTimestamp - Timestamp of the block where the trade was settled.
- TransactionHash - Hash of the transaction where the trade was settled.
func GetTradeFromEvent ¶
func GetTradeFromEvent(event *perpsMarket.PerpsMarketOrderSettled, time uint64) *Trade
GetTradeFromEvent is used to get new Trade from given event and block timestamp
type USDBurned ¶ added in v0.3.8
type USDBurned struct { AccountId *big.Int PoolId *big.Int CollateralType common.Address Amount *big.Int Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
USDBurned is a `usdBurned` Core smart-contract event struct
func GetUSDBurnedFromEvent ¶ added in v0.3.8
func GetUSDBurnedFromEvent(event *core.CoreUsdBurned, time uint64) *USDBurned
GetUSDBurnedFromEvent is used to get USDBurned struct from given contract event
type USDMinted ¶ added in v0.3.7
type USDMinted struct { AccountId *big.Int PoolId *big.Int CollateralType common.Address Amount *big.Int Sender common.Address BlockNumber uint64 BlockTimestamp uint64 }
USDMinted is a `usdMinted` Core smart-contract event struct
func GetUSDMintedFromEvent ¶ added in v0.3.7
func GetUSDMintedFromEvent(event *core.CoreUsdMinted, time uint64) *USDMinted
GetUSDMintedFromEvent is used to get USDMinted struct from given contract event
type UserPermissions ¶ added in v0.1.2
type UserPermissions struct { User common.Address Permissions []Permission }
UserPermissions is a struct for permissions granted by account owner to User with a list of Permissions