Documentation ¶
Index ¶
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 []perpsMarketGoerli.IAccountModuleAccountPermissions, ) *Account
FormatAccount is used to get account from given data
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 *perpsMarketGoerli.PerpsMarketGoerliPositionLiquidated, time uint64) *Liquidation
GetLiquidationFromEvent is used to get Liquidation struct from given contract event
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 }
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
func GetMarketSummaryFromContractModel ¶ added in v0.1.7
func GetMarketSummaryFromContractModel(summary perpsMarketGoerli.IPerpsMarketModuleMarketSummary, marketID *big.Int) *MarketSummary
GetMarketSummaryFromContractModel is used to get MarketSummary from contract data struct
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 *perpsMarketGoerli.PerpsMarketGoerliMarketUpdated, 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 *perpsMarketGoerli.PerpsMarketGoerliMarketUpdated, 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 *perpsMarketGoerli.PerpsMarketGoerliOrderCommitted, 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 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 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 *perpsMarketGoerli.PerpsMarketGoerliOrderSettled, time uint64) *Trade
GetTradeFromEvent is used to get new Trade from given event and block timestamp
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