diff --git a/docs/lighter/lighter-go-main/.gitignore b/docs/lighter/lighter-go-main/.gitignore deleted file mode 100644 index 73f90d2..0000000 --- a/docs/lighter/lighter-go-main/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.idea -vendor -build/* -!build/.keep \ No newline at end of file diff --git a/docs/lighter/lighter-go-main/README.md b/docs/lighter/lighter-go-main/README.md deleted file mode 100644 index 3a2ba49..0000000 --- a/docs/lighter/lighter-go-main/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# lighter-go - -In its current form, this repo serves as a starting point for anyone who wants to trade on Lighter using GO. -It covers all the signing procedures in order to trade on Lighter with an API key. -Minimal HTTP calls are implemented -On chain support, like depositing on Ethereum or modifying an API key directly with an Ethereum Tx are not supported yet. - -At the moment, its main purpose is to offer visibility on the code behind the precompiled libraries used by the Python SDK. -If you'd like to compile your own binaries, the commands are in the `justfile` \ No newline at end of file diff --git a/docs/lighter/lighter-go-main/types/tx_request.go b/docs/lighter/lighter-go-main/types/tx_request.go deleted file mode 100644 index e0787a8..0000000 --- a/docs/lighter/lighter-go-main/types/tx_request.go +++ /dev/null @@ -1,659 +0,0 @@ -package types - -import ( - "fmt" - "time" - - "github.com/elliottech/lighter-go/signer" - "github.com/elliottech/lighter-go/types/txtypes" - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - gFp5 "github.com/elliottech/poseidon_crypto/field/goldilocks_quintic_extension" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" - ethCommon "github.com/ethereum/go-ethereum/common" -) - -type TransactOpts struct { - FromAccountIndex *int64 - ApiKeyIndex *uint8 - ExpiredAt int64 - Nonce *int64 - DryRun bool -} - -type PublicKey = gFp5.Element - -type ChangePubKeyReq struct { - PubKey [40]byte -} - -type TransferTxReq struct { - ToAccountIndex int64 - USDCAmount int64 - Fee int64 - Memo [32]byte -} - -type WithdrawTxReq struct { - USDCAmount uint64 -} - -type CreateOrderTxReq struct { - MarketIndex uint8 - ClientOrderIndex int64 - BaseAmount int64 - Price uint32 - IsAsk uint8 - Type uint8 - TimeInForce uint8 - ReduceOnly uint8 - TriggerPrice uint32 - OrderExpiry int64 -} - -type CreateGroupedOrdersTxReq struct { - GroupingType uint8 - Orders []*CreateOrderTxReq -} - -type ModifyOrderTxReq struct { - MarketIndex uint8 - Index int64 - BaseAmount int64 - Price uint32 - TriggerPrice uint32 -} - -type CancelOrderTxReq struct { - MarketIndex uint8 - Index int64 -} - -type CancelAllOrdersTxReq struct { - TimeInForce uint8 - Time int64 -} - -type CreatePublicPoolTxReq struct { - OperatorFee int64 - InitialTotalShares int64 - MinOperatorShareRate int64 -} - -type UpdatePublicPoolTxReq struct { - PublicPoolIndex int64 - Status uint8 - OperatorFee int64 - MinOperatorShareRate int64 -} - -type MintSharesTxReq struct { - PublicPoolIndex int64 - ShareAmount int64 -} - -type BurnSharesTxReq struct { - PublicPoolIndex int64 - ShareAmount int64 -} - -type UpdateLeverageTxReq struct { - MarketIndex uint8 - InitialMarginFraction uint16 - MarginMode uint8 -} - -type UpdateMarginTxReq struct { - MarketIndex uint8 - USDCAmount int64 - Direction uint8 -} - -func ConstructAuthToken(key signer.Signer, deadline time.Time, ops *TransactOpts) (string, error) { - if ops.FromAccountIndex == nil { - return "", fmt.Errorf("missing FromAccountIndex") - } - if ops.ApiKeyIndex == nil { - return "", fmt.Errorf("missing ApiKeyIndex") - } - message := fmt.Sprintf("%v:%v:%v", deadline.Unix(), *ops.FromAccountIndex, *ops.ApiKeyIndex) - - msgInField, err := g.ArrayFromCanonicalLittleEndianBytes([]byte(message)) - if err != nil { - return "", fmt.Errorf("failed to convert bytes to field element. message: %s, error: %w", message, err) - } - - msgHash := p2.HashToQuinticExtension(msgInField).ToLittleEndianBytes() - - signatureBytes, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return "", err - } - signature := ethCommon.Bytes2Hex(signatureBytes) - - return fmt.Sprintf("%v:%v", message, signature), err -} - -func ConstructChangePubKeyTx(key signer.Signer, lighterChainId uint32, tx *ChangePubKeyReq, ops *TransactOpts) (*txtypes.L2ChangePubKeyTxInfo, error) { - convertedTx := ConvertChangePubKeyTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructCreateSubAccountTx(key signer.Signer, lighterChainId uint32, ops *TransactOpts) (*txtypes.L2CreateSubAccountTxInfo, error) { - convertedTx := ConvertCreateSubAccountTx(ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructCreatePublicPoolTx(key signer.Signer, lighterChainId uint32, tx *CreatePublicPoolTxReq, ops *TransactOpts) (*txtypes.L2CreatePublicPoolTxInfo, error) { - convertedTx := ConvertCreatePublicPoolTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructUpdatePublicPoolTx(key signer.Signer, lighterChainId uint32, tx *UpdatePublicPoolTxReq, ops *TransactOpts) (*txtypes.L2UpdatePublicPoolTxInfo, error) { - convertedTx := ConvertUpdatePublicPoolTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructWithdrawTx(key signer.Signer, lighterChainId uint32, tx *WithdrawTxReq, ops *TransactOpts) (*txtypes.L2WithdrawTxInfo, error) { - convertedTx := ConvertWithdrawTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructCreateOrderTx(key signer.Signer, lighterChainId uint32, tx *CreateOrderTxReq, ops *TransactOpts) (*txtypes.L2CreateOrderTxInfo, error) { - convertedTx := ConvertCreateOrderTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructL2CreateGroupedOrdersTx(key signer.Signer, lighterChainId uint32, tx *CreateGroupedOrdersTxReq, ops *TransactOpts) (*txtypes.L2CreateGroupedOrdersTxInfo, error) { - convertedTx := ConvertCreateGroupedOrdersTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructL2CancelOrderTx(key signer.Signer, lighterChainId uint32, tx *CancelOrderTxReq, ops *TransactOpts) (*txtypes.L2CancelOrderTxInfo, error) { - convertedTx := ConvertCancelOrderTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructL2ModifyOrderTx(key signer.Signer, lighterChainId uint32, tx *ModifyOrderTxReq, ops *TransactOpts) (*txtypes.L2ModifyOrderTxInfo, error) { - convertedTx := ConvertModifyOrderTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructL2CancelAllOrdersTx(key signer.Signer, lighterChainId uint32, tx *CancelAllOrdersTxReq, ops *TransactOpts) (*txtypes.L2CancelAllOrdersTxInfo, error) { - convertedTx := ConvertCancelAllOrdersTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructTransferTx(key signer.Signer, lighterChainId uint32, tx *TransferTxReq, ops *TransactOpts) (*txtypes.L2TransferTxInfo, error) { - convertedTx := ConvertTransferTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructMintSharesTx(key signer.Signer, lighterChainId uint32, tx *MintSharesTxReq, ops *TransactOpts) (*txtypes.L2MintSharesTxInfo, error) { - convertedTx := ConvertMintSharesTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructBurnSharesTx(key signer.Signer, lighterChainId uint32, tx *BurnSharesTxReq, ops *TransactOpts) (*txtypes.L2BurnSharesTxInfo, error) { - convertedTx := ConvertBurnSharesTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructUpdateLeverageTx(key signer.Signer, lighterChainId uint32, tx *UpdateLeverageTxReq, ops *TransactOpts) (*txtypes.L2UpdateLeverageTxInfo, error) { - convertedTx := ConvertUpdateLeverageTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConstructUpdateMarginTx(key signer.Signer, lighterChainId uint32, tx *UpdateMarginTxReq, ops *TransactOpts) (*txtypes.L2UpdateMarginTxInfo, error) { - convertedTx := ConvertUpdateMarginTx(tx, ops) - err := convertedTx.Validate() - if err != nil { - return nil, err - } - - msgHash, err := convertedTx.Hash(lighterChainId) - if err != nil { - return nil, err - } - - signature, err := key.Sign(msgHash, p2.NewPoseidon2()) - if err != nil { - return nil, err - } - - convertedTx.SignedHash = ethCommon.Bytes2Hex(msgHash) - convertedTx.Sig = signature - return convertedTx, nil -} - -func ConvertTransferTx(tx *TransferTxReq, ops *TransactOpts) *txtypes.L2TransferTxInfo { - return &txtypes.L2TransferTxInfo{ - FromAccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - ToAccountIndex: tx.ToAccountIndex, - USDCAmount: tx.USDCAmount, - Fee: tx.Fee, - Memo: tx.Memo, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertCreateOrderTx(tx *CreateOrderTxReq, ops *TransactOpts) *txtypes.L2CreateOrderTxInfo { - return &txtypes.L2CreateOrderTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - OrderInfo: &txtypes.OrderInfo{MarketIndex: tx.MarketIndex, - ClientOrderIndex: tx.ClientOrderIndex, - BaseAmount: tx.BaseAmount, - Price: tx.Price, - IsAsk: tx.IsAsk, - Type: tx.Type, - TimeInForce: tx.TimeInForce, - ReduceOnly: tx.ReduceOnly, - TriggerPrice: tx.TriggerPrice, - OrderExpiry: tx.OrderExpiry, - }, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertCreateGroupedOrdersTx(tx *CreateGroupedOrdersTxReq, ops *TransactOpts) *txtypes.L2CreateGroupedOrdersTxInfo { - ret := &txtypes.L2CreateGroupedOrdersTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - GroupingType: tx.GroupingType, - Orders: []*txtypes.OrderInfo{}, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } - - for _, order := range tx.Orders { - ret.Orders = append(ret.Orders, &txtypes.OrderInfo{ - MarketIndex: order.MarketIndex, - ClientOrderIndex: order.ClientOrderIndex, - BaseAmount: order.BaseAmount, - Price: order.Price, - IsAsk: order.IsAsk, - Type: order.Type, - TimeInForce: order.TimeInForce, - ReduceOnly: order.ReduceOnly, - TriggerPrice: order.TriggerPrice, - OrderExpiry: order.OrderExpiry, - }) - } - return ret -} - -func ConvertCancelOrderTx(tx *CancelOrderTxReq, ops *TransactOpts) *txtypes.L2CancelOrderTxInfo { - return &txtypes.L2CancelOrderTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - MarketIndex: tx.MarketIndex, - Index: tx.Index, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertModifyOrderTx(tx *ModifyOrderTxReq, ops *TransactOpts) *txtypes.L2ModifyOrderTxInfo { - return &txtypes.L2ModifyOrderTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - MarketIndex: tx.MarketIndex, - Index: tx.Index, - BaseAmount: tx.BaseAmount, - Price: tx.Price, - TriggerPrice: tx.TriggerPrice, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertCancelAllOrdersTx(tx *CancelAllOrdersTxReq, ops *TransactOpts) *txtypes.L2CancelAllOrdersTxInfo { - return &txtypes.L2CancelAllOrdersTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - TimeInForce: tx.TimeInForce, - Time: tx.Time, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertWithdrawTx(tx *WithdrawTxReq, ops *TransactOpts) *txtypes.L2WithdrawTxInfo { - return &txtypes.L2WithdrawTxInfo{ - FromAccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - USDCAmount: tx.USDCAmount, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertChangePubKeyTx(tx *ChangePubKeyReq, ops *TransactOpts) *txtypes.L2ChangePubKeyTxInfo { - return &txtypes.L2ChangePubKeyTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - PubKey: tx.PubKey[:], - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertCreateSubAccountTx(ops *TransactOpts) *txtypes.L2CreateSubAccountTxInfo { - return &txtypes.L2CreateSubAccountTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertCreatePublicPoolTx(tx *CreatePublicPoolTxReq, ops *TransactOpts) *txtypes.L2CreatePublicPoolTxInfo { - return &txtypes.L2CreatePublicPoolTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - OperatorFee: tx.OperatorFee, - InitialTotalShares: tx.InitialTotalShares, - MinOperatorShareRate: tx.MinOperatorShareRate, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertUpdatePublicPoolTx(tx *UpdatePublicPoolTxReq, ops *TransactOpts) *txtypes.L2UpdatePublicPoolTxInfo { - return &txtypes.L2UpdatePublicPoolTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - PublicPoolIndex: tx.PublicPoolIndex, - Status: tx.Status, - OperatorFee: tx.OperatorFee, - MinOperatorShareRate: tx.MinOperatorShareRate, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertMintSharesTx(tx *MintSharesTxReq, ops *TransactOpts) *txtypes.L2MintSharesTxInfo { - return &txtypes.L2MintSharesTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - PublicPoolIndex: tx.PublicPoolIndex, - ShareAmount: tx.ShareAmount, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertBurnSharesTx(tx *BurnSharesTxReq, ops *TransactOpts) *txtypes.L2BurnSharesTxInfo { - return &txtypes.L2BurnSharesTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - PublicPoolIndex: tx.PublicPoolIndex, - ShareAmount: tx.ShareAmount, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertUpdateLeverageTx(tx *UpdateLeverageTxReq, ops *TransactOpts) *txtypes.L2UpdateLeverageTxInfo { - return &txtypes.L2UpdateLeverageTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - MarketIndex: tx.MarketIndex, - InitialMarginFraction: tx.InitialMarginFraction, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} - -func ConvertUpdateMarginTx(tx *UpdateMarginTxReq, ops *TransactOpts) *txtypes.L2UpdateMarginTxInfo { - return &txtypes.L2UpdateMarginTxInfo{ - AccountIndex: *ops.FromAccountIndex, - ApiKeyIndex: *ops.ApiKeyIndex, - MarketIndex: tx.MarketIndex, - USDCAmount: tx.USDCAmount, - Direction: tx.Direction, - ExpiredAt: ops.ExpiredAt, - Nonce: *ops.Nonce, - } -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/burn_shares.go b/docs/lighter/lighter-go-main/types/txtypes/burn_shares.go deleted file mode 100644 index 6b44c9c..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/burn_shares.go +++ /dev/null @@ -1,91 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2BurnSharesTxInfo)(nil) - -type L2BurnSharesTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - PublicPoolIndex int64 - ShareAmount int64 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2BurnSharesTxInfo) GetTxType() uint8 { - return TxTypeL2BurnShares -} - -func (txInfo *L2BurnSharesTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2BurnSharesTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2BurnSharesTxInfo) Validate() error { - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // PublicPoolIndex - if txInfo.PublicPoolIndex < MinAccountIndex { - return ErrPublicPoolIndexTooLow - } - if txInfo.PublicPoolIndex > MaxAccountIndex { - return ErrPublicPoolIndexTooHigh - } - - if txInfo.ShareAmount < MinPoolSharesToMintOrBurn { - return ErrPoolBurnShareAmountTooLow - } - if txInfo.ShareAmount > MaxPoolSharesToMintOrBurn { - return ErrPoolBurnShareAmountTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2BurnSharesTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 8) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2BurnShares)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(txInfo.PublicPoolIndex)) - elems = append(elems, g.FromInt64(txInfo.ShareAmount)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/cancel_all_orders.go b/docs/lighter/lighter-go-main/types/txtypes/cancel_all_orders.go deleted file mode 100644 index b1afb3d..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/cancel_all_orders.go +++ /dev/null @@ -1,95 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CancelAllOrdersTxInfo)(nil) - -type L2CancelAllOrdersTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - TimeInForce uint8 - Time int64 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CancelAllOrdersTxInfo) GetTxType() uint8 { - return TxTypeL2CancelAllOrders -} - -func (txInfo *L2CancelAllOrdersTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CancelAllOrdersTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CancelAllOrdersTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrAccountIndexTooHigh - } - - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex && txInfo.ApiKeyIndex != NilApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - // TimeInForce and Time - switch txInfo.TimeInForce { - case ImmediateCancelAll: - if txInfo.Time != NilOrderExpiry { - return ErrCancelAllTimeisNotNill - } - case ScheduledCancelAll: - if txInfo.Time < MinOrderExpiry || txInfo.Time > MaxOrderExpiry { - return ErrCancelAllTimeIsNotInRange - } - case AbortScheduledCancelAll: - if txInfo.Time != 0 { - return ErrCancelAllTimeIsNotInRange - } - default: - return ErrInvalidCancelAllTimeInForce - } - - return nil -} - -func (txInfo *L2CancelAllOrdersTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 8) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CancelAllOrders)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint32(uint32(txInfo.TimeInForce))) - elems = append(elems, g.FromInt64(txInfo.Time)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/cancel_order.go b/docs/lighter/lighter-go-main/types/txtypes/cancel_order.go deleted file mode 100644 index 923f22c..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/cancel_order.go +++ /dev/null @@ -1,94 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CancelOrderTxInfo)(nil) - -type L2CancelOrderTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - MarketIndex uint8 - Index int64 // Client Order Index or Order Index of the order to cancel - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CancelOrderTxInfo) GetTxType() uint8 { - return TxTypeL2CancelOrder -} - -func (txInfo *L2CancelOrderTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CancelOrderTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CancelOrderTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // MarketIndex - if txInfo.MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - // Index - if txInfo.Index < MinClientOrderIndex && txInfo.Index < MinOrderIndex { - return ErrOrderIndexTooLow - } - if txInfo.Index > MaxClientOrderIndex && txInfo.Index > MaxOrderIndex { - return ErrOrderIndexTooHigh - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2CancelOrderTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 7) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CancelOrder)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint32(uint32(txInfo.MarketIndex))) - elems = append(elems, g.FromInt64(txInfo.Index)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/change_pub_key.go b/docs/lighter/lighter-go-main/types/txtypes/change_pub_key.go deleted file mode 100644 index 85a86c5..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/change_pub_key.go +++ /dev/null @@ -1,121 +0,0 @@ -package txtypes - -import ( - "fmt" - "strings" - - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" -) - -const ( - templateChangePubKey = "Register Lighter Account\n\npubkey: 0x%s\nnonce: %s\naccount index: %s\napi key index: %s\nOnly sign this message for a trusted client!" -) - -func getHex10FromUint64(value uint64) string { - v := hexutil.EncodeUint64(value) - v = strings.Replace(v, "0x", "", 1) - - // Make sure result has fixed bytes - vBytes := []byte(v) - if len(vBytes) < 16 { - toAppend := make([]byte, 16-len(vBytes)) - for i := range toAppend { - toAppend[i] = 48 - } - vBytes = append(toAppend, vBytes...) - } - - return fmt.Sprintf("0x%s", string(vBytes)) -} - -var _ TxInfo = (*L2ChangePubKeyTxInfo)(nil) - -type L2ChangePubKeyTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - PubKey []byte - L1Sig string - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2ChangePubKeyTxInfo) GetTxType() uint8 { - return TxTypeL2ChangePubKey -} - -func (txInfo *L2ChangePubKeyTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2ChangePubKeyTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2ChangePubKeyTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - if !IsValidPubKey(txInfo.PubKey) { - return ErrPubKeyInvalid - } - - return nil -} - -func (txInfo *L2ChangePubKeyTxInfo) GetL1SignatureBody() string { - signatureBody := fmt.Sprintf(templateChangePubKey, - common.Bytes2Hex(txInfo.PubKey), - getHex10FromUint64(uint64(txInfo.Nonce)), - getHex10FromUint64(uint64(txInfo.AccountIndex)), - getHex10FromUint64(uint64(txInfo.ApiKeyIndex)), - ) - return signatureBody -} - -func (txInfo *L2ChangePubKeyTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 11) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2ChangePubKey)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - - pubKeyFieldElems, err := g.ArrayFromCanonicalLittleEndianBytes(txInfo.PubKey) - if err != nil { - return nil, fmt.Errorf("failed to convert bytes to field element. bytes: %v, error: %w", txInfo.PubKey, err) - } - elems = append(elems, pubKeyFieldElems...) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/constants.go b/docs/lighter/lighter-go-main/types/txtypes/constants.go deleted file mode 100644 index c279dcd..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/constants.go +++ /dev/null @@ -1,175 +0,0 @@ -package txtypes - -import ( - "math" - - curve "github.com/elliottech/poseidon_crypto/curve/ecgfp5" - schnorr "github.com/elliottech/poseidon_crypto/signature/schnorr" -) - -type ( - Signature = schnorr.Signature - PrivateKey = curve.ECgFp5Scalar -) - -const ( - NilApiKeyIndex = MaxApiKeyIndex + 1 -) - -const ( - TxTypeL2ChangePubKey = 8 - TxTypeL2CreateSubAccount = 9 - TxTypeL2CreatePublicPool = 10 - TxTypeL2UpdatePublicPool = 11 - TxTypeL2Transfer = 12 - TxTypeL2Withdraw = 13 - TxTypeL2CreateOrder = 14 - TxTypeL2CancelOrder = 15 - TxTypeL2CancelAllOrders = 16 - TxTypeL2ModifyOrder = 17 - TxTypeL2MintShares = 18 - TxTypeL2BurnShares = 19 - TxTypeL2UpdateLeverage = 20 - - TxTypeInternalClaimOrder = 21 - TxTypeInternalCancelOrder = 22 - TxTypeInternalDeleverage = 23 - TxTypeInternalExitPosition = 24 - TxTypeInternalCancelAllOrders = 25 - TxTypeInternalLiquidatePosition = 26 - TxTypeInternalCreateOrder = 27 - - TxTypeL2CreateGroupedOrders = 28 - TxTypeL2UpdateMargin = 29 -) - -// Order Type -const ( - // User set order types - LimitOrder = iota - MarketOrder = 1 - StopLossOrder = 2 - StopLossLimitOrder = 3 - TakeProfitOrder = 4 - TakeProfitLimitOrder = 5 - TWAPOrder = 6 - - // Internal order types - TWAPSubOrder = 7 - LiquidationOrder = 8 - - ApiMaxOrderType = TWAPOrder -) - -// Order Time-In-Force -const ( - ImmediateOrCancel = iota - GoodTillTime = 1 - PostOnly = 2 -) - -// Grouping Type -const ( - GroupingType = 0 - GroupingType_OneTriggersTheOther = 1 - GroupingType_OneCancelsTheOther = 2 - GroupingType_OneTriggersAOneCancelsTheOther = 3 -) - -// Cancel All Orders Time-In-Force -const ( - ImmediateCancelAll = iota - ScheduledCancelAll = 1 - AbortScheduledCancelAll = 2 -) - -const ( - HashLength int = 32 - - OneUSDC = 1000000 - - FeeTick int64 = 1_000_000 - MarginFractionTick int64 = 10_000 - ShareTick int64 = 10_000 - - MinAccountIndex int64 = 0 - MaxAccountIndex int64 = 281474976710654 // (1 << 48) - 2 - MinApiKeyIndex uint8 = 0 - MaxApiKeyIndex uint8 = 254 // (1 << 8) - 2 - MaxMasterAccountIndex int64 = 140737488355327 // (1 << 47) - 1 - - MinMarketIndex uint8 = 0 - MaxMarketIndex uint8 = 254 // (1 << 8) - 2 - - MaxInvestedPublicPoolCount int64 = 16 - InitialPoolShareValue int64 = 1_000 // 0.001 USDC - MinInitialTotalShares int64 = 1_000 * (OneUSDC / InitialPoolShareValue) // 1,000 USDC worth of shares - MaxInitialTotalShares int64 = 1_000_000_000 * (OneUSDC / InitialPoolShareValue) // 1,000,000,000 USDC worth of shares - MaxPoolShares int64 = (1 << 60) - 1 - MaxBurntShareUSDCValue int64 = (1 << 60) - 1 - - MaxPoolEntryUSDC = (1 << 56) - 1 // 2^56 - 1 max USDC to invest in a pool - MinPoolSharesToMintOrBurn int64 = 1 - MaxPoolSharesToMintOrBurn int64 = (1 << 60) - 1 - - MinNonce int64 = 0 - - MinOrderNonce int64 = 0 - MaxOrderNonce int64 = (1 << 48) - 1 - - NilClientOrderIndex int64 = 0 - NilOrderIndex int64 = 0 - - MinClientOrderIndex int64 = 1 - MaxClientOrderIndex int64 = (1 << 48) - 1 - - MinOrderIndex int64 = MaxClientOrderIndex + 1 - MaxOrderIndex int64 = (1 << 56) - 1 - - MinOrderBaseAmount int64 = 1 - MaxOrderBaseAmount int64 = (1 << 48) - 1 - NilOrderBaseAmount int64 = 0 - - NilOrderPrice uint32 = 0 - MinOrderPrice uint32 = 1 - MaxOrderPrice uint32 = (1 << 32) - 1 - - MinOrderCancelAllPeriod int64 = 1000 * 60 * 5 // 5 minutes - MaxOrderCancelAllPeriod int64 = 1000 * 60 * 60 * 24 * 15 // 15 days - - NilOrderExpiry int64 = 0 - MinOrderExpiry int64 = 1 - MaxOrderExpiry int64 = math.MaxInt64 - - MinOrderExpiryPeriod int64 = 1000 * 60 * 5 // 5 minutes - MaxOrderExpiryPeriod int64 = 1000 * 60 * 60 * 24 * 30 // 30 days - - NilOrderTriggerPrice uint32 = 0 - MinOrderTriggerPrice uint32 = 1 - MaxOrderTriggerPrice uint32 = (1 << 32) - 1 - - MaxGroupedOrderCount int64 = 3 - - MaxTimestamp = (1 << 48) - 1 -) - -const ( - MaxExchangeUSDC = (1 << 60) - 1 - - MinTransferAmount int64 = 1 - MaxTransferAmount int64 = MaxExchangeUSDC - - MinWithdrawalAmount uint64 = 1 - MaxWithdrawalAmount uint64 = MaxExchangeUSDC -) - -// Margin Modes -const ( - CrossMargin = iota - IsolatedMargin = 1 -) - -const ( - RemoveFromIsolatedMargin = 0 - AddToIsolatedMargin = 1 -) diff --git a/docs/lighter/lighter-go-main/types/txtypes/create_grouped_orders.go b/docs/lighter/lighter-go-main/types/txtypes/create_grouped_orders.go deleted file mode 100644 index 4a671c5..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/create_grouped_orders.go +++ /dev/null @@ -1,336 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CreateGroupedOrdersTxInfo)(nil) - -// !!! Ensure that if primary order is reduce only, all child orders are also reduce only -// !!! Otherwise CancelPositionTiedAccountOrders flow breaks -type L2CreateGroupedOrdersTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - GroupingType uint8 - - Orders []*OrderInfo - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) GetTxType() uint8 { - return TxTypeL2CreateGroupedOrders -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrAccountIndexTooHigh - } - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - if len(txInfo.Orders) == 0 || len(txInfo.Orders) > int(MaxGroupedOrderCount) { - return ErrOrderGroupSizeInvalid - } - - // MarketIndex for first order - if txInfo.Orders[0].MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.Orders[0].MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - // Perform range checks for all orders - for _, order := range txInfo.Orders { - // MarketIndex - if order.MarketIndex != txInfo.Orders[0].MarketIndex { - return ErrMarketIndexMismatch - } - - // ClientOrderIndex - if order.ClientOrderIndex != NilClientOrderIndex { - return ErrClientOrderIndexNotNil - } - - // BaseAmount - if order.ReduceOnly != 1 && order.BaseAmount == NilOrderBaseAmount { - return ErrBaseAmountTooLow - } - if order.BaseAmount != NilOrderBaseAmount && order.BaseAmount < MinOrderBaseAmount { - return ErrBaseAmountTooLow - } - if order.BaseAmount > MaxOrderBaseAmount { - return ErrBaseAmountTooHigh - } - - // Price - if order.Price < MinOrderPrice { - return ErrPriceTooLow - } - if order.Price > MaxOrderPrice { - return ErrPriceTooHigh - } - - // IsAsk - if order.IsAsk != 0 && order.IsAsk != 1 { - return ErrIsAskInvalid - } - - // TimeInForce - if order.TimeInForce != ImmediateOrCancel && order.TimeInForce != GoodTillTime && order.TimeInForce != PostOnly { - return ErrOrderTimeInForceInvalid - } - - // ReduceOnly - if order.ReduceOnly != 0 && order.ReduceOnly != 1 { - return ErrOrderReduceOnlyInvalid - } - - // OrderExpiry - if (order.OrderExpiry < MinOrderExpiry || order.OrderExpiry > MaxOrderExpiry) && order.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } - - // TriggerPrice - if (order.TriggerPrice < MinOrderTriggerPrice || order.TriggerPrice > MaxOrderTriggerPrice) && order.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - switch txInfo.GroupingType { - case GroupingType_OneCancelsTheOther: - return txInfo.ValidateOCO() - case GroupingType_OneTriggersTheOther: - return txInfo.ValidateOTO() - case GroupingType_OneTriggersAOneCancelsTheOther: - return txInfo.ValidateOTOCO() - default: - return ErrGroupingTypeInvalid - } -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateParentOrder(order *OrderInfo) error { - switch order.Type { - case MarketOrder: - if order.TimeInForce != ImmediateOrCancel { - return ErrOrderTimeInForceInvalid - } else if order.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } else if order.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } - case LimitOrder: - if order.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if order.TimeInForce == ImmediateOrCancel && order.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } else if order.TimeInForce != ImmediateOrCancel && order.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - default: - return ErrOrderTypeInvalid - } - return nil -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateChildOrder(order *OrderInfo) error { - switch order.Type { - case StopLossOrder, TakeProfitOrder: - if order.TimeInForce != ImmediateOrCancel { - return ErrOrderTimeInForceInvalid - } else if order.TriggerPrice == NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if order.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - case StopLossLimitOrder, TakeProfitLimitOrder: - if order.TriggerPrice == NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if order.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - default: - return ErrOrderTypeInvalid - } - return nil -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateSiblingOrders(orders []*OrderInfo) error { - if len(orders) != 2 { - return ErrOrderGroupSizeInvalid - } - slFlag := false - tpFlag := false - for _, order := range orders { - err := txInfo.ValidateChildOrder(order) - if err != nil { - return err - } - if order.Type == StopLossOrder || order.Type == StopLossLimitOrder { - slFlag = true - } else if order.Type == TakeProfitOrder || order.Type == TakeProfitLimitOrder { - tpFlag = true - } - } - if !slFlag || !tpFlag { - return ErrOrderTypeInvalid - } - return nil -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateOCO() error { - if len(txInfo.Orders) != 2 { - return ErrOrderGroupSizeInvalid - } - - // Ensure both orders base sizes are same - if txInfo.Orders[0].BaseAmount != txInfo.Orders[1].BaseAmount { - return ErrBaseAmountsNotEqual - } - - // Orders should be in the same direction - if txInfo.Orders[0].IsAsk != txInfo.Orders[1].IsAsk { - return ErrIsAskInvalid - } - - // Ensure both orders are reduce only - if txInfo.Orders[0].ReduceOnly != 1 || txInfo.Orders[1].ReduceOnly != 1 { - return ErrOrderReduceOnlyInvalid - } - - // Ensure both orders have the same non-nil expiry - if txInfo.Orders[0].OrderExpiry != txInfo.Orders[1].OrderExpiry { - return ErrOrderExpiryInvalid - } - - return txInfo.ValidateSiblingOrders(txInfo.Orders) -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateOTO() error { - if len(txInfo.Orders) != 2 { - return ErrOrderGroupSizeInvalid - } - - // Ensure child order base size is 0 - if txInfo.Orders[1].BaseAmount != NilOrderBaseAmount { - return ErrBaseAmountNotNil - } - - // Orders should be in the opposite direction - if txInfo.Orders[0].IsAsk == txInfo.Orders[1].IsAsk { - return ErrIsAskInvalid - } - - // Ensure if expiries are not nil, they are the same - if txInfo.Orders[0].OrderExpiry != NilOrderExpiry && - txInfo.Orders[0].OrderExpiry != txInfo.Orders[1].OrderExpiry { - return ErrOrderExpiryInvalid - } - - err := txInfo.ValidateParentOrder(txInfo.Orders[0]) - if err != nil { - return err - } - - return txInfo.ValidateChildOrder(txInfo.Orders[1]) -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) ValidateOTOCO() error { - if len(txInfo.Orders) != 3 { - return ErrOrderGroupSizeInvalid - } - - // Ensure child orders base size is 0 - if txInfo.Orders[1].BaseAmount != NilOrderBaseAmount || txInfo.Orders[2].BaseAmount != NilOrderBaseAmount { - return ErrBaseAmountNotNil - } - - // Primary and child orders should be in the oppsite direction - if txInfo.Orders[0].IsAsk == txInfo.Orders[1].IsAsk || txInfo.Orders[0].IsAsk == txInfo.Orders[2].IsAsk { - return ErrIsAskInvalid - } - - // Ensure child orders has the same expiry - if txInfo.Orders[1].OrderExpiry != txInfo.Orders[2].OrderExpiry { - return ErrOrderExpiryInvalid - } - - // Ensure if expiries are not nil, they are the same - if txInfo.Orders[0].OrderExpiry != NilOrderExpiry && - txInfo.Orders[0].OrderExpiry != txInfo.Orders[1].OrderExpiry { - return ErrOrderExpiryInvalid - } - - err := txInfo.ValidateParentOrder(txInfo.Orders[0]) - if err != nil { - return err - } - return txInfo.ValidateSiblingOrders(txInfo.Orders[1:]) -} - -func (txInfo *L2CreateGroupedOrdersTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 11) - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CreateGroupedOrders)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint32(uint32(txInfo.GroupingType))) - - aggregatedOrderHash := p2.EmptyHashOut() - for index, order := range txInfo.Orders { - orderHash := p2.HashNoPad([]g.Element{ - g.FromUint32(uint32(order.MarketIndex)), - g.FromInt64(order.ClientOrderIndex), - g.FromInt64(order.BaseAmount), - g.FromUint32(order.Price), - g.FromUint32(uint32(order.IsAsk)), - g.FromUint32(uint32(order.Type)), - g.FromUint32(uint32(order.TimeInForce)), - g.FromUint32(uint32(order.ReduceOnly)), - g.FromUint32(order.TriggerPrice), - g.FromInt64(order.OrderExpiry), - }) - if index == 0 { - aggregatedOrderHash = orderHash - } else { - aggregatedOrderHash = p2.HashNToOne([]p2.HashOut{aggregatedOrderHash, orderHash}) - } - } - elems = append(elems, aggregatedOrderHash[:]...) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/create_order.go b/docs/lighter/lighter-go-main/types/txtypes/create_order.go deleted file mode 100644 index 29a2889..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/create_order.go +++ /dev/null @@ -1,186 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CreateOrderTxInfo)(nil) - -type L2CreateOrderTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - *OrderInfo - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CreateOrderTxInfo) GetTxType() uint8 { - return TxTypeL2CreateOrder -} - -func (txInfo *L2CreateOrderTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CreateOrderTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CreateOrderTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrAccountIndexTooHigh - } - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // MarketIndex - if txInfo.MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - // ClientOrderIndex - if txInfo.ClientOrderIndex != NilClientOrderIndex { - if txInfo.ClientOrderIndex < MinClientOrderIndex { - return ErrClientOrderIndexTooLow - } - if txInfo.ClientOrderIndex > MaxClientOrderIndex { - return ErrClientOrderIndexTooHigh - } - } - - // BaseAmount - if txInfo.ReduceOnly != 1 && txInfo.BaseAmount == NilOrderBaseAmount { - return ErrBaseAmountTooLow - } - if txInfo.BaseAmount != NilOrderBaseAmount && txInfo.BaseAmount < MinOrderBaseAmount { - return ErrBaseAmountTooLow - } - if txInfo.BaseAmount > MaxOrderBaseAmount { - return ErrBaseAmountTooHigh - } - - // Price - if txInfo.Price < MinOrderPrice { - return ErrPriceTooLow - } - if txInfo.Price > MaxOrderPrice { - return ErrPriceTooHigh - } - - // IsAsk - if txInfo.IsAsk != 0 && txInfo.IsAsk != 1 { - return ErrIsAskInvalid - } - - if txInfo.TimeInForce != ImmediateOrCancel && txInfo.TimeInForce != GoodTillTime && txInfo.TimeInForce != PostOnly { - return ErrOrderTimeInForceInvalid - } - - if txInfo.ReduceOnly != 0 && txInfo.ReduceOnly != 1 { - return ErrOrderReduceOnlyInvalid - } - - if (txInfo.OrderExpiry < MinOrderExpiry || txInfo.OrderExpiry > MaxOrderExpiry) && txInfo.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } - - switch txInfo.Type { - case MarketOrder: - if txInfo.TimeInForce != ImmediateOrCancel { - return ErrOrderTimeInForceInvalid - } else if txInfo.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } else if txInfo.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } - case LimitOrder: - if txInfo.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if txInfo.TimeInForce == ImmediateOrCancel && txInfo.OrderExpiry != NilOrderExpiry { - return ErrOrderExpiryInvalid - } else if txInfo.TimeInForce != ImmediateOrCancel && txInfo.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - case StopLossOrder, TakeProfitOrder: - if txInfo.TimeInForce != ImmediateOrCancel { - return ErrOrderTimeInForceInvalid - } else if txInfo.TriggerPrice == NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if txInfo.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - case StopLossLimitOrder, TakeProfitLimitOrder: - if txInfo.TriggerPrice == NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if txInfo.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - case TWAPOrder: - if txInfo.TimeInForce != GoodTillTime { - return ErrOrderTimeInForceInvalid - } else if txInfo.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } else if txInfo.OrderExpiry == NilOrderExpiry { - return ErrOrderExpiryInvalid - } - default: - return ErrOrderTypeInvalid - } - - // TriggerPrice - if (txInfo.TriggerPrice < MinOrderTriggerPrice || txInfo.TriggerPrice > MaxOrderTriggerPrice) && txInfo.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2CreateOrderTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 16) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CreateOrder)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint32(uint32(txInfo.MarketIndex))) - elems = append(elems, g.FromInt64(txInfo.ClientOrderIndex)) - elems = append(elems, g.FromInt64(txInfo.BaseAmount)) - elems = append(elems, g.FromUint32(txInfo.Price)) - elems = append(elems, g.FromUint32(uint32(txInfo.IsAsk))) - elems = append(elems, g.FromUint32(uint32(txInfo.Type))) - elems = append(elems, g.FromUint32(uint32(txInfo.TimeInForce))) - elems = append(elems, g.FromUint32(uint32(txInfo.ReduceOnly))) - elems = append(elems, g.FromUint32(txInfo.TriggerPrice)) - elems = append(elems, g.FromInt64(txInfo.OrderExpiry)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/create_public_pool.go b/docs/lighter/lighter-go-main/types/txtypes/create_public_pool.go deleted file mode 100644 index 2b95a9c..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/create_public_pool.go +++ /dev/null @@ -1,101 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CreatePublicPoolTxInfo)(nil) - -type L2CreatePublicPoolTxInfo struct { - AccountIndex int64 // Master account index - ApiKeyIndex uint8 - - OperatorFee int64 - InitialTotalShares int64 - MinOperatorShareRate int64 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CreatePublicPoolTxInfo) GetTxType() uint8 { - return TxTypeL2CreatePublicPool -} - -func (txInfo *L2CreatePublicPoolTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CreatePublicPoolTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CreatePublicPoolTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxMasterAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // OperatorFee - if txInfo.OperatorFee < 0 || txInfo.OperatorFee > FeeTick { - return ErrInvalidPoolOperatorFee - } - - // InitialTotalShares - if txInfo.InitialTotalShares <= 0 { - return ErrPoolInitialTotalSharesTooLow - } - if txInfo.InitialTotalShares > MaxInitialTotalShares { - return ErrPoolInitialTotalSharesTooHigh - } - - // MinOperatorShareRate - if txInfo.MinOperatorShareRate < 0 { - return ErrPoolMinOperatorShareRateTooLow - } - if txInfo.MinOperatorShareRate > ShareTick { - return ErrPoolMinOperatorShareRateTooHigh - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2CreatePublicPoolTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 9) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CreatePublicPool)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(txInfo.OperatorFee)) - elems = append(elems, g.FromInt64(txInfo.InitialTotalShares)) - elems = append(elems, g.FromInt64(txInfo.MinOperatorShareRate)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/create_sub_account.go b/docs/lighter/lighter-go-main/types/txtypes/create_sub_account.go deleted file mode 100644 index 4bd98aa..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/create_sub_account.go +++ /dev/null @@ -1,73 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2CreateSubAccountTxInfo)(nil) - -type L2CreateSubAccountTxInfo struct { - AccountIndex int64 // Master account index - ApiKeyIndex uint8 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2CreateSubAccountTxInfo) GetTxType() uint8 { - return TxTypeL2CreateSubAccount -} - -func (txInfo *L2CreateSubAccountTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2CreateSubAccountTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2CreateSubAccountTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2CreateSubAccountTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 6) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2CreateSubAccount)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/errors.go b/docs/lighter/lighter-go-main/types/txtypes/errors.go deleted file mode 100644 index 5121ba4..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/errors.go +++ /dev/null @@ -1,66 +0,0 @@ -package txtypes - -import "fmt" - -var ( - ErrAccountIndexTooLow = fmt.Errorf("AccountIndex should not be less than %d", MinAccountIndex) - ErrAccountIndexTooHigh = fmt.Errorf("AccountIndex should not be larger than %d", MaxAccountIndex) - ErrNonceTooLow = fmt.Errorf("AccountNonce should not be less than %d", MinNonce) - ErrInvalidCancelAllTimeInForce = fmt.Errorf("CancelAllTimeInForce is invalid") - ErrOrderReduceOnlyInvalid = fmt.Errorf("ReduceOnly is invalid") - ErrOrderTriggerPriceInvalid = fmt.Errorf("TriggerPrice is invalid") - ErrOrderExpiryInvalid = fmt.Errorf("OrderExpiry is invalid") - ErrExpiredAtInvalid = fmt.Errorf("ExpiredAt is invalid") - ErrCancelAllTimeIsNotInRange = fmt.Errorf("CancelAllTime should be larger than 0 and not larger than %d", MaxOrderExpiry) - ErrCancelAllTimeisNotNill = fmt.Errorf("CancelAllTime should be nil") - ErrPubKeyInvalid = fmt.Errorf("PubKey is invalid") - ErrToAccountIndexTooLow = fmt.Errorf("ToAccountIndex should not be less than %d", MinAccountIndex) - ErrToAccountIndexTooHigh = fmt.Errorf("ToAccountIndex should not be larger than %d", MaxAccountIndex) - ErrFromAccountIndexTooLow = fmt.Errorf("FromAccountIndex should not be less than %d", MinAccountIndex) - ErrFromAccountIndexTooHigh = fmt.Errorf("FromAccountIndex should not be larger than %d", MaxAccountIndex) - ErrApiKeyIndexTooLow = fmt.Errorf("ApiKeyIndex should not be less than %d", MinApiKeyIndex) - ErrApiKeyIndexTooHigh = fmt.Errorf("ApiKeyIndex should not be larger than %d", MaxApiKeyIndex) - ErrPublicPoolIndexTooLow = fmt.Errorf("PublicPoolIndex should not be less than %d", MinAccountIndex) - ErrPublicPoolIndexTooHigh = fmt.Errorf("PublicPoolIndex should not be larger than %d", MaxAccountIndex) - ErrInvalidPoolOperatorFee = fmt.Errorf("PoolOperatorFee should be larger than 0 and not larger than %d", FeeTick) - ErrInvalidPoolStatus = fmt.Errorf("PoolStatus should be either 0 or 1") - ErrPoolInitialTotalSharesTooLow = fmt.Errorf("PoolInitialTotalShares should be larger than %d", MinInitialTotalShares) - ErrPoolInitialTotalSharesTooHigh = fmt.Errorf("PoolInitialTotalShares should not be larger than %d", MaxInitialTotalShares) - ErrPoolMinOperatorShareRateTooLow = fmt.Errorf("PoolMinOperatorShareRate should be larger than 0") - ErrPoolMinOperatorShareRateTooHigh = fmt.Errorf("PoolMinOperatorShareRate should not be larger than %d", ShareTick) - ErrPoolMintShareAmountTooLow = fmt.Errorf("PoolMintShareAmount should be larger than %d", MinPoolSharesToMintOrBurn) - ErrPoolMintShareAmountTooHigh = fmt.Errorf("PoolMintShareAmount should not be larger than %d", MaxPoolSharesToMintOrBurn) - ErrPoolBurnShareAmountTooLow = fmt.Errorf("PoolBurnShareAmount should be larger than %d", MinPoolSharesToMintOrBurn) - ErrPoolBurnShareAmountTooHigh = fmt.Errorf("PoolBurnShareAmount should not be larger than %d", MaxPoolSharesToMintOrBurn) - ErrWithdrawalAmountTooLow = fmt.Errorf("WithdrawalAmount should be larger than %d", MinWithdrawalAmount) - ErrWithdrawalAmountTooHigh = fmt.Errorf("WithdrawalAmount should not be larger than %d", MaxWithdrawalAmount) - ErrTransferAmountTooLow = fmt.Errorf("TransferAmount should be larger than %d", MinTransferAmount) - ErrTransferAmountTooHigh = fmt.Errorf("TransferAmount should not be larger than %d", MaxTransferAmount) - ErrMarketIndexTooLow = fmt.Errorf("MarketIndex should not be less than %d", MinMarketIndex) - ErrMarketIndexTooHigh = fmt.Errorf("MarketIndex should not be larger than %d", MaxMarketIndex) - ErrMarketIndexMismatch = fmt.Errorf("MarketIndex should match the market index of the order") - ErrInitialMarginFractionTooLow = fmt.Errorf("InitialMarginFraction should not be less than %d", 0) - ErrInitialMarginFractionTooHigh = fmt.Errorf("InitialMarginFraction should not be larger than %d", MarginFractionTick) - ErrClientOrderIndexTooLow = fmt.Errorf("ClientOrderIndex should not be less than %d", MinClientOrderIndex) - ErrClientOrderIndexTooHigh = fmt.Errorf("ClientOrderIndex should not be larger than %d", MaxClientOrderIndex) - ErrClientOrderIndexNotNil = fmt.Errorf("ClientOrderIndex should be nil") - ErrOrderIndexTooLow = fmt.Errorf("OrderIndex should not be less than %d", MinOrderIndex) - ErrOrderIndexTooHigh = fmt.Errorf("OrderIndex should not be larger than %d", MaxOrderIndex) - ErrBaseAmountTooLow = fmt.Errorf("BaseAmount should not be less than %d", MinOrderBaseAmount) - ErrBaseAmountTooHigh = fmt.Errorf("BaseAmount should not be larger than %d", MaxOrderBaseAmount) - ErrBaseAmountsNotEqual = fmt.Errorf("BaseAmounts should be equal") - ErrBaseAmountNotNil = fmt.Errorf("BaseAmount should be nil") - ErrPriceTooLow = fmt.Errorf("OrderPrice should not be less than %d", MinOrderPrice) - ErrPriceTooHigh = fmt.Errorf("OrderPrice should not be larger than %d", MaxOrderPrice) - ErrIsAskInvalid = fmt.Errorf("IsAsk should be 0 or 1") - ErrOrderTypeInvalid = fmt.Errorf("OrderType is not valid") - ErrOrderTimeInForceInvalid = fmt.Errorf("OrderTimeInForce is not valid") - ErrGroupingTypeInvalid = fmt.Errorf("GroupingType is not valid") - ErrOrderGroupSizeInvalid = fmt.Errorf("OrderGroupSize is not valid") - ErrInvalidSignature = fmt.Errorf("TxSignature is invalid") - ErrInvalidMarginMode = fmt.Errorf("MarginMode is not valid") - ErrCancelModeInvalid = fmt.Errorf("CancelMode is not valid") - ErrInvalidUpdateMarginDirection = fmt.Errorf("Margin movement direction is not valid") - ErrTransferFeeNegative = fmt.Errorf("Transfer fee is negative") - ErrTransferFeeTooHigh = fmt.Errorf("Transfer fee is higher than %d", MaxTransferAmount) -) diff --git a/docs/lighter/lighter-go-main/types/txtypes/interface.go b/docs/lighter/lighter-go-main/types/txtypes/interface.go deleted file mode 100644 index b63192d..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/interface.go +++ /dev/null @@ -1,37 +0,0 @@ -package txtypes - -import g "github.com/elliottech/poseidon_crypto/field/goldilocks" - -type TxInfo interface { - GetTxType() uint8 - - GetTxInfo() (string, error) - - // GetTxHash returns the hash that was signed when creating this transaction. - // The hash coincides with the TxHash received from Lighter after submitting this Tx. - // It can be used to get the TxHash in advance, or to double-check the correctness of the SDK. - // As this hash is signed by the ApiKey, if the value differs than the one computed by the server, - // it'll result in an invalid signature. - // Returns empty string if the Tx is not signed. - GetTxHash() string - - Validate() error - - Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) -} - -type OrderInfo struct { - MarketIndex uint8 - - ClientOrderIndex int64 - - BaseAmount int64 - Price uint32 - IsAsk uint8 - - Type uint8 - TimeInForce uint8 - ReduceOnly uint8 - TriggerPrice uint32 - OrderExpiry int64 -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/mint_shares.go b/docs/lighter/lighter-go-main/types/txtypes/mint_shares.go deleted file mode 100644 index 5baeb17..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/mint_shares.go +++ /dev/null @@ -1,91 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2MintSharesTxInfo)(nil) - -type L2MintSharesTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - PublicPoolIndex int64 - ShareAmount int64 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2MintSharesTxInfo) GetTxType() uint8 { - return TxTypeL2MintShares -} - -func (txInfo *L2MintSharesTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2MintSharesTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2MintSharesTxInfo) Validate() error { - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // PublicPoolIndex - if txInfo.PublicPoolIndex < MinAccountIndex { - return ErrPublicPoolIndexTooLow - } - if txInfo.PublicPoolIndex > MaxAccountIndex { - return ErrPublicPoolIndexTooHigh - } - - if txInfo.ShareAmount < MinPoolSharesToMintOrBurn { - return ErrPoolMintShareAmountTooLow - } - if txInfo.ShareAmount > MaxPoolSharesToMintOrBurn { - return ErrPoolMintShareAmountTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2MintSharesTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 8) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2MintShares)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(txInfo.PublicPoolIndex)) - elems = append(elems, g.FromInt64(txInfo.ShareAmount)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/modify_order.go b/docs/lighter/lighter-go-main/types/txtypes/modify_order.go deleted file mode 100644 index bdf9406..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/modify_order.go +++ /dev/null @@ -1,120 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2ModifyOrderTxInfo)(nil) - -type L2ModifyOrderTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - MarketIndex uint8 - Index int64 // Client Order Index or Order Index of the order to modify - BaseAmount int64 - Price uint32 - TriggerPrice uint32 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2ModifyOrderTxInfo) GetTxType() uint8 { - return TxTypeL2ModifyOrder -} - -func (txInfo *L2ModifyOrderTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2ModifyOrderTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2ModifyOrderTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrAccountIndexTooHigh - } - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // MarketIndex - if txInfo.MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - // Index - if txInfo.Index < MinClientOrderIndex && txInfo.Index < MinOrderIndex { - return ErrClientOrderIndexTooLow - } - if txInfo.Index > MaxClientOrderIndex && txInfo.Index > MaxOrderIndex { - return ErrClientOrderIndexTooHigh - } - - // BaseAmount - if txInfo.BaseAmount != NilOrderBaseAmount && txInfo.BaseAmount < MinOrderBaseAmount { - return ErrBaseAmountTooLow - } - if txInfo.BaseAmount > MaxOrderBaseAmount { - return ErrBaseAmountTooHigh - } - - // Price - if txInfo.Price < MinOrderPrice { - return ErrPriceTooLow - } - if txInfo.Price > MaxOrderPrice { - return ErrPriceTooHigh - } - - // TriggerPrice - if (txInfo.TriggerPrice < MinOrderTriggerPrice || txInfo.TriggerPrice > MaxOrderTriggerPrice) && txInfo.TriggerPrice != NilOrderTriggerPrice { - return ErrOrderTriggerPriceInvalid - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2ModifyOrderTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 11) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2ModifyOrder)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint32(uint32(txInfo.MarketIndex))) - elems = append(elems, g.FromInt64(txInfo.Index)) - elems = append(elems, g.FromInt64(txInfo.BaseAmount)) - elems = append(elems, g.FromUint32(txInfo.Price)) - elems = append(elems, g.FromUint32(txInfo.TriggerPrice)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/transfer.go b/docs/lighter/lighter-go-main/types/txtypes/transfer.go deleted file mode 100644 index a7e7d6a..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/transfer.go +++ /dev/null @@ -1,128 +0,0 @@ -package txtypes - -import ( - "encoding/hex" - "fmt" - "strings" - - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -const templateTransfer = "Transfer\n\nnonce: %s\nfrom: %s\napi key: %s\nto: %s\namount: %s\nfee: %s\nmemo: %s\nOnly sign this message for a trusted client!" - -var _ TxInfo = (*L2TransferTxInfo)(nil) - -type L2TransferTxInfo struct { - FromAccountIndex int64 - ApiKeyIndex uint8 - - ToAccountIndex int64 - USDCAmount int64 // USDCAmount is given with 6 decimals - Fee int64 - Memo [32]byte - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2TransferTxInfo) Validate() error { - // plus one for treasury account - if txInfo.FromAccountIndex < MinAccountIndex+1 { - return ErrFromAccountIndexTooLow - } - if txInfo.FromAccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - if txInfo.ToAccountIndex < MinAccountIndex+1 { - return ErrToAccountIndexTooLow - } - if txInfo.ToAccountIndex > MaxAccountIndex { - return ErrToAccountIndexTooHigh - } - - if txInfo.USDCAmount <= 0 { - return ErrTransferAmountTooLow - } - if txInfo.USDCAmount > MaxTransferAmount { - return ErrTransferAmountTooHigh - } - - if txInfo.Fee < 0 { - return ErrTransferFeeNegative - } - if txInfo.Fee > MaxTransferAmount { - return ErrTransferFeeTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2TransferTxInfo) GetTxType() uint8 { - return TxTypeL2Transfer -} - -func (txInfo *L2TransferTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2TransferTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2TransferTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 11) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2Transfer)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.FromAccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(txInfo.ToAccountIndex)) - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)&0xFFFFFFFF)) //nolint:gosec - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)>>32)) //nolint:gosec - elems = append(elems, g.FromUint64(uint64(txInfo.Fee)&0xFFFFFFFF)) //nolint:gosec - elems = append(elems, g.FromUint64(uint64(txInfo.Fee)>>32)) //nolint:gosec - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} - -func (txInfo *L2TransferTxInfo) GetL1SignatureBody() string { - hexMemo := hex.EncodeToString(txInfo.Memo[:]) - hexMemo = strings.Replace(hexMemo, "0x", "", 1) - - signatureBody := fmt.Sprintf( - templateTransfer, - - getHex10FromUint64(uint64(txInfo.Nonce)), - getHex10FromUint64(uint64(txInfo.FromAccountIndex)), - getHex10FromUint64(uint64(txInfo.ApiKeyIndex)), - getHex10FromUint64(uint64(txInfo.ToAccountIndex)), - getHex10FromUint64(uint64(txInfo.USDCAmount)), - getHex10FromUint64(uint64(txInfo.Fee)), - hexMemo, - ) - return signatureBody -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/update_leverage.go b/docs/lighter/lighter-go-main/types/txtypes/update_leverage.go deleted file mode 100644 index e381138..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/update_leverage.go +++ /dev/null @@ -1,98 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2UpdateLeverageTxInfo)(nil) - -type L2UpdateLeverageTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - MarketIndex uint8 - InitialMarginFraction uint16 - MarginMode uint8 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2UpdateLeverageTxInfo) GetTxType() uint8 { - return TxTypeL2UpdateLeverage -} - -func (txInfo *L2UpdateLeverageTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2UpdateLeverageTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2UpdateLeverageTxInfo) Validate() error { - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // MarketIndex - if txInfo.MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - // InitialMarginFraction - if txInfo.InitialMarginFraction <= 0 { - return ErrInitialMarginFractionTooLow - } - if txInfo.InitialMarginFraction > uint16(MarginFractionTick) { //nolint:gosec - return ErrInitialMarginFractionTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - if txInfo.MarginMode != CrossMargin && txInfo.MarginMode != IsolatedMargin { - return ErrInvalidMarginMode - } - - return nil -} - -func (txInfo *L2UpdateLeverageTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 9) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2UpdateLeverage)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(int64(txInfo.MarketIndex))) - elems = append(elems, g.FromInt64(int64(txInfo.InitialMarginFraction))) - elems = append(elems, g.FromUint32(uint32(txInfo.MarginMode))) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/update_margin.go b/docs/lighter/lighter-go-main/types/txtypes/update_margin.go deleted file mode 100644 index 99f797a..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/update_margin.go +++ /dev/null @@ -1,98 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2UpdateMarginTxInfo)(nil) - -type L2UpdateMarginTxInfo struct { - AccountIndex int64 - ApiKeyIndex uint8 - - MarketIndex uint8 - USDCAmount int64 - Direction uint8 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2UpdateMarginTxInfo) GetTxType() uint8 { - return TxTypeL2UpdateMargin -} - -func (txInfo *L2UpdateMarginTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2UpdateMarginTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2UpdateMarginTxInfo) Validate() error { - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // MarketIndex - if txInfo.MarketIndex < MinMarketIndex { - return ErrMarketIndexTooLow - } - if txInfo.MarketIndex > MaxMarketIndex { - return ErrMarketIndexTooHigh - } - - if txInfo.USDCAmount <= 0 { - return ErrTransferAmountTooLow - } - if txInfo.USDCAmount > MaxTransferAmount { - return ErrTransferAmountTooHigh - } - - if txInfo.Direction != RemoveFromIsolatedMargin && txInfo.Direction != AddToIsolatedMargin { - return ErrInvalidUpdateMarginDirection - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2UpdateMarginTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 10) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2UpdateMargin)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(int64(txInfo.MarketIndex))) - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)&0xFFFFFFFF)) //nolint:gosec - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)>>32)) //nolint:gosec - elems = append(elems, g.FromUint32(uint32(txInfo.Direction))) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/update_public_pool.go b/docs/lighter/lighter-go-main/types/txtypes/update_public_pool.go deleted file mode 100644 index 2590227..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/update_public_pool.go +++ /dev/null @@ -1,109 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2UpdatePublicPoolTxInfo)(nil) - -type L2UpdatePublicPoolTxInfo struct { - AccountIndex int64 // Master account index - ApiKeyIndex uint8 - - PublicPoolIndex int64 - - Status uint8 - OperatorFee int64 - MinOperatorShareRate int64 - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2UpdatePublicPoolTxInfo) GetTxType() uint8 { - return TxTypeL2UpdatePublicPool -} - -func (txInfo *L2UpdatePublicPoolTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2UpdatePublicPoolTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2UpdatePublicPoolTxInfo) Validate() error { - // AccountIndex - if txInfo.AccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.AccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - // PublicPoolIndex - if txInfo.PublicPoolIndex < MinAccountIndex { - return ErrPublicPoolIndexTooLow - } - if txInfo.PublicPoolIndex > MaxAccountIndex { - return ErrPublicPoolIndexTooHigh - } - - // Status - if txInfo.Status != 0 && txInfo.Status != 1 { - return ErrInvalidPoolStatus - } - - // OperatorFee - if txInfo.OperatorFee < 0 || txInfo.OperatorFee > FeeTick { - return ErrInvalidPoolOperatorFee - } - - // MinOperatorShareRate - if txInfo.MinOperatorShareRate < 0 { - return ErrPoolMinOperatorShareRateTooLow - } - if txInfo.MinOperatorShareRate > ShareTick { - return ErrPoolMinOperatorShareRateTooHigh - } - - // Nonce - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2UpdatePublicPoolTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 10) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2UpdatePublicPool)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.AccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromInt64(txInfo.PublicPoolIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.Status))) - elems = append(elems, g.FromInt64(txInfo.OperatorFee)) - elems = append(elems, g.FromInt64(txInfo.MinOperatorShareRate)) - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/utils.go b/docs/lighter/lighter-go-main/types/txtypes/utils.go deleted file mode 100644 index c2d321e..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -package txtypes - -import "encoding/json" - -func IsValidPubKey(bytes []byte) bool { - if len(bytes) != 40 { - return false - } - - return !isZeroByteSlice(bytes) -} - -func isZeroByteSlice(bytes []byte) bool { - for _, s := range bytes { - if s != 0 { - return false - } - } - return true -} - -func getTxInfo(tx interface{}) (string, error) { - txInfoBytes, err := json.Marshal(tx) - if err != nil { - return "", err - } - return string(txInfoBytes), nil -} diff --git a/docs/lighter/lighter-go-main/types/txtypes/withdraw.go b/docs/lighter/lighter-go-main/types/txtypes/withdraw.go deleted file mode 100644 index ec6a40b..0000000 --- a/docs/lighter/lighter-go-main/types/txtypes/withdraw.go +++ /dev/null @@ -1,82 +0,0 @@ -package txtypes - -import ( - g "github.com/elliottech/poseidon_crypto/field/goldilocks" - p2 "github.com/elliottech/poseidon_crypto/hash/poseidon2_goldilocks" -) - -var _ TxInfo = (*L2WithdrawTxInfo)(nil) - -type L2WithdrawTxInfo struct { - FromAccountIndex int64 - ApiKeyIndex uint8 - - USDCAmount uint64 // USDCAmount is given with 6 decimals - - ExpiredAt int64 - Nonce int64 - Sig []byte - SignedHash string `json:"-"` -} - -func (txInfo *L2WithdrawTxInfo) Validate() error { - if txInfo.FromAccountIndex < MinAccountIndex { - return ErrFromAccountIndexTooLow - } - if txInfo.FromAccountIndex > MaxAccountIndex { - return ErrFromAccountIndexTooHigh - } - - // ApiKeyIndex - if txInfo.ApiKeyIndex < MinApiKeyIndex { - return ErrApiKeyIndexTooLow - } - if txInfo.ApiKeyIndex > MaxApiKeyIndex { - return ErrApiKeyIndexTooHigh - } - - if txInfo.USDCAmount == 0 { - return ErrWithdrawalAmountTooLow - } - if txInfo.USDCAmount > MaxWithdrawalAmount { - return ErrWithdrawalAmountTooHigh - } - - if txInfo.Nonce < MinNonce { - return ErrNonceTooLow - } - - if txInfo.ExpiredAt < 0 || txInfo.ExpiredAt > MaxTimestamp { - return ErrExpiredAtInvalid - } - - return nil -} - -func (txInfo *L2WithdrawTxInfo) GetTxType() uint8 { - return TxTypeL2Withdraw -} - -func (txInfo *L2WithdrawTxInfo) GetTxInfo() (string, error) { - return getTxInfo(txInfo) -} - -func (txInfo *L2WithdrawTxInfo) GetTxHash() string { - return txInfo.SignedHash -} - -func (txInfo *L2WithdrawTxInfo) Hash(lighterChainId uint32, extra ...g.Element) (msgHash []byte, err error) { - elems := make([]g.Element, 0, 8) - - elems = append(elems, g.FromUint32(lighterChainId)) - elems = append(elems, g.FromUint32(TxTypeL2Withdraw)) - elems = append(elems, g.FromInt64(txInfo.Nonce)) - elems = append(elems, g.FromInt64(txInfo.ExpiredAt)) - - elems = append(elems, g.FromInt64(txInfo.FromAccountIndex)) - elems = append(elems, g.FromUint32(uint32(txInfo.ApiKeyIndex))) - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)&0xFFFFFFFF)) //nolint:gosec - elems = append(elems, g.FromUint64(uint64(txInfo.USDCAmount)>>32)) //nolint:gosec - - return p2.HashToQuinticExtension(elems).ToLittleEndianBytes(), nil -} diff --git a/docs/lighter/lighter-python-main/.gitignore b/docs/lighter/lighter-python-main/.gitignore index f77f5a6..416367f 100644 --- a/docs/lighter/lighter-python-main/.gitignore +++ b/docs/lighter/lighter-python-main/.gitignore @@ -68,4 +68,9 @@ openapi-generator-cli.jar .idea -examples/secrets.py \ No newline at end of file +examples/secrets.py + +# Environment variables +.env +.env.* +api_key_config.json \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/.openapi-generator/FILES b/docs/lighter/lighter-python-main/.openapi-generator/FILES index 2f225cd..071d41f 100644 --- a/docs/lighter/lighter-python-main/.openapi-generator/FILES +++ b/docs/lighter/lighter-python-main/.openapi-generator/FILES @@ -1,6 +1,7 @@ docs/Account.md docs/AccountApi.md docs/AccountApiKeys.md +docs/AccountAsset.md docs/AccountLimits.md docs/AccountMarginStats.md docs/AccountMarketStats.md @@ -14,9 +15,12 @@ docs/Announcement.md docs/AnnouncementApi.md docs/Announcements.md docs/ApiKey.md +docs/Asset.md +docs/AssetDetails.md docs/Block.md docs/BlockApi.md docs/Blocks.md +docs/Bridge.md docs/BridgeApi.md docs/BridgeSupportedNetwork.md docs/Candlestick.md @@ -46,28 +50,27 @@ docs/LiqTrade.md docs/Liquidation.md docs/LiquidationInfo.md docs/LiquidationInfos.md -docs/MarketInfo.md +docs/MarketConfig.md docs/NextNonce.md docs/NotificationApi.md docs/Order.md docs/OrderApi.md docs/OrderBook.md docs/OrderBookDepth.md -docs/OrderBookDetail.md docs/OrderBookDetails.md docs/OrderBookOrders.md docs/OrderBookStats.md docs/OrderBooks.md docs/Orders.md +docs/PerpsMarketStats.md +docs/PerpsOrderBookDetail.md docs/PnLEntry.md docs/PositionFunding.md docs/PositionFundings.md docs/PriceLevel.md -docs/PublicPool.md docs/PublicPoolInfo.md docs/PublicPoolMetadata.md docs/PublicPoolShare.md -docs/PublicPools.md docs/ReferralApi.md docs/ReferralPointEntry.md docs/ReferralPoints.md @@ -81,8 +84,10 @@ docs/ReqGetAccountLimits.md docs/ReqGetAccountMetadata.md docs/ReqGetAccountPnL.md docs/ReqGetAccountTxs.md +docs/ReqGetAssetDetails.md docs/ReqGetBlock.md docs/ReqGetBlockTxs.md +docs/ReqGetBridgesByL1Addr.md docs/ReqGetByAccount.md docs/ReqGetCandlesticks.md docs/ReqGetDepositHistory.md @@ -97,7 +102,6 @@ docs/ReqGetOrderBookDetails.md docs/ReqGetOrderBookOrders.md docs/ReqGetOrderBooks.md docs/ReqGetPositionFunding.md -docs/ReqGetPublicPools.md docs/ReqGetPublicPoolsMetadata.md docs/ReqGetRangeWithCursor.md docs/ReqGetRangeWithIndex.md @@ -110,10 +114,14 @@ docs/ReqGetTransferHistory.md docs/ReqGetTx.md docs/ReqGetWithdrawHistory.md docs/RespChangeAccountTier.md +docs/RespGetBridgesByL1Addr.md docs/RespGetFastBridgeInfo.md +docs/RespGetIsNextBridgeFast.md docs/RespPublicPoolsMetadata.md docs/RespSendTx.md docs/RespSendTxBatch.md +docs/RespUpdateKickback.md +docs/RespUpdateReferralCode.md docs/RespWithdrawalDelay.md docs/ResultCode.md docs/RiskInfo.md @@ -121,6 +129,8 @@ docs/RiskParameters.md docs/RootApi.md docs/SharePrice.md docs/SimpleOrder.md +docs/SpotMarketStats.md +docs/SpotOrderBookDetail.md docs/Status.md docs/SubAccounts.md docs/Ticker.md @@ -160,6 +170,7 @@ lighter/exceptions.py lighter/models/__init__.py lighter/models/account.py lighter/models/account_api_keys.py +lighter/models/account_asset.py lighter/models/account_limits.py lighter/models/account_margin_stats.py lighter/models/account_market_stats.py @@ -172,8 +183,11 @@ lighter/models/account_trade_stats.py lighter/models/announcement.py lighter/models/announcements.py lighter/models/api_key.py +lighter/models/asset.py +lighter/models/asset_details.py lighter/models/block.py lighter/models/blocks.py +lighter/models/bridge.py lighter/models/bridge_supported_network.py lighter/models/candlestick.py lighter/models/candlesticks.py @@ -199,26 +213,25 @@ lighter/models/liq_trade.py lighter/models/liquidation.py lighter/models/liquidation_info.py lighter/models/liquidation_infos.py -lighter/models/market_info.py +lighter/models/market_config.py lighter/models/next_nonce.py lighter/models/order.py lighter/models/order_book.py lighter/models/order_book_depth.py -lighter/models/order_book_detail.py lighter/models/order_book_details.py lighter/models/order_book_orders.py lighter/models/order_book_stats.py lighter/models/order_books.py lighter/models/orders.py +lighter/models/perps_market_stats.py +lighter/models/perps_order_book_detail.py lighter/models/pn_l_entry.py lighter/models/position_funding.py lighter/models/position_fundings.py lighter/models/price_level.py -lighter/models/public_pool.py lighter/models/public_pool_info.py lighter/models/public_pool_metadata.py lighter/models/public_pool_share.py -lighter/models/public_pools.py lighter/models/referral_point_entry.py lighter/models/referral_points.py lighter/models/req_export_data.py @@ -231,8 +244,10 @@ lighter/models/req_get_account_limits.py lighter/models/req_get_account_metadata.py lighter/models/req_get_account_pn_l.py lighter/models/req_get_account_txs.py +lighter/models/req_get_asset_details.py lighter/models/req_get_block.py lighter/models/req_get_block_txs.py +lighter/models/req_get_bridges_by_l1_addr.py lighter/models/req_get_by_account.py lighter/models/req_get_candlesticks.py lighter/models/req_get_deposit_history.py @@ -247,7 +262,6 @@ lighter/models/req_get_order_book_details.py lighter/models/req_get_order_book_orders.py lighter/models/req_get_order_books.py lighter/models/req_get_position_funding.py -lighter/models/req_get_public_pools.py lighter/models/req_get_public_pools_metadata.py lighter/models/req_get_range_with_cursor.py lighter/models/req_get_range_with_index.py @@ -260,16 +274,22 @@ lighter/models/req_get_transfer_history.py lighter/models/req_get_tx.py lighter/models/req_get_withdraw_history.py lighter/models/resp_change_account_tier.py +lighter/models/resp_get_bridges_by_l1_addr.py lighter/models/resp_get_fast_bridge_info.py +lighter/models/resp_get_is_next_bridge_fast.py lighter/models/resp_public_pools_metadata.py lighter/models/resp_send_tx.py lighter/models/resp_send_tx_batch.py +lighter/models/resp_update_kickback.py +lighter/models/resp_update_referral_code.py lighter/models/resp_withdrawal_delay.py lighter/models/result_code.py lighter/models/risk_info.py lighter/models/risk_parameters.py lighter/models/share_price.py lighter/models/simple_order.py +lighter/models/spot_market_stats.py +lighter/models/spot_order_book_detail.py lighter/models/status.py lighter/models/sub_accounts.py lighter/models/ticker.py @@ -291,4 +311,19 @@ lighter/rest.py setup.cfg test-requirements.txt test/__init__.py +test/test_account_asset.py +test/test_asset.py +test/test_asset_details.py +test/test_bridge.py +test/test_market_config.py +test/test_perps_market_stats.py +test/test_perps_order_book_detail.py +test/test_req_get_asset_details.py +test/test_req_get_bridges_by_l1_addr.py +test/test_resp_get_bridges_by_l1_addr.py +test/test_resp_get_is_next_bridge_fast.py +test/test_resp_update_kickback.py +test/test_resp_update_referral_code.py +test/test_spot_market_stats.py +test/test_spot_order_book_detail.py tox.ini diff --git a/docs/lighter/lighter-python-main/LICENSE b/docs/lighter/lighter-python-main/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/docs/lighter/lighter-python-main/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/lighter/lighter-python-main/README.md b/docs/lighter/lighter-python-main/README.md index 607ade1..59a2b3f 100644 --- a/docs/lighter/lighter-python-main/README.md +++ b/docs/lighter/lighter-python-main/README.md @@ -36,9 +36,12 @@ import asyncio async def main(): client = lighter.ApiClient() - account_api = lighter.AccountApi(client) - account = await account_api.get_account(by="index", value="1") - print(account) + try: + account_api = lighter.AccountApi(client) + account = await account_api.account(by="index", value="1") + print(account) + finally: + await client.close() # Make sure connection is cleanly closed if __name__ == "__main__": asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/config.yaml b/docs/lighter/lighter-python-main/config.yaml new file mode 100644 index 0000000..9581407 --- /dev/null +++ b/docs/lighter/lighter-python-main/config.yaml @@ -0,0 +1,4 @@ +disallowAdditionalPropertiesIfNotPresent: false +library: asyncio +packageName: lighter-sdk +projectName: lighter-sdk diff --git a/docs/lighter/lighter-python-main/docs/Account.md b/docs/lighter/lighter-python-main/docs/Account.md index 173acf4..68a4b51 100644 --- a/docs/lighter/lighter-python-main/docs/Account.md +++ b/docs/lighter/lighter-python-main/docs/Account.md @@ -12,7 +12,6 @@ Name | Type | Description | Notes **l1_address** | **str** | | **cancel_all_time** | **int** | | **total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | **pending_order_count** | **int** | | **available_balance** | **str** | | **status** | **int** | | diff --git a/docs/lighter/lighter-python-main/docs/AccountApi.md b/docs/lighter/lighter-python-main/docs/AccountApi.md index 9e90478..77df45d 100644 --- a/docs/lighter/lighter-python-main/docs/AccountApi.md +++ b/docs/lighter/lighter-python-main/docs/AccountApi.md @@ -14,7 +14,6 @@ Method | HTTP request | Description [**liquidations**](AccountApi.md#liquidations) | **GET** /api/v1/liquidations | liquidations [**pnl**](AccountApi.md#pnl) | **GET** /api/v1/pnl | pnl [**position_funding**](AccountApi.md#position_funding) | **GET** /api/v1/positionFunding | positionFunding -[**public_pools**](AccountApi.md#public_pools) | **GET** /api/v1/publicPools | publicPools [**public_pools_metadata**](AccountApi.md#public_pools_metadata) | **GET** /api/v1/publicPoolsMetadata | publicPoolsMetadata @@ -770,85 +769,6 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **public_pools** -> PublicPools public_pools(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) - -publicPools - -Get public pools - -### Example - - -```python -import lighter -from lighter.models.public_pools import PublicPools -from lighter.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai -# See configuration.py for a list of all supported configuration parameters. -configuration = lighter.Configuration( - host = "https://mainnet.zklighter.elliot.ai" -) - - -# Enter a context with an instance of the API client -async with lighter.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = lighter.AccountApi(api_client) - index = 56 # int | - limit = 56 # int | - authorization = 'authorization_example' # str | (optional) - auth = 'auth_example' # str | (optional) - filter = 'filter_example' # str | (optional) - account_index = 56 # int | (optional) - - try: - # publicPools - api_response = await api_instance.public_pools(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) - print("The response of AccountApi->public_pools:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling AccountApi->public_pools: %s\n" % e) -``` - - - -### Parameters - - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **index** | **int**| | - **limit** | **int**| | - **authorization** | **str**| | [optional] - **auth** | **str**| | [optional] - **filter** | **str**| | [optional] - **account_index** | **int**| | [optional] - -### Return type - -[**PublicPools**](PublicPools.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details - -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | A successful response. | - | -**400** | Bad request | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **public_pools_metadata** > RespPublicPoolsMetadata public_pools_metadata(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) diff --git a/docs/lighter/lighter-python-main/docs/AccountAsset.md b/docs/lighter/lighter-python-main/docs/AccountAsset.md new file mode 100644 index 0000000..45956b9 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/AccountAsset.md @@ -0,0 +1,32 @@ +# AccountAsset + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**asset_id** | **int** | | +**balance** | **str** | | +**locked_balance** | **str** | | + +## Example + +```python +from lighter.models.account_asset import AccountAsset + +# TODO update the JSON string below +json = "{}" +# create an instance of AccountAsset from a JSON string +account_asset_instance = AccountAsset.from_json(json) +# print the JSON string representation of the object +print(AccountAsset.to_json()) + +# convert the object into a dict +account_asset_dict = account_asset_instance.to_dict() +# create an instance of AccountAsset from a dict +account_asset_from_dict = AccountAsset.from_dict(account_asset_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/AccountLimits.md b/docs/lighter/lighter-python-main/docs/AccountLimits.md index 0ca7ba2..f19b1a0 100644 --- a/docs/lighter/lighter-python-main/docs/AccountLimits.md +++ b/docs/lighter/lighter-python-main/docs/AccountLimits.md @@ -8,7 +8,9 @@ Name | Type | Description | Notes **code** | **int** | | **message** | **str** | | [optional] **max_llp_percentage** | **int** | | +**max_llp_amount** | **str** | | **user_tier** | **str** | | +**can_create_public_pool** | **bool** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/Announcement.md b/docs/lighter/lighter-python-main/docs/Announcement.md index 271e6d9..3cb4b46 100644 --- a/docs/lighter/lighter-python-main/docs/Announcement.md +++ b/docs/lighter/lighter-python-main/docs/Announcement.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **title** | **str** | | **content** | **str** | | **created_at** | **int** | | +**expired_at** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/Asset.md b/docs/lighter/lighter-python-main/docs/Asset.md new file mode 100644 index 0000000..1987347 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/Asset.md @@ -0,0 +1,37 @@ +# Asset + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | **int** | | +**symbol** | **str** | | +**l1_decimals** | **int** | | +**decimals** | **int** | | +**min_transfer_amount** | **str** | | +**min_withdrawal_amount** | **str** | | +**margin_mode** | **str** | | +**index_price** | **str** | | +**l1_address** | **str** | | + +## Example + +```python +from lighter.models.asset import Asset + +# TODO update the JSON string below +json = "{}" +# create an instance of Asset from a JSON string +asset_instance = Asset.from_json(json) +# print the JSON string representation of the object +print(Asset.to_json()) + +# convert the object into a dict +asset_dict = asset_instance.to_dict() +# create an instance of Asset from a dict +asset_from_dict = Asset.from_dict(asset_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/PublicPools.md b/docs/lighter/lighter-python-main/docs/AssetDetails.md similarity index 52% rename from docs/lighter/lighter-python-main/docs/PublicPools.md rename to docs/lighter/lighter-python-main/docs/AssetDetails.md index 5ebeb86..df406f7 100644 --- a/docs/lighter/lighter-python-main/docs/PublicPools.md +++ b/docs/lighter/lighter-python-main/docs/AssetDetails.md @@ -1,4 +1,4 @@ -# PublicPools +# AssetDetails ## Properties @@ -7,25 +7,24 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**total** | **int** | | -**public_pools** | [**List[PublicPool]**](PublicPool.md) | | +**asset_details** | [**List[Asset]**](Asset.md) | | ## Example ```python -from lighter.models.public_pools import PublicPools +from lighter.models.asset_details import AssetDetails # TODO update the JSON string below json = "{}" -# create an instance of PublicPools from a JSON string -public_pools_instance = PublicPools.from_json(json) +# create an instance of AssetDetails from a JSON string +asset_details_instance = AssetDetails.from_json(json) # print the JSON string representation of the object -print(PublicPools.to_json()) +print(AssetDetails.to_json()) # convert the object into a dict -public_pools_dict = public_pools_instance.to_dict() -# create an instance of PublicPools from a dict -public_pools_from_dict = PublicPools.from_dict(public_pools_dict) +asset_details_dict = asset_details_instance.to_dict() +# create an instance of AssetDetails from a dict +asset_details_from_dict = AssetDetails.from_dict(asset_details_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/lighter/lighter-python-main/docs/Bridge.md b/docs/lighter/lighter-python-main/docs/Bridge.md new file mode 100644 index 0000000..9147bde --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/Bridge.md @@ -0,0 +1,43 @@ +# Bridge + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | +**version** | **int** | | +**source** | **str** | | +**source_chain_id** | **str** | | +**fast_bridge_tx_hash** | **str** | | +**batch_claim_tx_hash** | **str** | | +**cctp_burn_tx_hash** | **str** | | +**amount** | **str** | | +**intent_address** | **str** | | +**status** | **str** | | +**step** | **str** | | +**description** | **str** | | +**created_at** | **int** | | +**updated_at** | **int** | | +**is_external_deposit** | **bool** | | + +## Example + +```python +from lighter.models.bridge import Bridge + +# TODO update the JSON string below +json = "{}" +# create an instance of Bridge from a JSON string +bridge_instance = Bridge.from_json(json) +# print the JSON string representation of the object +print(Bridge.to_json()) + +# convert the object into a dict +bridge_dict = bridge_instance.to_dict() +# create an instance of Bridge from a dict +bridge_from_dict = Bridge.from_dict(bridge_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/BridgeApi.md b/docs/lighter/lighter-python-main/docs/BridgeApi.md index 4180a8f..29092ef 100644 --- a/docs/lighter/lighter-python-main/docs/BridgeApi.md +++ b/docs/lighter/lighter-python-main/docs/BridgeApi.md @@ -4,9 +4,149 @@ All URIs are relative to *https://mainnet.zklighter.elliot.ai* Method | HTTP request | Description ------------- | ------------- | ------------- +[**bridges**](BridgeApi.md#bridges) | **GET** /api/v1/bridges | bridges +[**bridges_is_next_bridge_fast**](BridgeApi.md#bridges_is_next_bridge_fast) | **GET** /api/v1/bridges/isNextBridgeFast | bridges_isNextBridgeFast [**fastbridge_info**](BridgeApi.md#fastbridge_info) | **GET** /api/v1/fastbridge/info | fastbridge_info +# **bridges** +> RespGetBridgesByL1Addr bridges(l1_address) + +bridges + +Get bridges for given l1 address + +### Example + + +```python +import lighter +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.BridgeApi(api_client) + l1_address = 'l1_address_example' # str | + + try: + # bridges + api_response = await api_instance.bridges(l1_address) + print("The response of BridgeApi->bridges:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BridgeApi->bridges: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **l1_address** | **str**| | + +### Return type + +[**RespGetBridgesByL1Addr**](RespGetBridgesByL1Addr.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **bridges_is_next_bridge_fast** +> RespGetIsNextBridgeFast bridges_is_next_bridge_fast(l1_address) + +bridges_isNextBridgeFast + +Get if next bridge is fast + +### Example + + +```python +import lighter +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.BridgeApi(api_client) + l1_address = 'l1_address_example' # str | + + try: + # bridges_isNextBridgeFast + api_response = await api_instance.bridges_is_next_bridge_fast(l1_address) + print("The response of BridgeApi->bridges_is_next_bridge_fast:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BridgeApi->bridges_is_next_bridge_fast: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **l1_address** | **str**| | + +### Return type + +[**RespGetIsNextBridgeFast**](RespGetIsNextBridgeFast.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **fastbridge_info** > RespGetFastBridgeInfo fastbridge_info() diff --git a/docs/lighter/lighter-python-main/docs/Candlestick.md b/docs/lighter/lighter-python-main/docs/Candlestick.md index 6071dfc..c7f48e8 100644 --- a/docs/lighter/lighter-python-main/docs/Candlestick.md +++ b/docs/lighter/lighter-python-main/docs/Candlestick.md @@ -10,6 +10,10 @@ Name | Type | Description | Notes **high** | **float** | | **low** | **float** | | **close** | **float** | | +**open_raw** | **float** | | +**high_raw** | **float** | | +**low_raw** | **float** | | +**close_raw** | **float** | | **volume0** | **float** | | **volume1** | **float** | | **last_trade_id** | **int** | | diff --git a/docs/lighter/lighter-python-main/docs/DepositHistoryItem.md b/docs/lighter/lighter-python-main/docs/DepositHistoryItem.md index 3e850fe..c046dfc 100644 --- a/docs/lighter/lighter-python-main/docs/DepositHistoryItem.md +++ b/docs/lighter/lighter-python-main/docs/DepositHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **status** | **str** | | diff --git a/docs/lighter/lighter-python-main/docs/DetailedAccount.md b/docs/lighter/lighter-python-main/docs/DetailedAccount.md index 768c3e2..d96f4b6 100644 --- a/docs/lighter/lighter-python-main/docs/DetailedAccount.md +++ b/docs/lighter/lighter-python-main/docs/DetailedAccount.md @@ -12,7 +12,6 @@ Name | Type | Description | Notes **l1_address** | **str** | | **cancel_all_time** | **int** | | **total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | **pending_order_count** | **int** | | **available_balance** | **str** | | **status** | **int** | | @@ -23,6 +22,7 @@ Name | Type | Description | Notes **can_invite** | **bool** | Remove After FE uses L1 meta endpoint | **referral_points_percentage** | **str** | Remove After FE uses L1 meta endpoint | **positions** | [**List[AccountPosition]**](AccountPosition.md) | | +**assets** | [**List[AccountAsset]**](AccountAsset.md) | | **total_asset_value** | **str** | | **cross_asset_value** | **str** | | **pool_info** | [**PublicPoolInfo**](PublicPoolInfo.md) | | diff --git a/docs/lighter/lighter-python-main/docs/DetailedCandlestick.md b/docs/lighter/lighter-python-main/docs/DetailedCandlestick.md index 4bba057..f00f2e1 100644 --- a/docs/lighter/lighter-python-main/docs/DetailedCandlestick.md +++ b/docs/lighter/lighter-python-main/docs/DetailedCandlestick.md @@ -10,6 +10,10 @@ Name | Type | Description | Notes **high** | **float** | | **low** | **float** | | **close** | **float** | | +**open_raw** | **float** | | +**high_raw** | **float** | | +**low_raw** | **float** | | +**close_raw** | **float** | | **volume0** | **float** | | **volume1** | **float** | | **last_trade_id** | **int** | | diff --git a/docs/lighter/lighter-python-main/docs/EnrichedTx.md b/docs/lighter/lighter-python-main/docs/EnrichedTx.md index 27d2156..e9b0a32 100644 --- a/docs/lighter/lighter-python-main/docs/EnrichedTx.md +++ b/docs/lighter/lighter-python-main/docs/EnrichedTx.md @@ -22,6 +22,7 @@ Name | Type | Description | Notes **executed_at** | **int** | | **sequence_index** | **int** | | **parent_hash** | **str** | | +**api_key_index** | **int** | | **committed_at** | **int** | | **verified_at** | **int** | | diff --git a/docs/lighter/lighter-python-main/docs/MarketConfig.md b/docs/lighter/lighter-python-main/docs/MarketConfig.md new file mode 100644 index 0000000..1a94e25 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/MarketConfig.md @@ -0,0 +1,33 @@ +# MarketConfig + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**market_margin_mode** | **int** | | +**insurance_fund_account_index** | **int** | | +**liquidation_mode** | **int** | | +**force_reduce_only** | **bool** | | +**trading_hours** | **str** | | + +## Example + +```python +from lighter.models.market_config import MarketConfig + +# TODO update the JSON string below +json = "{}" +# create an instance of MarketConfig from a JSON string +market_config_instance = MarketConfig.from_json(json) +# print the JSON string representation of the object +print(MarketConfig.to_json()) + +# convert the object into a dict +market_config_dict = market_config_instance.to_dict() +# create an instance of MarketConfig from a dict +market_config_from_dict = MarketConfig.from_dict(market_config_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/Order.md b/docs/lighter/lighter-python-main/docs/Order.md index a3415f4..c1eac6d 100644 --- a/docs/lighter/lighter-python-main/docs/Order.md +++ b/docs/lighter/lighter-python-main/docs/Order.md @@ -36,6 +36,8 @@ Name | Type | Description | Notes **to_cancel_order_id_0** | **str** | | **block_height** | **int** | | **timestamp** | **int** | | +**created_at** | **int** | | +**updated_at** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/OrderApi.md b/docs/lighter/lighter-python-main/docs/OrderApi.md index 2b59510..46d6379 100644 --- a/docs/lighter/lighter-python-main/docs/OrderApi.md +++ b/docs/lighter/lighter-python-main/docs/OrderApi.md @@ -6,6 +6,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**account_active_orders**](OrderApi.md#account_active_orders) | **GET** /api/v1/accountActiveOrders | accountActiveOrders [**account_inactive_orders**](OrderApi.md#account_inactive_orders) | **GET** /api/v1/accountInactiveOrders | accountInactiveOrders +[**asset_details**](OrderApi.md#asset_details) | **GET** /api/v1/assetDetails | assetDetails [**exchange_stats**](OrderApi.md#exchange_stats) | **GET** /api/v1/exchangeStats | exchangeStats [**export**](OrderApi.md#export) | **GET** /api/v1/export | export [**order_book_details**](OrderApi.md#order_book_details) | **GET** /api/v1/orderBookDetails | orderBookDetails @@ -173,6 +174,75 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **asset_details** +> AssetDetails asset_details(asset_id=asset_id) + +assetDetails + +Get asset details + +### Example + + +```python +import lighter +from lighter.models.asset_details import AssetDetails +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.OrderApi(api_client) + asset_id = 0 # int | (optional) (default to 0) + + try: + # assetDetails + api_response = await api_instance.asset_details(asset_id=asset_id) + print("The response of OrderApi->asset_details:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling OrderApi->asset_details: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **asset_id** | **int**| | [optional] [default to 0] + +### Return type + +[**AssetDetails**](AssetDetails.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **exchange_stats** > ExchangeStats exchange_stats() @@ -316,7 +386,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **order_book_details** -> OrderBookDetails order_book_details(market_id=market_id) +> OrderBookDetails order_book_details(market_id=market_id, filter=filter) orderBookDetails @@ -343,10 +413,11 @@ async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.OrderApi(api_client) market_id = 255 # int | (optional) (default to 255) + filter = all # str | (optional) (default to all) try: # orderBookDetails - api_response = await api_instance.order_book_details(market_id=market_id) + api_response = await api_instance.order_book_details(market_id=market_id, filter=filter) print("The response of OrderApi->order_book_details:\n") pprint(api_response) except Exception as e: @@ -361,6 +432,7 @@ async with lighter.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **market_id** | **int**| | [optional] [default to 255] + **filter** | **str**| | [optional] [default to all] ### Return type @@ -456,7 +528,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **order_books** -> OrderBooks order_books(market_id=market_id) +> OrderBooks order_books(market_id=market_id, filter=filter) orderBooks @@ -483,10 +555,11 @@ async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.OrderApi(api_client) market_id = 255 # int | (optional) (default to 255) + filter = all # str | (optional) (default to all) try: # orderBooks - api_response = await api_instance.order_books(market_id=market_id) + api_response = await api_instance.order_books(market_id=market_id, filter=filter) print("The response of OrderApi->order_books:\n") pprint(api_response) except Exception as e: @@ -501,6 +574,7 @@ async with lighter.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **market_id** | **int**| | [optional] [default to 255] + **filter** | **str**| | [optional] [default to all] ### Return type @@ -596,7 +670,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **trades** -> Trades trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter) +> Trades trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter, role=role, type=type, aggregate=aggregate) trades @@ -633,10 +707,13 @@ async with lighter.ApiClient(configuration) as api_client: cursor = 'cursor_example' # str | (optional) var_from = -1 # int | (optional) (default to -1) ask_filter = -1 # int | (optional) (default to -1) + role = all # str | (optional) (default to all) + type = all # str | (optional) (default to all) + aggregate = False # bool | (optional) (default to False) try: # trades - api_response = await api_instance.trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter) + api_response = await api_instance.trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter, role=role, type=type, aggregate=aggregate) print("The response of OrderApi->trades:\n") pprint(api_response) except Exception as e: @@ -661,6 +738,9 @@ Name | Type | Description | Notes **cursor** | **str**| | [optional] **var_from** | **int**| | [optional] [default to -1] **ask_filter** | **int**| | [optional] [default to -1] + **role** | **str**| | [optional] [default to all] + **type** | **str**| | [optional] [default to all] + **aggregate** | **bool**| | [optional] [default to False] ### Return type diff --git a/docs/lighter/lighter-python-main/docs/OrderBook.md b/docs/lighter/lighter-python-main/docs/OrderBook.md index 054b931..18d7edb 100644 --- a/docs/lighter/lighter-python-main/docs/OrderBook.md +++ b/docs/lighter/lighter-python-main/docs/OrderBook.md @@ -7,12 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **symbol** | **str** | | **market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | **status** | **str** | | **taker_fee** | **str** | | **maker_fee** | **str** | | **liquidation_fee** | **str** | | **min_base_amount** | **str** | | **min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | **supported_size_decimals** | **int** | | **supported_price_decimals** | **int** | | **supported_quote_decimals** | **int** | | diff --git a/docs/lighter/lighter-python-main/docs/OrderBookDepth.md b/docs/lighter/lighter-python-main/docs/OrderBookDepth.md index d2cafe9..6659c51 100644 --- a/docs/lighter/lighter-python-main/docs/OrderBookDepth.md +++ b/docs/lighter/lighter-python-main/docs/OrderBookDepth.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **asks** | [**List[PriceLevel]**](PriceLevel.md) | | **bids** | [**List[PriceLevel]**](PriceLevel.md) | | **offset** | **int** | | +**nonce** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/OrderBookDetails.md b/docs/lighter/lighter-python-main/docs/OrderBookDetails.md index 8480c35..0256daa 100644 --- a/docs/lighter/lighter-python-main/docs/OrderBookDetails.md +++ b/docs/lighter/lighter-python-main/docs/OrderBookDetails.md @@ -7,7 +7,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**order_book_details** | [**List[OrderBookDetail]**](OrderBookDetail.md) | | +**order_book_details** | [**List[PerpsOrderBookDetail]**](PerpsOrderBookDetail.md) | | +**spot_order_book_details** | [**List[SpotOrderBookDetail]**](SpotOrderBookDetail.md) | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/MarketInfo.md b/docs/lighter/lighter-python-main/docs/PerpsMarketStats.md similarity index 61% rename from docs/lighter/lighter-python-main/docs/MarketInfo.md rename to docs/lighter/lighter-python-main/docs/PerpsMarketStats.md index 7b495c7..bd2ed7b 100644 --- a/docs/lighter/lighter-python-main/docs/MarketInfo.md +++ b/docs/lighter/lighter-python-main/docs/PerpsMarketStats.md @@ -1,14 +1,18 @@ -# MarketInfo +# PerpsMarketStats ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | **market_id** | **int** | | **index_price** | **str** | | **mark_price** | **str** | | **open_interest** | **str** | | +**open_interest_limit** | **str** | | +**funding_clamp_small** | **str** | | +**funding_clamp_big** | **str** | | **last_trade_price** | **str** | | **current_funding_rate** | **str** | | **funding_rate** | **str** | | @@ -22,19 +26,19 @@ Name | Type | Description | Notes ## Example ```python -from lighter.models.market_info import MarketInfo +from lighter.models.perps_market_stats import PerpsMarketStats # TODO update the JSON string below json = "{}" -# create an instance of MarketInfo from a JSON string -market_info_instance = MarketInfo.from_json(json) +# create an instance of PerpsMarketStats from a JSON string +perps_market_stats_instance = PerpsMarketStats.from_json(json) # print the JSON string representation of the object -print(MarketInfo.to_json()) +print(PerpsMarketStats.to_json()) # convert the object into a dict -market_info_dict = market_info_instance.to_dict() -# create an instance of MarketInfo from a dict -market_info_from_dict = MarketInfo.from_dict(market_info_dict) +perps_market_stats_dict = perps_market_stats_instance.to_dict() +# create an instance of PerpsMarketStats from a dict +perps_market_stats_from_dict = PerpsMarketStats.from_dict(perps_market_stats_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/lighter/lighter-python-main/docs/OrderBookDetail.md b/docs/lighter/lighter-python-main/docs/PerpsOrderBookDetail.md similarity index 68% rename from docs/lighter/lighter-python-main/docs/OrderBookDetail.md rename to docs/lighter/lighter-python-main/docs/PerpsOrderBookDetail.md index 69de4ba..ad69ae3 100644 --- a/docs/lighter/lighter-python-main/docs/OrderBookDetail.md +++ b/docs/lighter/lighter-python-main/docs/PerpsOrderBookDetail.md @@ -1,4 +1,4 @@ -# OrderBookDetail +# PerpsOrderBookDetail ## Properties @@ -7,12 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **symbol** | **str** | | **market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | **status** | **str** | | **taker_fee** | **str** | | **maker_fee** | **str** | | **liquidation_fee** | **str** | | **min_base_amount** | **str** | | **min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | **supported_size_decimals** | **int** | | **supported_price_decimals** | **int** | | **supported_quote_decimals** | **int** | | @@ -32,23 +36,24 @@ Name | Type | Description | Notes **daily_price_change** | **float** | | **open_interest** | **float** | | **daily_chart** | **Dict[str, float]** | | +**market_config** | [**MarketConfig**](MarketConfig.md) | | ## Example ```python -from lighter.models.order_book_detail import OrderBookDetail +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail # TODO update the JSON string below json = "{}" -# create an instance of OrderBookDetail from a JSON string -order_book_detail_instance = OrderBookDetail.from_json(json) +# create an instance of PerpsOrderBookDetail from a JSON string +perps_order_book_detail_instance = PerpsOrderBookDetail.from_json(json) # print the JSON string representation of the object -print(OrderBookDetail.to_json()) +print(PerpsOrderBookDetail.to_json()) # convert the object into a dict -order_book_detail_dict = order_book_detail_instance.to_dict() -# create an instance of OrderBookDetail from a dict -order_book_detail_from_dict = OrderBookDetail.from_dict(order_book_detail_dict) +perps_order_book_detail_dict = perps_order_book_detail_instance.to_dict() +# create an instance of PerpsOrderBookDetail from a dict +perps_order_book_detail_from_dict = PerpsOrderBookDetail.from_dict(perps_order_book_detail_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/lighter/lighter-python-main/docs/PnLEntry.md b/docs/lighter/lighter-python-main/docs/PnLEntry.md index 6f80183..6032475 100644 --- a/docs/lighter/lighter-python-main/docs/PnLEntry.md +++ b/docs/lighter/lighter-python-main/docs/PnLEntry.md @@ -7,8 +7,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **timestamp** | **int** | | **trade_pnl** | **float** | | +**trade_spot_pnl** | **float** | | **inflow** | **float** | | **outflow** | **float** | | +**spot_outflow** | **float** | | +**spot_inflow** | **float** | | **pool_pnl** | **float** | | **pool_inflow** | **float** | | **pool_outflow** | **float** | | diff --git a/docs/lighter/lighter-python-main/docs/PublicPool.md b/docs/lighter/lighter-python-main/docs/PublicPool.md deleted file mode 100644 index 527e94e..0000000 --- a/docs/lighter/lighter-python-main/docs/PublicPool.md +++ /dev/null @@ -1,49 +0,0 @@ -# PublicPool - - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **int** | | -**message** | **str** | | [optional] -**account_type** | **int** | | -**index** | **int** | | -**l1_address** | **str** | | -**cancel_all_time** | **int** | | -**total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | -**pending_order_count** | **int** | | -**available_balance** | **str** | | -**status** | **int** | | -**collateral** | **str** | | -**account_index** | **int** | | -**name** | **str** | | -**description** | **str** | | -**can_invite** | **bool** | Remove After FE uses L1 meta endpoint | -**referral_points_percentage** | **str** | Remove After FE uses L1 meta endpoint | -**total_asset_value** | **str** | | -**cross_asset_value** | **str** | | -**pool_info** | [**PublicPoolInfo**](PublicPoolInfo.md) | | -**account_share** | [**PublicPoolShare**](PublicPoolShare.md) | | [optional] - -## Example - -```python -from lighter.models.public_pool import PublicPool - -# TODO update the JSON string below -json = "{}" -# create an instance of PublicPool from a JSON string -public_pool_instance = PublicPool.from_json(json) -# print the JSON string representation of the object -print(PublicPool.to_json()) - -# convert the object into a dict -public_pool_dict = public_pool_instance.to_dict() -# create an instance of PublicPool from a dict -public_pool_from_dict = PublicPool.from_dict(public_pool_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/docs/lighter/lighter-python-main/docs/PublicPoolInfo.md b/docs/lighter/lighter-python-main/docs/PublicPoolInfo.md index d3aac46..da382c3 100644 --- a/docs/lighter/lighter-python-main/docs/PublicPoolInfo.md +++ b/docs/lighter/lighter-python-main/docs/PublicPoolInfo.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **total_shares** | **int** | | **operator_shares** | **int** | | **annual_percentage_yield** | **float** | | +**sharpe_ratio** | **float** | | **daily_returns** | [**List[DailyReturn]**](DailyReturn.md) | | **share_prices** | [**List[SharePrice]**](SharePrice.md) | | diff --git a/docs/lighter/lighter-python-main/docs/PublicPoolMetadata.md b/docs/lighter/lighter-python-main/docs/PublicPoolMetadata.md index f3769c2..453108f 100644 --- a/docs/lighter/lighter-python-main/docs/PublicPoolMetadata.md +++ b/docs/lighter/lighter-python-main/docs/PublicPoolMetadata.md @@ -8,10 +8,13 @@ Name | Type | Description | Notes **code** | **int** | | **message** | **str** | | [optional] **account_index** | **int** | | +**created_at** | **int** | | +**master_account_index** | **int** | | **account_type** | **int** | | **name** | **str** | | **l1_address** | **str** | | **annual_percentage_yield** | **float** | | +**sharpe_ratio** | **float** | | **status** | **int** | | **operator_fee** | **str** | | **total_asset_value** | **str** | | diff --git a/docs/lighter/lighter-python-main/docs/ReferralApi.md b/docs/lighter/lighter-python-main/docs/ReferralApi.md index 0ee3c8b..77c7db1 100644 --- a/docs/lighter/lighter-python-main/docs/ReferralApi.md +++ b/docs/lighter/lighter-python-main/docs/ReferralApi.md @@ -4,9 +4,86 @@ All URIs are relative to *https://mainnet.zklighter.elliot.ai* Method | HTTP request | Description ------------- | ------------- | ------------- +[**referral_kickback_update**](ReferralApi.md#referral_kickback_update) | **POST** /api/v1/referral/kickback/update | referral_kickback_update [**referral_points**](ReferralApi.md#referral_points) | **GET** /api/v1/referral/points | referral_points +[**referral_update**](ReferralApi.md#referral_update) | **POST** /api/v1/referral/update | referral_update +# **referral_kickback_update** +> RespUpdateKickback referral_kickback_update(account_index, kickback_percentage, authorization=authorization, auth=auth) + +referral_kickback_update + +Update kickback percentage for referral rewards + +### Example + + +```python +import lighter +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.ReferralApi(api_client) + account_index = 56 # int | + kickback_percentage = 3.4 # float | + authorization = 'authorization_example' # str | make required after integ is done (optional) + auth = 'auth_example' # str | made optional to support header auth clients (optional) + + try: + # referral_kickback_update + api_response = await api_instance.referral_kickback_update(account_index, kickback_percentage, authorization=authorization, auth=auth) + print("The response of ReferralApi->referral_kickback_update:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ReferralApi->referral_kickback_update: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_index** | **int**| | + **kickback_percentage** | **float**| | + **authorization** | **str**| make required after integ is done | [optional] + **auth** | **str**| made optional to support header auth clients | [optional] + +### Return type + +[**RespUpdateKickback**](RespUpdateKickback.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **referral_points** > ReferralPoints referral_points(account_index, authorization=authorization, auth=auth) @@ -80,3 +157,78 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **referral_update** +> RespUpdateReferralCode referral_update(account_index, new_referral_code, authorization=authorization, auth=auth) + +referral_update + +Update referral code (allowed once per account) + +### Example + + +```python +import lighter +from lighter.models.resp_update_referral_code import RespUpdateReferralCode +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.ReferralApi(api_client) + account_index = 56 # int | + new_referral_code = 'new_referral_code_example' # str | + authorization = 'authorization_example' # str | make required after integ is done (optional) + auth = 'auth_example' # str | made optional to support header auth clients (optional) + + try: + # referral_update + api_response = await api_instance.referral_update(account_index, new_referral_code, authorization=authorization, auth=auth) + print("The response of ReferralApi->referral_update:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ReferralApi->referral_update: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_index** | **int**| | + **new_referral_code** | **str**| | + **authorization** | **str**| make required after integ is done | [optional] + **auth** | **str**| made optional to support header auth clients | [optional] + +### Return type + +[**RespUpdateReferralCode**](RespUpdateReferralCode.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/lighter/lighter-python-main/docs/ReferralPointEntry.md b/docs/lighter/lighter-python-main/docs/ReferralPointEntry.md index 2bb70bb..359a2eb 100644 --- a/docs/lighter/lighter-python-main/docs/ReferralPointEntry.md +++ b/docs/lighter/lighter-python-main/docs/ReferralPointEntry.md @@ -6,10 +6,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **l1_address** | **str** | | -**total_points** | **int** | | -**week_points** | **int** | | -**total_reward_points** | **int** | | -**week_reward_points** | **int** | | +**total_points** | **float** | | +**week_points** | **float** | | +**total_reward_points** | **float** | | +**week_reward_points** | **float** | | **reward_point_multiplier** | **str** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/ReferralPoints.md b/docs/lighter/lighter-python-main/docs/ReferralPoints.md index 3ed5f35..4235fa6 100644 --- a/docs/lighter/lighter-python-main/docs/ReferralPoints.md +++ b/docs/lighter/lighter-python-main/docs/ReferralPoints.md @@ -6,10 +6,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **referrals** | [**List[ReferralPointEntry]**](ReferralPointEntry.md) | | -**user_total_points** | **int** | | -**user_last_week_points** | **int** | | -**user_total_referral_reward_points** | **int** | | -**user_last_week_referral_reward_points** | **int** | | +**user_total_points** | **float** | | +**user_last_week_points** | **float** | | +**user_total_referral_reward_points** | **float** | | +**user_last_week_referral_reward_points** | **float** | | **reward_point_multiplier** | **str** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/ReqGetAssetDetails.md b/docs/lighter/lighter-python-main/docs/ReqGetAssetDetails.md new file mode 100644 index 0000000..ee1e39d --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/ReqGetAssetDetails.md @@ -0,0 +1,29 @@ +# ReqGetAssetDetails + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | **int** | | [optional] + +## Example + +```python +from lighter.models.req_get_asset_details import ReqGetAssetDetails + +# TODO update the JSON string below +json = "{}" +# create an instance of ReqGetAssetDetails from a JSON string +req_get_asset_details_instance = ReqGetAssetDetails.from_json(json) +# print the JSON string representation of the object +print(ReqGetAssetDetails.to_json()) + +# convert the object into a dict +req_get_asset_details_dict = req_get_asset_details_instance.to_dict() +# create an instance of ReqGetAssetDetails from a dict +req_get_asset_details_from_dict = ReqGetAssetDetails.from_dict(req_get_asset_details_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/ReqGetBridgesByL1Addr.md b/docs/lighter/lighter-python-main/docs/ReqGetBridgesByL1Addr.md new file mode 100644 index 0000000..a06ef98 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/ReqGetBridgesByL1Addr.md @@ -0,0 +1,29 @@ +# ReqGetBridgesByL1Addr + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**l1_address** | **str** | | + +## Example + +```python +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr + +# TODO update the JSON string below +json = "{}" +# create an instance of ReqGetBridgesByL1Addr from a JSON string +req_get_bridges_by_l1_addr_instance = ReqGetBridgesByL1Addr.from_json(json) +# print the JSON string representation of the object +print(ReqGetBridgesByL1Addr.to_json()) + +# convert the object into a dict +req_get_bridges_by_l1_addr_dict = req_get_bridges_by_l1_addr_instance.to_dict() +# create an instance of ReqGetBridgesByL1Addr from a dict +req_get_bridges_by_l1_addr_from_dict = ReqGetBridgesByL1Addr.from_dict(req_get_bridges_by_l1_addr_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/ReqGetOrderBookDetails.md b/docs/lighter/lighter-python-main/docs/ReqGetOrderBookDetails.md index 333f27a..81d1cf8 100644 --- a/docs/lighter/lighter-python-main/docs/ReqGetOrderBookDetails.md +++ b/docs/lighter/lighter-python-main/docs/ReqGetOrderBookDetails.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **market_id** | **int** | | [optional] +**filter** | **str** | | [optional] [default to 'all'] ## Example diff --git a/docs/lighter/lighter-python-main/docs/ReqGetOrderBooks.md b/docs/lighter/lighter-python-main/docs/ReqGetOrderBooks.md index 4cb4b5d..0b89605 100644 --- a/docs/lighter/lighter-python-main/docs/ReqGetOrderBooks.md +++ b/docs/lighter/lighter-python-main/docs/ReqGetOrderBooks.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **market_id** | **int** | | [optional] +**filter** | **str** | | [optional] [default to 'all'] ## Example diff --git a/docs/lighter/lighter-python-main/docs/ReqGetPublicPools.md b/docs/lighter/lighter-python-main/docs/ReqGetPublicPools.md deleted file mode 100644 index 367eef0..0000000 --- a/docs/lighter/lighter-python-main/docs/ReqGetPublicPools.md +++ /dev/null @@ -1,33 +0,0 @@ -# ReqGetPublicPools - - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**auth** | **str** | | [optional] -**filter** | **str** | | [optional] -**index** | **int** | | -**limit** | **int** | | -**account_index** | **int** | | [optional] - -## Example - -```python -from lighter.models.req_get_public_pools import ReqGetPublicPools - -# TODO update the JSON string below -json = "{}" -# create an instance of ReqGetPublicPools from a JSON string -req_get_public_pools_instance = ReqGetPublicPools.from_json(json) -# print the JSON string representation of the object -print(ReqGetPublicPools.to_json()) - -# convert the object into a dict -req_get_public_pools_dict = req_get_public_pools_instance.to_dict() -# create an instance of ReqGetPublicPools from a dict -req_get_public_pools_from_dict = ReqGetPublicPools.from_dict(req_get_public_pools_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/docs/lighter/lighter-python-main/docs/ReqGetTrades.md b/docs/lighter/lighter-python-main/docs/ReqGetTrades.md index 947005c..2d11282 100644 --- a/docs/lighter/lighter-python-main/docs/ReqGetTrades.md +++ b/docs/lighter/lighter-python-main/docs/ReqGetTrades.md @@ -14,7 +14,10 @@ Name | Type | Description | Notes **cursor** | **str** | | [optional] **var_from** | **int** | | [optional] [default to -1] **ask_filter** | **int** | | [optional] +**role** | **str** | | [optional] [default to 'all'] +**type** | **str** | | [optional] [default to 'all'] **limit** | **int** | | +**aggregate** | **bool** | | [optional] [default to False] ## Example diff --git a/docs/lighter/lighter-python-main/docs/RespGetBridgesByL1Addr.md b/docs/lighter/lighter-python-main/docs/RespGetBridgesByL1Addr.md new file mode 100644 index 0000000..3d797bd --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/RespGetBridgesByL1Addr.md @@ -0,0 +1,31 @@ +# RespGetBridgesByL1Addr + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**bridges** | [**List[Bridge]**](Bridge.md) | | + +## Example + +```python +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr + +# TODO update the JSON string below +json = "{}" +# create an instance of RespGetBridgesByL1Addr from a JSON string +resp_get_bridges_by_l1_addr_instance = RespGetBridgesByL1Addr.from_json(json) +# print the JSON string representation of the object +print(RespGetBridgesByL1Addr.to_json()) + +# convert the object into a dict +resp_get_bridges_by_l1_addr_dict = resp_get_bridges_by_l1_addr_instance.to_dict() +# create an instance of RespGetBridgesByL1Addr from a dict +resp_get_bridges_by_l1_addr_from_dict = RespGetBridgesByL1Addr.from_dict(resp_get_bridges_by_l1_addr_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/RespGetIsNextBridgeFast.md b/docs/lighter/lighter-python-main/docs/RespGetIsNextBridgeFast.md new file mode 100644 index 0000000..09ccf87 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/RespGetIsNextBridgeFast.md @@ -0,0 +1,31 @@ +# RespGetIsNextBridgeFast + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**is_next_bridge_fast** | **bool** | | + +## Example + +```python +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast + +# TODO update the JSON string below +json = "{}" +# create an instance of RespGetIsNextBridgeFast from a JSON string +resp_get_is_next_bridge_fast_instance = RespGetIsNextBridgeFast.from_json(json) +# print the JSON string representation of the object +print(RespGetIsNextBridgeFast.to_json()) + +# convert the object into a dict +resp_get_is_next_bridge_fast_dict = resp_get_is_next_bridge_fast_instance.to_dict() +# create an instance of RespGetIsNextBridgeFast from a dict +resp_get_is_next_bridge_fast_from_dict = RespGetIsNextBridgeFast.from_dict(resp_get_is_next_bridge_fast_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/RespSendTx.md b/docs/lighter/lighter-python-main/docs/RespSendTx.md index 5d58479..1fa1758 100644 --- a/docs/lighter/lighter-python-main/docs/RespSendTx.md +++ b/docs/lighter/lighter-python-main/docs/RespSendTx.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **message** | **str** | | [optional] **tx_hash** | **str** | | **predicted_execution_time_ms** | **int** | | +**volume_quota_remaining** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/RespSendTxBatch.md b/docs/lighter/lighter-python-main/docs/RespSendTxBatch.md index 1b02a5b..cf70435 100644 --- a/docs/lighter/lighter-python-main/docs/RespSendTxBatch.md +++ b/docs/lighter/lighter-python-main/docs/RespSendTxBatch.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **message** | **str** | | [optional] **tx_hash** | **List[str]** | | **predicted_execution_time_ms** | **int** | | +**volume_quota_remaining** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/RespUpdateKickback.md b/docs/lighter/lighter-python-main/docs/RespUpdateKickback.md new file mode 100644 index 0000000..db81414 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/RespUpdateKickback.md @@ -0,0 +1,31 @@ +# RespUpdateKickback + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**success** | **bool** | | + +## Example + +```python +from lighter.models.resp_update_kickback import RespUpdateKickback + +# TODO update the JSON string below +json = "{}" +# create an instance of RespUpdateKickback from a JSON string +resp_update_kickback_instance = RespUpdateKickback.from_json(json) +# print the JSON string representation of the object +print(RespUpdateKickback.to_json()) + +# convert the object into a dict +resp_update_kickback_dict = resp_update_kickback_instance.to_dict() +# create an instance of RespUpdateKickback from a dict +resp_update_kickback_from_dict = RespUpdateKickback.from_dict(resp_update_kickback_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/RespUpdateReferralCode.md b/docs/lighter/lighter-python-main/docs/RespUpdateReferralCode.md new file mode 100644 index 0000000..0579638 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/RespUpdateReferralCode.md @@ -0,0 +1,31 @@ +# RespUpdateReferralCode + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**success** | **bool** | | + +## Example + +```python +from lighter.models.resp_update_referral_code import RespUpdateReferralCode + +# TODO update the JSON string below +json = "{}" +# create an instance of RespUpdateReferralCode from a JSON string +resp_update_referral_code_instance = RespUpdateReferralCode.from_json(json) +# print the JSON string representation of the object +print(RespUpdateReferralCode.to_json()) + +# convert the object into a dict +resp_update_referral_code_dict = resp_update_referral_code_instance.to_dict() +# create an instance of RespUpdateReferralCode from a dict +resp_update_referral_code_from_dict = RespUpdateReferralCode.from_dict(resp_update_referral_code_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/SpotMarketStats.md b/docs/lighter/lighter-python-main/docs/SpotMarketStats.md new file mode 100644 index 0000000..d471d39 --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/SpotMarketStats.md @@ -0,0 +1,38 @@ +# SpotMarketStats + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**market_id** | **int** | | +**index_price** | **str** | | +**mid_price** | **str** | | +**last_trade_price** | **str** | | +**daily_base_token_volume** | **float** | | +**daily_quote_token_volume** | **float** | | +**daily_price_low** | **float** | | +**daily_price_high** | **float** | | +**daily_price_change** | **float** | | + +## Example + +```python +from lighter.models.spot_market_stats import SpotMarketStats + +# TODO update the JSON string below +json = "{}" +# create an instance of SpotMarketStats from a JSON string +spot_market_stats_instance = SpotMarketStats.from_json(json) +# print the JSON string representation of the object +print(SpotMarketStats.to_json()) + +# convert the object into a dict +spot_market_stats_dict = spot_market_stats_instance.to_dict() +# create an instance of SpotMarketStats from a dict +spot_market_stats_from_dict = SpotMarketStats.from_dict(spot_market_stats_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/SpotOrderBookDetail.md b/docs/lighter/lighter-python-main/docs/SpotOrderBookDetail.md new file mode 100644 index 0000000..a41e15e --- /dev/null +++ b/docs/lighter/lighter-python-main/docs/SpotOrderBookDetail.md @@ -0,0 +1,53 @@ +# SpotOrderBookDetail + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | +**status** | **str** | | +**taker_fee** | **str** | | +**maker_fee** | **str** | | +**liquidation_fee** | **str** | | +**min_base_amount** | **str** | | +**min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | +**supported_size_decimals** | **int** | | +**supported_price_decimals** | **int** | | +**supported_quote_decimals** | **int** | | +**size_decimals** | **int** | | +**price_decimals** | **int** | | +**last_trade_price** | **float** | | +**daily_trades_count** | **int** | | +**daily_base_token_volume** | **float** | | +**daily_quote_token_volume** | **float** | | +**daily_price_low** | **float** | | +**daily_price_high** | **float** | | +**daily_price_change** | **float** | | +**daily_chart** | **Dict[str, float]** | | + +## Example + +```python +from lighter.models.spot_order_book_detail import SpotOrderBookDetail + +# TODO update the JSON string below +json = "{}" +# create an instance of SpotOrderBookDetail from a JSON string +spot_order_book_detail_instance = SpotOrderBookDetail.from_json(json) +# print the JSON string representation of the object +print(SpotOrderBookDetail.to_json()) + +# convert the object into a dict +spot_order_book_detail_dict = spot_order_book_detail_instance.to_dict() +# create an instance of SpotOrderBookDetail from a dict +spot_order_book_detail_from_dict = SpotOrderBookDetail.from_dict(spot_order_book_detail_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/lighter/lighter-python-main/docs/Trade.md b/docs/lighter/lighter-python-main/docs/Trade.md index ac611a0..2e00927 100644 --- a/docs/lighter/lighter-python-main/docs/Trade.md +++ b/docs/lighter/lighter-python-main/docs/Trade.md @@ -14,6 +14,8 @@ Name | Type | Description | Notes **usd_amount** | **str** | | **ask_id** | **int** | | **bid_id** | **int** | | +**ask_client_id** | **int** | | +**bid_client_id** | **int** | | **ask_account_id** | **int** | | **bid_account_id** | **int** | | **is_maker_ask** | **bool** | | diff --git a/docs/lighter/lighter-python-main/docs/TransferHistoryItem.md b/docs/lighter/lighter-python-main/docs/TransferHistoryItem.md index 4d7f5df..b3984ce 100644 --- a/docs/lighter/lighter-python-main/docs/TransferHistoryItem.md +++ b/docs/lighter/lighter-python-main/docs/TransferHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **type** | **str** | | @@ -13,6 +14,8 @@ Name | Type | Description | Notes **to_l1_address** | **str** | | **from_account_index** | **int** | | **to_account_index** | **int** | | +**from_route** | **str** | | +**to_route** | **str** | | **tx_hash** | **str** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/Tx.md b/docs/lighter/lighter-python-main/docs/Tx.md index 76f8f11..193c21e 100644 --- a/docs/lighter/lighter-python-main/docs/Tx.md +++ b/docs/lighter/lighter-python-main/docs/Tx.md @@ -20,6 +20,7 @@ Name | Type | Description | Notes **executed_at** | **int** | | **sequence_index** | **int** | | **parent_hash** | **str** | | +**api_key_index** | **int** | | ## Example diff --git a/docs/lighter/lighter-python-main/docs/WithdrawHistoryItem.md b/docs/lighter/lighter-python-main/docs/WithdrawHistoryItem.md index 1ae6002..8ce329d 100644 --- a/docs/lighter/lighter-python-main/docs/WithdrawHistoryItem.md +++ b/docs/lighter/lighter-python-main/docs/WithdrawHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **status** | **str** | | diff --git a/docs/lighter/lighter-python-main/examples/.gitignore b/docs/lighter/lighter-python-main/examples/.gitignore new file mode 100644 index 0000000..87b6ebd --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/.gitignore @@ -0,0 +1 @@ +api_key_config.json \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/README.md b/docs/lighter/lighter-python-main/examples/README.md index b506b7c..f565290 100644 --- a/docs/lighter/lighter-python-main/examples/README.md +++ b/docs/lighter/lighter-python-main/examples/README.md @@ -5,18 +5,152 @@ - this will require you to enter your Ethereum private key - the eth private key will only be used in the Py SDK to sign a message - the eth private key is not required in order to trade on the platform - - the eth private key is not passed to the binary - - copy the output of the script and post it into `create_cancel_order.py` - - the output should look like -``` -BASE_URL = 'https://testnet.zklighter.elliot.ai' -API_KEY_PRIVATE_KEY = '0xea5d2eca5be67eca056752eaf27b173518b8a5550117c09d2b58c7ea7d306cc4426f913ccf27ab19' -ACCOUNT_INDEX = 595 -API_KEY_INDEX = 1 -``` -- start trading using - - `create_cancel_order.py` has an example which created an order on testnet & cancels it - - you'll need to set up both your account index, api key index & API Key private key + - the eth private key is not passed to the binary + - the API key config is saved in a local file `./api_key_config.json` + +## Start trading on testnet +- `create_modify_cancel_order_http.py` + - creates an ask (sell) order for 0.1 ETH @ $4050 + - modified the order and increases the size to 0.11 ETH and increases the price to $4100 + - cancels the order + - Note: all of these operations use the client order index of the order. You can use the order from the exchange as well + +- `create_modify_cancel_order_ws.py` + - same flow as `create_modify_cancel_order_http.py` + - sends TXs over WS instead of HTTP + +- `create_market_order_eth_buy.py` + - creates a market buy order for 0.1 ETH @ market price +- `create_market_order_eth_sell.py` + - creates a market sell order for 0.1 ETH @ market price + +- `create_grouped_ioc_with_attached_sl_tp.py` + - creates an ask (sell) IoC order for 0.1 ETH + - along w/ the order, it sets up a Stop Loss (SL) and a Take Profit (TP) order for the whole size of the order + - the size of the SL/TP will be equal to the executed size of the order + - the SL/TP orders are canceled when the sign of your position changes + +- `create_position_tied_sl_tp.py` + - creates a bid (buy) Stop Loss (SL) and a Take Profit (TP) to close your short position + - the size of the orders will be for your whole position (because BaseAmount=0) + - the orders will grow / shrink as you accumulate more position + - the SL/TP orders are canceled when the sign of your position changes + +## On SL/TP orders +SL/TP orders need to be configured beyond just setting the trigger price. When the trigger price is set, +the order will just be executed, like a normal order. This means that a market order, for example, might not have enough slippage! \ +Let's say that you have a 1 BTC long position, and the current price is $110'000. \ +You want to set up a take profit at $120'000 +- order should be an ask (sell) order, to close your position +- the trigger price should be $120'000 + +What about the order types? Just as normal orders, SL/TP orders trigger an order, which can be: +- market order +- limit IOC / GTC + +## Modify leverage / Margin Mode (Cross, Isolated) / Add Collateral to isolated-only positions +- `margin_eth_20x_cross_http` + - sets ETH market to 20x leverage and cross-margin mode, using HTTP +- `margin_eth_50x_isolate_ws` + - sets ETH market to 50x leverage and isolated margin mode, using HTTP +- `margin_eth_add_collateral_http.py` + - adds $10.5 USDC to the ETH position (must be opened and in isolated mode) +- `margin_eth_remove_collateral_ws.py` + - removes $5 USDC from the ETH position (must be opened and in isolated mode) + +## Batch orders +- `send_batch_tx_http.py` + - sends multiple orders in a single HTTP request +- `send_batch_tx_ws.py` + - sends multiple orders in a single WS request` + +Batch TXs will be executed back to back, without the possibility of other TXs interfering. + +## Spot Trading +To trade spot markets, you need to have spot USDC. USDC used in your perpetual account will be used as collateral for your cross-positions. +USDC deposited in the spot account can only be used to buy spot assets. +To transfer USDC between spot <> perp balance, or vice verse, check out +- `spot_self_transfer_perp_spot.py` +- `spot_self_transfer_spot_perp.py` + +Order placement / trades work in the same way as for perpetual markets. +The fee will be paid in the received asset for premium spot trades. +This means that if you sell ETH, you'll receive less USDC, and if you BUY 1 ETH, you'll receive slightly less than 1 ETH. +You can check out the following examples, which should work on spot ETH by changing the market index to 2048 instead of 0. +- `create_modify_cancel_order_http.py` +- `create_modify_cancel_order_ws.py` +- `create_market_order_eth_buy.py` +- `create_market_order_eth_sell.py` +- `send_batch_tx_http.py` +- `send_batch_tx_ws.py` + +Trading setup is very similar to perpetual markets. +The only difference is that you'll need to hold USDC / ETH before placing an order. +For example, on perp markets you can place an order to short (sell) ETH without having to worry that much. +The limitation there would be to have enough available collateral to cover the order. +On spot orders, you need to have enough assets in your spot account to cover all open orders. +If you want to place two orders, to buy 1000 USDC worth of ETH and 1000 USDC worth of ZK, you'll need to have at least 2000 available USDC. + +You can get the order book details (including symbol and market index) as well as quote asset id (ETH) and base asset id (USDC) +by following the example below: +- `spot_get_order_books.py` + +Note: you'll need the quote asset id and base asset id to check available balance. +Available balance is not locked in open orders. + +To keep track of your spot balance, you can use HTTP calls or a websocket subscription. +Examples on how to do this can be found here: +- `spot_get_account_assets_http.py` +- `spot_get_account_assets_ws.py` + +Moving money to / from subaccounts is possible for spot assets. +For USDC, you can move directly from main perp balance to subaccount spot balance, for example. +More details can be found in the following example: +- `sub_account_create.py` +- `sub_account_transfer_eth.py` +- `sub_account_transfer_usdc.py` + +## Public Pools +Public pools behave just like subaccounts, except that anyone can join them. +You can create / modify a public pool using the SDK. Check out the following example: +- `public_pool_create_modify.py` + +To create API keys for a public pool, you need to run the setup script but specify the `ACCOUNT_INDEX` to be the one of the public pool. +After that, you can trade from the public as from any other account. + +If you want to deposit / withdraw from a public pool, check the following example: +- `public_pool_deposit.py` +- `public_pool_withdraw.py` + +To get information about pools, check: +- `public_pool_info.py` + +## Moving funds around +- `withdraw_fast.py` + - send USDC directly from Lighter to Arbitrum +- `withdraw_normal.py` + - send USDC/ETH from Lighter to Ethereum +- `transfer.py` + - generic example of how to transfer funds between accounts. + - same functionality as `sub_account_transfer_eth` and `sub_account_transfer_usdc` + +## Transfer Notes +The `memo` field is a user message, and it has to be exactly 32 bytes long. In case of fast withdrawals, you need to specify the recipient in the memo. +This is the case since the memo is part of the signature. This way, the recipient is verified. + +When calling `client.transfer`, you pass the amount without needing to worry about the decimals. +When calling `client.sign_transfer` on the other hand, you need to specify the decimals and pass an integer. + +The `fee` field can be obtained by calling `info_api.transfer_fee_info(...)`. The field can be passed as it is. +Transfers between subaccounts are free for all assets. + +When sending assets, you can specify the source and destination routes. +A route is either `perp` or `spot`. You can send USDC directly from your perp balance to another person's spot balance. +If you receive USDC in your perp account, it will be instantly used as collateral for open positions. +This also allows you to move USDC from your spot balance to your perp balance. +Spot assets (like ETH) need to have both the from and to route set to `spot`. +You can get all `asset_id`s by following the example below: +- `spot_get_order_books.py` ## Setup steps for mainnet - deposit money on Lighter to create an account first diff --git a/docs/lighter/lighter-python-main/examples/create_cancel_order.py b/docs/lighter/lighter-python-main/examples/create_cancel_order.py deleted file mode 100644 index 4264e3c..0000000 --- a/docs/lighter/lighter-python-main/examples/create_cancel_order.py +++ /dev/null @@ -1,70 +0,0 @@ -import asyncio -import logging -import lighter - -logging.basicConfig(level=logging.DEBUG) - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and servers as an example. -# Alternatively, you can go to https://app.lighter.xyz/apikeys for mainnet api keys -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = "0xed636277f3753b6c0275f7a28c2678a7f3a95655e09deaebec15179b50c5da7f903152e50f594f7b" -ACCOUNT_INDEX = 65 -API_KEY_INDEX = 1 - - -def trim_exception(e: Exception) -> str: - return str(e).strip().split("\n")[-1] - - -async def main(): - api_client = lighter.ApiClient(configuration=lighter.Configuration(host=BASE_URL)) - - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - - err = client.check_client() - if err is not None: - print(f"CheckClient error: {trim_exception(err)}") - return - - # create order - tx, tx_hash, err = await client.create_order( - market_index=0, - client_order_index=123, - base_amount=100000, - price=405000, - is_ask=True, - order_type=lighter.SignerClient.ORDER_TYPE_LIMIT, - time_in_force=lighter.SignerClient.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=0, - trigger_price=0, - ) - print(f"Create Order {tx=} {tx_hash=} {err=}") - if err is not None: - raise Exception(err) - - auth, err = client.create_auth_token_with_expiry(lighter.SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY) - print(f"{auth=}") - if err is not None: - raise Exception(err) - - # cancel order - tx, tx_hash, err = await client.cancel_order( - market_index=0, - order_index=123, - ) - print(f"Cancel Order {tx=} {tx_hash=} {err=}") - if err is not None: - raise Exception(err) - - await client.close() - await api_client.close() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_grouped_ioc_with_attached_sl_tp.py b/docs/lighter/lighter-python-main/examples/create_grouped_ioc_with_attached_sl_tp.py new file mode 100644 index 0000000..4fd9012 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_grouped_ioc_with_attached_sl_tp.py @@ -0,0 +1,69 @@ +import asyncio +from lighter.signer_client import CreateOrderTxReq +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + # Sell some ETH at $2500 + # The size of the SL/TP orders will be equal to the size of the executed order + + # set SL trigger price at 5000 and limit price at 5050 + # set TP trigger price at 1500 and limit price at 1550 + # Note: set the limit price to be higher than the SL/TP trigger price to ensure the order will be filled + # If the mark price of ETH reaches 1500, there might be no one willing to sell you ETH at 1500, so trying to buy at 1550 would increase the fill rate + + ioc_order = CreateOrderTxReq( + MarketIndex=0, + ClientOrderIndex=0, + BaseAmount=1000, # 0.1 ETH + Price=2500_00, # $2500 + IsAsk=1, # sell + Type=client.ORDER_TYPE_LIMIT, + TimeInForce=client.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + ReduceOnly=0, + TriggerPrice=0, + OrderExpiry=0, + ) + + # Create a One-Cancels-the-Other grouped order with a take-profit and a stop-loss order + take_profit_order = CreateOrderTxReq( + MarketIndex=0, + ClientOrderIndex=0, + BaseAmount=0, + Price=1550_00, + IsAsk=0, + Type=client.ORDER_TYPE_TAKE_PROFIT_LIMIT, + TimeInForce=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + ReduceOnly=1, + TriggerPrice=1500_00, + OrderExpiry=-1, + ) + + stop_loss_order = CreateOrderTxReq( + MarketIndex=0, + ClientOrderIndex=0, + BaseAmount=0, + Price=5050_00, + IsAsk=0, + Type=client.ORDER_TYPE_STOP_LOSS_LIMIT, + TimeInForce=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + ReduceOnly=1, + TriggerPrice=5000_00, + OrderExpiry=-1, + ) + + transaction = await client.create_grouped_orders( + grouping_type=client.GROUPING_TYPE_ONE_TRIGGERS_A_ONE_CANCELS_THE_OTHER, + orders=[ioc_order, take_profit_order, stop_loss_order], + ) + + print("Create Grouped Order Tx:", transaction) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_market_order.py b/docs/lighter/lighter-python-main/examples/create_market_order.py deleted file mode 100644 index 069d2db..0000000 --- a/docs/lighter/lighter-python-main/examples/create_market_order.py +++ /dev/null @@ -1,39 +0,0 @@ -import asyncio -import logging -import lighter - -logging.basicConfig(level=logging.DEBUG) - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and serves as an example. -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = "0xed636277f3753b6c0275f7a28c2678a7f3a95655e09deaebec15179b50c5da7f903152e50f594f7b" -ACCOUNT_INDEX = 65 -API_KEY_INDEX = 3 - - -def trim_exception(e: Exception) -> str: - return str(e).strip().split("\n")[-1] - - -async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - - tx = await client.create_market_order( - market_index=0, - client_order_index=0, - base_amount=1000, # 0.1 ETH - avg_execution_price=170000, # $1700 -- worst acceptable price for the order - is_ask=True, - ) - print("Create Order Tx:", tx) - await client.close() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_market_order_eth_buy.py b/docs/lighter/lighter-python-main/examples/create_market_order_eth_buy.py new file mode 100644 index 0000000..32a6128 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_market_order_eth_buy.py @@ -0,0 +1,28 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + client.check_client() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + tx, tx_hash, err = await client.create_market_order( + market_index=market_index, + client_order_index=0, + base_amount=1000, # 0.1 ETH + avg_execution_price=4000_00, # $4000 -- worst acceptable price for the order + is_ask=False, + ) + print(f"Create Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_market_order_eth_sell.py b/docs/lighter/lighter-python-main/examples/create_market_order_eth_sell.py new file mode 100644 index 0000000..1eac770 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_market_order_eth_sell.py @@ -0,0 +1,28 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + client.check_client() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + tx, tx_hash, err = await client.create_market_order( + market_index=market_index, + client_order_index=0, + base_amount=1000, # 0.1 ETH + avg_execution_price=1700_00, # $1700 -- worst acceptable price for the order + is_ask=True, + ) + print(f"Create Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_market_order_max_slippage.py b/docs/lighter/lighter-python-main/examples/create_market_order_max_slippage.py index f219a22..b05fa40 100644 --- a/docs/lighter/lighter-python-main/examples/create_market_order_max_slippage.py +++ b/docs/lighter/lighter-python-main/examples/create_market_order_max_slippage.py @@ -1,33 +1,21 @@ import asyncio -import logging -import lighter - -logging.basicConfig(level=logging.DEBUG) - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and serves as an example. -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = "0xe0fa55e11d6b5575d54c0500bd2f3b240221ae90241e3b573f2307e27de20c04ea628de3f1936e56" -ACCOUNT_INDEX = 22 -API_KEY_INDEX = 3 - - -def trim_exception(e: Exception) -> str: - return str(e).strip().split("\n")[-1] +from utils import default_example_setup async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) + client, api_client, _ = default_example_setup() # tx = await client.create_market_order_limited_slippage(market_index=0, client_order_index=0, base_amount=30000000, # max_slippage=0.001, is_ask=True) - tx = await client.create_market_order_if_slippage(market_index=0, client_order_index=0, base_amount=30000000, - max_slippage=0.01, is_ask=True, ideal_price=300000) + tx = await client.create_market_order_if_slippage( + market_index=0, # ETH + client_order_index=0, + base_amount=1000, # 0.1 ETH + max_slippage=0.01, # 1% + is_ask=True, + ideal_price=300000 # $3000 + ) + print("Create Order Tx:", tx) await client.close() diff --git a/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_http.py b/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_http.py new file mode 100644 index 0000000..4cab96d --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_http.py @@ -0,0 +1,65 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + client.check_client() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + # create order + api_key_index, nonce = client.nonce_manager.next_nonce() + tx, tx_hash, err = await client.create_order( + market_index=market_index, + client_order_index=123, + base_amount=1000, # 0.1 ETH + price=4050_00, # $4050 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + print(f"Create Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + ## modify order + # use the same API key so the TX goes after the create order TX + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + tx, tx_hash, err = await client.modify_order( + market_index=market_index, + order_index=123, + base_amount=1100, # 0.11 ETH + price=4100_00, # $4100 + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + print(f"Modify Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + ## cancel order + # use the same API key so the TX goes after the modify order TX + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + tx, tx_hash, err = await client.cancel_order( + market_index=market_index, + order_index=123, + nonce=nonce, + api_key_index=api_key_index, + ) + print(f"Cancel Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_ws.py b/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_ws.py new file mode 100644 index 0000000..1c8f2d6 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_modify_cancel_order_ws.py @@ -0,0 +1,72 @@ +import websockets +import asyncio +from utils import default_example_setup, ws_send_tx + + +# this example does the same thing as the create_modify_cancel_order.py example, but sends the TX over WS instead of HTTP +async def main(): + client, api_client, ws_client_promise = default_example_setup() + client.check_client() + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + print("Received:", await ws_client.recv()) + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + # create order + api_key_index, nonce = client.nonce_manager.next_nonce() + tx_type, tx_info, tx_hash, err = client.sign_create_order( + market_index=market_index, + client_order_index=123, + base_amount=1000, # 0.1 ETH + price=4050_00, # $4050 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + if err is not None: + raise Exception(err) + await ws_send_tx(ws_client, tx_type, tx_info, tx_hash) + + ## modify order + # use the same API key so the TX goes after the create order TX + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + tx_type, tx_info, tx_hash, err = client.sign_modify_order( + market_index=market_index, + order_index=123, + base_amount=1100, # 0.11 ETH + price=4100_00, # $4100 + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + if err is not None: + raise Exception(err) + await ws_send_tx(ws_client, tx_type, tx_info, tx_hash) + + ## cancel order + # use the same API key so the TX goes after the modify order TX + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + tx_type, tx_info, tx_hash, err = client.sign_cancel_order( + market_index=market_index, + order_index=123, + nonce=nonce, + api_key_index=api_key_index, + ) + if err is not None: + raise Exception(err) + await ws_send_tx(ws_client, tx_type, tx_info, tx_hash) + + await client.close() + await api_client.close() + await ws_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_position_tied_sl_tp.py b/docs/lighter/lighter-python-main/examples/create_position_tied_sl_tp.py new file mode 100644 index 0000000..0b691e1 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/create_position_tied_sl_tp.py @@ -0,0 +1,56 @@ +import asyncio +from lighter.signer_client import CreateOrderTxReq +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + # Creates a position tied SL/TP pair + # The SL/TP orders will close your whole position, even if you add/remove from it later on + # if the positions reach 0 or switches from short -> long, the orders are canceled + + # this particular example, sets the SL/TP for a short position + # set SL trigger price at 5000 and limit price at 5050 + # set TP trigger price at 1500 and limit price at 1550 + # Note: set the limit price to be higher than the SL/TP trigger price to ensure the order will be filled + # If the mark price of ETH reaches 1500, there might be no one willing to sell you ETH at 1500, so trying to buy at 1550 would increase the fill rate + + # Create a One-Cancels-the-Other grouped order with a take-profit and a stop-loss order + take_profit_order = CreateOrderTxReq( + MarketIndex=0, + ClientOrderIndex=0, + BaseAmount=0, + Price=1550_00, + IsAsk=0, + Type=client.ORDER_TYPE_TAKE_PROFIT_LIMIT, + TimeInForce=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + ReduceOnly=1, + TriggerPrice=1500_00, + OrderExpiry=-1, + ) + + stop_loss_order = CreateOrderTxReq( + MarketIndex=0, + ClientOrderIndex=0, + BaseAmount=0, + Price=4050_00, + IsAsk=0, + Type=client.ORDER_TYPE_STOP_LOSS_LIMIT, + TimeInForce=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + ReduceOnly=1, + TriggerPrice=4000_00, + OrderExpiry=-1, + ) + + transaction = await client.create_grouped_orders( + grouping_type=client.GROUPING_TYPE_ONE_CANCELS_THE_OTHER, + orders=[take_profit_order, stop_loss_order], + ) + + print("Create Grouped Order Tx:", transaction) + await client.close() + await api_client.close() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_sl_tp.py b/docs/lighter/lighter-python-main/examples/create_sl_tp.py deleted file mode 100644 index a6b4b6d..0000000 --- a/docs/lighter/lighter-python-main/examples/create_sl_tp.py +++ /dev/null @@ -1,70 +0,0 @@ -import asyncio -import logging -import lighter - -logging.basicConfig(level=logging.DEBUG) - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and servers as an example. -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = "0xe0fa55e11d6b5575d54c0500bd2f3b240221ae90241e3b573f2307e27de20c04ea628de3f1936e56" -ACCOUNT_INDEX = 22 -API_KEY_INDEX = 3 - - -def trim_exception(e: Exception) -> str: - return str(e).strip().split("\n")[-1] - - -async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - - tx = await client.create_tp_order( - market_index=0, - client_order_index=0, - base_amount=1000, # 0.1 ETH - trigger_price=500000, - price=500000, - is_ask=False - ) - print("Create Order Tx:", tx) - - - tx = await client.create_sl_order( - market_index=0, - client_order_index=0, - base_amount=1000, # 0.1 ETH - trigger_price=500000, - price=500000, - is_ask=False - ) - print("Create Order Tx:", tx) - - tx = await client.create_tp_limit_order( - market_index=0, - client_order_index=0, - base_amount=1000, # 0.1 ETH - trigger_price=500000, - price=500000, - is_ask=False - ) - - tx = await client.create_sl_limit_order( - market_index=0, - client_order_index=0, - base_amount=1000, # 0.1 ETH - trigger_price=500000, - price=500000, - is_ask=False - ) - print("Create Order Tx:", tx) - await client.close() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/create_with_multiple_keys.py b/docs/lighter/lighter-python-main/examples/create_with_multiple_keys.py index 45c874c..94e0b2e 100644 --- a/docs/lighter/lighter-python-main/examples/create_with_multiple_keys.py +++ b/docs/lighter/lighter-python-main/examples/create_with_multiple_keys.py @@ -1,47 +1,30 @@ +import time import asyncio -import lighter - - -BASE_URL = "https://testnet.zklighter.elliot.ai" -# use examples/system_setup.py or the apikeys page (for mainnet) to generate new api keys -KEYS = { - 5: "API_PRIVATE_KEY_5", - 6: "API_PRIVATE_KEY_6", - 7: "API_PRIVATE_KEY_7", -} -ACCOUNT_INDEX = 100 # replace with your account_index +from utils import default_example_setup async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=KEYS[5], - account_index=ACCOUNT_INDEX, - api_key_index=5, - max_api_key_index=7, - private_keys=KEYS, - ) + client, api_client, _ = default_example_setup() - err = client.check_client() - if err is not None: - print(f"CheckClient error: {err}") - return + # create 20 orders. The client will use as many API keys as it was configured. for i in range(20): res_tuple = await client.create_order( market_index=0, client_order_index=123 + i, - base_amount=100000 + i, - price=385000 + i, + base_amount=1000 + i, # 0.1 ETH + dust + price=3850_00 + i, is_ask=True, - order_type=lighter.SignerClient.ORDER_TYPE_LIMIT, - time_in_force=lighter.SignerClient.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=0, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, trigger_price=0, ) print(res_tuple) - await client.cancel_all_orders(time_in_force=client.CANCEL_ALL_TIF_IMMEDIATE, time=0) + # wait for orders to be created + time.sleep(1) + await client.cancel_all_orders(time_in_force=client.CANCEL_ALL_TIF_IMMEDIATE, timestamp_ms=0) if __name__ == "__main__": diff --git a/docs/lighter/lighter-python-main/examples/get_info.py b/docs/lighter/lighter-python-main/examples/get_info.py index 30187b0..fd44dd2 100644 --- a/docs/lighter/lighter-python-main/examples/get_info.py +++ b/docs/lighter/lighter-python-main/examples/get_info.py @@ -75,7 +75,11 @@ async def transaction_apis(client: lighter.ApiClient): # use with a valid sequence index # await print_api(transaction_instance.tx, by="sequence_index", value="5") await print_api(transaction_instance.txs, index=0, limit=2) - + +async def funding_apis(client: lighter.ApiClient): + logging.info("FUNDING APIS") + account_instance = lighter.FundingApi(client) + await print_api(account_instance.funding_rates) async def main(): client = lighter.ApiClient(configuration=lighter.Configuration(host="https://testnet.zklighter.elliot.ai")) @@ -84,6 +88,7 @@ async def main(): await candlestick_apis(client) await order_apis(client) await transaction_apis(client) + await funding_apis(client) await client.close() diff --git a/docs/lighter/lighter-python-main/examples/margin_eth_20x_cross_http.py b/docs/lighter/lighter-python-main/examples/margin_eth_20x_cross_http.py new file mode 100644 index 0000000..afdb023 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/margin_eth_20x_cross_http.py @@ -0,0 +1,29 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + # Note: the HTTP method `update_leverage` receives `leverage` as the argument, + # while the WS one that calls `sign_update_leverage` to get the TX to send it directly over WS + # receives `fraction` as the argument, which is 10_000 / leverage + # this was kept this way to not break backwards compatibility. Ideally, they would be consistent. + + tx, tx_hash, err = await client.update_leverage( + market_index=0, + leverage=20, + margin_mode=client.CROSS_MARGIN_MODE + ) + + print(f"Update Leverage {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) + diff --git a/docs/lighter/lighter-python-main/examples/margin_eth_50x_isolate_ws.py b/docs/lighter/lighter-python-main/examples/margin_eth_50x_isolate_ws.py new file mode 100644 index 0000000..dd08b4c --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/margin_eth_50x_isolate_ws.py @@ -0,0 +1,33 @@ +import websockets +import asyncio +from utils import default_example_setup, ws_send_tx + + +async def main(): + client, api_client, ws_client_promise = default_example_setup() + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + print("Received:", await ws_client.recv()) + + # Note: the HTTP method `update_leverage` receives `leverage` as the argument, + # while the WS one that calls `sign_update_leverage` to get the TX to send it directly over WS + # receives `fraction` as the argument, which is 10_000 / leverage + # this was kept this way to not break backwards compatibility. Ideally, they would be consistent. + + tx_type, tx_info, tx_hash, err = client.sign_update_leverage( + market_index=0, + fraction=10_000 // 50, + margin_mode=client.ISOLATED_MARGIN_MODE + ) + if err is not None: + raise Exception(err) + await ws_send_tx(ws_client, tx_type, tx_info, tx_hash) + + await client.close() + await api_client.close() + await ws_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/margin_eth_add_collateral_http.py b/docs/lighter/lighter-python-main/examples/margin_eth_add_collateral_http.py new file mode 100644 index 0000000..c0d1fed --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/margin_eth_add_collateral_http.py @@ -0,0 +1,29 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + # Note: the HTTP method `update_margin` receives `usdc_amount` (float) as the argument, + # while the WS one that calls `sign_update_margin` to get the TX to send it directly over WS + # receives `usdc_amount` (int) as the argument, which is the float one * 1_000_000 + # this was kept this way to not break backwards compatibility. Ideally, they would be consistent. + + tx, tx_hash, err = await client.update_margin( + market_index=0, + usdc_amount=10.5, + direction=client.ISOLATED_MARGIN_ADD_COLLATERAL + ) + + print(f"Update Margin {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) + diff --git a/docs/lighter/lighter-python-main/examples/margin_eth_remove_collateral_ws.py b/docs/lighter/lighter-python-main/examples/margin_eth_remove_collateral_ws.py new file mode 100644 index 0000000..11dbadc --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/margin_eth_remove_collateral_ws.py @@ -0,0 +1,32 @@ +import asyncio +import websockets +from utils import default_example_setup, ws_send_tx + + +async def main(): + client, api_client, ws_client_promise = default_example_setup() + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + print("Received:", await ws_client.recv()) + + # Note: the HTTP method `update_margin` receives `usdc_amount` (float) as the argument, + # while the WS one that calls `sign_update_margin` to get the TX to send it directly over WS + # receives `usdc_amount` (int) as the argument, which is the float one * 1_000_000 + # this was kept this way to not break backwards compatibility. Ideally, they would be consistent. + + tx_type, tx_info, tx_hash, err = client.sign_update_margin( + market_index=0, + usdc_amount=5_000_000, # 5 USDC + direction=client.ISOLATED_MARGIN_REMOVE_COLLATERAL + ) + if err is not None: + raise Exception(err) + await ws_send_tx(ws_client, tx_type, tx_info, tx_hash) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/public_pool_create_modify.py b/docs/lighter/lighter-python-main/examples/public_pool_create_modify.py new file mode 100644 index 0000000..dbffee7 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/public_pool_create_modify.py @@ -0,0 +1,59 @@ +import time +import json +import asyncio +import lighter +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + tx_api = lighter.TransactionApi(api_client) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + auth, _ = client.create_auth_token_with_expiry() + + # create a public pool + tx_info, response, err = await client.create_public_pool( + operator_fee=100000, # 10% + initial_total_shares=1_000_000, # 1000 USDC + min_operator_share_rate=100, # 1% + ) + if err is not None: + raise Exception(f'failed to create public pool {err}') + tx_hash = response.tx_hash + print(f"✅ send create public pool tx. hash: {tx_hash}") + + # fetch pool account index from tx hash + pool_account_index = -1 + for i in range(10): + time.sleep(1) + try: + response = await tx_api.tx(by="hash", value=tx_hash) + event_info_j = json.loads(response.event_info) + pool_account_index = event_info_j['a'] + except Exception as e: + pass + if pool_account_index != -1: + break + if pool_account_index == -1: + raise Exception(f"failed to find pool account index for tx {tx_hash}") + print(f"✅ pool account index: {pool_account_index}") + + # Note: ❗️operator_fee can only decrease + # modify pool metadata + tx_info, response, err = await client.update_public_pool( + public_pool_index=pool_account_index, + status=0, # 0 is active | 1 is frozen + operator_fee=50000, # 5% + min_operator_share_rate=1000, # 10% + ) + if err is not None: + raise Exception(f'failed to create update pool {err}') + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/public_pool_deposit.py b/docs/lighter/lighter-python-main/examples/public_pool_deposit.py new file mode 100644 index 0000000..dae44fe --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/public_pool_deposit.py @@ -0,0 +1,25 @@ +import asyncio + +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + tx_info, response, err = await client.mint_shares(public_pool_index=POOL_ACCOUNT_INDEX, share_amount=10_000) + if err is not None: + raise Exception(f'failed to mint shares {err}') + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/public_pool_info.py b/docs/lighter/lighter-python-main/examples/public_pool_info.py new file mode 100644 index 0000000..e519407 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/public_pool_info.py @@ -0,0 +1,33 @@ +import asyncio +import lighter +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + account_api = lighter.AccountApi(api_client) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + account = await account_api.account(by="index", value=str(client.account_index)) + + # Note: ❗️shares field does not return the shared you have in pools that you're the operator + for pool in account.accounts[0].shares: + pool_resp = await account_api.account(by="index", value=str(pool.public_pool_index)) + pool_account = pool_resp.accounts[0] + + share_price = float(pool_account.total_asset_value) / float(pool_account.pool_info.total_shares) + print( + f"poolAccountId: {pool.public_pool_index} numShared: {pool.shares_amount} sharePrice: {share_price:.6f} value: {share_price * pool.shares_amount:.2f} pnl: {share_price * pool.shares_amount - float(pool.entry_usdc):.2f}") + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/public_pool_withdraw.py b/docs/lighter/lighter-python-main/examples/public_pool_withdraw.py new file mode 100644 index 0000000..f3ce3f3 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/public_pool_withdraw.py @@ -0,0 +1,26 @@ +import asyncio +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + auth, _ = client.create_auth_token_with_expiry() + + tx_info, response, err = await client.burn_shares(public_pool_index=POOL_ACCOUNT_INDEX, share_amount=10_000) + if err is not None: + raise Exception(f'failed to mint shares {err}') + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/read-only-auth/.gitignore b/docs/lighter/lighter-python-main/examples/read-only-auth/.gitignore new file mode 100644 index 0000000..94a2dd1 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/read-only-auth/.gitignore @@ -0,0 +1 @@ +*.json \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/read-only-auth/README.md b/docs/lighter/lighter-python-main/examples/read-only-auth/README.md new file mode 100644 index 0000000..90d3208 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/read-only-auth/README.md @@ -0,0 +1,168 @@ +# Read-Only Auth Token Pre-Generation + +This example demonstrates how to pre-generate authentication tokens for read-only operations on the Lighter platform. By generating tokens ahead of time, you can avoid needing access to your API private keys during runtime for read-only queries. + +## Overview + +Authentication tokens on Lighter have a maximum expiry of 8 hours. This example allows you to: + +1. Configure a dedicated API key (index 253) for all your accounts +2. Pre-generate authentication tokens for future time periods +3. Use these tokens for read-only operations without exposing your private keys + +The tokens are generated at 6-hour intervals (aligned to Unix timestamp // 6 hours), with each token valid for 8 hours. This provides an overlap period ensuring continuous coverage. + +## Setup + +The setup script configures API key 253 for all accounts associated with your Ethereum private key. + +### Running Setup + +```bash +cd examples/read-only-auth +python3 setup.py config.json +``` + +This will: +- Query all accounts for your L1 address +- Generate new API key pairs for each account +- Change API key 253 to use the new keys +- Output configuration in JSON format + +### Configuration Variables + +Edit the constants in `setup.py`: + +```python +BASE_URL = "https://testnet.zklighter.elliot.ai" +ETH_PRIVATE_KEY = "your_ethereum_private_key_here" +API_KEY_INDEX = 253 # Using 253 as it's typically unused +``` + +### Config Format + +```json +{ + "BASE_URL": "https://testnet.zklighter.elliot.ai", + "ACCOUNTS": [ + { + "api_key_private_key": "...", + "account_index": 0, + "api_key_index": 253 + }, + { + "api_key_private_key": "...", + "account_index": 1, + "api_key_index": 253 + } + ] +} +``` + +## Generating Tokens + +The generation script creates authentication tokens for future time periods. + +### Running Generation + +```bash +NUM_DAYS=10 python3 generate.py config.json +``` + +If no config file is specified, it defaults to `config.json`. + +### Duration Configuration + +You can specify the duration in days using the `NUM_DAYS` environment variable, as in the command above. +If the value is not specified, it defaults to 28 days. + +### Output Format + +The script generates `auth-tokens.json`: + +```json +{ + "0": { + "1697184000": "auth_token_string_1", + "1697205600": "auth_token_string_2", + "1697227200": "auth_token_string_3" + }, + "1": { + "1697184000": "auth_token_string_1", + "1697205600": "auth_token_string_2" + } +} +``` + +Where: +- First level key: account index +- Second level key: Unix timestamp (aligned to 6-hour boundaries) +- Value: authentication token + +## Usage + +### Looking Up Tokens + +Check the `get_auth_token.py` script which prints the Auth Token that should be used **at this moment**, as this will be invalidated in at most 8 hours. + +### Time Alignment + +All timestamps are aligned to 6-hour boundaries: +- Timestamps are divisible by 21600 seconds (6 hours) +- Calculation: `unix_timestamp // (6 * 3600) * (6 * 3600)` +- This ensures consistent token lookup across different systems + +### Token Expiry + +Each token is valid for 8 hours from its timestamp: +- Token timestamp: aligned to 6-hour boundary +- Valid until: timestamp + 8 hours +- This provides 2 hours of overlap between consecutive tokens + +## Security + +### API Key 253 + +We use API key index 253 because: +- It's the last available index [0-253] +- It's not typically used by trading +- Easy to remember for this specific use case +- Easy to change and invalidate all tokens. + +### Invalidating Tokens + +To invalidate all existing tokens: + +```bash +python3 setup.py config.json +``` + +Re-running the setup script generates new API keys for index 253, which invalidates all previously generated authentication tokens. This is useful if: +- You suspect your tokens have been compromised +- You want to rotate your tokens periodically +- You need to revoke access immediately + +### Best Practices + +1. **Store tokens securely**: The `auth-tokens.json` file contains sensitive data (read only, but still) +2. **Dedicated API key**: Use API key 253 for read-only token generation, as it can be invalidated easely. + + +## Troubleshooting + +### "Account not found" error + +Make sure your Ethereum private key corresponds to an account registered on the Lighter platform. + +### "Failed to change API key" error + +This could happen if: +- The API key change transaction failed +- Network connectivity issues +- The account is not active + +## Additional Notes + +- Tokens are specific to each account index +- Each account has its own set of time-aligned tokens +- The system uses the SignerClient's native `create_auth_token_with_expiry` method diff --git a/docs/lighter/lighter-python-main/examples/read-only-auth/generate.py b/docs/lighter/lighter-python-main/examples/read-only-auth/generate.py new file mode 100644 index 0000000..bd5c407 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/read-only-auth/generate.py @@ -0,0 +1,103 @@ +import asyncio +import json +import logging +import os +import time +import sys +import lighter + +logging.basicConfig(level=logging.INFO, force=True) + + +def create_auth_token_for_timestamp(signer_client, timestamp, expiry_hours): + auth_token, error = signer_client.create_auth_token_with_expiry(expiry_hours * 3600, timestamp=timestamp) + if error is not None: + raise Exception(f"Failed to create auth token: {error}") + return auth_token + + +async def generate_tokens_for_account(account_info, base_url, duration_days): + account_index = account_info["account_index"] + api_key_private_key = account_info["api_key_private_key"] + api_key_index = account_info["api_key_index"] + + logging.info(f"Generating tokens for account {account_index}") + + signer_client = lighter.SignerClient( + url=base_url, + private_key=api_key_private_key, + account_index=account_index, + api_key_index=api_key_index, + ) + + current_time = int(time.time()) + interval_seconds = 6 * 3600 + start_timestamp = (current_time // interval_seconds) * interval_seconds + + num_tokens = 4 * duration_days + expiry_hours = 8 + + tokens = {} + for i in range(num_tokens): + timestamp = start_timestamp + (i * interval_seconds) + try: + auth_token = create_auth_token_for_timestamp(signer_client, timestamp, expiry_hours) + tokens[str(timestamp)] = auth_token + logging.debug(f"Generated token for timestamp {timestamp}") + except Exception as e: + logging.error(f"Failed to generate token for timestamp {timestamp}: {e}") + + await signer_client.close() + + return account_index, tokens + + +async def main(): + config_file = "config.json" + if len(sys.argv) > 1: + config_file = sys.argv[1] + + try: + with open(config_file, "r") as f: + config = json.load(f) + except FileNotFoundError: + logging.error(f"Config file '{config_file}' not found") + logging.error("Run setup.py first: python3 setup.py > config.json") + sys.exit(1) + except json.JSONDecodeError as e: + logging.error(f"Invalid JSON in config file: {e}") + sys.exit(1) + + num_days = int(os.getenv("NUM_DAYS") or 28) + base_url = config.get("BASE_URL") + accounts = config.get("ACCOUNTS", []) + duration_days = config.get("DURATION_IN_DAYS", num_days) + + if not base_url: + logging.error("BASE_URL not found in config") + sys.exit(1) + + if not accounts: + logging.error("No accounts found in config") + sys.exit(1) + + logging.info(f"Generating tokens for {len(accounts)} account(s)") + logging.info(f"Duration: {duration_days} days ({4 * duration_days} tokens per account)") + + auth_tokens = {} + for account_info in accounts: + account_index, tokens = await generate_tokens_for_account(account_info, base_url, duration_days) + auth_tokens[str(account_index)] = tokens + + output_file = "auth-tokens.json" + with open(output_file, "w") as f: + json.dump(auth_tokens, f, indent=2) + + logging.info(f"Successfully generated tokens and saved to {output_file}") + logging.info(f"Total accounts: {len(auth_tokens)}") + for account_index, tokens in auth_tokens.items(): + logging.info(f" Account {account_index}: {len(tokens)} tokens") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/read-only-auth/get_auth_token.py b/docs/lighter/lighter-python-main/examples/read-only-auth/get_auth_token.py new file mode 100644 index 0000000..e12522a --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/read-only-auth/get_auth_token.py @@ -0,0 +1,30 @@ +import json +import logging +import sys +import time + +logging.basicConfig(level=logging.INFO, force=True) + + +def main(): + if len(sys.argv) == 1: + logging.error("No account index specified") + return + + account_index = sys.argv[1] + + # Load pre-generated tokens + with open('auth-tokens.json') as f: + auth_tokens = json.load(f) + + # Get current aligned timestamp (6-hour boundary) + current_timestamp = (int(time.time()) // (6 * 3600)) * (6 * 3600) + + # Look up token for specific account + auth_token = auth_tokens[account_index][str(current_timestamp)] + + print(f"{auth_token=}") + + +if __name__ == "__main__": + main() diff --git a/docs/lighter/lighter-python-main/examples/read-only-auth/setup.py b/docs/lighter/lighter-python-main/examples/read-only-auth/setup.py new file mode 100644 index 0000000..31790ad --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/read-only-auth/setup.py @@ -0,0 +1,113 @@ +import asyncio +import json +import logging +import sys +import time +import eth_account +import lighter + +logging.basicConfig(level=logging.INFO, force=True) + +# use https://mainnet.zklighter.elliot.ai for mainnet +BASE_URL = "https://testnet.zklighter.elliot.ai" +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +API_KEY_INDEX = 253 + + +async def setup_account(eth_private_key, account_index, base_url, api_key_index): + private_key, public_key, err = lighter.create_api_key() + if err is not None: + return None, f"Failed to create API key for account {account_index}: {err}" + + tx_client = lighter.SignerClient( + url=base_url, + private_key=private_key, + account_index=account_index, + api_key_index=api_key_index, + ) + + response, err = await tx_client.change_api_key( + eth_private_key=eth_private_key, + new_pubkey=public_key, + ) + if err is not None: + await tx_client.close() + return None, f"Failed to change API key for account {account_index}: {err}" + + time.sleep(5) + + err = tx_client.check_client() + if err is not None: + await tx_client.close() + return None, f"Failed to verify API key for account {account_index}: {err}" + + await tx_client.close() + + return { + "api_key_private_key": private_key, + "account_index": account_index, + "api_key_index": api_key_index, + }, None + + +async def main(): + config_file = "config.json" + if len(sys.argv) > 1: + config_file = sys.argv[1] + + api_client = lighter.ApiClient(configuration=lighter.Configuration(host=BASE_URL)) + eth_acc = eth_account.Account.from_key(ETH_PRIVATE_KEY) + eth_address = eth_acc.address + + try: + response = await lighter.AccountApi(api_client).accounts_by_l1_address( + l1_address=eth_address + ) + except lighter.ApiException as e: + if e.data.message == "account not found": + print(f"error: account not found for {eth_address}", file=__import__('sys').stderr) + await api_client.close() + return + else: + await api_client.close() + raise e + + if len(response.sub_accounts) == 0: + print(f"error: no accounts found for {eth_address}", file=__import__('sys').stderr) + await api_client.close() + return + + logging.info(f"Found {len(response.sub_accounts)} account(s)") + + # don't do this async + accounts = [] + for sub_account in response.sub_accounts: + logging.info(f"Setting up account index: {sub_account.index}") + result, err = await setup_account( + ETH_PRIVATE_KEY, + sub_account.index, + BASE_URL, + API_KEY_INDEX, + ) + + if err is not None: + logging.error(err) + else: + accounts.append(result) + + if not accounts: + print("error: failed to setup any accounts", file=__import__('sys').stderr) + await api_client.close() + return + + with open(config_file, "w", encoding="utf-8") as f: + json.dump({ + "BASE_URL": BASE_URL, + "ACCOUNTS": accounts, + }, f, ensure_ascii=False, indent=2) + + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/send_batch_tx_http.py b/docs/lighter/lighter-python-main/examples/send_batch_tx_http.py new file mode 100644 index 0000000..d9ac8c1 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/send_batch_tx_http.py @@ -0,0 +1,156 @@ +import asyncio +import time +from utils import default_example_setup, trim_exception + + +# this example does the same thing as the send_batch_tx_ws.py example, but sends the TX over HTTP instead of WS +async def main(): + client, api_client, _ = default_example_setup() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + api_key_index, nonce = client.nonce_manager.next_nonce() + ask_tx_type, ask_tx_info, ask_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1001, # Unique identifier for this order + base_amount=1000, # 0.1 ETH + price=5000_00, # $5000 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing ask order (first batch): {trim_exception(error)}") + return + + # intentionally pass api_key_index to the client.nonce_manager so it increases the nonce, without changing the API key. + # in batch TXs, all TXs must come from the same API key. + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + bid_tx_type, bid_tx_info, bid_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1002, # Different unique identifier + base_amount=1000, # 0.1 ETH + price=1500_00, # $1500 + is_ask=False, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (first batch): {trim_exception(error)}") + return + + tx_types = [ask_tx_type, bid_tx_type] + tx_infos = [ask_tx_info, bid_tx_info] + tx_hashes = [ask_tx_hash, bid_tx_hash] + + try: + response = await client.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) + print(f"Batch transaction successful: {response} expected: {tx_hashes}") + except Exception as e: + print(f"Error sending batch transaction: {trim_exception(e)}") + + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_tx_type, cancel_tx_info, cancel_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1001, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (second batch): {trim_exception(error)}") + return + + # intentionally pass api_key_index to the client.nonce_manager so it increases the nonce, without changing the API key. + # in batch TXs, all TXs must come from the same API key. + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + new_ask_tx_type, new_ask_tx_info, new_ask_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1003, # Different unique identifier + base_amount=2000, # 0.2 ETH + price=5500_00, # $5500 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (second batch): {trim_exception(error)}") + return + + tx_types = [cancel_tx_type, new_ask_tx_type] + tx_infos = [cancel_tx_info, new_ask_tx_info] + tx_hashes = [cancel_tx_hash, new_ask_tx_hash] + + try: + response = await client.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) + print(f"Batch transaction successful: {response} expected: {tx_hashes}") + except Exception as e: + print(f"Error sending batch transaction: {trim_exception(e)}") + + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_1_tx_type, cancel_1_tx_info, cancel_1_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1002, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (third batch): {trim_exception(error)}") + return + + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + cancel_2_tx_type, cancel_2_tx_info, cancel_2_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1003, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (third batch): {trim_exception(error)}") + return + + tx_types = [cancel_1_tx_type, cancel_2_tx_type] + tx_infos = [cancel_1_tx_info, cancel_2_tx_info] + tx_hashes = [cancel_1_tx_hash, cancel_2_tx_hash] + + try: + response = await client.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) + print(f"Batch transaction successful: {response} expected: {tx_hashes}") + except Exception as e: + print(f"Error sending batch transaction: {trim_exception(e)}") + + + # Clean up + await client.close() + await api_client.close() + + +# Run the async main function +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/send_batch_tx_ws.py b/docs/lighter/lighter-python-main/examples/send_batch_tx_ws.py new file mode 100644 index 0000000..8266b53 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/send_batch_tx_ws.py @@ -0,0 +1,150 @@ +import websockets +import asyncio +import time + +from utils import default_example_setup, ws_send_batch_tx, trim_exception + + +# this example does the same thing as the send_batch_tx_http.py example, but sends the TX over WS instead of HTTP +async def main(): + client, api_client, ws_client_promise = default_example_setup() + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + print("Received:", await ws_client.recv()) + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 2048 + + api_key_index, nonce = client.nonce_manager.next_nonce() + ask_tx_type, ask_tx_info, ask_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1001, # Unique identifier for this order + base_amount=1000, # 0.1 ETH + price=5000_00, # $5000 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing ask order (first batch): {trim_exception(error)}") + return + + # intentionally pass api_key_index to the client.nonce_manager so it increases the nonce, without changing the API key. + # in batch TXs, all TXs must come from the same API key. + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + bid_tx_type, bid_tx_info, bid_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1002, # Different unique identifier + base_amount=1000, # 0.1 ETH + price=1500_00, # $1500 + is_ask=False, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (first batch): {trim_exception(error)}") + return + + tx_types = [ask_tx_type, bid_tx_type] + tx_infos = [ask_tx_info, bid_tx_info] + tx_hashes = [ask_tx_hash, bid_tx_hash] + + await ws_send_batch_tx(ws_client, tx_types, tx_infos, tx_hashes) + + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_tx_type, cancel_tx_info, cancel_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1001, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (second batch): {trim_exception(error)}") + return + + # intentionally pass api_key_index to the client.nonce_manager so it increases the nonce, without changing the API key. + # in batch TXs, all TXs must come from the same API key. + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + new_ask_tx_type, new_ask_tx_info, new_ask_tx_hash, error = client.sign_create_order( + market_index=market_index, + client_order_index=1003, # Different unique identifier + base_amount=2000, # 0.2 ETH + price=5500_00, # $5500 + is_ask=True, + order_type=client.ORDER_TYPE_LIMIT, + time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only=False, + trigger_price=0, + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (second batch): {trim_exception(error)}") + return + + tx_types = [cancel_tx_type, new_ask_tx_type] + tx_infos = [cancel_tx_info, new_ask_tx_info] + tx_hashes = [cancel_tx_hash, new_ask_tx_hash] + + await ws_send_batch_tx(ws_client, tx_types, tx_infos, tx_hashes) + + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_1_tx_type, cancel_1_tx_info, cancel_1_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1002, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (third batch): {trim_exception(error)}") + return + + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + cancel_2_tx_type, cancel_2_tx_info, cancel_2_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1003, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (third batch): {trim_exception(error)}") + return + + tx_types = [cancel_1_tx_type, cancel_2_tx_type] + tx_infos = [cancel_1_tx_info, cancel_2_tx_info] + tx_hashes = [cancel_1_tx_hash, cancel_2_tx_hash] + + await ws_send_batch_tx(ws_client, tx_types, tx_infos, tx_hashes) + + + # Clean up + await client.close() + await api_client.close() + await ws_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/send_tx_batch.py b/docs/lighter/lighter-python-main/examples/send_tx_batch.py deleted file mode 100644 index b6bc3e7..0000000 --- a/docs/lighter/lighter-python-main/examples/send_tx_batch.py +++ /dev/null @@ -1,138 +0,0 @@ -import asyncio -import logging -import lighter -import json - -logging.basicConfig(level=logging.DEBUG) - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and servers as an example. -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = "0xed636277f3753b6c0275f7a28c2678a7f3a95655e09deaebec15179b50c5da7f903152e50f594f7b" -ACCOUNT_INDEX = 65 -API_KEY_INDEX = 1 - -def trim_exception(e: Exception) -> str: - return str(e).strip().split("\n")[-1] - - -async def main(): - # Initialize configuration and clients - configuration = lighter.Configuration(BASE_URL) - api_client = lighter.ApiClient(configuration) - transaction_api = lighter.TransactionApi(api_client) - - # Initialize signer client - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX - ) - - # Check client connection - err = client.check_client() - if err is not None: - print(f"CheckClient error: {trim_exception(err)}") - return - - # use next nonce for getting nonces - next_nonce = await transaction_api.next_nonce(account_index=ACCOUNT_INDEX, api_key_index=API_KEY_INDEX) - nonce_value = next_nonce.nonce - - ask_tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1001, # Unique identifier for this order - base_amount=100000, - price=280000, - is_ask=True, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value - ) - nonce_value += 1 - - if error is not None: - print(f"Error signing first order (first batch): {trim_exception(error)}") - return - - # Sign second order - bid_tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1002, # Different unique identifier - base_amount=200000, - price=200000, - is_ask=False, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value - ) - nonce_value += 1 - - if error is not None: - print(f"Error signing second order (first batch): {trim_exception(error)}") - return - - tx_types = json.dumps([client.TX_TYPE_CREATE_ORDER, client.TX_TYPE_CREATE_ORDER]) - tx_infos = json.dumps([ask_tx_info, bid_tx_info]) - - try: - tx_hashes = await transaction_api.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) - print(f"Batch transaction successful: {tx_hashes}") - except Exception as e: - print(f"Error sending batch transaction: {trim_exception(e)}") - - # In case we want to see the changes in the UI, sleep a bit - import time - time.sleep(5) - - cancel_tx_info, error = client.sign_cancel_order( - market_index=0, - order_index=1001, # the index of the order we want cancelled - nonce=nonce_value - ) - nonce_value += 1 - - if error is not None: - print(f"Error signing first order (second batch): {trim_exception(error)}") - return - - # Sign second order - new_ask_tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1003, # Different unique identifier - base_amount=300000, - price=310000, - is_ask=True, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value - ) - nonce_value += 1 - - if error is not None: - print(f"Error signing second order (second batch): {trim_exception(error)}") - return - - tx_types = json.dumps([client.TX_TYPE_CANCEL_ORDER, client.TX_TYPE_CREATE_ORDER]) - tx_infos = json.dumps([cancel_tx_info, new_ask_tx_info]) - - try: - tx_hashes = await transaction_api.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) - print(f"Batch 2 transaction successful: {tx_hashes}") - except Exception as e: - print(f"Error sending batch transaction 2: {trim_exception(e)}") - - # Clean up - await client.close() - await api_client.close() - -# Run the async main function -if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/spot_get_account_assets_http.py b/docs/lighter/lighter-python-main/examples/spot_get_account_assets_http.py new file mode 100644 index 0000000..dd5d1d6 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/spot_get_account_assets_http.py @@ -0,0 +1,31 @@ +import logging +import asyncio +import lighter +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + logging.basicConfig(level=logging.INFO) + + account_api = lighter.AccountApi(api_client) + response = await account_api.account(by="index", value=str(client.account_index)) + if len(response.accounts) == 0: + raise "No account found" + + account = response.accounts[0] + # Note: cross-account value does not take into account isolated positions, but total does + print("=== perp assets ===") + print(f"total: {account.total_asset_value} available: {account.available_balance}") + print(f"cross: {account.cross_asset_value} isolated: {float(account.total_asset_value) - float(account.cross_asset_value)}") + + # Spot Assets + print("=== spot assets ===") + for asset in account.assets: + print(f"{asset.symbol} total: {asset.balance} available: {float(asset.balance) - float(asset.locked_balance)}") + + await client.close() + await api_client.close() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/spot_get_account_assets_ws.py b/docs/lighter/lighter-python-main/examples/spot_get_account_assets_ws.py new file mode 100644 index 0000000..de5522e --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/spot_get_account_assets_ws.py @@ -0,0 +1,53 @@ +import json +import logging +import asyncio +import websockets + +from lighter.models import WSAccountAssets +from utils import default_example_setup, ws_subscribe, ws_ping + + +async def consume_messages(ws): + while True: + msg_str = await ws.recv() + if isinstance(msg_str, str): + msg = json.loads(msg_str) + else: + raise msg_str + + # handle ping here; if we receive, send pong + if msg["type"] == "ping": + await ws_ping(ws) + continue + + # handle account_all_assets updates -- just print stuff + if msg["type"] == "subscribed/account_all_assets" or msg["type"] == "update/account_all_assets" : + o = WSAccountAssets.from_dict(msg) + for asset in o.assets.values(): + print(f"{asset.symbol} total: {asset.balance} available: {float(asset.balance) - float(asset.locked_balance)} accountId: {o.account_id}") + + +async def main(): + client, api_client, ws_client_promise = default_example_setup() + logging.basicConfig(level=logging.INFO) + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + await ws_client.recv() + + consume_task = asyncio.create_task(consume_messages(ws_client)) + + auth, _ = client.create_auth_token_with_expiry() + await ws_subscribe(ws_client, f"account_all_assets/{client.account_index}", auth) + + # wait a bit to print messages + await asyncio.sleep(1000) + + consume_task.cancel() + await client.close() + await api_client.close() + await ws_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/spot_get_order_books.py b/docs/lighter/lighter-python-main/examples/spot_get_order_books.py new file mode 100644 index 0000000..d5b84e6 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/spot_get_order_books.py @@ -0,0 +1,42 @@ +import logging +import asyncio +import lighter +from lighter import Asset +from utils import default_example_setup + +# This example shows how to fetch order books and assets details +# This information should be enough to be able to trade on Lighter +# Select the market ID accordingly to the symbol. +# For spot markets, the order book contains base asset (ETH) and quote asset (USDC) +# You can use these to keep track of your inventory +async def main(): + client, api_client, _ = default_example_setup() + logging.basicConfig(level=logging.INFO) + + orders_api = lighter.OrderApi(api_client) + response = await orders_api.order_books() + response.order_books.sort(key=lambda x: x.market_id) + + # fetch all assets + assets_response = await orders_api.asset_details() + + assets_dict: dict[int, Asset] = {} + for asset in assets_response.asset_details: + assets_dict[asset.asset_id] = asset + + for order_book in response.order_books: + if order_book.market_type == 'perp': + print(f'symbol={order_book.symbol} id={order_book.market_id} type={order_book.market_type} sizeDecimals={order_book.supported_size_decimals} priceDecimals={order_book.supported_price_decimals}') + else: + print(f'symbol={order_book.symbol} id={order_book.market_id} type={order_book.market_type} sizeDecimals={order_book.supported_size_decimals} priceDecimals={order_book.supported_price_decimals} baseAssetId={order_book.base_asset_id} quoteAssetId={order_book.quote_asset_id}') + b = assets_dict[order_book.base_asset_id] + q = assets_dict[order_book.quote_asset_id] + print(f' baseAsset: symbol={b.symbol} assetId={b.asset_id} decimals={b.decimals} price={b.index_price} min_withdraw={b.min_withdrawal_amount}') + print(f' quoteAsset: symbol={q.symbol} assetId={q.asset_id} decimals={q.decimals} price={q.index_price} min_withdraw={q.min_withdrawal_amount}') + + + await client.close() + await api_client.close() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/spot_self_transfer_perp_spot.py b/docs/lighter/lighter-python-main/examples/spot_self_transfer_perp_spot.py new file mode 100644 index 0000000..b0962fe --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/spot_self_transfer_perp_spot.py @@ -0,0 +1,34 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=client.account_index, + asset_id=client.ASSET_ID_USDC, + amount=1.234567, # decimals are added by sdk + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) + print(lev_tx, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/spot_self_transfer_spot_perp.py b/docs/lighter/lighter-python-main/examples/spot_self_transfer_spot_perp.py new file mode 100644 index 0000000..52c9afe --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/spot_self_transfer_spot_perp.py @@ -0,0 +1,34 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=client.account_index, + asset_id=client.ASSET_ID_USDC, + amount=1.234567, # decimals are added by sdk + route_from=client.ROUTE_SPOT, + route_to=client.ROUTE_PERP, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) + print(lev_tx, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/sub_account_create.py b/docs/lighter/lighter-python-main/examples/sub_account_create.py new file mode 100644 index 0000000..e634b25 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/sub_account_create.py @@ -0,0 +1,17 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + tx_info, response, err = await client.create_sub_account() + print(tx_info, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/sub_account_transfer_eth.py b/docs/lighter/lighter-python-main/examples/sub_account_transfer_eth.py new file mode 100644 index 0000000..5fb8cb0 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/sub_account_transfer_eth.py @@ -0,0 +1,32 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +TO_ACCOUNT_INDEX = 281474976710649 + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_ETH, + amount=0.4, # decimals are added by sdk + route_from=client.ROUTE_SPOT, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/sub_account_transfer_usdc.py b/docs/lighter/lighter-python-main/examples/sub_account_transfer_usdc.py new file mode 100644 index 0000000..d253be5 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/sub_account_transfer_usdc.py @@ -0,0 +1,32 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +TO_ACCOUNT_INDEX = 281474976710649 + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_USDC, + amount=100, # decimals are added by sdk + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/system_setup.py b/docs/lighter/lighter-python-main/examples/system_setup.py index 0896d7d..859274b 100644 --- a/docs/lighter/lighter-python-main/examples/system_setup.py +++ b/docs/lighter/lighter-python-main/examples/system_setup.py @@ -3,15 +3,21 @@ import logging import time import eth_account import lighter +from utils import save_api_key_config logging.basicConfig(level=logging.DEBUG) -# this is a dummy private key which is registered on Testnet. +# this is a dummy private key registered on Testnet. # It serves as a good example BASE_URL = "https://testnet.zklighter.elliot.ai" ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" API_KEY_INDEX = 3 +NUM_API_KEYS = 5 +# If you set this to something other than None, the script will use that account index instead of using the master account index. +# This is useful if you have multiple accounts on the same L1 address or are the owner of a public pool. +# You need to use the private key associated to the master account or the owner of the public pool to change the API keys. +ACCOUNT_INDEX = None async def main(): # verify that the account exists & fetch account index @@ -19,47 +25,58 @@ async def main(): eth_acc = eth_account.Account.from_key(ETH_PRIVATE_KEY) eth_address = eth_acc.address - try: - response = await lighter.AccountApi(api_client).accounts_by_l1_address( - l1_address=eth_address - ) - except lighter.ApiException as e: - if e.data.message == "account not found": - print(f"error: account not found for {eth_address}") - return - else: - raise e - - if len(response.sub_accounts) > 1: - for sub_account in response.sub_accounts: - print(f"found accountIndex: {sub_account.index}") - - print("multiple accounts found, using the first one") - account_index = response.sub_accounts[0].index + if ACCOUNT_INDEX is not None: + account_index = ACCOUNT_INDEX else: - account_index = response.sub_accounts[0].index + try: + response = await lighter.AccountApi(api_client).accounts_by_l1_address(l1_address=eth_address) + except lighter.ApiException as e: + if e.data.message == "account not found": + print(f"error: account not found for {eth_address}") + return + else: + raise e + + if len(response.sub_accounts) > 1: + for sub_account in response.sub_accounts: + print(f"found accountIndex: {sub_account.index}") + + account = min(response.sub_accounts, key=lambda x: int(x.index)) + account_index = account.index + print(f"multiple accounts found, using the master account {account_index}") + else: + account_index = response.sub_accounts[0].index + # create a private/public key pair for the new API key # pass any string to be used as seed for create_api_key like # create_api_key("Hello world random seed to make things more secure") - private_key, public_key, err = lighter.create_api_key() - if err is not None: - raise Exception(err) + + private_keys = {} + public_keys = [] + + for i in range(NUM_API_KEYS): + private_key, public_key, err = lighter.create_api_key() + if err is not None: + raise Exception(err) + public_keys.append(public_key) + private_keys[API_KEY_INDEX + i] = private_key tx_client = lighter.SignerClient( url=BASE_URL, - private_key=private_key, account_index=account_index, - api_key_index=API_KEY_INDEX, + api_private_keys=private_keys, ) - # change the API key - response, err = await tx_client.change_api_key( - eth_private_key=ETH_PRIVATE_KEY, - new_pubkey=public_key, - ) - if err is not None: - raise Exception(err) + # change all API keys + for i in range(NUM_API_KEYS): + response, err = await tx_client.change_api_key( + eth_private_key=ETH_PRIVATE_KEY, + new_pubkey=public_keys[i], + api_key_index=API_KEY_INDEX + i + ) + if err is not None: + raise Exception(err) # wait some time so that we receive the new API key in the response time.sleep(10) @@ -69,14 +86,7 @@ async def main(): if err is not None: raise Exception(err) - print( - f""" -BASE_URL = '{BASE_URL}' -API_KEY_PRIVATE_KEY = '{private_key}' -ACCOUNT_INDEX = {account_index} -API_KEY_INDEX = {API_KEY_INDEX} - """ - ) + save_api_key_config(BASE_URL, account_index, private_keys) await tx_client.close() await api_client.close() diff --git a/docs/lighter/lighter-python-main/examples/transfer.py b/docs/lighter/lighter-python-main/examples/transfer.py new file mode 100644 index 0000000..0b14d2e --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/transfer.py @@ -0,0 +1,37 @@ +import asyncio +import lighter +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +TO_ACCOUNT_INDEX = 9 + + +async def main(): + client, api_client, _ = default_example_setup() + info_api = lighter.InfoApi(api_client) + + auth_token, err = client.create_auth_token_with_expiry() + if err: + raise Exception(f"Auth token failed: {err}") + + fee_info = await info_api.transfer_fee_info(client.account_index, authorization=auth_token, auth=auth_token, to_account_index=TO_ACCOUNT_INDEX) + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + eth_private_key=ETH_PRIVATE_KEY, + to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_USDC, + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_PERP, + amount=5, # decimals are added by sdk + fee=fee_info.transfer_fee_usdc, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + + print(transfer_tx, response) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/transfer_update_leverage.py b/docs/lighter/lighter-python-main/examples/transfer_update_leverage.py deleted file mode 100644 index e5593b7..0000000 --- a/docs/lighter/lighter-python-main/examples/transfer_update_leverage.py +++ /dev/null @@ -1,47 +0,0 @@ -import asyncio -import lighter - - -from examples.secrets import BASE_URL, API_KEY_PRIVATE_KEY, ETH_PRIVATE_KEY - -API_KEY_INDEX = 10 -TO_ACCOUNT_INDEX = 9 -ACCOUNT_INDEX = 10 # replace with your account_index - - -async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - api_client = lighter.ApiClient(configuration=lighter.Configuration(host=BASE_URL)) - info_api = lighter.InfoApi(api_client) - order_api = lighter.OrderApi(api_client) - - auth_token, _ = client.create_auth_token_with_expiry() - fee_info = await info_api.transfer_fee_info(ACCOUNT_INDEX, authorization=auth_token, auth=auth_token, to_account_index=TO_ACCOUNT_INDEX) - print(fee_info) - - err = client.check_client() - if err is not None: - print(f"CheckClient error: {err}") - return - memo = "a"*32 # memo is a user message and it has to be exactly 32 bytes long - transfer_tx, response, err = await client.transfer( - ETH_PRIVATE_KEY, - usdc_amount=100, # decimals are added by sdk - to_account_index=TO_ACCOUNT_INDEX, - fee=fee_info.transfer_fee_usdc, - memo=memo, - ) - if err != None: - raise Exception(f"error transferring {err}") - print(transfer_tx, response) - - lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) - print(lev_tx, response, err) - -if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/utils.py b/docs/lighter/lighter-python-main/examples/utils.py new file mode 100644 index 0000000..8ae2f29 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/utils.py @@ -0,0 +1,100 @@ +from typing import Tuple, Optional +import logging +import json +import websockets +import lighter + + +def trim_exception(e: Exception) -> str: + return str(e).strip().split("\n")[-1] + + +def save_api_key_config(base_url, account_index, private_keys, config_file="./api_key_config.json"): + with open(config_file, "w", encoding="utf-8") as f: + json.dump({ + "baseUrl": base_url, + "accountIndex": account_index, + "privateKeys": private_keys, + }, f, ensure_ascii=False, indent=2) + + +def get_api_key_config(config_file="./api_key_config.json"): + with open(config_file) as f: + cfg = json.load(f) + + private_keys_original = cfg["privateKeys"] + private_key = {} + for key in private_keys_original.keys(): + private_key[int(key)] = private_keys_original[key] + + return cfg["baseUrl"], cfg["accountIndex"], private_key + + +def default_example_setup(config_file="./api_key_config.json") -> Optional[Tuple[lighter.SignerClient, lighter.ApiClient, websockets.connect]]: + logging.basicConfig(level=logging.DEBUG) + + base_url, account_index, private_keys = get_api_key_config(config_file) + api_client = lighter.ApiClient(configuration=lighter.Configuration(host=base_url)) + client = lighter.SignerClient( + url=base_url, + account_index=account_index, + api_private_keys=private_keys, + ) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {trim_exception(err)}") + return + + return client, api_client, websockets.connect(f"{base_url.replace('https', 'wss')}/stream") + + +async def ws_ping(ws_client: websockets.ClientConnection): + await ws_client.send(json.dumps({"type": "pong"})) + +async def ws_subscribe(ws_client: websockets.ClientConnection, channel: str, auth: Optional[str] = None): + if auth is None: + await ws_client.send(json.dumps({"type": "subscribe", "channel": channel})) + else: + await ws_client.send(json.dumps({"type": "subscribe", "channel": channel, "auth": auth})) + +async def ws_send_tx(ws_client: websockets.ClientConnection, tx_type, tx_info, tx_hash): + # Note: you have the TX Hash from signing the TX + # You can use this TX Hash to check the status of the TX later on + # if the server generates a different hash, the signature will fail, so the hash will always be correct + # because of this, the hash returned by the server will always be the same + await ws_client.send( + json.dumps( + { + "type": "jsonapi/sendtx", + "data": { + "id": f"my_random_id_{12345678}", # optional helps id the response + "tx_type": tx_type, + "tx_info": json.loads(tx_info), + }, + } + ) + ) + + print(f"expectedHash {tx_hash} response {await ws_client.recv()}") + + +async def ws_send_batch_tx(ws_client: websockets.ClientConnection, tx_types, tx_infos, tx_hashes): + # Note: you have the TX Hash from signing the TX + # You can use this TX Hash to check the status of the TX later on + # if the server generates a different hash, the signature will fail, so the hash will always be correct + # because of this, the hash returned by the server will always be the same + await ws_client.send( + json.dumps( + { + "type": "jsonapi/sendtxbatch", + "data": { + "id": f"my_random_id_{12345678}", # optional helps id the response + "tx_types": json.dumps(tx_types), + "tx_infos": json.dumps(tx_infos), + }, + } + ) + ) + + print(f"expectedHash {tx_hashes} response {await ws_client.recv()}") diff --git a/docs/lighter/lighter-python-main/examples/withdraw_fast.py b/docs/lighter/lighter-python-main/examples/withdraw_fast.py new file mode 100644 index 0000000..7532e4e --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/withdraw_fast.py @@ -0,0 +1,104 @@ +import asyncio +import json +import lighter +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +WITHDRAW_ADDRESS = "0x0000..." +AMOUNT_USDC = 5.0 + +async def main(): + client, api_client, _ = default_example_setup() + + auth_token, err = client.create_auth_token_with_expiry() + if err: + raise Exception(f"Auth token failed: {err}") + + info_api = lighter.InfoApi(api_client) + + try: + # Get fast withdraw pool + params = api_client.param_serialize( + method='GET', + resource_path='/api/v1/fastwithdraw/info', + query_params=[('account_index', client.account_index)], + header_params={'Authorization': auth_token} + ) + response = await api_client.call_api(*params) + await response.read() + data = response.data + assert data is not None + + # get account to which to send money + pool_info = json.loads(data.decode('utf-8')) + if pool_info.get('code') != 200: + raise Exception(f"Pool info failed: {pool_info.get('message')}") + to_account = pool_info['to_account_index'] + print(f"Pool: {to_account}, Limit: {pool_info.get('withdraw_limit')}") + + # get transfer fee + fee_info = await info_api.transfer_fee_info( + account_index=client.account_index, + to_account_index=to_account, + auth=auth_token + ) + fee = fee_info.transfer_fee_usdc # this is already int + + # Get Nonce & API key -- you can get this using HTTP call as well + api_key_index, nonce = client.nonce_manager.next_nonce() + + # Build memo (20-byte address + 12 zeros) + addr_hex = WITHDRAW_ADDRESS.lower().removeprefix("0x") + addr_bytes = bytes.fromhex(addr_hex) + if len(addr_bytes) != 20: + raise ValueError(f"Invalid address length: {len(addr_bytes)}") + memo_list = list(addr_bytes + b"\x00" * 12) + memo_hex = ''.join(format(b, '02x') for b in memo_list) + + # create TX + tx_type, tx_info_str, tx_hash, err = client.sign_transfer( + eth_private_key=ETH_PRIVATE_KEY, + to_account_index=to_account, + asset_id=client.ASSET_ID_USDC, + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_PERP, + usdc_amount=int(AMOUNT_USDC) * 10 ** 6, + fee=fee, + memo=memo_hex, + api_key_index=api_key_index, + nonce=nonce + ) + if err: + raise Exception(f"L2 signing failed: {err}") + + # Submit + params = api_client.param_serialize( + method='POST', + resource_path='/api/v1/fastwithdraw', + post_params=[ + ('tx_info', tx_info_str), + ('to_address', WITHDRAW_ADDRESS) + ], + header_params={ + 'Authorization': auth_token, + 'Content-Type': 'application/x-www-form-urlencoded' + } + ) + response = await api_client.call_api(*params) + await response.read() + data = response.data + assert data is not None + result = json.loads(data.decode('utf-8')) + + if result.get('code') == 200: + print(f"✓ Success! TX: {result.get('tx_hash')}") + else: + raise Exception(f"Failed: {result.get('message')}") + + finally: + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/withdraw_normal.py b/docs/lighter/lighter-python-main/examples/withdraw_normal.py new file mode 100644 index 0000000..acd3611 --- /dev/null +++ b/docs/lighter/lighter-python-main/examples/withdraw_normal.py @@ -0,0 +1,25 @@ +import asyncio +from utils import default_example_setup + +AMOUNT = 5.0 + +async def main(): + client, api_client, _ = default_example_setup() + + # Note: There is no limit or fee for normal withdrawal + withdraw_tx, response, err = await client.withdraw( + asset_id=client.ASSET_ID_USDC, # change this to `client.ASSET_ID_ETH` to withdraw ETH. Also, change route_type to spot + route_type=client.ROUTE_PERP, # change this to `client.ROUTE_SPOT` to withdraw from spot balance + amount=AMOUNT, + ) + if err is not None: + raise Exception(f"error withdrawing {err}") + + print(withdraw_tx, response) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/examples/ws_send_batch_tx.py b/docs/lighter/lighter-python-main/examples/ws_send_batch_tx.py deleted file mode 100644 index 375d8fb..0000000 --- a/docs/lighter/lighter-python-main/examples/ws_send_batch_tx.py +++ /dev/null @@ -1,101 +0,0 @@ -import lighter -import json -import websockets -import asyncio - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and servers as an example. -# Alternatively, you can go to https://app.lighter.xyz/apikeys for mainnet api keys -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = ( - "0xed636277f3753b6c0275f7a28c2678a7f3a95655e09deaebec15179b50c5da7f903152e50f594f7b" -) -ACCOUNT_INDEX = 65 -API_KEY_INDEX = 1 - - -async def ws_flow(tx_types, tx_infos): - async with websockets.connect(f"{BASE_URL.replace('https', 'wss')}/stream") as ws: - msg = await ws.recv() - print("Received:", msg) - - await ws.send( - json.dumps( - { - "type": "jsonapi/sendtxbatch", - "data": { - "id": f"my_random_batch_id_{12345678}", # optional, helps id the response - "tx_types": json.dumps(tx_types), - "tx_infos": json.dumps(tx_infos), - }, - } - ) - ) - - print("Response:", await ws.recv()) - - -async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - configuration = lighter.Configuration(BASE_URL) - api_client = lighter.ApiClient(configuration) - transaction_api = lighter.TransactionApi(api_client) - - # use next nonce for getting nonces - next_nonce = await transaction_api.next_nonce( - account_index=ACCOUNT_INDEX, api_key_index=API_KEY_INDEX - ) - nonce_value = next_nonce.nonce - - ask_tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1001, # Unique identifier for this order - base_amount=100000, - price=280000, - is_ask=True, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value, - ) - nonce_value += 1 - - if error is not None: - print(f"Error signing first order (first batch): {error}") - return - - # Sign second order - bid_tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1002, # Different unique identifier - base_amount=200000, - price=200000, - is_ask=False, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value, - ) - - if error is not None: - print(f"Error signing second order (first batch): {error}") - return - - tx_types = [ - lighter.SignerClient.TX_TYPE_CREATE_ORDER, - lighter.SignerClient.TX_TYPE_CREATE_ORDER, - ] - tx_infos = [ask_tx_info, bid_tx_info] - - await ws_flow(tx_types, tx_infos) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/examples/ws_send_tx.py b/docs/lighter/lighter-python-main/examples/ws_send_tx.py deleted file mode 100644 index c120b83..0000000 --- a/docs/lighter/lighter-python-main/examples/ws_send_tx.py +++ /dev/null @@ -1,74 +0,0 @@ -import lighter -import json -import websockets -import asyncio - -# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. -# It was generated using the setup_system.py script, and servers as an example. -# Alternatively, you can go to https://app.lighter.xyz/apikeys for mainnet api keys -BASE_URL = "https://testnet.zklighter.elliot.ai" -API_KEY_PRIVATE_KEY = ( - "0xed636277f3753b6c0275f7a28c2678a7f3a95655e09deaebec15179b50c5da7f903152e50f594f7b" -) -ACCOUNT_INDEX = 65 -API_KEY_INDEX = 3 - - -async def ws_flow(tx_type, tx_info): - async with websockets.connect(f"{BASE_URL.replace('https', 'wss')}/stream") as ws: - msg = await ws.recv() - print("Received:", msg) - - await ws.send( - json.dumps( - { - "type": "jsonapi/sendtx", - "data": { - "id": f"my_random_id_{12345678}", # optional, helps id the response - "tx_type": tx_type, - "tx_info": json.loads(tx_info), - }, - } - ) - ) - - print("Response:", await ws.recv()) - - -async def main(): - client = lighter.SignerClient( - url=BASE_URL, - private_key=API_KEY_PRIVATE_KEY, - account_index=ACCOUNT_INDEX, - api_key_index=API_KEY_INDEX, - ) - configuration = lighter.Configuration(BASE_URL) - api_client = lighter.ApiClient(configuration) - transaction_api = lighter.TransactionApi(api_client) - - next_nonce = await transaction_api.next_nonce( - account_index=ACCOUNT_INDEX, api_key_index=API_KEY_INDEX - ) - nonce_value = next_nonce.nonce - - tx_info, error = client.sign_create_order( - market_index=0, - client_order_index=1002, # Different unique identifier - base_amount=200000, - price=200000, - is_ask=False, - order_type=client.ORDER_TYPE_LIMIT, - time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, - reduce_only=False, - trigger_price=0, - nonce=nonce_value, - ) - if error is not None: - print(f"Error signing order: {error}") - return - - await ws_flow(lighter.SignerClient.TX_TYPE_CREATE_ORDER, tx_info) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/docs/lighter/lighter-python-main/git_push.sh b/docs/lighter/lighter-python-main/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/docs/lighter/lighter-python-main/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/docs/lighter/lighter-python-main/lighter/__init__.py b/docs/lighter/lighter-python-main/lighter/__init__.py new file mode 100644 index 0000000..afcc0a9 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/__init__.py @@ -0,0 +1,184 @@ +# coding: utf-8 + +# flake8: noqa + +""" + zkLighter API + + Public APIs for Lighter + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# import apis into sdk package +from lighter.api.account_api import AccountApi +from lighter.api.announcement_api import AnnouncementApi +from lighter.api.block_api import BlockApi +from lighter.api.bridge_api import BridgeApi +from lighter.api.candlestick_api import CandlestickApi +from lighter.api.funding_api import FundingApi +from lighter.api.info_api import InfoApi +from lighter.api.notification_api import NotificationApi +from lighter.api.order_api import OrderApi +from lighter.api.referral_api import ReferralApi +from lighter.api.root_api import RootApi +from lighter.api.transaction_api import TransactionApi + +# import ApiClient +from lighter.api_response import ApiResponse +from lighter.api_client import ApiClient +from lighter.configuration import Configuration +from lighter.exceptions import OpenApiException +from lighter.exceptions import ApiTypeError +from lighter.exceptions import ApiValueError +from lighter.exceptions import ApiKeyError +from lighter.exceptions import ApiAttributeError +from lighter.exceptions import ApiException + +# import models into sdk package +from lighter.models.account import Account +from lighter.models.account_api_keys import AccountApiKeys +from lighter.models.account_asset import AccountAsset +from lighter.models.account_limits import AccountLimits +from lighter.models.account_margin_stats import AccountMarginStats +from lighter.models.account_market_stats import AccountMarketStats +from lighter.models.account_metadata import AccountMetadata +from lighter.models.account_metadatas import AccountMetadatas +from lighter.models.account_pn_l import AccountPnL +from lighter.models.account_position import AccountPosition +from lighter.models.account_stats import AccountStats +from lighter.models.account_trade_stats import AccountTradeStats +from lighter.models.announcement import Announcement +from lighter.models.announcements import Announcements +from lighter.models.api_key import ApiKey +from lighter.models.asset import Asset +from lighter.models.asset_details import AssetDetails +from lighter.models.block import Block +from lighter.models.blocks import Blocks +from lighter.models.bridge import Bridge +from lighter.models.bridge_supported_network import BridgeSupportedNetwork +from lighter.models.candlestick import Candlestick +from lighter.models.candlesticks import Candlesticks +from lighter.models.contract_address import ContractAddress +from lighter.models.current_height import CurrentHeight +from lighter.models.cursor import Cursor +from lighter.models.daily_return import DailyReturn +from lighter.models.deposit_history import DepositHistory +from lighter.models.deposit_history_item import DepositHistoryItem +from lighter.models.detailed_account import DetailedAccount +from lighter.models.detailed_accounts import DetailedAccounts +from lighter.models.detailed_candlestick import DetailedCandlestick +from lighter.models.enriched_tx import EnrichedTx +from lighter.models.exchange_stats import ExchangeStats +from lighter.models.export_data import ExportData +from lighter.models.funding import Funding +from lighter.models.funding_rate import FundingRate +from lighter.models.funding_rates import FundingRates +from lighter.models.fundings import Fundings +from lighter.models.l1_metadata import L1Metadata +from lighter.models.l1_provider_info import L1ProviderInfo +from lighter.models.liq_trade import LiqTrade +from lighter.models.liquidation import Liquidation +from lighter.models.liquidation_info import LiquidationInfo +from lighter.models.liquidation_infos import LiquidationInfos +from lighter.models.market_config import MarketConfig +from lighter.models.next_nonce import NextNonce +from lighter.models.order import Order +from lighter.models.order_book import OrderBook +from lighter.models.order_book_depth import OrderBookDepth +from lighter.models.order_book_details import OrderBookDetails +from lighter.models.order_book_orders import OrderBookOrders +from lighter.models.order_book_stats import OrderBookStats +from lighter.models.order_books import OrderBooks +from lighter.models.orders import Orders +from lighter.models.perps_market_stats import PerpsMarketStats +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail +from lighter.models.pn_l_entry import PnLEntry +from lighter.models.position_funding import PositionFunding +from lighter.models.position_fundings import PositionFundings +from lighter.models.price_level import PriceLevel +from lighter.models.public_pool_info import PublicPoolInfo +from lighter.models.public_pool_metadata import PublicPoolMetadata +from lighter.models.public_pool_share import PublicPoolShare +from lighter.models.referral_point_entry import ReferralPointEntry +from lighter.models.referral_points import ReferralPoints +from lighter.models.req_export_data import ReqExportData +from lighter.models.req_get_account import ReqGetAccount +from lighter.models.req_get_account_active_orders import ReqGetAccountActiveOrders +from lighter.models.req_get_account_api_keys import ReqGetAccountApiKeys +from lighter.models.req_get_account_by_l1_address import ReqGetAccountByL1Address +from lighter.models.req_get_account_inactive_orders import ReqGetAccountInactiveOrders +from lighter.models.req_get_account_limits import ReqGetAccountLimits +from lighter.models.req_get_account_metadata import ReqGetAccountMetadata +from lighter.models.req_get_account_pn_l import ReqGetAccountPnL +from lighter.models.req_get_account_txs import ReqGetAccountTxs +from lighter.models.req_get_asset_details import ReqGetAssetDetails +from lighter.models.req_get_block import ReqGetBlock +from lighter.models.req_get_block_txs import ReqGetBlockTxs +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr +from lighter.models.req_get_by_account import ReqGetByAccount +from lighter.models.req_get_candlesticks import ReqGetCandlesticks +from lighter.models.req_get_deposit_history import ReqGetDepositHistory +from lighter.models.req_get_fast_withdraw_info import ReqGetFastWithdrawInfo +from lighter.models.req_get_fundings import ReqGetFundings +from lighter.models.req_get_l1_metadata import ReqGetL1Metadata +from lighter.models.req_get_l1_tx import ReqGetL1Tx +from lighter.models.req_get_latest_deposit import ReqGetLatestDeposit +from lighter.models.req_get_liquidation_infos import ReqGetLiquidationInfos +from lighter.models.req_get_next_nonce import ReqGetNextNonce +from lighter.models.req_get_order_book_details import ReqGetOrderBookDetails +from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders +from lighter.models.req_get_order_books import ReqGetOrderBooks +from lighter.models.req_get_position_funding import ReqGetPositionFunding +from lighter.models.req_get_public_pools_metadata import ReqGetPublicPoolsMetadata +from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor +from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex +from lighter.models.req_get_range_with_index_sortable import ReqGetRangeWithIndexSortable +from lighter.models.req_get_recent_trades import ReqGetRecentTrades +from lighter.models.req_get_referral_points import ReqGetReferralPoints +from lighter.models.req_get_trades import ReqGetTrades +from lighter.models.req_get_transfer_fee_info import ReqGetTransferFeeInfo +from lighter.models.req_get_transfer_history import ReqGetTransferHistory +from lighter.models.req_get_tx import ReqGetTx +from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory +from lighter.models.resp_change_account_tier import RespChangeAccountTier +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr +from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast +from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata +from lighter.models.resp_send_tx import RespSendTx +from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode +from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay +from lighter.models.result_code import ResultCode +from lighter.models.risk_info import RiskInfo +from lighter.models.risk_parameters import RiskParameters +from lighter.models.share_price import SharePrice +from lighter.models.simple_order import SimpleOrder +from lighter.models.spot_market_stats import SpotMarketStats +from lighter.models.spot_order_book_detail import SpotOrderBookDetail +from lighter.models.status import Status +from lighter.models.sub_accounts import SubAccounts +from lighter.models.ticker import Ticker +from lighter.models.trade import Trade +from lighter.models.trades import Trades +from lighter.models.transfer_fee_info import TransferFeeInfo +from lighter.models.transfer_history import TransferHistory +from lighter.models.transfer_history_item import TransferHistoryItem +from lighter.models.tx import Tx +from lighter.models.tx_hash import TxHash +from lighter.models.tx_hashes import TxHashes +from lighter.models.txs import Txs +from lighter.models.validator_info import ValidatorInfo +from lighter.models.withdraw_history import WithdrawHistory +from lighter.models.withdraw_history_item import WithdrawHistoryItem +from lighter.models.zk_lighter_info import ZkLighterInfo +from lighter.ws_client import WsClient +from lighter.signer_client import SignerClient, create_api_key \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/lighter/api/__init__.py b/docs/lighter/lighter-python-main/lighter/api/__init__.py new file mode 100644 index 0000000..a238373 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/__init__.py @@ -0,0 +1,16 @@ +# flake8: noqa + +# import apis into api package +from lighter.api.account_api import AccountApi +from lighter.api.announcement_api import AnnouncementApi +from lighter.api.block_api import BlockApi +from lighter.api.bridge_api import BridgeApi +from lighter.api.candlestick_api import CandlestickApi +from lighter.api.funding_api import FundingApi +from lighter.api.info_api import InfoApi +from lighter.api.notification_api import NotificationApi +from lighter.api.order_api import OrderApi +from lighter.api.referral_api import ReferralApi +from lighter.api.root_api import RootApi +from lighter.api.transaction_api import TransactionApi + diff --git a/docs/lighter/lighter-python-main/lighter/api/account_api.py b/docs/lighter/lighter-python-main/lighter/api/account_api.py new file mode 100644 index 0000000..688ac0f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/account_api.py @@ -0,0 +1,3544 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Optional +from typing_extensions import Annotated +from lighter.models.account_api_keys import AccountApiKeys +from lighter.models.account_limits import AccountLimits +from lighter.models.account_metadatas import AccountMetadatas +from lighter.models.account_pn_l import AccountPnL +from lighter.models.detailed_accounts import DetailedAccounts +from lighter.models.l1_metadata import L1Metadata +from lighter.models.liquidation_infos import LiquidationInfos +from lighter.models.position_fundings import PositionFundings +from lighter.models.resp_change_account_tier import RespChangeAccountTier +from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata +from lighter.models.sub_accounts import SubAccounts + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class AccountApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def account( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DetailedAccounts: + """account + + Get account by account's index.
More details about account index: [Account Index](https://apidocs.lighter.xyz/docs/account-index)
**Response Description:**

1) **Status:** 1 is active 0 is inactive.
2) **Collateral:** The amount of collateral in the account.
**Position Details Description:**
1) **OOC:** Open order count in that market.
2) **Sign:** 1 for Long, -1 for Short.
3) **Position:** The amount of position in that market.
4) **Avg Entry Price:** The average entry price of the position.
5) **Position Value:** The value of the position.
6) **Unrealized PnL:** The unrealized profit and loss of the position.
7) **Realized PnL:** The realized profit and loss of the position. + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DetailedAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_with_http_info( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DetailedAccounts]: + """account + + Get account by account's index.
More details about account index: [Account Index](https://apidocs.lighter.xyz/docs/account-index)
**Response Description:**

1) **Status:** 1 is active 0 is inactive.
2) **Collateral:** The amount of collateral in the account.
**Position Details Description:**
1) **OOC:** Open order count in that market.
2) **Sign:** 1 for Long, -1 for Short.
3) **Position:** The amount of position in that market.
4) **Avg Entry Price:** The average entry price of the position.
5) **Position Value:** The value of the position.
6) **Unrealized PnL:** The unrealized profit and loss of the position.
7) **Realized PnL:** The realized profit and loss of the position. + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DetailedAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """account + + Get account by account's index.
More details about account index: [Account Index](https://apidocs.lighter.xyz/docs/account-index)
**Response Description:**

1) **Status:** 1 is active 0 is inactive.
2) **Collateral:** The amount of collateral in the account.
**Position Details Description:**
1) **OOC:** Open order count in that market.
2) **Sign:** 1 for Long, -1 for Short.
3) **Position:** The amount of position in that market.
4) **Avg Entry Price:** The average entry price of the position.
5) **Position Value:** The value of the position.
6) **Unrealized PnL:** The unrealized profit and loss of the position.
7) **Realized PnL:** The realized profit and loss of the position. + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DetailedAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_serialize( + self, + by, + value, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/account', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def account_limits( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AccountLimits: + """accountLimits + + Get account limits + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_limits_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountLimits", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_limits_with_http_info( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AccountLimits]: + """accountLimits + + Get account limits + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_limits_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountLimits", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_limits_without_preload_content( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountLimits + + Get account limits + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_limits_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountLimits", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_limits_serialize( + self, + account_index, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountLimits', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def account_metadata( + self, + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AccountMetadatas: + """accountMetadata + + Get account metadatas + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_metadata_serialize( + by=by, + value=value, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountMetadatas", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_metadata_with_http_info( + self, + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AccountMetadatas]: + """accountMetadata + + Get account metadatas + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_metadata_serialize( + by=by, + value=value, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountMetadatas", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_metadata_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountMetadata + + Get account metadatas + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_metadata_serialize( + by=by, + value=value, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountMetadatas", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_metadata_serialize( + self, + by, + value, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountMetadata', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def accounts_by_l1_address( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> SubAccounts: + """accountsByL1Address + + Get accounts by l1_address returns all accounts associated with the given L1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._accounts_by_l1_address_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SubAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def accounts_by_l1_address_with_http_info( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[SubAccounts]: + """accountsByL1Address + + Get accounts by l1_address returns all accounts associated with the given L1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._accounts_by_l1_address_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SubAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def accounts_by_l1_address_without_preload_content( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountsByL1Address + + Get accounts by l1_address returns all accounts associated with the given L1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._accounts_by_l1_address_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SubAccounts", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _accounts_by_l1_address_serialize( + self, + l1_address, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountsByL1Address', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def apikeys( + self, + account_index: StrictInt, + api_key_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AccountApiKeys: + """apikeys + + Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account. + + :param account_index: (required) + :type account_index: int + :param api_key_index: + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._apikeys_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountApiKeys", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def apikeys_with_http_info( + self, + account_index: StrictInt, + api_key_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AccountApiKeys]: + """apikeys + + Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account. + + :param account_index: (required) + :type account_index: int + :param api_key_index: + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._apikeys_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountApiKeys", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def apikeys_without_preload_content( + self, + account_index: StrictInt, + api_key_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """apikeys + + Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account. + + :param account_index: (required) + :type account_index: int + :param api_key_index: + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._apikeys_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountApiKeys", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _apikeys_serialize( + self, + account_index, + api_key_index, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if api_key_index is not None: + + _query_params.append(('api_key_index', api_key_index)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/apikeys', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def change_account_tier( + self, + account_index: StrictInt, + new_tier: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespChangeAccountTier: + """changeAccountTier + + Change account tier + + :param account_index: (required) + :type account_index: int + :param new_tier: (required) + :type new_tier: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._change_account_tier_serialize( + account_index=account_index, + new_tier=new_tier, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespChangeAccountTier", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def change_account_tier_with_http_info( + self, + account_index: StrictInt, + new_tier: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespChangeAccountTier]: + """changeAccountTier + + Change account tier + + :param account_index: (required) + :type account_index: int + :param new_tier: (required) + :type new_tier: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._change_account_tier_serialize( + account_index=account_index, + new_tier=new_tier, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespChangeAccountTier", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def change_account_tier_without_preload_content( + self, + account_index: StrictInt, + new_tier: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """changeAccountTier + + Change account tier + + :param account_index: (required) + :type account_index: int + :param new_tier: (required) + :type new_tier: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._change_account_tier_serialize( + account_index=account_index, + new_tier=new_tier, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespChangeAccountTier", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _change_account_tier_serialize( + self, + account_index, + new_tier, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + if new_tier is not None: + _form_params.append(('new_tier', new_tier)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/changeAccountTier', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def l1_metadata( + self, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> L1Metadata: + """l1Metadata + + Get L1 metadata + + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._l1_metadata_serialize( + l1_address=l1_address, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "L1Metadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def l1_metadata_with_http_info( + self, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[L1Metadata]: + """l1Metadata + + Get L1 metadata + + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._l1_metadata_serialize( + l1_address=l1_address, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "L1Metadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def l1_metadata_without_preload_content( + self, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """l1Metadata + + Get L1 metadata + + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._l1_metadata_serialize( + l1_address=l1_address, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "L1Metadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _l1_metadata_serialize( + self, + l1_address, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/l1Metadata', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def liquidations( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> LiquidationInfos: + """liquidations + + Get liquidation infos + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._liquidations_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LiquidationInfos", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def liquidations_with_http_info( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[LiquidationInfos]: + """liquidations + + Get liquidation infos + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._liquidations_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LiquidationInfos", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def liquidations_without_preload_content( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """liquidations + + Get liquidation infos + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._liquidations_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LiquidationInfos", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _liquidations_serialize( + self, + account_index, + limit, + authorization, + auth, + market_id, + cursor, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/liquidations', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def pnl( + self, + by: StrictStr, + value: StrictStr, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + ignore_transfers: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AccountPnL: + """pnl + + Get account PnL chart + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param ignore_transfers: + :type ignore_transfers: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._pnl_serialize( + by=by, + value=value, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + authorization=authorization, + auth=auth, + ignore_transfers=ignore_transfers, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountPnL", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def pnl_with_http_info( + self, + by: StrictStr, + value: StrictStr, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + ignore_transfers: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AccountPnL]: + """pnl + + Get account PnL chart + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param ignore_transfers: + :type ignore_transfers: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._pnl_serialize( + by=by, + value=value, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + authorization=authorization, + auth=auth, + ignore_transfers=ignore_transfers, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountPnL", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def pnl_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + ignore_transfers: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """pnl + + Get account PnL chart + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param ignore_transfers: + :type ignore_transfers: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._pnl_serialize( + by=by, + value=value, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + authorization=authorization, + auth=auth, + ignore_transfers=ignore_transfers, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AccountPnL", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _pnl_serialize( + self, + by, + value, + resolution, + start_timestamp, + end_timestamp, + count_back, + authorization, + auth, + ignore_transfers, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + if resolution is not None: + + _query_params.append(('resolution', resolution)) + + if start_timestamp is not None: + + _query_params.append(('start_timestamp', start_timestamp)) + + if end_timestamp is not None: + + _query_params.append(('end_timestamp', end_timestamp)) + + if count_back is not None: + + _query_params.append(('count_back', count_back)) + + if ignore_transfers is not None: + + _query_params.append(('ignore_transfers', ignore_transfers)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/pnl', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def position_funding( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + side: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PositionFundings: + """positionFunding + + Get accounts position fundings + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param side: + :type side: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._position_funding_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + side=side, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PositionFundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def position_funding_with_http_info( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + side: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PositionFundings]: + """positionFunding + + Get accounts position fundings + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param side: + :type side: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._position_funding_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + side=side, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PositionFundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def position_funding_without_preload_content( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + cursor: Optional[StrictStr] = None, + side: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """positionFunding + + Get accounts position fundings + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param cursor: + :type cursor: str + :param side: + :type side: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._position_funding_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + cursor=cursor, + side=side, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PositionFundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _position_funding_serialize( + self, + account_index, + limit, + authorization, + auth, + market_id, + cursor, + side, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if side is not None: + + _query_params.append(('side', side)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/positionFunding', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call + async def public_pools_metadata( + self, + index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespPublicPoolsMetadata: + """publicPoolsMetadata + + Get public pools metadata + + :param index: (required) + :type index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param filter: + :type filter: str + :param account_index: + :type account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._public_pools_metadata_serialize( + index=index, + limit=limit, + authorization=authorization, + auth=auth, + filter=filter, + account_index=account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespPublicPoolsMetadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def public_pools_metadata_with_http_info( + self, + index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespPublicPoolsMetadata]: + """publicPoolsMetadata + + Get public pools metadata + + :param index: (required) + :type index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param filter: + :type filter: str + :param account_index: + :type account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._public_pools_metadata_serialize( + index=index, + limit=limit, + authorization=authorization, + auth=auth, + filter=filter, + account_index=account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespPublicPoolsMetadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def public_pools_metadata_without_preload_content( + self, + index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """publicPoolsMetadata + + Get public pools metadata + + :param index: (required) + :type index: int + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param filter: + :type filter: str + :param account_index: + :type account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._public_pools_metadata_serialize( + index=index, + limit=limit, + authorization=authorization, + auth=auth, + filter=filter, + account_index=account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespPublicPoolsMetadata", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _public_pools_metadata_serialize( + self, + index, + limit, + authorization, + auth, + filter, + account_index, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if filter is not None: + + _query_params.append(('filter', filter)) + + if index is not None: + + _query_params.append(('index', index)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/publicPoolsMetadata', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/announcement_api.py b/docs/lighter/lighter-python-main/lighter/api/announcement_api.py new file mode 100644 index 0000000..7eaa982 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/announcement_api.py @@ -0,0 +1,282 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from lighter.models.announcements import Announcements + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class AnnouncementApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def announcement( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Announcements: + """announcement + + Get announcement + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._announcement_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Announcements", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def announcement_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Announcements]: + """announcement + + Get announcement + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._announcement_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Announcements", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def announcement_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """announcement + + Get announcement + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._announcement_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Announcements", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _announcement_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/announcement', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/block_api.py b/docs/lighter/lighter-python-main/lighter/api/block_api.py new file mode 100644 index 0000000..e09888a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/block_api.py @@ -0,0 +1,863 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt, StrictStr, field_validator +from typing import Optional +from typing_extensions import Annotated +from lighter.models.blocks import Blocks +from lighter.models.current_height import CurrentHeight + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class BlockApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def block( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Blocks: + """block + + Get block by its height or commitment + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def block_with_http_info( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Blocks]: + """block + + Get block by its height or commitment + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def block_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """block + + Get block by its height or commitment + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _block_serialize( + self, + by, + value, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/block', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def blocks( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + sort: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Blocks: + """blocks + + Get blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param sort: + :type sort: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._blocks_serialize( + limit=limit, + index=index, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def blocks_with_http_info( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + sort: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Blocks]: + """blocks + + Get blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param sort: + :type sort: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._blocks_serialize( + limit=limit, + index=index, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def blocks_without_preload_content( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + sort: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """blocks + + Get blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param sort: + :type sort: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._blocks_serialize( + limit=limit, + index=index, + sort=sort, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Blocks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _blocks_serialize( + self, + limit, + index, + sort, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if index is not None: + + _query_params.append(('index', index)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if sort is not None: + + _query_params.append(('sort', sort)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/blocks', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def current_height( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CurrentHeight: + """currentHeight + + Get current height + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._current_height_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CurrentHeight", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def current_height_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CurrentHeight]: + """currentHeight + + Get current height + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._current_height_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CurrentHeight", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def current_height_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """currentHeight + + Get current height + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._current_height_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CurrentHeight", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _current_height_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/currentHeight', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/bridge_api.py b/docs/lighter/lighter-python-main/lighter/api/bridge_api.py new file mode 100644 index 0000000..73e739f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/bridge_api.py @@ -0,0 +1,804 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import StrictStr +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr +from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class BridgeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + async def bridges( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespGetBridgesByL1Addr: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def bridges_with_http_info( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespGetBridgesByL1Addr]: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def bridges_without_preload_content( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _bridges_serialize( + self, + l1_address, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/bridges', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + async def bridges_is_next_bridge_fast( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespGetIsNextBridgeFast: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def bridges_is_next_bridge_fast_with_http_info( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespGetIsNextBridgeFast]: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def bridges_is_next_bridge_fast_without_preload_content( + self, + l1_address: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _bridges_is_next_bridge_fast_serialize( + self, + l1_address, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/bridges/isNextBridgeFast', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + async def fastbridge_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespGetFastBridgeInfo: + """fastbridge_info + + Get fast bridge info + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fastbridge_info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetFastBridgeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def fastbridge_info_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespGetFastBridgeInfo]: + """fastbridge_info + + Get fast bridge info + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fastbridge_info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetFastBridgeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def fastbridge_info_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """fastbridge_info + + Get fast bridge info + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fastbridge_info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetFastBridgeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _fastbridge_info_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/fastbridge/info', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/candlestick_api.py b/docs/lighter/lighter-python-main/lighter/api/candlestick_api.py new file mode 100644 index 0000000..c964c30 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/candlestick_api.py @@ -0,0 +1,719 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Optional +from typing_extensions import Annotated +from lighter.models.candlesticks import Candlesticks +from lighter.models.fundings import Fundings + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class CandlestickApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def candlesticks( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + set_timestamp_to_end: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Candlesticks: + """candlesticks + + Get candlesticks + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param set_timestamp_to_end: + :type set_timestamp_to_end: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._candlesticks_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + set_timestamp_to_end=set_timestamp_to_end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Candlesticks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def candlesticks_with_http_info( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + set_timestamp_to_end: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Candlesticks]: + """candlesticks + + Get candlesticks + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param set_timestamp_to_end: + :type set_timestamp_to_end: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._candlesticks_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + set_timestamp_to_end=set_timestamp_to_end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Candlesticks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def candlesticks_without_preload_content( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + set_timestamp_to_end: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """candlesticks + + Get candlesticks + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param set_timestamp_to_end: + :type set_timestamp_to_end: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._candlesticks_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + set_timestamp_to_end=set_timestamp_to_end, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Candlesticks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _candlesticks_serialize( + self, + market_id, + resolution, + start_timestamp, + end_timestamp, + count_back, + set_timestamp_to_end, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if resolution is not None: + + _query_params.append(('resolution', resolution)) + + if start_timestamp is not None: + + _query_params.append(('start_timestamp', start_timestamp)) + + if end_timestamp is not None: + + _query_params.append(('end_timestamp', end_timestamp)) + + if count_back is not None: + + _query_params.append(('count_back', count_back)) + + if set_timestamp_to_end is not None: + + _query_params.append(('set_timestamp_to_end', set_timestamp_to_end)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/candlesticks', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def fundings( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Fundings: + """fundings + + Get fundings + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fundings_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Fundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def fundings_with_http_info( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Fundings]: + """fundings + + Get fundings + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fundings_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Fundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def fundings_without_preload_content( + self, + market_id: StrictInt, + resolution: StrictStr, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + count_back: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """fundings + + Get fundings + + :param market_id: (required) + :type market_id: int + :param resolution: (required) + :type resolution: str + :param start_timestamp: (required) + :type start_timestamp: int + :param end_timestamp: (required) + :type end_timestamp: int + :param count_back: (required) + :type count_back: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._fundings_serialize( + market_id=market_id, + resolution=resolution, + start_timestamp=start_timestamp, + end_timestamp=end_timestamp, + count_back=count_back, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Fundings", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _fundings_serialize( + self, + market_id, + resolution, + start_timestamp, + end_timestamp, + count_back, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if resolution is not None: + + _query_params.append(('resolution', resolution)) + + if start_timestamp is not None: + + _query_params.append(('start_timestamp', start_timestamp)) + + if end_timestamp is not None: + + _query_params.append(('end_timestamp', end_timestamp)) + + if count_back is not None: + + _query_params.append(('count_back', count_back)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/fundings', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/funding_api.py b/docs/lighter/lighter-python-main/lighter/api/funding_api.py new file mode 100644 index 0000000..5bcc028 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/funding_api.py @@ -0,0 +1,282 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from lighter.models.funding_rates import FundingRates + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class FundingApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def funding_rates( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> FundingRates: + """funding-rates + + Get funding rates + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._funding_rates_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FundingRates", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def funding_rates_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[FundingRates]: + """funding-rates + + Get funding rates + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._funding_rates_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FundingRates", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def funding_rates_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """funding-rates + + Get funding rates + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._funding_rates_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FundingRates", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _funding_rates_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/funding-rates', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/info_api.py b/docs/lighter/lighter-python-main/lighter/api/info_api.py new file mode 100644 index 0000000..9e2591a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/info_api.py @@ -0,0 +1,597 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import StrictInt, StrictStr +from typing import Optional +from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay +from lighter.models.transfer_fee_info import TransferFeeInfo + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class InfoApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def transfer_fee_info( + self, + account_index: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + to_account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> TransferFeeInfo: + """transferFeeInfo + + Transfer fee info + + :param account_index: (required) + :type account_index: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param to_account_index: + :type to_account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_fee_info_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + to_account_index=to_account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferFeeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def transfer_fee_info_with_http_info( + self, + account_index: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + to_account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[TransferFeeInfo]: + """transferFeeInfo + + Transfer fee info + + :param account_index: (required) + :type account_index: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param to_account_index: + :type to_account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_fee_info_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + to_account_index=to_account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferFeeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def transfer_fee_info_without_preload_content( + self, + account_index: StrictInt, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + to_account_index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """transferFeeInfo + + Transfer fee info + + :param account_index: (required) + :type account_index: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param to_account_index: + :type to_account_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_fee_info_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + to_account_index=to_account_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferFeeInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _transfer_fee_info_serialize( + self, + account_index, + authorization, + auth, + to_account_index, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if to_account_index is not None: + + _query_params.append(('to_account_index', to_account_index)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/transferFeeInfo', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def withdrawal_delay( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespWithdrawalDelay: + """withdrawalDelay + + Withdrawal delay in seconds + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdrawal_delay_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespWithdrawalDelay", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def withdrawal_delay_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespWithdrawalDelay]: + """withdrawalDelay + + Withdrawal delay in seconds + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdrawal_delay_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespWithdrawalDelay", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def withdrawal_delay_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """withdrawalDelay + + Withdrawal delay in seconds + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdrawal_delay_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespWithdrawalDelay", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _withdrawal_delay_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/withdrawalDelay', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/notification_api.py b/docs/lighter/lighter-python-main/lighter/api/notification_api.py new file mode 100644 index 0000000..a3c2477 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/notification_api.py @@ -0,0 +1,358 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt, StrictStr +from typing import Optional +from typing_extensions import Annotated +from lighter.models.result_code import ResultCode + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class NotificationApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def notification_ack( + self, + notif_id: StrictStr, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ResultCode: + """notification_ack + + Ack notification + + :param notif_id: (required) + :type notif_id: str + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._notification_ack_serialize( + notif_id=notif_id, + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResultCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def notification_ack_with_http_info( + self, + notif_id: StrictStr, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ResultCode]: + """notification_ack + + Ack notification + + :param notif_id: (required) + :type notif_id: str + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._notification_ack_serialize( + notif_id=notif_id, + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResultCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def notification_ack_without_preload_content( + self, + notif_id: StrictStr, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """notification_ack + + Ack notification + + :param notif_id: (required) + :type notif_id: str + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._notification_ack_serialize( + notif_id=notif_id, + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ResultCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _notification_ack_serialize( + self, + notif_id, + account_index, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + if notif_id is not None: + _form_params.append(('notif_id', notif_id)) + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/notification/ack', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/order_api.py b/docs/lighter/lighter-python-main/lighter/api/order_api.py new file mode 100644 index 0000000..76154ef --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/order_api.py @@ -0,0 +1,3175 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Optional +from typing_extensions import Annotated +from lighter.models.asset_details import AssetDetails +from lighter.models.exchange_stats import ExchangeStats +from lighter.models.export_data import ExportData +from lighter.models.order_book_details import OrderBookDetails +from lighter.models.order_book_orders import OrderBookOrders +from lighter.models.order_books import OrderBooks +from lighter.models.orders import Orders +from lighter.models.trades import Trades + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class OrderApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + async def account_active_orders( + self, + account_index: StrictInt, + market_id: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Orders: + """accountActiveOrders + + Get account active orders. `auth` can be generated using the SDK. + + :param account_index: (required) + :type account_index: int + :param market_id: (required) + :type market_id: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_active_orders_serialize( + account_index=account_index, + market_id=market_id, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_active_orders_with_http_info( + self, + account_index: StrictInt, + market_id: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Orders]: + """accountActiveOrders + + Get account active orders. `auth` can be generated using the SDK. + + :param account_index: (required) + :type account_index: int + :param market_id: (required) + :type market_id: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_active_orders_serialize( + account_index=account_index, + market_id=market_id, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_active_orders_without_preload_content( + self, + account_index: StrictInt, + market_id: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountActiveOrders + + Get account active orders. `auth` can be generated using the SDK. + + :param account_index: (required) + :type account_index: int + :param market_id: (required) + :type market_id: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_active_orders_serialize( + account_index=account_index, + market_id=market_id, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_active_orders_serialize( + self, + account_index, + market_id, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountActiveOrders', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def account_inactive_orders( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + between_timestamps: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Orders: + """accountInactiveOrders + + Get account inactive orders + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param ask_filter: + :type ask_filter: int + :param between_timestamps: + :type between_timestamps: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_inactive_orders_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + ask_filter=ask_filter, + between_timestamps=between_timestamps, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_inactive_orders_with_http_info( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + between_timestamps: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Orders]: + """accountInactiveOrders + + Get account inactive orders + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param ask_filter: + :type ask_filter: int + :param between_timestamps: + :type between_timestamps: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_inactive_orders_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + ask_filter=ask_filter, + between_timestamps=between_timestamps, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_inactive_orders_without_preload_content( + self, + account_index: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + market_id: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + between_timestamps: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountInactiveOrders + + Get account inactive orders + + :param account_index: (required) + :type account_index: int + :param limit: (required) + :type limit: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param market_id: + :type market_id: int + :param ask_filter: + :type ask_filter: int + :param between_timestamps: + :type between_timestamps: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_inactive_orders_serialize( + account_index=account_index, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + ask_filter=ask_filter, + between_timestamps=between_timestamps, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Orders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_inactive_orders_serialize( + self, + account_index, + limit, + authorization, + auth, + market_id, + ask_filter, + between_timestamps, + cursor, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if ask_filter is not None: + + _query_params.append(('ask_filter', ask_filter)) + + if between_timestamps is not None: + + _query_params.append(('between_timestamps', between_timestamps)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountInactiveOrders', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def asset_details( + self, + asset_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AssetDetails: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def asset_details_with_http_info( + self, + asset_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AssetDetails]: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def asset_details_without_preload_content( + self, + asset_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _asset_details_serialize( + self, + asset_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if asset_id is not None: + + _query_params.append(('asset_id', asset_id)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/assetDetails', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def exchange_stats( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ExchangeStats: + """exchangeStats + + Get exchange stats + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._exchange_stats_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExchangeStats", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def exchange_stats_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ExchangeStats]: + """exchangeStats + + Get exchange stats + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._exchange_stats_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExchangeStats", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def exchange_stats_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """exchangeStats + + Get exchange stats + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._exchange_stats_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExchangeStats", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _exchange_stats_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/exchangeStats', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def export( + self, + type: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + market_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ExportData: + """export + + Export data + + :param type: (required) + :type type: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param account_index: + :type account_index: int + :param market_id: + :type market_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._export_serialize( + type=type, + authorization=authorization, + auth=auth, + account_index=account_index, + market_id=market_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExportData", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def export_with_http_info( + self, + type: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + market_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ExportData]: + """export + + Export data + + :param type: (required) + :type type: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param account_index: + :type account_index: int + :param market_id: + :type market_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._export_serialize( + type=type, + authorization=authorization, + auth=auth, + account_index=account_index, + market_id=market_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExportData", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def export_without_preload_content( + self, + type: StrictStr, + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + account_index: Optional[StrictInt] = None, + market_id: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """export + + Export data + + :param type: (required) + :type type: str + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param account_index: + :type account_index: int + :param market_id: + :type market_id: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._export_serialize( + type=type, + authorization=authorization, + auth=auth, + account_index=account_index, + market_id=market_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ExportData", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _export_serialize( + self, + type, + authorization, + auth, + account_index, + market_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if type is not None: + + _query_params.append(('type', type)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/export', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def order_book_details( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> OrderBookDetails: + """orderBookDetails + + Get order books metadata + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_details_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def order_book_details_with_http_info( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[OrderBookDetails]: + """orderBookDetails + + Get order books metadata + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_details_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def order_book_details_without_preload_content( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """orderBookDetails + + Get order books metadata + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_details_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _order_book_details_serialize( + self, + market_id, + filter, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if filter is not None: + + _query_params.append(('filter', filter)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/orderBookDetails', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def order_book_orders( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=250, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> OrderBookOrders: + """orderBookOrders + + Get order book orders + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_orders_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookOrders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def order_book_orders_with_http_info( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=250, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[OrderBookOrders]: + """orderBookOrders + + Get order book orders + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_orders_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookOrders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def order_book_orders_without_preload_content( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=250, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """orderBookOrders + + Get order book orders + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_book_orders_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBookOrders", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _order_book_orders_serialize( + self, + market_id, + limit, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/orderBookOrders', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def order_books( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> OrderBooks: + """orderBooks + + Get order books metadata.
**Response Description:**

1) **Taker and maker fees** are in percentage.
2) **Min base amount:** The amount of base token that can be traded in a single order.
3) **Min quote amount:** The amount of quote token that can be traded in a single order.
4) **Supported size decimals:** The number of decimal places that can be used for the size of the order.
5) **Supported price decimals:** The number of decimal places that can be used for the price of the order.
6) **Supported quote decimals:** Size Decimals + Quote Decimals. + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_books_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBooks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def order_books_with_http_info( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[OrderBooks]: + """orderBooks + + Get order books metadata.
**Response Description:**

1) **Taker and maker fees** are in percentage.
2) **Min base amount:** The amount of base token that can be traded in a single order.
3) **Min quote amount:** The amount of quote token that can be traded in a single order.
4) **Supported size decimals:** The number of decimal places that can be used for the size of the order.
5) **Supported price decimals:** The number of decimal places that can be used for the price of the order.
6) **Supported quote decimals:** Size Decimals + Quote Decimals. + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_books_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBooks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def order_books_without_preload_content( + self, + market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """orderBooks + + Get order books metadata.
**Response Description:**

1) **Taker and maker fees** are in percentage.
2) **Min base amount:** The amount of base token that can be traded in a single order.
3) **Min quote amount:** The amount of quote token that can be traded in a single order.
4) **Supported size decimals:** The number of decimal places that can be used for the size of the order.
5) **Supported price decimals:** The number of decimal places that can be used for the price of the order.
6) **Supported quote decimals:** Size Decimals + Quote Decimals. + + :param market_id: + :type market_id: int + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._order_books_serialize( + market_id=market_id, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrderBooks", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _order_books_serialize( + self, + market_id, + filter, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if filter is not None: + + _query_params.append(('filter', filter)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/orderBooks', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def recent_trades( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Trades: + """recentTrades + + Get recent trades + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._recent_trades_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def recent_trades_with_http_info( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Trades]: + """recentTrades + + Get recent trades + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._recent_trades_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def recent_trades_without_preload_content( + self, + market_id: StrictInt, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """recentTrades + + Get recent trades + + :param market_id: (required) + :type market_id: int + :param limit: (required) + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._recent_trades_serialize( + market_id=market_id, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _recent_trades_serialize( + self, + market_id, + limit, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/recentTrades', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def trades( + self, + sort_by: StrictStr, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + account_index: Optional[StrictInt] = None, + order_index: Optional[StrictInt] = None, + sort_dir: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + var_from: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Trades: + """trades + + Get trades + + :param sort_by: (required) + :type sort_by: str + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param account_index: + :type account_index: int + :param order_index: + :type order_index: int + :param sort_dir: + :type sort_dir: str + :param cursor: + :type cursor: str + :param var_from: + :type var_from: int + :param ask_filter: + :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._trades_serialize( + sort_by=sort_by, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + account_index=account_index, + order_index=order_index, + sort_dir=sort_dir, + cursor=cursor, + var_from=var_from, + ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def trades_with_http_info( + self, + sort_by: StrictStr, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + account_index: Optional[StrictInt] = None, + order_index: Optional[StrictInt] = None, + sort_dir: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + var_from: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Trades]: + """trades + + Get trades + + :param sort_by: (required) + :type sort_by: str + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param account_index: + :type account_index: int + :param order_index: + :type order_index: int + :param sort_dir: + :type sort_dir: str + :param cursor: + :type cursor: str + :param var_from: + :type var_from: int + :param ask_filter: + :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._trades_serialize( + sort_by=sort_by, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + account_index=account_index, + order_index=order_index, + sort_dir=sort_dir, + cursor=cursor, + var_from=var_from, + ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def trades_without_preload_content( + self, + sort_by: StrictStr, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + authorization: Optional[StrictStr] = None, + auth: Optional[StrictStr] = None, + market_id: Optional[StrictInt] = None, + account_index: Optional[StrictInt] = None, + order_index: Optional[StrictInt] = None, + sort_dir: Optional[StrictStr] = None, + cursor: Optional[StrictStr] = None, + var_from: Optional[StrictInt] = None, + ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """trades + + Get trades + + :param sort_by: (required) + :type sort_by: str + :param limit: (required) + :type limit: int + :param authorization: + :type authorization: str + :param auth: + :type auth: str + :param market_id: + :type market_id: int + :param account_index: + :type account_index: int + :param order_index: + :type order_index: int + :param sort_dir: + :type sort_dir: str + :param cursor: + :type cursor: str + :param var_from: + :type var_from: int + :param ask_filter: + :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._trades_serialize( + sort_by=sort_by, + limit=limit, + authorization=authorization, + auth=auth, + market_id=market_id, + account_index=account_index, + order_index=order_index, + sort_dir=sort_dir, + cursor=cursor, + var_from=var_from, + ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Trades", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _trades_serialize( + self, + sort_by, + limit, + authorization, + auth, + market_id, + account_index, + order_index, + sort_dir, + cursor, + var_from, + ask_filter, + role, + type, + aggregate, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if market_id is not None: + + _query_params.append(('market_id', market_id)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if order_index is not None: + + _query_params.append(('order_index', order_index)) + + if sort_by is not None: + + _query_params.append(('sort_by', sort_by)) + + if sort_dir is not None: + + _query_params.append(('sort_dir', sort_dir)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if var_from is not None: + + _query_params.append(('from', var_from)) + + if ask_filter is not None: + + _query_params.append(('ask_filter', ask_filter)) + + if role is not None: + + _query_params.append(('role', role)) + + if type is not None: + + _query_params.append(('type', type)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if aggregate is not None: + + _query_params.append(('aggregate', aggregate)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/trades', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/referral_api.py b/docs/lighter/lighter-python-main/lighter/api/referral_api.py new file mode 100644 index 0000000..7425d71 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/referral_api.py @@ -0,0 +1,965 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt, StrictStr +from typing import Optional, Union +from typing_extensions import Annotated +from lighter.models.referral_points import ReferralPoints +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class ReferralApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + async def referral_kickback_update( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespUpdateKickback: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def referral_kickback_update_with_http_info( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespUpdateKickback]: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def referral_kickback_update_without_preload_content( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _referral_kickback_update_serialize( + self, + account_index, + kickback_percentage, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + if kickback_percentage is not None: + _form_params.append(('kickback_percentage', kickback_percentage)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/referral/kickback/update', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + async def referral_points( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ReferralPoints: + """referral_points + + Get referral points + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_points_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ReferralPoints", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def referral_points_with_http_info( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ReferralPoints]: + """referral_points + + Get referral points + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_points_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ReferralPoints", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def referral_points_without_preload_content( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """referral_points + + Get referral points + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_points_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ReferralPoints", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _referral_points_serialize( + self, + account_index, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/referral/points', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + async def referral_update( + self, + account_index: StrictInt, + new_referral_code: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespUpdateReferralCode: + """referral_update + + Update referral code (allowed once per account) + + :param account_index: (required) + :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_update_serialize( + account_index=account_index, + new_referral_code=new_referral_code, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateReferralCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + async def referral_update_with_http_info( + self, + account_index: StrictInt, + new_referral_code: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespUpdateReferralCode]: + """referral_update + + Update referral code (allowed once per account) + + :param account_index: (required) + :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_update_serialize( + account_index=account_index, + new_referral_code=new_referral_code, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateReferralCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + async def referral_update_without_preload_content( + self, + account_index: StrictInt, + new_referral_code: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """referral_update + + Update referral code (allowed once per account) + + :param account_index: (required) + :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._referral_update_serialize( + account_index=account_index, + new_referral_code=new_referral_code, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateReferralCode", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _referral_update_serialize( + self, + account_index, + new_referral_code, + authorization, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + if new_referral_code is not None: + _form_params.append(('new_referral_code', new_referral_code)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/referral/update', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/root_api.py b/docs/lighter/lighter-python-main/lighter/api/root_api.py new file mode 100644 index 0000000..f009fdc --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/root_api.py @@ -0,0 +1,529 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from lighter.models.status import Status +from lighter.models.zk_lighter_info import ZkLighterInfo + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class RootApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ZkLighterInfo: + """info + + Get info of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ZkLighterInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def info_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ZkLighterInfo]: + """info + + Get info of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ZkLighterInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def info_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """info + + Get info of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._info_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ZkLighterInfo", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _info_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/info', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def status( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Status: + """status + + Get status of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Status", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def status_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Status]: + """status + + Get status of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Status", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def status_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """status + + Get status of zklighter + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Status", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _status_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api/transaction_api.py b/docs/lighter/lighter-python-main/lighter/api/transaction_api.py new file mode 100644 index 0000000..5129ab0 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api/transaction_api.py @@ -0,0 +1,3373 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import List, Optional +from typing_extensions import Annotated +from lighter.models.deposit_history import DepositHistory +from lighter.models.enriched_tx import EnrichedTx +from lighter.models.next_nonce import NextNonce +from lighter.models.resp_send_tx import RespSendTx +from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.models.transfer_history import TransferHistory +from lighter.models.txs import Txs +from lighter.models.withdraw_history import WithdrawHistory + +from lighter.api_client import ApiClient, RequestSerialized +from lighter.api_response import ApiResponse +from lighter.rest import RESTResponseType + + +class TransactionApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + async def account_txs( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + index: Optional[StrictInt] = None, + types: Optional[List[StrictInt]] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Txs: + """accountTxs + + Get transactions of a specific account + + :param limit: (required) + :type limit: int + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param index: + :type index: int + :param types: + :type types: List[int] + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_txs_serialize( + limit=limit, + by=by, + value=value, + authorization=authorization, + index=index, + types=types, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def account_txs_with_http_info( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + index: Optional[StrictInt] = None, + types: Optional[List[StrictInt]] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Txs]: + """accountTxs + + Get transactions of a specific account + + :param limit: (required) + :type limit: int + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param index: + :type index: int + :param types: + :type types: List[int] + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_txs_serialize( + limit=limit, + by=by, + value=value, + authorization=authorization, + index=index, + types=types, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def account_txs_without_preload_content( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + by: StrictStr, + value: StrictStr, + authorization: Optional[StrictStr] = None, + index: Optional[StrictInt] = None, + types: Optional[List[StrictInt]] = None, + auth: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """accountTxs + + Get transactions of a specific account + + :param limit: (required) + :type limit: int + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param authorization: + :type authorization: str + :param index: + :type index: int + :param types: + :type types: List[int] + :param auth: + :type auth: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._account_txs_serialize( + limit=limit, + by=by, + value=value, + authorization=authorization, + index=index, + types=types, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _account_txs_serialize( + self, + limit, + by, + value, + authorization, + index, + types, + auth, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + 'types': 'csv', + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if index is not None: + + _query_params.append(('index', index)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + if types is not None: + + _query_params.append(('types', types)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accountTxs', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def block_txs( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Txs: + """blockTxs + + Get transactions in a block + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_txs_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def block_txs_with_http_info( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Txs]: + """blockTxs + + Get transactions in a block + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_txs_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def block_txs_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """blockTxs + + Get transactions in a block + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._block_txs_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _block_txs_serialize( + self, + by, + value, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/blockTxs', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def deposit_history( + self, + account_index: StrictInt, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DepositHistory: + """deposit_history + + Get deposit history + + :param account_index: (required) + :type account_index: int + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._deposit_history_serialize( + account_index=account_index, + l1_address=l1_address, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DepositHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def deposit_history_with_http_info( + self, + account_index: StrictInt, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[DepositHistory]: + """deposit_history + + Get deposit history + + :param account_index: (required) + :type account_index: int + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._deposit_history_serialize( + account_index=account_index, + l1_address=l1_address, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DepositHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def deposit_history_without_preload_content( + self, + account_index: StrictInt, + l1_address: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """deposit_history + + Get deposit history + + :param account_index: (required) + :type account_index: int + :param l1_address: (required) + :type l1_address: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._deposit_history_serialize( + account_index=account_index, + l1_address=l1_address, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "DepositHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _deposit_history_serialize( + self, + account_index, + l1_address, + authorization, + auth, + cursor, + filter, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + if l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if filter is not None: + + _query_params.append(('filter', filter)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/deposit/history', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def next_nonce( + self, + account_index: StrictInt, + api_key_index: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> NextNonce: + """nextNonce + + Get next nonce for a specific account and api key + + :param account_index: (required) + :type account_index: int + :param api_key_index: (required) + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._next_nonce_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "NextNonce", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def next_nonce_with_http_info( + self, + account_index: StrictInt, + api_key_index: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[NextNonce]: + """nextNonce + + Get next nonce for a specific account and api key + + :param account_index: (required) + :type account_index: int + :param api_key_index: (required) + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._next_nonce_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "NextNonce", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def next_nonce_without_preload_content( + self, + account_index: StrictInt, + api_key_index: StrictInt, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """nextNonce + + Get next nonce for a specific account and api key + + :param account_index: (required) + :type account_index: int + :param api_key_index: (required) + :type api_key_index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._next_nonce_serialize( + account_index=account_index, + api_key_index=api_key_index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "NextNonce", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _next_nonce_serialize( + self, + account_index, + api_key_index, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if api_key_index is not None: + + _query_params.append(('api_key_index', api_key_index)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/nextNonce', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def send_tx( + self, + tx_type: StrictInt, + tx_info: StrictStr, + price_protection: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespSendTx: + """sendTx + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_type: (required) + :type tx_type: int + :param tx_info: (required) + :type tx_info: str + :param price_protection: + :type price_protection: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_serialize( + tx_type=tx_type, + tx_info=tx_info, + price_protection=price_protection, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def send_tx_with_http_info( + self, + tx_type: StrictInt, + tx_info: StrictStr, + price_protection: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespSendTx]: + """sendTx + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_type: (required) + :type tx_type: int + :param tx_info: (required) + :type tx_info: str + :param price_protection: + :type price_protection: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_serialize( + tx_type=tx_type, + tx_info=tx_info, + price_protection=price_protection, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def send_tx_without_preload_content( + self, + tx_type: StrictInt, + tx_info: StrictStr, + price_protection: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """sendTx + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_type: (required) + :type tx_type: int + :param tx_info: (required) + :type tx_info: str + :param price_protection: + :type price_protection: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_serialize( + tx_type=tx_type, + tx_info=tx_info, + price_protection=price_protection, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _send_tx_serialize( + self, + tx_type, + tx_info, + price_protection, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + if tx_type is not None: + _form_params.append(('tx_type', tx_type)) + if tx_info is not None: + _form_params.append(('tx_info', tx_info)) + if price_protection is not None: + _form_params.append(('price_protection', price_protection)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/sendTx', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def send_tx_batch( + self, + tx_types: StrictStr, + tx_infos: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RespSendTxBatch: + """sendTxBatch + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_types: (required) + :type tx_types: str + :param tx_infos: (required) + :type tx_infos: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_batch_serialize( + tx_types=tx_types, + tx_infos=tx_infos, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTxBatch", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def send_tx_batch_with_http_info( + self, + tx_types: StrictStr, + tx_infos: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[RespSendTxBatch]: + """sendTxBatch + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_types: (required) + :type tx_types: str + :param tx_infos: (required) + :type tx_infos: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_batch_serialize( + tx_types=tx_types, + tx_infos=tx_infos, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTxBatch", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def send_tx_batch_without_preload_content( + self, + tx_types: StrictStr, + tx_infos: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """sendTxBatch + + You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers) + + :param tx_types: (required) + :type tx_types: str + :param tx_infos: (required) + :type tx_infos: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._send_tx_batch_serialize( + tx_types=tx_types, + tx_infos=tx_infos, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespSendTxBatch", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _send_tx_batch_serialize( + self, + tx_types, + tx_infos, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + if tx_types is not None: + _form_params.append(('tx_types', tx_types)) + if tx_infos is not None: + _form_params.append(('tx_infos', tx_infos)) + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/sendTxBatch', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def transfer_history( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> TransferHistory: + """transfer_history + + Get transfer history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def transfer_history_with_http_info( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[TransferHistory]: + """transfer_history + + Get transfer history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def transfer_history_without_preload_content( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """transfer_history + + Get transfer history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._transfer_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "TransferHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _transfer_history_serialize( + self, + account_index, + authorization, + auth, + cursor, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/transfer/history', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def tx( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> EnrichedTx: + """tx + + Get transaction by hash or sequence index + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def tx_with_http_info( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[EnrichedTx]: + """tx + + Get transaction by hash or sequence index + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def tx_without_preload_content( + self, + by: StrictStr, + value: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """tx + + Get transaction by hash or sequence index + + :param by: (required) + :type by: str + :param value: (required) + :type value: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_serialize( + by=by, + value=value, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _tx_serialize( + self, + by, + value, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if by is not None: + + _query_params.append(('by', by)) + + if value is not None: + + _query_params.append(('value', value)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/tx', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def tx_from_l1_tx_hash( + self, + hash: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> EnrichedTx: + """txFromL1TxHash + + Get L1 transaction by L1 transaction hash + + :param hash: (required) + :type hash: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_from_l1_tx_hash_serialize( + hash=hash, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def tx_from_l1_tx_hash_with_http_info( + self, + hash: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[EnrichedTx]: + """txFromL1TxHash + + Get L1 transaction by L1 transaction hash + + :param hash: (required) + :type hash: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_from_l1_tx_hash_serialize( + hash=hash, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def tx_from_l1_tx_hash_without_preload_content( + self, + hash: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """txFromL1TxHash + + Get L1 transaction by L1 transaction hash + + :param hash: (required) + :type hash: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._tx_from_l1_tx_hash_serialize( + hash=hash, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "EnrichedTx", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _tx_from_l1_tx_hash_serialize( + self, + hash, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if hash is not None: + + _query_params.append(('hash', hash)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/txFromL1TxHash', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def txs( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Txs: + """txs + + Get transactions which are already packed into blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._txs_serialize( + limit=limit, + index=index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def txs_with_http_info( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Txs]: + """txs + + Get transactions which are already packed into blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._txs_serialize( + limit=limit, + index=index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def txs_without_preload_content( + self, + limit: Annotated[int, Field(le=100, strict=True, ge=1)], + index: Optional[StrictInt] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """txs + + Get transactions which are already packed into blocks + + :param limit: (required) + :type limit: int + :param index: + :type index: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._txs_serialize( + limit=limit, + index=index, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Txs", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _txs_serialize( + self, + limit, + index, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if index is not None: + + _query_params.append(('index', index)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/txs', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + async def withdraw_history( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WithdrawHistory: + """withdraw_history + + Get withdraw history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdraw_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WithdrawHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def withdraw_history_with_http_info( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WithdrawHistory]: + """withdraw_history + + Get withdraw history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdraw_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WithdrawHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def withdraw_history_without_preload_content( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, + cursor: Optional[StrictStr] = None, + filter: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """withdraw_history + + Get withdraw history + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: str + :param cursor: + :type cursor: str + :param filter: + :type filter: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._withdraw_history_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + cursor=cursor, + filter=filter, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WithdrawHistory", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _withdraw_history_serialize( + self, + account_index, + authorization, + auth, + cursor, + filter, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if auth is not None: + + _query_params.append(('auth', auth)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + + if filter is not None: + + _query_params.append(('filter', filter)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/withdraw/history', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/docs/lighter/lighter-python-main/lighter/api_client.py b/docs/lighter/lighter-python-main/lighter/api_client.py new file mode 100644 index 0000000..c3c5849 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api_client.py @@ -0,0 +1,784 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import datetime +from dateutil.parser import parse +from enum import Enum +import json +import mimetypes +import os +import re +import tempfile + +from urllib.parse import quote +from typing import Tuple, Optional, List, Dict, Union +from pydantic import SecretStr + +from lighter.configuration import Configuration +from lighter.api_response import ApiResponse, T as ApiResponseT +import lighter.models +from lighter import rest +from lighter.exceptions import ( + ApiValueError, + ApiException, + BadRequestException, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int, # TODO remove as only py3 is supported? + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + _pool = None + + def __init__( + self, + configuration=None, + header_name=None, + header_value=None, + cookie=None + ) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.client_side_validation = configuration.client_side_validation + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + + async def close(self): + await self.rest_client.close() + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None + ) -> RequestSerialized: + + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict( + self.parameters_to_tuples(header_params,collection_formats) + ) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples( + path_params, + collection_formats + ) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples( + post_params, + collection_formats + ) + if files: + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, + query_params, + auth_settings, + resource_path, + method, + body, + request_auth=_request_auth + ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None or self.configuration.ignore_operation_servers: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query( + query_params, + collection_formats + ) + url += "?" + url_query + + return method, url, header_params, body, post_params + + + async def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = await self.rest_client.request( + method, url, + headers=header_params, + body=body, post_params=post_params, + _request_timeout=_request_timeout + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]]=None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [ + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ] + elif isinstance(obj, tuple): + return tuple( + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + return { + key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items() + } + + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + :param content_type: content type of response. + + :return: deserialized object. + """ + + # fetch data from response object + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif content_type.startswith("application/json"): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif content_type.startswith("text/plain"): + data = response_text + else: + raise ApiException( + status=0, + reason="Unsupported content type: {0}".format(content_type) + ) + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith('List['): + m = re.match(r'List\[(.*)]', klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + m = re.match(r'Dict\[([^,]*), (.*)]', klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(lighter.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, str(value)) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v)) + ) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters(self, files: Dict[str, Union[str, bytes]]): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + else: + raise ValueError("Unsupported file value") + mimetype = ( + mimetypes.guess_type(filename)[0] + or 'application/octet-stream' + ) + params.append( + tuple([k, tuple([filename, filedata, mimetype])]) + ) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, + headers, + queries, + auth_settings, + resource_path, + method, + body, + request_auth=None + ) -> None: + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + request_auth + ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + auth_setting + ) + + def _apply_auth_params( + self, + headers, + queries, + resource_path, + method, + body, + auth_setting + ) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + queries.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition + ) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as `{1}`" + .format(data, klass) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/docs/lighter/lighter-python-main/lighter/api_response.py b/docs/lighter/lighter-python-main/lighter/api_response.py new file mode 100644 index 0000000..9bc7c11 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/api_response.py @@ -0,0 +1,21 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel + +T = TypeVar("T") + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = { + "arbitrary_types_allowed": True + } diff --git a/docs/lighter/lighter-python-main/lighter/configuration.py b/docs/lighter/lighter-python-main/lighter/configuration.py new file mode 100644 index 0000000..ff0507e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/configuration.py @@ -0,0 +1,475 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import copy +import logging +from logging import FileHandler +import sys +from typing import Optional +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + :param retries: Number of retries for API requests. + + :Example: + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = lighter.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ignore_operation_servers=False, + ssl_ca_cert=None, + retries=None, + *, + debug: Optional[bool] = None + ) -> None: + """Constructor + """ + self._base_path = "https://mainnet.zklighter.elliot.ai" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("lighter") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler: Optional[FileHandler] = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + if debug is not None: + self.debug = debug + else: + self.__debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = 100 + """This value is passed to the aiohttp to limit simultaneous connections. + Default values is 100, None means no-limit. + """ + + self.proxy: Optional[str] = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = retries + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls): + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls): + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = Configuration() + return cls._default + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + if 'apiKey' in self.api_key: + auth['apiKey'] = { + 'type': 'api_key', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_api_key_with_prefix( + 'apiKey', + ), + } + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: \n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "https://mainnet.zklighter.elliot.ai", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/docs/lighter/lighter-python-main/lighter/errors.py b/docs/lighter/lighter-python-main/lighter/errors.py new file mode 100644 index 0000000..2851fa7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/errors.py @@ -0,0 +1,2 @@ +class ValidationError(ValueError): + pass diff --git a/docs/lighter/lighter-python-main/lighter/exceptions.py b/docs/lighter/lighter-python-main/lighter/exceptions.py new file mode 100644 index 0000000..a2fd39d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/exceptions.py @@ -0,0 +1,199 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from typing import Any, Optional +from typing_extensions import Self + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None) -> None: + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/docs/lighter/lighter-python-main/lighter/models/__init__.py b/docs/lighter/lighter-python-main/lighter/models/__init__.py new file mode 100644 index 0000000..3123460 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/__init__.py @@ -0,0 +1,156 @@ +# coding: utf-8 + +# flake8: noqa +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package +from lighter.models.account import Account +from lighter.models.account_api_keys import AccountApiKeys +from lighter.models.account_asset import AccountAsset +from lighter.models.account_limits import AccountLimits +from lighter.models.account_margin_stats import AccountMarginStats +from lighter.models.account_market_stats import AccountMarketStats +from lighter.models.account_metadata import AccountMetadata +from lighter.models.account_metadatas import AccountMetadatas +from lighter.models.account_pn_l import AccountPnL +from lighter.models.account_position import AccountPosition +from lighter.models.account_stats import AccountStats +from lighter.models.account_trade_stats import AccountTradeStats +from lighter.models.announcement import Announcement +from lighter.models.announcements import Announcements +from lighter.models.api_key import ApiKey +from lighter.models.asset import Asset +from lighter.models.asset_details import AssetDetails +from lighter.models.block import Block +from lighter.models.blocks import Blocks +from lighter.models.bridge import Bridge +from lighter.models.bridge_supported_network import BridgeSupportedNetwork +from lighter.models.candlestick import Candlestick +from lighter.models.candlesticks import Candlesticks +from lighter.models.contract_address import ContractAddress +from lighter.models.current_height import CurrentHeight +from lighter.models.cursor import Cursor +from lighter.models.daily_return import DailyReturn +from lighter.models.deposit_history import DepositHistory +from lighter.models.deposit_history_item import DepositHistoryItem +from lighter.models.detailed_account import DetailedAccount +from lighter.models.detailed_accounts import DetailedAccounts +from lighter.models.detailed_candlestick import DetailedCandlestick +from lighter.models.enriched_tx import EnrichedTx +from lighter.models.exchange_stats import ExchangeStats +from lighter.models.export_data import ExportData +from lighter.models.funding import Funding +from lighter.models.funding_rate import FundingRate +from lighter.models.funding_rates import FundingRates +from lighter.models.fundings import Fundings +from lighter.models.l1_metadata import L1Metadata +from lighter.models.l1_provider_info import L1ProviderInfo +from lighter.models.liq_trade import LiqTrade +from lighter.models.liquidation import Liquidation +from lighter.models.liquidation_info import LiquidationInfo +from lighter.models.liquidation_infos import LiquidationInfos +from lighter.models.market_config import MarketConfig +from lighter.models.next_nonce import NextNonce +from lighter.models.order import Order +from lighter.models.order_book import OrderBook +from lighter.models.order_book_depth import OrderBookDepth +from lighter.models.order_book_details import OrderBookDetails +from lighter.models.order_book_orders import OrderBookOrders +from lighter.models.order_book_stats import OrderBookStats +from lighter.models.order_books import OrderBooks +from lighter.models.orders import Orders +from lighter.models.perps_market_stats import PerpsMarketStats +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail +from lighter.models.pn_l_entry import PnLEntry +from lighter.models.position_funding import PositionFunding +from lighter.models.position_fundings import PositionFundings +from lighter.models.price_level import PriceLevel +from lighter.models.public_pool_info import PublicPoolInfo +from lighter.models.public_pool_metadata import PublicPoolMetadata +from lighter.models.public_pool_share import PublicPoolShare +from lighter.models.referral_point_entry import ReferralPointEntry +from lighter.models.referral_points import ReferralPoints +from lighter.models.req_export_data import ReqExportData +from lighter.models.req_get_account import ReqGetAccount +from lighter.models.req_get_account_active_orders import ReqGetAccountActiveOrders +from lighter.models.req_get_account_api_keys import ReqGetAccountApiKeys +from lighter.models.req_get_account_by_l1_address import ReqGetAccountByL1Address +from lighter.models.req_get_account_inactive_orders import ReqGetAccountInactiveOrders +from lighter.models.req_get_account_limits import ReqGetAccountLimits +from lighter.models.req_get_account_metadata import ReqGetAccountMetadata +from lighter.models.req_get_account_pn_l import ReqGetAccountPnL +from lighter.models.req_get_account_txs import ReqGetAccountTxs +from lighter.models.req_get_asset_details import ReqGetAssetDetails +from lighter.models.req_get_block import ReqGetBlock +from lighter.models.req_get_block_txs import ReqGetBlockTxs +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr +from lighter.models.req_get_by_account import ReqGetByAccount +from lighter.models.req_get_candlesticks import ReqGetCandlesticks +from lighter.models.req_get_deposit_history import ReqGetDepositHistory +from lighter.models.req_get_fast_withdraw_info import ReqGetFastWithdrawInfo +from lighter.models.req_get_fundings import ReqGetFundings +from lighter.models.req_get_l1_metadata import ReqGetL1Metadata +from lighter.models.req_get_l1_tx import ReqGetL1Tx +from lighter.models.req_get_latest_deposit import ReqGetLatestDeposit +from lighter.models.req_get_liquidation_infos import ReqGetLiquidationInfos +from lighter.models.req_get_next_nonce import ReqGetNextNonce +from lighter.models.req_get_order_book_details import ReqGetOrderBookDetails +from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders +from lighter.models.req_get_order_books import ReqGetOrderBooks +from lighter.models.req_get_position_funding import ReqGetPositionFunding +from lighter.models.req_get_public_pools_metadata import ReqGetPublicPoolsMetadata +from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor +from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex +from lighter.models.req_get_range_with_index_sortable import ReqGetRangeWithIndexSortable +from lighter.models.req_get_recent_trades import ReqGetRecentTrades +from lighter.models.req_get_referral_points import ReqGetReferralPoints +from lighter.models.req_get_trades import ReqGetTrades +from lighter.models.req_get_transfer_fee_info import ReqGetTransferFeeInfo +from lighter.models.req_get_transfer_history import ReqGetTransferHistory +from lighter.models.req_get_tx import ReqGetTx +from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory +from lighter.models.resp_change_account_tier import RespChangeAccountTier +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr +from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast +from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata +from lighter.models.resp_send_tx import RespSendTx +from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode +from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay +from lighter.models.result_code import ResultCode +from lighter.models.risk_info import RiskInfo +from lighter.models.risk_parameters import RiskParameters +from lighter.models.share_price import SharePrice +from lighter.models.simple_order import SimpleOrder +from lighter.models.spot_market_stats import SpotMarketStats +from lighter.models.spot_order_book_detail import SpotOrderBookDetail +from lighter.models.status import Status +from lighter.models.sub_accounts import SubAccounts +from lighter.models.ticker import Ticker +from lighter.models.trade import Trade +from lighter.models.trades import Trades +from lighter.models.transfer_fee_info import TransferFeeInfo +from lighter.models.transfer_history import TransferHistory +from lighter.models.transfer_history_item import TransferHistoryItem +from lighter.models.tx import Tx +from lighter.models.tx_hash import TxHash +from lighter.models.tx_hashes import TxHashes +from lighter.models.txs import Txs +from lighter.models.validator_info import ValidatorInfo +from lighter.models.withdraw_history import WithdrawHistory +from lighter.models.withdraw_history_item import WithdrawHistoryItem +from lighter.models.zk_lighter_info import ZkLighterInfo + +from lighter.models.ws_account_assets import WSAccountAssets \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/lighter/models/account.py b/docs/lighter/lighter-python-main/lighter/models/account.py new file mode 100644 index 0000000..82958bf --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class Account(BaseModel): + """ + Account + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + account_type: StrictInt + index: StrictInt + l1_address: StrictStr + cancel_all_time: StrictInt + total_order_count: StrictInt + pending_order_count: StrictInt + available_balance: Optional[StrictStr] + status: StrictInt + collateral: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "available_balance", "status", "collateral"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Account from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Account from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "account_type": obj.get("account_type"), + "index": obj.get("index"), + "l1_address": obj.get("l1_address"), + "cancel_all_time": obj.get("cancel_all_time"), + "total_order_count": obj.get("total_order_count"), + "pending_order_count": obj.get("pending_order_count"), + "available_balance": obj.get("available_balance"), + "status": obj.get("status"), + "collateral": obj.get("collateral") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_api_keys.py b/docs/lighter/lighter-python-main/lighter/models/account_api_keys.py new file mode 100644 index 0000000..da1e42c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_api_keys.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.api_key import ApiKey +from typing import Optional, Set +from typing_extensions import Self + +class AccountApiKeys(BaseModel): + """ + AccountApiKeys + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + api_keys: List[ApiKey] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "api_keys"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountApiKeys from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in api_keys (list) + _items = [] + if self.api_keys: + for _item in self.api_keys: + if _item: + _items.append(_item.to_dict()) + _dict['api_keys'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountApiKeys from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "api_keys": [ApiKey.from_dict(_item) for _item in obj["api_keys"]] if obj.get("api_keys") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_asset.py b/docs/lighter/lighter-python-main/lighter/models/account_asset.py new file mode 100644 index 0000000..a5a8c7b --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_asset.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class AccountAsset(BaseModel): + """ + AccountAsset + """ # noqa: E501 + symbol: StrictStr + asset_id: StrictInt + balance: StrictStr + locked_balance: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "asset_id", "balance", "locked_balance"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountAsset from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountAsset from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "asset_id": obj.get("asset_id"), + "balance": obj.get("balance"), + "locked_balance": obj.get("locked_balance") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_limits.py b/docs/lighter/lighter-python-main/lighter/models/account_limits.py new file mode 100644 index 0000000..a6bdc2a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_limits.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AccountLimits(BaseModel): + """ + AccountLimits + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + max_llp_percentage: StrictInt + max_llp_amount: StrictStr + user_tier: StrictStr + can_create_public_pool: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "max_llp_percentage", "max_llp_amount", "user_tier", "can_create_public_pool"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountLimits from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountLimits from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "max_llp_percentage": obj.get("max_llp_percentage"), + "max_llp_amount": obj.get("max_llp_amount"), + "user_tier": obj.get("user_tier"), + "can_create_public_pool": obj.get("can_create_public_pool") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_margin_stats.py b/docs/lighter/lighter-python-main/lighter/models/account_margin_stats.py new file mode 100644 index 0000000..bad64a8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_margin_stats.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class AccountMarginStats(BaseModel): + """ + AccountMarginStats + """ # noqa: E501 + collateral: StrictStr + portfolio_value: StrictStr + leverage: StrictStr + available_balance: StrictStr + margin_usage: StrictStr + buying_power: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["collateral", "portfolio_value", "leverage", "available_balance", "margin_usage", "buying_power"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountMarginStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountMarginStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "collateral": obj.get("collateral"), + "portfolio_value": obj.get("portfolio_value"), + "leverage": obj.get("leverage"), + "available_balance": obj.get("available_balance"), + "margin_usage": obj.get("margin_usage"), + "buying_power": obj.get("buying_power") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_market_stats.py b/docs/lighter/lighter-python-main/lighter/models/account_market_stats.py new file mode 100644 index 0000000..efa1731 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_market_stats.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class AccountMarketStats(BaseModel): + """ + AccountMarketStats + """ # noqa: E501 + market_id: StrictInt + daily_trades_count: StrictInt + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + weekly_trades_count: StrictInt + weekly_base_token_volume: Union[StrictFloat, StrictInt] + weekly_quote_token_volume: Union[StrictFloat, StrictInt] + monthly_trades_count: StrictInt + monthly_base_token_volume: Union[StrictFloat, StrictInt] + monthly_quote_token_volume: Union[StrictFloat, StrictInt] + total_trades_count: StrictInt + total_base_token_volume: Union[StrictFloat, StrictInt] + total_quote_token_volume: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "weekly_trades_count", "weekly_base_token_volume", "weekly_quote_token_volume", "monthly_trades_count", "monthly_base_token_volume", "monthly_quote_token_volume", "total_trades_count", "total_base_token_volume", "total_quote_token_volume"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountMarketStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountMarketStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "daily_trades_count": obj.get("daily_trades_count"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "weekly_trades_count": obj.get("weekly_trades_count"), + "weekly_base_token_volume": obj.get("weekly_base_token_volume"), + "weekly_quote_token_volume": obj.get("weekly_quote_token_volume"), + "monthly_trades_count": obj.get("monthly_trades_count"), + "monthly_base_token_volume": obj.get("monthly_base_token_volume"), + "monthly_quote_token_volume": obj.get("monthly_quote_token_volume"), + "total_trades_count": obj.get("total_trades_count"), + "total_base_token_volume": obj.get("total_base_token_volume"), + "total_quote_token_volume": obj.get("total_quote_token_volume") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_metadata.py b/docs/lighter/lighter-python-main/lighter/models/account_metadata.py new file mode 100644 index 0000000..ddd09e6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_metadata.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class AccountMetadata(BaseModel): + """ + AccountMetadata + """ # noqa: E501 + account_index: StrictInt + name: StrictStr + description: StrictStr + can_invite: StrictBool = Field(description=" Remove After FE uses L1 meta endpoint") + referral_points_percentage: StrictStr = Field(description=" Remove After FE uses L1 meta endpoint") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "name", "description", "can_invite", "referral_points_percentage"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountMetadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "name": obj.get("name"), + "description": obj.get("description"), + "can_invite": obj.get("can_invite"), + "referral_points_percentage": obj.get("referral_points_percentage") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_metadatas.py b/docs/lighter/lighter-python-main/lighter/models/account_metadatas.py new file mode 100644 index 0000000..3d41085 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_metadatas.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.account_metadata import AccountMetadata +from typing import Optional, Set +from typing_extensions import Self + +class AccountMetadatas(BaseModel): + """ + AccountMetadatas + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + account_metadatas: List[AccountMetadata] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "account_metadatas"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountMetadatas from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in account_metadatas (list) + _items = [] + if self.account_metadatas: + for _item in self.account_metadatas: + if _item: + _items.append(_item.to_dict()) + _dict['account_metadatas'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountMetadatas from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "account_metadatas": [AccountMetadata.from_dict(_item) for _item in obj["account_metadatas"]] if obj.get("account_metadatas") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_pn_l.py b/docs/lighter/lighter-python-main/lighter/models/account_pn_l.py new file mode 100644 index 0000000..9196cf0 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_pn_l.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.pn_l_entry import PnLEntry +from typing import Optional, Set +from typing_extensions import Self + +class AccountPnL(BaseModel): + """ + AccountPnL + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + resolution: StrictStr + pnl: List[PnLEntry] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "resolution", "pnl"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountPnL from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in pnl (list) + _items = [] + if self.pnl: + for _item in self.pnl: + if _item: + _items.append(_item.to_dict()) + _dict['pnl'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountPnL from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "resolution": obj.get("resolution"), + "pnl": [PnLEntry.from_dict(_item) for _item in obj["pnl"]] if obj.get("pnl") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_position.py b/docs/lighter/lighter-python-main/lighter/models/account_position.py new file mode 100644 index 0000000..9942715 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_position.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AccountPosition(BaseModel): + """ + AccountPosition + """ # noqa: E501 + market_id: StrictInt + symbol: StrictStr + initial_margin_fraction: StrictStr + open_order_count: StrictInt + pending_order_count: StrictInt + position_tied_order_count: StrictInt + sign: StrictInt + position: StrictStr + avg_entry_price: StrictStr + position_value: StrictStr + unrealized_pnl: StrictStr + realized_pnl: StrictStr + liquidation_price: StrictStr + total_funding_paid_out: Optional[StrictStr] = None + margin_mode: StrictInt + allocated_margin: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "symbol", "initial_margin_fraction", "open_order_count", "pending_order_count", "position_tied_order_count", "sign", "position", "avg_entry_price", "position_value", "unrealized_pnl", "realized_pnl", "liquidation_price", "total_funding_paid_out", "margin_mode", "allocated_margin"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountPosition from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountPosition from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "symbol": obj.get("symbol"), + "initial_margin_fraction": obj.get("initial_margin_fraction"), + "open_order_count": obj.get("open_order_count"), + "pending_order_count": obj.get("pending_order_count"), + "position_tied_order_count": obj.get("position_tied_order_count"), + "sign": obj.get("sign"), + "position": obj.get("position"), + "avg_entry_price": obj.get("avg_entry_price"), + "position_value": obj.get("position_value"), + "unrealized_pnl": obj.get("unrealized_pnl"), + "realized_pnl": obj.get("realized_pnl"), + "liquidation_price": obj.get("liquidation_price"), + "total_funding_paid_out": obj.get("total_funding_paid_out"), + "margin_mode": obj.get("margin_mode"), + "allocated_margin": obj.get("allocated_margin") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_stats.py b/docs/lighter/lighter-python-main/lighter/models/account_stats.py new file mode 100644 index 0000000..9fac368 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_stats.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from lighter.models.account_margin_stats import AccountMarginStats +from typing import Optional, Set +from typing_extensions import Self + +class AccountStats(BaseModel): + """ + AccountStats + """ # noqa: E501 + collateral: StrictStr + portfolio_value: StrictStr + leverage: StrictStr + available_balance: Optional[StrictStr] + margin_usage: StrictStr + buying_power: StrictStr + cross_stats: AccountMarginStats + total_stats: AccountMarginStats + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["collateral", "portfolio_value", "leverage", "available_balance", "margin_usage", "buying_power", "cross_stats", "total_stats"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of cross_stats + if self.cross_stats: + _dict['cross_stats'] = self.cross_stats.to_dict() + # override the default output from pydantic by calling `to_dict()` of total_stats + if self.total_stats: + _dict['total_stats'] = self.total_stats.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "collateral": obj.get("collateral"), + "portfolio_value": obj.get("portfolio_value"), + "leverage": obj.get("leverage"), + "available_balance": obj.get("available_balance"), + "margin_usage": obj.get("margin_usage"), + "buying_power": obj.get("buying_power"), + "cross_stats": AccountMarginStats.from_dict(obj["cross_stats"]) if obj.get("cross_stats") is not None else None, + "total_stats": AccountMarginStats.from_dict(obj["total_stats"]) if obj.get("total_stats") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/account_trade_stats.py b/docs/lighter/lighter-python-main/lighter/models/account_trade_stats.py new file mode 100644 index 0000000..a266610 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/account_trade_stats.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class AccountTradeStats(BaseModel): + """ + AccountTradeStats + """ # noqa: E501 + daily_trades_count: StrictInt + daily_volume: Union[StrictFloat, StrictInt] + weekly_trades_count: StrictInt + weekly_volume: Union[StrictFloat, StrictInt] + monthly_trades_count: StrictInt + monthly_volume: Union[StrictFloat, StrictInt] + total_trades_count: StrictInt + total_volume: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["daily_trades_count", "daily_volume", "weekly_trades_count", "weekly_volume", "monthly_trades_count", "monthly_volume", "total_trades_count", "total_volume"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AccountTradeStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AccountTradeStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "daily_trades_count": obj.get("daily_trades_count"), + "daily_volume": obj.get("daily_volume"), + "weekly_trades_count": obj.get("weekly_trades_count"), + "weekly_volume": obj.get("weekly_volume"), + "monthly_trades_count": obj.get("monthly_trades_count"), + "monthly_volume": obj.get("monthly_volume"), + "total_trades_count": obj.get("total_trades_count"), + "total_volume": obj.get("total_volume") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/announcement.py b/docs/lighter/lighter-python-main/lighter/models/announcement.py new file mode 100644 index 0000000..27ab271 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/announcement.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Announcement(BaseModel): + """ + Announcement + """ # noqa: E501 + title: StrictStr + content: StrictStr + created_at: StrictInt + expired_at: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["title", "content", "created_at", "expired_at"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Announcement from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Announcement from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "title": obj.get("title"), + "content": obj.get("content"), + "created_at": obj.get("created_at"), + "expired_at": obj.get("expired_at") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/announcements.py b/docs/lighter/lighter-python-main/lighter/models/announcements.py new file mode 100644 index 0000000..d89894f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/announcements.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.announcement import Announcement +from typing import Optional, Set +from typing_extensions import Self + +class Announcements(BaseModel): + """ + Announcements + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + announcements: List[Announcement] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "announcements"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Announcements from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in announcements (list) + _items = [] + if self.announcements: + for _item in self.announcements: + if _item: + _items.append(_item.to_dict()) + _dict['announcements'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Announcements from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "announcements": [Announcement.from_dict(_item) for _item in obj["announcements"]] if obj.get("announcements") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/api_key.py b/docs/lighter/lighter-python-main/lighter/models/api_key.py new file mode 100644 index 0000000..f02af99 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/api_key.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ApiKey(BaseModel): + """ + ApiKey + """ # noqa: E501 + account_index: StrictInt + api_key_index: StrictInt + nonce: StrictInt + public_key: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "api_key_index", "nonce", "public_key"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ApiKey from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ApiKey from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "api_key_index": obj.get("api_key_index"), + "nonce": obj.get("nonce"), + "public_key": obj.get("public_key") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/asset.py b/docs/lighter/lighter-python-main/lighter/models/asset.py new file mode 100644 index 0000000..ec3b522 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/asset.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Asset(BaseModel): + """ + Asset + """ # noqa: E501 + asset_id: StrictInt + symbol: StrictStr + l1_decimals: StrictInt + decimals: StrictInt + min_transfer_amount: StrictStr + min_withdrawal_amount: StrictStr + margin_mode: StrictStr + index_price: StrictStr + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["asset_id", "symbol", "l1_decimals", "decimals", "min_transfer_amount", "min_withdrawal_amount", "margin_mode", "index_price", "l1_address"] + + @field_validator('margin_mode') + def margin_mode_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['enabled', 'disabled']): + raise ValueError("must be one of enum values ('enabled', 'disabled')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Asset from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Asset from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "asset_id": obj.get("asset_id"), + "symbol": obj.get("symbol"), + "l1_decimals": obj.get("l1_decimals"), + "decimals": obj.get("decimals"), + "min_transfer_amount": obj.get("min_transfer_amount"), + "min_withdrawal_amount": obj.get("min_withdrawal_amount"), + "margin_mode": obj.get("margin_mode"), + "index_price": obj.get("index_price"), + "l1_address": obj.get("l1_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/asset_details.py b/docs/lighter/lighter-python-main/lighter/models/asset_details.py new file mode 100644 index 0000000..6437910 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/asset_details.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.asset import Asset +from typing import Optional, Set +from typing_extensions import Self + +class AssetDetails(BaseModel): + """ + AssetDetails + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + asset_details: List[Asset] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "asset_details"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AssetDetails from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in asset_details (list) + _items = [] + if self.asset_details: + for _item in self.asset_details: + if _item: + _items.append(_item.to_dict()) + _dict['asset_details'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AssetDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "asset_details": [Asset.from_dict(_item) for _item in obj["asset_details"]] if obj.get("asset_details") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/block.py b/docs/lighter/lighter-python-main/lighter/models/block.py new file mode 100644 index 0000000..7e550d7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/block.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from lighter.models.tx import Tx +from typing import Optional, Set +from typing_extensions import Self + +class Block(BaseModel): + """ + Block + """ # noqa: E501 + commitment: StrictStr + height: StrictInt + state_root: StrictStr + priority_operations: StrictInt + on_chain_l2_operations: StrictInt + pending_on_chain_operations_pub_data: StrictStr + committed_tx_hash: StrictStr + committed_at: StrictInt + verified_tx_hash: StrictStr + verified_at: StrictInt + txs: List[Tx] + status: StrictInt + size: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["commitment", "height", "state_root", "priority_operations", "on_chain_l2_operations", "pending_on_chain_operations_pub_data", "committed_tx_hash", "committed_at", "verified_tx_hash", "verified_at", "txs", "status", "size"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Block from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in txs (list) + _items = [] + if self.txs: + for _item in self.txs: + if _item: + _items.append(_item.to_dict()) + _dict['txs'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Block from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "commitment": obj.get("commitment"), + "height": obj.get("height"), + "state_root": obj.get("state_root"), + "priority_operations": obj.get("priority_operations"), + "on_chain_l2_operations": obj.get("on_chain_l2_operations"), + "pending_on_chain_operations_pub_data": obj.get("pending_on_chain_operations_pub_data"), + "committed_tx_hash": obj.get("committed_tx_hash"), + "committed_at": obj.get("committed_at"), + "verified_tx_hash": obj.get("verified_tx_hash"), + "verified_at": obj.get("verified_at"), + "txs": [Tx.from_dict(_item) for _item in obj["txs"]] if obj.get("txs") is not None else None, + "status": obj.get("status"), + "size": obj.get("size") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/blocks.py b/docs/lighter/lighter-python-main/lighter/models/blocks.py new file mode 100644 index 0000000..2591f16 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/blocks.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.block import Block +from typing import Optional, Set +from typing_extensions import Self + +class Blocks(BaseModel): + """ + Blocks + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + total: StrictInt + blocks: List[Block] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "total", "blocks"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Blocks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in blocks (list) + _items = [] + if self.blocks: + for _item in self.blocks: + if _item: + _items.append(_item.to_dict()) + _dict['blocks'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Blocks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "total": obj.get("total"), + "blocks": [Block.from_dict(_item) for _item in obj["blocks"]] if obj.get("blocks") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/bridge.py b/docs/lighter/lighter-python-main/lighter/models/bridge.py new file mode 100644 index 0000000..23bc14d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/bridge.py @@ -0,0 +1,142 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Bridge(BaseModel): + """ + Bridge + """ # noqa: E501 + id: StrictInt + version: StrictInt + source: StrictStr + source_chain_id: StrictStr + fast_bridge_tx_hash: StrictStr + batch_claim_tx_hash: StrictStr + cctp_burn_tx_hash: StrictStr + amount: StrictStr + intent_address: StrictStr + status: StrictStr + step: StrictStr + description: StrictStr + created_at: StrictInt + updated_at: StrictInt + is_external_deposit: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "version", "source", "source_chain_id", "fast_bridge_tx_hash", "batch_claim_tx_hash", "cctp_burn_tx_hash", "amount", "intent_address", "status", "step", "description", "created_at", "updated_at", "is_external_deposit"] + + @field_validator('version') + def version_validate_enum(cls, value): + """Validates the enum""" + if value not in set([1, 2]): + raise ValueError("must be one of enum values (1, 2)") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['pending', 'bridging', 'completed']): + raise ValueError("must be one of enum values ('pending', 'bridging', 'completed')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Bridge from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Bridge from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "version": obj.get("version"), + "source": obj.get("source"), + "source_chain_id": obj.get("source_chain_id"), + "fast_bridge_tx_hash": obj.get("fast_bridge_tx_hash"), + "batch_claim_tx_hash": obj.get("batch_claim_tx_hash"), + "cctp_burn_tx_hash": obj.get("cctp_burn_tx_hash"), + "amount": obj.get("amount"), + "intent_address": obj.get("intent_address"), + "status": obj.get("status"), + "step": obj.get("step"), + "description": obj.get("description"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at"), + "is_external_deposit": obj.get("is_external_deposit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/bridge_supported_network.py b/docs/lighter/lighter-python-main/lighter/models/bridge_supported_network.py new file mode 100644 index 0000000..4e3533a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/bridge_supported_network.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class BridgeSupportedNetwork(BaseModel): + """ + BridgeSupportedNetwork + """ # noqa: E501 + name: StrictStr + chain_id: StrictStr + explorer: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["name", "chain_id", "explorer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BridgeSupportedNetwork from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BridgeSupportedNetwork from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "chain_id": obj.get("chain_id"), + "explorer": obj.get("explorer") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/candlestick.py b/docs/lighter/lighter-python-main/lighter/models/candlestick.py new file mode 100644 index 0000000..b1722af --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/candlestick.py @@ -0,0 +1,122 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class Candlestick(BaseModel): + """ + Candlestick + """ # noqa: E501 + timestamp: StrictInt + open: Union[StrictFloat, StrictInt] + high: Union[StrictFloat, StrictInt] + low: Union[StrictFloat, StrictInt] + close: Union[StrictFloat, StrictInt] + open_raw: Union[StrictFloat, StrictInt] + high_raw: Union[StrictFloat, StrictInt] + low_raw: Union[StrictFloat, StrictInt] + close_raw: Union[StrictFloat, StrictInt] + volume0: Union[StrictFloat, StrictInt] + volume1: Union[StrictFloat, StrictInt] + last_trade_id: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "open_raw", "high_raw", "low_raw", "close_raw", "volume0", "volume1", "last_trade_id"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Candlestick from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Candlestick from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "open": obj.get("open"), + "high": obj.get("high"), + "low": obj.get("low"), + "close": obj.get("close"), + "open_raw": obj.get("open_raw"), + "high_raw": obj.get("high_raw"), + "low_raw": obj.get("low_raw"), + "close_raw": obj.get("close_raw"), + "volume0": obj.get("volume0"), + "volume1": obj.get("volume1"), + "last_trade_id": obj.get("last_trade_id") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/candlesticks.py b/docs/lighter/lighter-python-main/lighter/models/candlesticks.py new file mode 100644 index 0000000..a8184f9 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/candlesticks.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.candlestick import Candlestick +from typing import Optional, Set +from typing_extensions import Self + +class Candlesticks(BaseModel): + """ + Candlesticks + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + resolution: StrictStr + candlesticks: List[Candlestick] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "resolution", "candlesticks"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Candlesticks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in candlesticks (list) + _items = [] + if self.candlesticks: + for _item in self.candlesticks: + if _item: + _items.append(_item.to_dict()) + _dict['candlesticks'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Candlesticks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "resolution": obj.get("resolution"), + "candlesticks": [Candlestick.from_dict(_item) for _item in obj["candlesticks"]] if obj.get("candlesticks") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/contract_address.py b/docs/lighter/lighter-python-main/lighter/models/contract_address.py new file mode 100644 index 0000000..768652e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/contract_address.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ContractAddress(BaseModel): + """ + ContractAddress + """ # noqa: E501 + name: StrictStr + address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["name", "address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ContractAddress from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ContractAddress from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "address": obj.get("address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/current_height.py b/docs/lighter/lighter-python-main/lighter/models/current_height.py new file mode 100644 index 0000000..5aa2b8f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/current_height.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class CurrentHeight(BaseModel): + """ + CurrentHeight + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + height: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "height"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CurrentHeight from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CurrentHeight from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "height": obj.get("height") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/cursor.py b/docs/lighter/lighter-python-main/lighter/models/cursor.py new file mode 100644 index 0000000..a1ca1ef --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/cursor.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class Cursor(BaseModel): + """ + Cursor + """ # noqa: E501 + next_cursor: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["next_cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Cursor from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Cursor from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "next_cursor": obj.get("next_cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/daily_return.py b/docs/lighter/lighter-python-main/lighter/models/daily_return.py new file mode 100644 index 0000000..0453381 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/daily_return.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class DailyReturn(BaseModel): + """ + DailyReturn + """ # noqa: E501 + timestamp: StrictInt + daily_return: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "daily_return"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DailyReturn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DailyReturn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "daily_return": obj.get("daily_return") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/deposit_history.py b/docs/lighter/lighter-python-main/lighter/models/deposit_history.py new file mode 100644 index 0000000..2b2e238 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/deposit_history.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.deposit_history_item import DepositHistoryItem +from typing import Optional, Set +from typing_extensions import Self + +class DepositHistory(BaseModel): + """ + DepositHistory + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + deposits: List[DepositHistoryItem] + cursor: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "deposits", "cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DepositHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in deposits (list) + _items = [] + if self.deposits: + for _item in self.deposits: + if _item: + _items.append(_item.to_dict()) + _dict['deposits'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DepositHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "deposits": [DepositHistoryItem.from_dict(_item) for _item in obj["deposits"]] if obj.get("deposits") is not None else None, + "cursor": obj.get("cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/deposit_history_item.py b/docs/lighter/lighter-python-main/lighter/models/deposit_history_item.py new file mode 100644 index 0000000..41fb0da --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/deposit_history_item.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class DepositHistoryItem(BaseModel): + """ + DepositHistoryItem + """ # noqa: E501 + id: StrictStr + asset_id: StrictInt + amount: StrictStr + timestamp: StrictInt + status: StrictStr + l1_tx_hash: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "status", "l1_tx_hash"] + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['failed', 'pending', 'completed', 'claimable']): + raise ValueError("must be one of enum values ('failed', 'pending', 'completed', 'claimable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DepositHistoryItem from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DepositHistoryItem from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "asset_id": obj.get("asset_id"), + "amount": obj.get("amount"), + "timestamp": obj.get("timestamp"), + "status": obj.get("status"), + "l1_tx_hash": obj.get("l1_tx_hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/detailed_account.py b/docs/lighter/lighter-python-main/lighter/models/detailed_account.py new file mode 100644 index 0000000..e0c4b07 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/detailed_account.py @@ -0,0 +1,170 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.account_asset import AccountAsset +from lighter.models.account_position import AccountPosition +from lighter.models.public_pool_info import PublicPoolInfo +from lighter.models.public_pool_share import PublicPoolShare +from typing import Optional, Set +from typing_extensions import Self + +class DetailedAccount(BaseModel): + """ + DetailedAccount + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + account_type: StrictInt + index: StrictInt + l1_address: StrictStr + cancel_all_time: StrictInt + total_order_count: StrictInt + pending_order_count: StrictInt + available_balance: Optional[StrictStr] + status: StrictInt + collateral: StrictStr + account_index: StrictInt + name: StrictStr + description: StrictStr + can_invite: StrictBool = Field(description=" Remove After FE uses L1 meta endpoint") + referral_points_percentage: StrictStr = Field(description=" Remove After FE uses L1 meta endpoint") + positions: List[AccountPosition] + assets: List[AccountAsset] + total_asset_value: StrictStr + cross_asset_value: StrictStr + pool_info: Optional[PublicPoolInfo] + shares: List[PublicPoolShare] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "available_balance", "status", "collateral", "account_index", "name", "description", "can_invite", "referral_points_percentage", "positions", "assets", "total_asset_value", "cross_asset_value", "pool_info", "shares"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DetailedAccount from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in positions (list) + _items = [] + if self.positions: + for _item in self.positions: + if _item: + _items.append(_item.to_dict()) + _dict['positions'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in assets (list) + _items = [] + if self.assets: + for _item in self.assets: + if _item: + _items.append(_item.to_dict()) + _dict['assets'] = _items + # override the default output from pydantic by calling `to_dict()` of pool_info + if self.pool_info: + _dict['pool_info'] = self.pool_info.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in shares (list) + _items = [] + if self.shares: + for _item in self.shares: + if _item: + _items.append(_item.to_dict()) + _dict['shares'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DetailedAccount from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "account_type": obj.get("account_type"), + "index": obj.get("index"), + "l1_address": obj.get("l1_address"), + "cancel_all_time": obj.get("cancel_all_time"), + "total_order_count": obj.get("total_order_count"), + "pending_order_count": obj.get("pending_order_count"), + "available_balance": obj.get("available_balance"), + "status": obj.get("status"), + "collateral": obj.get("collateral"), + "account_index": obj.get("account_index"), + "name": obj.get("name"), + "description": obj.get("description"), + "can_invite": obj.get("can_invite"), + "referral_points_percentage": obj.get("referral_points_percentage"), + "positions": [AccountPosition.from_dict(_item) for _item in obj["positions"]] if obj.get("positions") is not None else None, + "assets": [AccountAsset.from_dict(_item) for _item in obj["assets"]] if obj.get("assets") is not None else None, + "total_asset_value": obj.get("total_asset_value"), + "cross_asset_value": obj.get("cross_asset_value"), + "pool_info": PublicPoolInfo.from_dict(obj["pool_info"]) if obj.get("pool_info") is not None else None, + "shares": [PublicPoolShare.from_dict(_item) for _item in obj["shares"]] if obj.get("shares") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/detailed_accounts.py b/docs/lighter/lighter-python-main/lighter/models/detailed_accounts.py new file mode 100644 index 0000000..50f61e1 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/detailed_accounts.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.detailed_account import DetailedAccount +from typing import Optional, Set +from typing_extensions import Self + +class DetailedAccounts(BaseModel): + """ + DetailedAccounts + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + total: StrictInt + accounts: List[DetailedAccount] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "total", "accounts"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DetailedAccounts from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in accounts (list) + _items = [] + if self.accounts: + for _item in self.accounts: + if _item: + _items.append(_item.to_dict()) + _dict['accounts'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DetailedAccounts from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "total": obj.get("total"), + "accounts": [DetailedAccount.from_dict(_item) for _item in obj["accounts"]] if obj.get("accounts") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/detailed_candlestick.py b/docs/lighter/lighter-python-main/lighter/models/detailed_candlestick.py new file mode 100644 index 0000000..1a1460d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/detailed_candlestick.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class DetailedCandlestick(BaseModel): + """ + DetailedCandlestick + """ # noqa: E501 + timestamp: StrictInt + open: Union[StrictFloat, StrictInt] + high: Union[StrictFloat, StrictInt] + low: Union[StrictFloat, StrictInt] + close: Union[StrictFloat, StrictInt] + open_raw: Union[StrictFloat, StrictInt] + high_raw: Union[StrictFloat, StrictInt] + low_raw: Union[StrictFloat, StrictInt] + close_raw: Union[StrictFloat, StrictInt] + volume0: Union[StrictFloat, StrictInt] + volume1: Union[StrictFloat, StrictInt] + last_trade_id: StrictInt + trade_count: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "open_raw", "high_raw", "low_raw", "close_raw", "volume0", "volume1", "last_trade_id", "trade_count"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DetailedCandlestick from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DetailedCandlestick from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "open": obj.get("open"), + "high": obj.get("high"), + "low": obj.get("low"), + "close": obj.get("close"), + "open_raw": obj.get("open_raw"), + "high_raw": obj.get("high_raw"), + "low_raw": obj.get("low_raw"), + "close_raw": obj.get("close_raw"), + "volume0": obj.get("volume0"), + "volume1": obj.get("volume1"), + "last_trade_id": obj.get("last_trade_id"), + "trade_count": obj.get("trade_count") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/enriched_tx.py b/docs/lighter/lighter-python-main/lighter/models/enriched_tx.py new file mode 100644 index 0000000..caa40af --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/enriched_tx.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class EnrichedTx(BaseModel): + """ + EnrichedTx + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + hash: StrictStr + type: Annotated[int, Field(le=64, strict=True, ge=1)] + info: StrictStr + event_info: StrictStr + status: StrictInt + transaction_index: StrictInt + l1_address: StrictStr + account_index: StrictInt + nonce: StrictInt + expire_at: StrictInt + block_height: StrictInt + queued_at: StrictInt + executed_at: StrictInt + sequence_index: StrictInt + parent_hash: StrictStr + api_key_index: StrictInt + committed_at: StrictInt + verified_at: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash", "api_key_index", "committed_at", "verified_at"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of EnrichedTx from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of EnrichedTx from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "hash": obj.get("hash"), + "type": obj.get("type"), + "info": obj.get("info"), + "event_info": obj.get("event_info"), + "status": obj.get("status"), + "transaction_index": obj.get("transaction_index"), + "l1_address": obj.get("l1_address"), + "account_index": obj.get("account_index"), + "nonce": obj.get("nonce"), + "expire_at": obj.get("expire_at"), + "block_height": obj.get("block_height"), + "queued_at": obj.get("queued_at"), + "executed_at": obj.get("executed_at"), + "sequence_index": obj.get("sequence_index"), + "parent_hash": obj.get("parent_hash"), + "api_key_index": obj.get("api_key_index"), + "committed_at": obj.get("committed_at"), + "verified_at": obj.get("verified_at") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/exchange_stats.py b/docs/lighter/lighter-python-main/lighter/models/exchange_stats.py new file mode 100644 index 0000000..fa276ce --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/exchange_stats.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from lighter.models.order_book_stats import OrderBookStats +from typing import Optional, Set +from typing_extensions import Self + +class ExchangeStats(BaseModel): + """ + ExchangeStats + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + total: StrictInt + order_book_stats: List[OrderBookStats] + daily_usd_volume: Union[StrictFloat, StrictInt] + daily_trades_count: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "total", "order_book_stats", "daily_usd_volume", "daily_trades_count"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ExchangeStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in order_book_stats (list) + _items = [] + if self.order_book_stats: + for _item in self.order_book_stats: + if _item: + _items.append(_item.to_dict()) + _dict['order_book_stats'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ExchangeStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "total": obj.get("total"), + "order_book_stats": [OrderBookStats.from_dict(_item) for _item in obj["order_book_stats"]] if obj.get("order_book_stats") is not None else None, + "daily_usd_volume": obj.get("daily_usd_volume"), + "daily_trades_count": obj.get("daily_trades_count") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/export_data.py b/docs/lighter/lighter-python-main/lighter/models/export_data.py new file mode 100644 index 0000000..4e712d8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/export_data.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ExportData(BaseModel): + """ + ExportData + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + data_url: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "data_url"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ExportData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ExportData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "data_url": obj.get("data_url") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/funding.py b/docs/lighter/lighter-python-main/lighter/models/funding.py new file mode 100644 index 0000000..727be7d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/funding.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Funding(BaseModel): + """ + Funding + """ # noqa: E501 + timestamp: StrictInt + value: StrictStr + rate: StrictStr + direction: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "value", "rate", "direction"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Funding from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Funding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "value": obj.get("value"), + "rate": obj.get("rate"), + "direction": obj.get("direction") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/funding_rate.py b/docs/lighter/lighter-python-main/lighter/models/funding_rate.py new file mode 100644 index 0000000..ff591b1 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/funding_rate.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class FundingRate(BaseModel): + """ + FundingRate + """ # noqa: E501 + market_id: StrictInt + exchange: StrictStr + symbol: StrictStr + rate: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "exchange", "symbol", "rate"] + + @field_validator('exchange') + def exchange_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['binance', 'bybit', 'hyperliquid', 'lighter']): + raise ValueError("must be one of enum values ('binance', 'bybit', 'hyperliquid', 'lighter')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FundingRate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FundingRate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "exchange": obj.get("exchange"), + "symbol": obj.get("symbol"), + "rate": obj.get("rate") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/funding_rates.py b/docs/lighter/lighter-python-main/lighter/models/funding_rates.py new file mode 100644 index 0000000..90e062b --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/funding_rates.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.funding_rate import FundingRate +from typing import Optional, Set +from typing_extensions import Self + +class FundingRates(BaseModel): + """ + FundingRates + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + funding_rates: List[FundingRate] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "funding_rates"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FundingRates from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in funding_rates (list) + _items = [] + if self.funding_rates: + for _item in self.funding_rates: + if _item: + _items.append(_item.to_dict()) + _dict['funding_rates'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FundingRates from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "funding_rates": [FundingRate.from_dict(_item) for _item in obj["funding_rates"]] if obj.get("funding_rates") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/fundings.py b/docs/lighter/lighter-python-main/lighter/models/fundings.py new file mode 100644 index 0000000..0ace19a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/fundings.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.funding import Funding +from typing import Optional, Set +from typing_extensions import Self + +class Fundings(BaseModel): + """ + Fundings + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + resolution: StrictStr + fundings: List[Funding] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "resolution", "fundings"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Fundings from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in fundings (list) + _items = [] + if self.fundings: + for _item in self.fundings: + if _item: + _items.append(_item.to_dict()) + _dict['fundings'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Fundings from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "resolution": obj.get("resolution"), + "fundings": [Funding.from_dict(_item) for _item in obj["fundings"]] if obj.get("fundings") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/l1_metadata.py b/docs/lighter/lighter-python-main/lighter/models/l1_metadata.py new file mode 100644 index 0000000..19f653b --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/l1_metadata.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class L1Metadata(BaseModel): + """ + L1Metadata + """ # noqa: E501 + l1_address: StrictStr + can_invite: StrictBool + referral_points_percentage: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["l1_address", "can_invite", "referral_points_percentage"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of L1Metadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of L1Metadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "l1_address": obj.get("l1_address"), + "can_invite": obj.get("can_invite"), + "referral_points_percentage": obj.get("referral_points_percentage") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/l1_provider_info.py b/docs/lighter/lighter-python-main/lighter/models/l1_provider_info.py new file mode 100644 index 0000000..41e5a3b --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/l1_provider_info.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class L1ProviderInfo(BaseModel): + """ + L1ProviderInfo + """ # noqa: E501 + chain_id: StrictInt = Field(alias="chainId") + network_id: StrictInt = Field(alias="networkId") + latest_block_number: StrictInt = Field(alias="latestBlockNumber") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["chainId", "networkId", "latestBlockNumber"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of L1ProviderInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of L1ProviderInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "chainId": obj.get("chainId"), + "networkId": obj.get("networkId"), + "latestBlockNumber": obj.get("latestBlockNumber") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/liq_trade.py b/docs/lighter/lighter-python-main/lighter/models/liq_trade.py new file mode 100644 index 0000000..276042e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/liq_trade.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class LiqTrade(BaseModel): + """ + LiqTrade + """ # noqa: E501 + price: StrictStr + size: StrictStr + taker_fee: StrictStr + maker_fee: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["price", "size", "taker_fee", "maker_fee"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LiqTrade from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LiqTrade from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "price": obj.get("price"), + "size": obj.get("size"), + "taker_fee": obj.get("taker_fee"), + "maker_fee": obj.get("maker_fee") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/liquidation.py b/docs/lighter/lighter-python-main/lighter/models/liquidation.py new file mode 100644 index 0000000..aa012a4 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/liquidation.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from lighter.models.liq_trade import LiqTrade +from lighter.models.liquidation_info import LiquidationInfo +from typing import Optional, Set +from typing_extensions import Self + +class Liquidation(BaseModel): + """ + Liquidation + """ # noqa: E501 + id: StrictInt + market_id: StrictInt + type: StrictStr + trade: LiqTrade + info: LiquidationInfo + executed_at: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "market_id", "type", "trade", "info", "executed_at"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['partial', 'deleverage']): + raise ValueError("must be one of enum values ('partial', 'deleverage')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Liquidation from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of trade + if self.trade: + _dict['trade'] = self.trade.to_dict() + # override the default output from pydantic by calling `to_dict()` of info + if self.info: + _dict['info'] = self.info.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Liquidation from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "market_id": obj.get("market_id"), + "type": obj.get("type"), + "trade": LiqTrade.from_dict(obj["trade"]) if obj.get("trade") is not None else None, + "info": LiquidationInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, + "executed_at": obj.get("executed_at") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/liquidation_info.py b/docs/lighter/lighter-python-main/lighter/models/liquidation_info.py new file mode 100644 index 0000000..91519d1 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/liquidation_info.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.account_position import AccountPosition +from lighter.models.risk_info import RiskInfo +from typing import Optional, Set +from typing_extensions import Self + +class LiquidationInfo(BaseModel): + """ + LiquidationInfo + """ # noqa: E501 + positions: List[AccountPosition] + risk_info_before: RiskInfo + risk_info_after: RiskInfo + mark_prices: Dict[str, Union[StrictFloat, StrictInt]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["positions", "risk_info_before", "risk_info_after", "mark_prices"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LiquidationInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in positions (list) + _items = [] + if self.positions: + for _item in self.positions: + if _item: + _items.append(_item.to_dict()) + _dict['positions'] = _items + # override the default output from pydantic by calling `to_dict()` of risk_info_before + if self.risk_info_before: + _dict['risk_info_before'] = self.risk_info_before.to_dict() + # override the default output from pydantic by calling `to_dict()` of risk_info_after + if self.risk_info_after: + _dict['risk_info_after'] = self.risk_info_after.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LiquidationInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "positions": [AccountPosition.from_dict(_item) for _item in obj["positions"]] if obj.get("positions") is not None else None, + "risk_info_before": RiskInfo.from_dict(obj["risk_info_before"]) if obj.get("risk_info_before") is not None else None, + "risk_info_after": RiskInfo.from_dict(obj["risk_info_after"]) if obj.get("risk_info_after") is not None else None, + "mark_prices": obj.get("mark_prices") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/liquidation_infos.py b/docs/lighter/lighter-python-main/lighter/models/liquidation_infos.py new file mode 100644 index 0000000..9d633d7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/liquidation_infos.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.liquidation import Liquidation +from typing import Optional, Set +from typing_extensions import Self + +class LiquidationInfos(BaseModel): + """ + LiquidationInfos + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + liquidations: List[Liquidation] + next_cursor: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "liquidations", "next_cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LiquidationInfos from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in liquidations (list) + _items = [] + if self.liquidations: + for _item in self.liquidations: + if _item: + _items.append(_item.to_dict()) + _dict['liquidations'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LiquidationInfos from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "liquidations": [Liquidation.from_dict(_item) for _item in obj["liquidations"]] if obj.get("liquidations") is not None else None, + "next_cursor": obj.get("next_cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/market_config.py b/docs/lighter/lighter-python-main/lighter/models/market_config.py new file mode 100644 index 0000000..c5f9ddb --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/market_config.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class MarketConfig(BaseModel): + """ + MarketConfig + """ # noqa: E501 + market_margin_mode: StrictInt + insurance_fund_account_index: StrictInt + liquidation_mode: StrictInt + force_reduce_only: StrictBool + trading_hours: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_margin_mode", "insurance_fund_account_index", "liquidation_mode", "force_reduce_only", "trading_hours"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of MarketConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MarketConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_margin_mode": obj.get("market_margin_mode"), + "insurance_fund_account_index": obj.get("insurance_fund_account_index"), + "liquidation_mode": obj.get("liquidation_mode"), + "force_reduce_only": obj.get("force_reduce_only"), + "trading_hours": obj.get("trading_hours") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/next_nonce.py b/docs/lighter/lighter-python-main/lighter/models/next_nonce.py new file mode 100644 index 0000000..94ab734 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/next_nonce.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class NextNonce(BaseModel): + """ + NextNonce + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + nonce: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "nonce"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of NextNonce from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of NextNonce from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "nonce": obj.get("nonce") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order.py b/docs/lighter/lighter-python-main/lighter/models/order.py new file mode 100644 index 0000000..a0db5d2 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order.py @@ -0,0 +1,192 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Order(BaseModel): + """ + Order + """ # noqa: E501 + order_index: StrictInt + client_order_index: StrictInt + order_id: StrictStr + client_order_id: StrictStr + market_index: StrictInt + owner_account_index: StrictInt + initial_base_amount: StrictStr + price: StrictStr + nonce: StrictInt + remaining_base_amount: StrictStr + is_ask: StrictBool + base_size: StrictInt + base_price: StrictInt + filled_base_amount: StrictStr + filled_quote_amount: StrictStr + side: StrictStr = Field(description=" TODO: remove this") + type: StrictStr + time_in_force: StrictStr + reduce_only: StrictBool + trigger_price: StrictStr + order_expiry: StrictInt + status: StrictStr + trigger_status: StrictStr + trigger_time: StrictInt + parent_order_index: StrictInt + parent_order_id: StrictStr + to_trigger_order_id_0: StrictStr + to_trigger_order_id_1: StrictStr + to_cancel_order_id_0: StrictStr + block_height: StrictInt + timestamp: StrictInt + created_at: StrictInt + updated_at: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["order_index", "client_order_index", "order_id", "client_order_id", "market_index", "owner_account_index", "initial_base_amount", "price", "nonce", "remaining_base_amount", "is_ask", "base_size", "base_price", "filled_base_amount", "filled_quote_amount", "side", "type", "time_in_force", "reduce_only", "trigger_price", "order_expiry", "status", "trigger_status", "trigger_time", "parent_order_index", "parent_order_id", "to_trigger_order_id_0", "to_trigger_order_id_1", "to_cancel_order_id_0", "block_height", "timestamp", "created_at", "updated_at"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['limit', 'market', 'stop-loss', 'stop-loss-limit', 'take-profit', 'take-profit-limit', 'twap', 'twap-sub', 'liquidation']): + raise ValueError("must be one of enum values ('limit', 'market', 'stop-loss', 'stop-loss-limit', 'take-profit', 'take-profit-limit', 'twap', 'twap-sub', 'liquidation')") + return value + + @field_validator('time_in_force') + def time_in_force_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['good-till-time', 'immediate-or-cancel', 'post-only', 'Unknown']): + raise ValueError("must be one of enum values ('good-till-time', 'immediate-or-cancel', 'post-only', 'Unknown')") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired', 'canceled-oco', 'canceled-child', 'canceled-liquidation', 'canceled-invalid-balance']): + raise ValueError("must be one of enum values ('in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired', 'canceled-oco', 'canceled-child', 'canceled-liquidation', 'canceled-invalid-balance')") + return value + + @field_validator('trigger_status') + def trigger_status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['na', 'ready', 'mark-price', 'twap', 'parent-order']): + raise ValueError("must be one of enum values ('na', 'ready', 'mark-price', 'twap', 'parent-order')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Order from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Order from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "order_index": obj.get("order_index"), + "client_order_index": obj.get("client_order_index"), + "order_id": obj.get("order_id"), + "client_order_id": obj.get("client_order_id"), + "market_index": obj.get("market_index"), + "owner_account_index": obj.get("owner_account_index"), + "initial_base_amount": obj.get("initial_base_amount"), + "price": obj.get("price"), + "nonce": obj.get("nonce"), + "remaining_base_amount": obj.get("remaining_base_amount"), + "is_ask": obj.get("is_ask"), + "base_size": obj.get("base_size"), + "base_price": obj.get("base_price"), + "filled_base_amount": obj.get("filled_base_amount"), + "filled_quote_amount": obj.get("filled_quote_amount"), + "side": obj.get("side") if obj.get("side") is not None else 'buy', + "type": obj.get("type"), + "time_in_force": obj.get("time_in_force") if obj.get("time_in_force") is not None else 'good-till-time', + "reduce_only": obj.get("reduce_only"), + "trigger_price": obj.get("trigger_price"), + "order_expiry": obj.get("order_expiry"), + "status": obj.get("status"), + "trigger_status": obj.get("trigger_status"), + "trigger_time": obj.get("trigger_time"), + "parent_order_index": obj.get("parent_order_index"), + "parent_order_id": obj.get("parent_order_id"), + "to_trigger_order_id_0": obj.get("to_trigger_order_id_0"), + "to_trigger_order_id_1": obj.get("to_trigger_order_id_1"), + "to_cancel_order_id_0": obj.get("to_cancel_order_id_0"), + "block_height": obj.get("block_height"), + "timestamp": obj.get("timestamp"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_book.py b/docs/lighter/lighter-python-main/lighter/models/order_book.py new file mode 100644 index 0000000..0c39960 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_book.py @@ -0,0 +1,142 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class OrderBook(BaseModel): + """ + OrderBook + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt + status: StrictStr + taker_fee: StrictStr + maker_fee: StrictStr + liquidation_fee: StrictStr + min_base_amount: StrictStr + min_quote_amount: StrictStr + order_quote_limit: StrictStr + supported_size_decimals: StrictInt + supported_price_decimals: StrictInt + supported_quote_decimals: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBook from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBook from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), + "status": obj.get("status"), + "taker_fee": obj.get("taker_fee"), + "maker_fee": obj.get("maker_fee"), + "liquidation_fee": obj.get("liquidation_fee"), + "min_base_amount": obj.get("min_base_amount"), + "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), + "supported_size_decimals": obj.get("supported_size_decimals"), + "supported_price_decimals": obj.get("supported_price_decimals"), + "supported_quote_decimals": obj.get("supported_quote_decimals") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_book_depth.py b/docs/lighter/lighter-python-main/lighter/models/order_book_depth.py new file mode 100644 index 0000000..68d7534 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_book_depth.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.price_level import PriceLevel +from typing import Optional, Set +from typing_extensions import Self + +class OrderBookDepth(BaseModel): + """ + OrderBookDepth + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + asks: List[PriceLevel] + bids: List[PriceLevel] + offset: StrictInt + nonce: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "asks", "bids", "offset", "nonce"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBookDepth from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in asks (list) + _items = [] + if self.asks: + for _item in self.asks: + if _item: + _items.append(_item.to_dict()) + _dict['asks'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bids (list) + _items = [] + if self.bids: + for _item in self.bids: + if _item: + _items.append(_item.to_dict()) + _dict['bids'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBookDepth from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "asks": [PriceLevel.from_dict(_item) for _item in obj["asks"]] if obj.get("asks") is not None else None, + "bids": [PriceLevel.from_dict(_item) for _item in obj["bids"]] if obj.get("bids") is not None else None, + "offset": obj.get("offset"), + "nonce": obj.get("nonce") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_book_details.py b/docs/lighter/lighter-python-main/lighter/models/order_book_details.py new file mode 100644 index 0000000..b2f5091 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_book_details.py @@ -0,0 +1,122 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail +from lighter.models.spot_order_book_detail import SpotOrderBookDetail +from typing import Optional, Set +from typing_extensions import Self + +class OrderBookDetails(BaseModel): + """ + OrderBookDetails + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + order_book_details: List[PerpsOrderBookDetail] + spot_order_book_details: List[SpotOrderBookDetail] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "order_book_details", "spot_order_book_details"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBookDetails from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in order_book_details (list) + _items = [] + if self.order_book_details: + for _item in self.order_book_details: + if _item: + _items.append(_item.to_dict()) + _dict['order_book_details'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in spot_order_book_details (list) + _items = [] + if self.spot_order_book_details: + for _item in self.spot_order_book_details: + if _item: + _items.append(_item.to_dict()) + _dict['spot_order_book_details'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBookDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "order_book_details": [PerpsOrderBookDetail.from_dict(_item) for _item in obj["order_book_details"]] if obj.get("order_book_details") is not None else None, + "spot_order_book_details": [SpotOrderBookDetail.from_dict(_item) for _item in obj["spot_order_book_details"]] if obj.get("spot_order_book_details") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_book_orders.py b/docs/lighter/lighter-python-main/lighter/models/order_book_orders.py new file mode 100644 index 0000000..549d79c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_book_orders.py @@ -0,0 +1,125 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.simple_order import SimpleOrder +from typing import Optional, Set +from typing_extensions import Self + +class OrderBookOrders(BaseModel): + """ + OrderBookOrders + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + total_asks: StrictInt + asks: List[SimpleOrder] + total_bids: StrictInt + bids: List[SimpleOrder] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "total_asks", "asks", "total_bids", "bids"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBookOrders from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in asks (list) + _items = [] + if self.asks: + for _item in self.asks: + if _item: + _items.append(_item.to_dict()) + _dict['asks'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bids (list) + _items = [] + if self.bids: + for _item in self.bids: + if _item: + _items.append(_item.to_dict()) + _dict['bids'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBookOrders from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "total_asks": obj.get("total_asks"), + "asks": [SimpleOrder.from_dict(_item) for _item in obj["asks"]] if obj.get("asks") is not None else None, + "total_bids": obj.get("total_bids"), + "bids": [SimpleOrder.from_dict(_item) for _item in obj["bids"]] if obj.get("bids") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_book_stats.py b/docs/lighter/lighter-python-main/lighter/models/order_book_stats.py new file mode 100644 index 0000000..5f09676 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_book_stats.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class OrderBookStats(BaseModel): + """ + OrderBookStats + """ # noqa: E501 + symbol: StrictStr + last_trade_price: Union[StrictFloat, StrictInt] + daily_trades_count: StrictInt + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + daily_price_change: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_change"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBookStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBookStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "last_trade_price": obj.get("last_trade_price"), + "daily_trades_count": obj.get("daily_trades_count"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "daily_price_change": obj.get("daily_price_change") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/order_books.py b/docs/lighter/lighter-python-main/lighter/models/order_books.py new file mode 100644 index 0000000..f7cc8e8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/order_books.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.order_book import OrderBook +from typing import Optional, Set +from typing_extensions import Self + +class OrderBooks(BaseModel): + """ + OrderBooks + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + order_books: List[OrderBook] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "order_books"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrderBooks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in order_books (list) + _items = [] + if self.order_books: + for _item in self.order_books: + if _item: + _items.append(_item.to_dict()) + _dict['order_books'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrderBooks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "order_books": [OrderBook.from_dict(_item) for _item in obj["order_books"]] if obj.get("order_books") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/orders.py b/docs/lighter/lighter-python-main/lighter/models/orders.py new file mode 100644 index 0000000..b494259 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/orders.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.order import Order +from typing import Optional, Set +from typing_extensions import Self + +class Orders(BaseModel): + """ + Orders + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + next_cursor: Optional[StrictStr] = None + orders: List[Order] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "next_cursor", "orders"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Orders from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in orders (list) + _items = [] + if self.orders: + for _item in self.orders: + if _item: + _items.append(_item.to_dict()) + _dict['orders'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Orders from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "next_cursor": obj.get("next_cursor"), + "orders": [Order.from_dict(_item) for _item in obj["orders"]] if obj.get("orders") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/perps_market_stats.py b/docs/lighter/lighter-python-main/lighter/models/perps_market_stats.py new file mode 100644 index 0000000..e810dc5 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/perps_market_stats.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PerpsMarketStats(BaseModel): + """ + PerpsMarketStats + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + index_price: StrictStr + mark_price: StrictStr + open_interest: StrictStr + open_interest_limit: StrictStr + funding_clamp_small: StrictStr + funding_clamp_big: StrictStr + last_trade_price: StrictStr + current_funding_rate: StrictStr + funding_rate: StrictStr + funding_timestamp: StrictInt + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + daily_price_low: Union[StrictFloat, StrictInt] + daily_price_high: Union[StrictFloat, StrictInt] + daily_price_change: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "index_price", "mark_price", "open_interest", "open_interest_limit", "funding_clamp_small", "funding_clamp_big", "last_trade_price", "current_funding_rate", "funding_rate", "funding_timestamp", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PerpsMarketStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PerpsMarketStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "index_price": obj.get("index_price"), + "mark_price": obj.get("mark_price"), + "open_interest": obj.get("open_interest"), + "open_interest_limit": obj.get("open_interest_limit"), + "funding_clamp_small": obj.get("funding_clamp_small"), + "funding_clamp_big": obj.get("funding_clamp_big"), + "last_trade_price": obj.get("last_trade_price"), + "current_funding_rate": obj.get("current_funding_rate"), + "funding_rate": obj.get("funding_rate"), + "funding_timestamp": obj.get("funding_timestamp"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "daily_price_low": obj.get("daily_price_low"), + "daily_price_high": obj.get("daily_price_high"), + "daily_price_change": obj.get("daily_price_change") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/perps_order_book_detail.py b/docs/lighter/lighter-python-main/lighter/models/perps_order_book_detail.py new file mode 100644 index 0000000..2ec0269 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/perps_order_book_detail.py @@ -0,0 +1,180 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.market_config import MarketConfig +from typing import Optional, Set +from typing_extensions import Self + +class PerpsOrderBookDetail(BaseModel): + """ + PerpsOrderBookDetail + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt + status: StrictStr + taker_fee: StrictStr + maker_fee: StrictStr + liquidation_fee: StrictStr + min_base_amount: StrictStr + min_quote_amount: StrictStr + order_quote_limit: StrictStr + supported_size_decimals: StrictInt + supported_price_decimals: StrictInt + supported_quote_decimals: StrictInt + size_decimals: StrictInt + price_decimals: StrictInt + quote_multiplier: StrictInt + default_initial_margin_fraction: StrictInt + min_initial_margin_fraction: StrictInt + maintenance_margin_fraction: StrictInt + closeout_margin_fraction: StrictInt + last_trade_price: Union[StrictFloat, StrictInt] + daily_trades_count: StrictInt + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + daily_price_low: Union[StrictFloat, StrictInt] + daily_price_high: Union[StrictFloat, StrictInt] + daily_price_change: Union[StrictFloat, StrictInt] + open_interest: Union[StrictFloat, StrictInt] + daily_chart: Dict[str, Union[StrictFloat, StrictInt]] + market_config: MarketConfig + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals", "size_decimals", "price_decimals", "quote_multiplier", "default_initial_margin_fraction", "min_initial_margin_fraction", "maintenance_margin_fraction", "closeout_margin_fraction", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change", "open_interest", "daily_chart", "market_config"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PerpsOrderBookDetail from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of market_config + if self.market_config: + _dict['market_config'] = self.market_config.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PerpsOrderBookDetail from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), + "status": obj.get("status"), + "taker_fee": obj.get("taker_fee"), + "maker_fee": obj.get("maker_fee"), + "liquidation_fee": obj.get("liquidation_fee"), + "min_base_amount": obj.get("min_base_amount"), + "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), + "supported_size_decimals": obj.get("supported_size_decimals"), + "supported_price_decimals": obj.get("supported_price_decimals"), + "supported_quote_decimals": obj.get("supported_quote_decimals"), + "size_decimals": obj.get("size_decimals"), + "price_decimals": obj.get("price_decimals"), + "quote_multiplier": obj.get("quote_multiplier"), + "default_initial_margin_fraction": obj.get("default_initial_margin_fraction"), + "min_initial_margin_fraction": obj.get("min_initial_margin_fraction"), + "maintenance_margin_fraction": obj.get("maintenance_margin_fraction"), + "closeout_margin_fraction": obj.get("closeout_margin_fraction"), + "last_trade_price": obj.get("last_trade_price"), + "daily_trades_count": obj.get("daily_trades_count"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "daily_price_low": obj.get("daily_price_low"), + "daily_price_high": obj.get("daily_price_high"), + "daily_price_change": obj.get("daily_price_change"), + "open_interest": obj.get("open_interest"), + "daily_chart": obj.get("daily_chart"), + "market_config": MarketConfig.from_dict(obj["market_config"]) if obj.get("market_config") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/pn_l_entry.py b/docs/lighter/lighter-python-main/lighter/models/pn_l_entry.py new file mode 100644 index 0000000..bff1f17 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/pn_l_entry.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PnLEntry(BaseModel): + """ + PnLEntry + """ # noqa: E501 + timestamp: StrictInt + trade_pnl: Union[StrictFloat, StrictInt] + trade_spot_pnl: Union[StrictFloat, StrictInt] + inflow: Union[StrictFloat, StrictInt] + outflow: Union[StrictFloat, StrictInt] + spot_outflow: Union[StrictFloat, StrictInt] + spot_inflow: Union[StrictFloat, StrictInt] + pool_pnl: Union[StrictFloat, StrictInt] + pool_inflow: Union[StrictFloat, StrictInt] + pool_outflow: Union[StrictFloat, StrictInt] + pool_total_shares: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "trade_pnl", "trade_spot_pnl", "inflow", "outflow", "spot_outflow", "spot_inflow", "pool_pnl", "pool_inflow", "pool_outflow", "pool_total_shares"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PnLEntry from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PnLEntry from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "trade_pnl": obj.get("trade_pnl"), + "trade_spot_pnl": obj.get("trade_spot_pnl"), + "inflow": obj.get("inflow"), + "outflow": obj.get("outflow"), + "spot_outflow": obj.get("spot_outflow"), + "spot_inflow": obj.get("spot_inflow"), + "pool_pnl": obj.get("pool_pnl"), + "pool_inflow": obj.get("pool_inflow"), + "pool_outflow": obj.get("pool_outflow"), + "pool_total_shares": obj.get("pool_total_shares") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/position_funding.py b/docs/lighter/lighter-python-main/lighter/models/position_funding.py new file mode 100644 index 0000000..1fee27f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/position_funding.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class PositionFunding(BaseModel): + """ + PositionFunding + """ # noqa: E501 + timestamp: StrictInt + market_id: StrictInt + funding_id: StrictInt + change: StrictStr + rate: StrictStr + position_size: StrictStr + position_side: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "market_id", "funding_id", "change", "rate", "position_size", "position_side"] + + @field_validator('position_side') + def position_side_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['long', 'short']): + raise ValueError("must be one of enum values ('long', 'short')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PositionFunding from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PositionFunding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "market_id": obj.get("market_id"), + "funding_id": obj.get("funding_id"), + "change": obj.get("change"), + "rate": obj.get("rate"), + "position_size": obj.get("position_size"), + "position_side": obj.get("position_side") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/position_fundings.py b/docs/lighter/lighter-python-main/lighter/models/position_fundings.py new file mode 100644 index 0000000..fcd8677 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/position_fundings.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.position_funding import PositionFunding +from typing import Optional, Set +from typing_extensions import Self + +class PositionFundings(BaseModel): + """ + PositionFundings + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + position_fundings: List[PositionFunding] + next_cursor: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "position_fundings", "next_cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PositionFundings from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in position_fundings (list) + _items = [] + if self.position_fundings: + for _item in self.position_fundings: + if _item: + _items.append(_item.to_dict()) + _dict['position_fundings'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PositionFundings from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "position_fundings": [PositionFunding.from_dict(_item) for _item in obj["position_fundings"]] if obj.get("position_fundings") is not None else None, + "next_cursor": obj.get("next_cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/price_level.py b/docs/lighter/lighter-python-main/lighter/models/price_level.py new file mode 100644 index 0000000..dc5b081 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/price_level.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class PriceLevel(BaseModel): + """ + PriceLevel + """ # noqa: E501 + price: StrictStr + size: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["price", "size"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PriceLevel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PriceLevel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "price": obj.get("price"), + "size": obj.get("size") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/public_pool_info.py b/docs/lighter/lighter-python-main/lighter/models/public_pool_info.py new file mode 100644 index 0000000..ea35eba --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/public_pool_info.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.daily_return import DailyReturn +from lighter.models.share_price import SharePrice +from typing import Optional, Set +from typing_extensions import Self + +class PublicPoolInfo(BaseModel): + """ + PublicPoolInfo + """ # noqa: E501 + status: StrictInt + operator_fee: StrictStr + min_operator_share_rate: StrictStr + total_shares: StrictInt + operator_shares: StrictInt + annual_percentage_yield: Union[StrictFloat, StrictInt] + sharpe_ratio: Union[StrictFloat, StrictInt] + daily_returns: List[DailyReturn] + share_prices: List[SharePrice] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares", "annual_percentage_yield", "sharpe_ratio", "daily_returns", "share_prices"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PublicPoolInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in daily_returns (list) + _items = [] + if self.daily_returns: + for _item in self.daily_returns: + if _item: + _items.append(_item.to_dict()) + _dict['daily_returns'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in share_prices (list) + _items = [] + if self.share_prices: + for _item in self.share_prices: + if _item: + _items.append(_item.to_dict()) + _dict['share_prices'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PublicPoolInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "status": obj.get("status"), + "operator_fee": obj.get("operator_fee"), + "min_operator_share_rate": obj.get("min_operator_share_rate"), + "total_shares": obj.get("total_shares"), + "operator_shares": obj.get("operator_shares"), + "annual_percentage_yield": obj.get("annual_percentage_yield"), + "sharpe_ratio": obj.get("sharpe_ratio"), + "daily_returns": [DailyReturn.from_dict(_item) for _item in obj["daily_returns"]] if obj.get("daily_returns") is not None else None, + "share_prices": [SharePrice.from_dict(_item) for _item in obj["share_prices"]] if obj.get("share_prices") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/public_pool_metadata.py b/docs/lighter/lighter-python-main/lighter/models/public_pool_metadata.py new file mode 100644 index 0000000..f4ec073 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/public_pool_metadata.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from lighter.models.public_pool_share import PublicPoolShare +from typing import Optional, Set +from typing_extensions import Self + +class PublicPoolMetadata(BaseModel): + """ + PublicPoolMetadata + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + account_index: StrictInt + created_at: StrictInt + master_account_index: StrictInt + account_type: StrictInt + name: StrictStr + l1_address: StrictStr + annual_percentage_yield: Union[StrictFloat, StrictInt] + sharpe_ratio: Union[StrictFloat, StrictInt] + status: StrictInt + operator_fee: StrictStr + total_asset_value: StrictStr + total_shares: StrictInt + account_share: Optional[PublicPoolShare] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "account_index", "created_at", "master_account_index", "account_type", "name", "l1_address", "annual_percentage_yield", "sharpe_ratio", "status", "operator_fee", "total_asset_value", "total_shares", "account_share"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PublicPoolMetadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of account_share + if self.account_share: + _dict['account_share'] = self.account_share.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PublicPoolMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "account_index": obj.get("account_index"), + "created_at": obj.get("created_at"), + "master_account_index": obj.get("master_account_index"), + "account_type": obj.get("account_type"), + "name": obj.get("name"), + "l1_address": obj.get("l1_address"), + "annual_percentage_yield": obj.get("annual_percentage_yield"), + "sharpe_ratio": obj.get("sharpe_ratio"), + "status": obj.get("status"), + "operator_fee": obj.get("operator_fee"), + "total_asset_value": obj.get("total_asset_value"), + "total_shares": obj.get("total_shares"), + "account_share": PublicPoolShare.from_dict(obj["account_share"]) if obj.get("account_share") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/public_pool_share.py b/docs/lighter/lighter-python-main/lighter/models/public_pool_share.py new file mode 100644 index 0000000..0261075 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/public_pool_share.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class PublicPoolShare(BaseModel): + """ + PublicPoolShare + """ # noqa: E501 + public_pool_index: StrictInt + shares_amount: StrictInt + entry_usdc: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["public_pool_index", "shares_amount", "entry_usdc"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PublicPoolShare from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PublicPoolShare from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "public_pool_index": obj.get("public_pool_index"), + "shares_amount": obj.get("shares_amount"), + "entry_usdc": obj.get("entry_usdc") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/referral_point_entry.py b/docs/lighter/lighter-python-main/lighter/models/referral_point_entry.py new file mode 100644 index 0000000..5524e71 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/referral_point_entry.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class ReferralPointEntry(BaseModel): + """ + ReferralPointEntry + """ # noqa: E501 + l1_address: StrictStr + total_points: Union[StrictFloat, StrictInt] + week_points: Union[StrictFloat, StrictInt] + total_reward_points: Union[StrictFloat, StrictInt] + week_reward_points: Union[StrictFloat, StrictInt] + reward_point_multiplier: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["l1_address", "total_points", "week_points", "total_reward_points", "week_reward_points", "reward_point_multiplier"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReferralPointEntry from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReferralPointEntry from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "l1_address": obj.get("l1_address"), + "total_points": obj.get("total_points"), + "week_points": obj.get("week_points"), + "total_reward_points": obj.get("total_reward_points"), + "week_reward_points": obj.get("week_reward_points"), + "reward_point_multiplier": obj.get("reward_point_multiplier") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/referral_points.py b/docs/lighter/lighter-python-main/lighter/models/referral_points.py new file mode 100644 index 0000000..e6f4900 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/referral_points.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.referral_point_entry import ReferralPointEntry +from typing import Optional, Set +from typing_extensions import Self + +class ReferralPoints(BaseModel): + """ + ReferralPoints + """ # noqa: E501 + referrals: List[ReferralPointEntry] + user_total_points: Union[StrictFloat, StrictInt] + user_last_week_points: Union[StrictFloat, StrictInt] + user_total_referral_reward_points: Union[StrictFloat, StrictInt] + user_last_week_referral_reward_points: Union[StrictFloat, StrictInt] + reward_point_multiplier: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["referrals", "user_total_points", "user_last_week_points", "user_total_referral_reward_points", "user_last_week_referral_reward_points", "reward_point_multiplier"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReferralPoints from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in referrals (list) + _items = [] + if self.referrals: + for _item in self.referrals: + if _item: + _items.append(_item.to_dict()) + _dict['referrals'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReferralPoints from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "referrals": [ReferralPointEntry.from_dict(_item) for _item in obj["referrals"]] if obj.get("referrals") is not None else None, + "user_total_points": obj.get("user_total_points"), + "user_last_week_points": obj.get("user_last_week_points"), + "user_total_referral_reward_points": obj.get("user_total_referral_reward_points"), + "user_last_week_referral_reward_points": obj.get("user_last_week_referral_reward_points"), + "reward_point_multiplier": obj.get("reward_point_multiplier") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_export_data.py b/docs/lighter/lighter-python-main/lighter/models/req_export_data.py new file mode 100644 index 0000000..d82b64e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_export_data.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqExportData(BaseModel): + """ + ReqExportData + """ # noqa: E501 + auth: Optional[StrictStr] = None + account_index: Optional[StrictInt] = -1 + market_id: Optional[StrictInt] = None + type: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index", "market_id", "type"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['funding', 'trade']): + raise ValueError("must be one of enum values ('funding', 'trade')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqExportData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqExportData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index") if obj.get("account_index") is not None else -1, + "market_id": obj.get("market_id"), + "type": obj.get("type") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account.py new file mode 100644 index 0000000..c6108e6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccount(BaseModel): + """ + ReqGetAccount + """ # noqa: E501 + by: StrictStr + value: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['index', 'l1_address']): + raise ValueError("must be one of enum values ('index', 'l1_address')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccount from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccount from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_active_orders.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_active_orders.py new file mode 100644 index 0000000..bf3daff --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_active_orders.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountActiveOrders(BaseModel): + """ + ReqGetAccountActiveOrders + """ # noqa: E501 + account_index: StrictInt + market_id: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "market_id", "auth"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountActiveOrders from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountActiveOrders from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "market_id": obj.get("market_id"), + "auth": obj.get("auth") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_api_keys.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_api_keys.py new file mode 100644 index 0000000..2a395ad --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_api_keys.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountApiKeys(BaseModel): + """ + ReqGetAccountApiKeys + """ # noqa: E501 + account_index: StrictInt + api_key_index: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "api_key_index"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountApiKeys from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountApiKeys from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "api_key_index": obj.get("api_key_index") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_by_l1_address.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_by_l1_address.py new file mode 100644 index 0000000..a0b86eb --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_by_l1_address.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountByL1Address(BaseModel): + """ + ReqGetAccountByL1Address + """ # noqa: E501 + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["l1_address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountByL1Address from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountByL1Address from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "l1_address": obj.get("l1_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_inactive_orders.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_inactive_orders.py new file mode 100644 index 0000000..9ea9b18 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_inactive_orders.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountInactiveOrders(BaseModel): + """ + ReqGetAccountInactiveOrders + """ # noqa: E501 + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + account_index: StrictInt + market_id: Optional[StrictInt] = None + ask_filter: Optional[StrictInt] = None + between_timestamps: Optional[StrictStr] = None + cursor: Optional[StrictStr] = None + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index", "market_id", "ask_filter", "between_timestamps", "cursor", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountInactiveOrders from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountInactiveOrders from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index"), + "market_id": obj.get("market_id"), + "ask_filter": obj.get("ask_filter"), + "between_timestamps": obj.get("between_timestamps"), + "cursor": obj.get("cursor"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_limits.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_limits.py new file mode 100644 index 0000000..206f876 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_limits.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountLimits(BaseModel): + """ + ReqGetAccountLimits + """ # noqa: E501 + account_index: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "auth"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountLimits from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountLimits from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "auth": obj.get("auth") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_metadata.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_metadata.py new file mode 100644 index 0000000..4403e9d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_metadata.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountMetadata(BaseModel): + """ + ReqGetAccountMetadata + """ # noqa: E501 + by: StrictStr + value: StrictStr + auth: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value", "auth"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['index', 'l1_address']): + raise ValueError("must be one of enum values ('index', 'l1_address')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountMetadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value"), + "auth": obj.get("auth") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_pn_l.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_pn_l.py new file mode 100644 index 0000000..034022c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_pn_l.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountPnL(BaseModel): + """ + ReqGetAccountPnL + """ # noqa: E501 + auth: Optional[StrictStr] = None + by: StrictStr + value: StrictStr + resolution: StrictStr + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + count_back: StrictInt + ignore_transfers: Optional[StrictBool] = False + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "by", "value", "resolution", "start_timestamp", "end_timestamp", "count_back", "ignore_transfers"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['index']): + raise ValueError("must be one of enum values ('index')") + return value + + @field_validator('resolution') + def resolution_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['1m', '5m', '15m', '1h', '4h', '1d']): + raise ValueError("must be one of enum values ('1m', '5m', '15m', '1h', '4h', '1d')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountPnL from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountPnL from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "by": obj.get("by"), + "value": obj.get("value"), + "resolution": obj.get("resolution"), + "start_timestamp": obj.get("start_timestamp"), + "end_timestamp": obj.get("end_timestamp"), + "count_back": obj.get("count_back"), + "ignore_transfers": obj.get("ignore_transfers") if obj.get("ignore_transfers") is not None else False + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_account_txs.py b/docs/lighter/lighter-python-main/lighter/models/req_get_account_txs.py new file mode 100644 index 0000000..6c785f6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_account_txs.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAccountTxs(BaseModel): + """ + ReqGetAccountTxs + """ # noqa: E501 + index: Optional[StrictInt] = None + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None + by: Optional[StrictStr] = None + value: Optional[StrictStr] = None + types: Optional[List[StrictInt]] = None + auth: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["index", "limit", "by", "value", "types", "auth"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['account_index']): + raise ValueError("must be one of enum values ('account_index')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAccountTxs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAccountTxs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "index": obj.get("index"), + "limit": obj.get("limit"), + "by": obj.get("by"), + "value": obj.get("value"), + "types": obj.get("types"), + "auth": obj.get("auth") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_asset_details.py b/docs/lighter/lighter-python-main/lighter/models/req_get_asset_details.py new file mode 100644 index 0000000..9f4b7ef --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_asset_details.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetAssetDetails(BaseModel): + """ + ReqGetAssetDetails + """ # noqa: E501 + asset_id: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["asset_id"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetAssetDetails from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetAssetDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "asset_id": obj.get("asset_id") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_block.py b/docs/lighter/lighter-python-main/lighter/models/req_get_block.py new file mode 100644 index 0000000..574e2c7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_block.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetBlock(BaseModel): + """ + ReqGetBlock + """ # noqa: E501 + by: StrictStr + value: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['commitment', 'height']): + raise ValueError("must be one of enum values ('commitment', 'height')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetBlock from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetBlock from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_block_txs.py b/docs/lighter/lighter-python-main/lighter/models/req_get_block_txs.py new file mode 100644 index 0000000..b040c5e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_block_txs.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetBlockTxs(BaseModel): + """ + ReqGetBlockTxs + """ # noqa: E501 + by: StrictStr + value: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['block_height', 'block_commitment']): + raise ValueError("must be one of enum values ('block_height', 'block_commitment')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetBlockTxs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetBlockTxs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_bridges_by_l1_addr.py b/docs/lighter/lighter-python-main/lighter/models/req_get_bridges_by_l1_addr.py new file mode 100644 index 0000000..6b3d0dc --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_bridges_by_l1_addr.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetBridgesByL1Addr(BaseModel): + """ + ReqGetBridgesByL1Addr + """ # noqa: E501 + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["l1_address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetBridgesByL1Addr from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetBridgesByL1Addr from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "l1_address": obj.get("l1_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_by_account.py b/docs/lighter/lighter-python-main/lighter/models/req_get_by_account.py new file mode 100644 index 0000000..9e52c14 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_by_account.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetByAccount(BaseModel): + """ + ReqGetByAccount + """ # noqa: E501 + by: StrictStr + value: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['account_index']): + raise ValueError("must be one of enum values ('account_index')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetByAccount from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetByAccount from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_candlesticks.py b/docs/lighter/lighter-python-main/lighter/models/req_get_candlesticks.py new file mode 100644 index 0000000..33aecbe --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_candlesticks.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetCandlesticks(BaseModel): + """ + ReqGetCandlesticks + """ # noqa: E501 + market_id: StrictInt + resolution: StrictStr + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + count_back: StrictInt + set_timestamp_to_end: Optional[StrictBool] = False + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "resolution", "start_timestamp", "end_timestamp", "count_back", "set_timestamp_to_end"] + + @field_validator('resolution') + def resolution_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['1m', '5m', '15m', '30m', '1h', '4h', '12h', '1d', '1w']): + raise ValueError("must be one of enum values ('1m', '5m', '15m', '30m', '1h', '4h', '12h', '1d', '1w')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetCandlesticks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetCandlesticks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "resolution": obj.get("resolution"), + "start_timestamp": obj.get("start_timestamp"), + "end_timestamp": obj.get("end_timestamp"), + "count_back": obj.get("count_back"), + "set_timestamp_to_end": obj.get("set_timestamp_to_end") if obj.get("set_timestamp_to_end") is not None else False + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_deposit_history.py b/docs/lighter/lighter-python-main/lighter/models/req_get_deposit_history.py new file mode 100644 index 0000000..b51846c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_deposit_history.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetDepositHistory(BaseModel): + """ + ReqGetDepositHistory + """ # noqa: E501 + account_index: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + l1_address: StrictStr + cursor: Optional[StrictStr] = None + filter: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "auth", "l1_address", "cursor", "filter"] + + @field_validator('filter') + def filter_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'pending', 'claimable']): + raise ValueError("must be one of enum values ('all', 'pending', 'claimable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetDepositHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetDepositHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "auth": obj.get("auth"), + "l1_address": obj.get("l1_address"), + "cursor": obj.get("cursor"), + "filter": obj.get("filter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_fast_withdraw_info.py b/docs/lighter/lighter-python-main/lighter/models/req_get_fast_withdraw_info.py new file mode 100644 index 0000000..bced0a8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_fast_withdraw_info.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetFastWithdrawInfo(BaseModel): + """ + ReqGetFastWithdrawInfo + """ # noqa: E501 + account_index: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "auth"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetFastWithdrawInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetFastWithdrawInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "auth": obj.get("auth") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_fundings.py b/docs/lighter/lighter-python-main/lighter/models/req_get_fundings.py new file mode 100644 index 0000000..d2fe9a5 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_fundings.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetFundings(BaseModel): + """ + ReqGetFundings + """ # noqa: E501 + market_id: StrictInt + resolution: StrictStr + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True)] + count_back: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "resolution", "start_timestamp", "end_timestamp", "count_back"] + + @field_validator('resolution') + def resolution_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['1h', '1d']): + raise ValueError("must be one of enum values ('1h', '1d')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetFundings from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetFundings from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "resolution": obj.get("resolution"), + "start_timestamp": obj.get("start_timestamp"), + "end_timestamp": obj.get("end_timestamp"), + "count_back": obj.get("count_back") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_l1_metadata.py b/docs/lighter/lighter-python-main/lighter/models/req_get_l1_metadata.py new file mode 100644 index 0000000..0ce494a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_l1_metadata.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetL1Metadata(BaseModel): + """ + ReqGetL1Metadata + """ # noqa: E501 + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "l1_address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetL1Metadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetL1Metadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "l1_address": obj.get("l1_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_l1_tx.py b/docs/lighter/lighter-python-main/lighter/models/req_get_l1_tx.py new file mode 100644 index 0000000..dda8501 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_l1_tx.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetL1Tx(BaseModel): + """ + ReqGetL1Tx + """ # noqa: E501 + hash: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["hash"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetL1Tx from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetL1Tx from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "hash": obj.get("hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_latest_deposit.py b/docs/lighter/lighter-python-main/lighter/models/req_get_latest_deposit.py new file mode 100644 index 0000000..6ce2506 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_latest_deposit.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetLatestDeposit(BaseModel): + """ + ReqGetLatestDeposit + """ # noqa: E501 + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["l1_address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetLatestDeposit from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetLatestDeposit from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "l1_address": obj.get("l1_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_liquidation_infos.py b/docs/lighter/lighter-python-main/lighter/models/req_get_liquidation_infos.py new file mode 100644 index 0000000..16701b7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_liquidation_infos.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetLiquidationInfos(BaseModel): + """ + ReqGetLiquidationInfos + """ # noqa: E501 + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + account_index: StrictInt + market_id: Optional[StrictInt] = None + cursor: Optional[StrictStr] = None + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index", "market_id", "cursor", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetLiquidationInfos from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetLiquidationInfos from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index"), + "market_id": obj.get("market_id"), + "cursor": obj.get("cursor"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_next_nonce.py b/docs/lighter/lighter-python-main/lighter/models/req_get_next_nonce.py new file mode 100644 index 0000000..90920a0 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_next_nonce.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetNextNonce(BaseModel): + """ + ReqGetNextNonce + """ # noqa: E501 + account_index: StrictInt + api_key_index: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "api_key_index"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetNextNonce from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetNextNonce from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "api_key_index": obj.get("api_key_index") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_details.py b/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_details.py new file mode 100644 index 0000000..a172c1f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_details.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetOrderBookDetails(BaseModel): + """ + ReqGetOrderBookDetails + """ # noqa: E501 + market_id: Optional[StrictInt] = None + filter: Optional[StrictStr] = 'all' + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "filter"] + + @field_validator('filter') + def filter_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'spot', 'perp']): + raise ValueError("must be one of enum values ('all', 'spot', 'perp')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetOrderBookDetails from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetOrderBookDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "filter": obj.get("filter") if obj.get("filter") is not None else 'all' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_orders.py b/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_orders.py new file mode 100644 index 0000000..19c6a71 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_order_book_orders.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetOrderBookOrders(BaseModel): + """ + ReqGetOrderBookOrders + """ # noqa: E501 + market_id: StrictInt + limit: Annotated[int, Field(le=250, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetOrderBookOrders from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetOrderBookOrders from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_order_books.py b/docs/lighter/lighter-python-main/lighter/models/req_get_order_books.py new file mode 100644 index 0000000..d7cd179 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_order_books.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetOrderBooks(BaseModel): + """ + ReqGetOrderBooks + """ # noqa: E501 + market_id: Optional[StrictInt] = None + filter: Optional[StrictStr] = 'all' + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "filter"] + + @field_validator('filter') + def filter_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'spot', 'perp']): + raise ValueError("must be one of enum values ('all', 'spot', 'perp')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetOrderBooks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetOrderBooks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "filter": obj.get("filter") if obj.get("filter") is not None else 'all' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_position_funding.py b/docs/lighter/lighter-python-main/lighter/models/req_get_position_funding.py new file mode 100644 index 0000000..04d07f8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_position_funding.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetPositionFunding(BaseModel): + """ + ReqGetPositionFunding + """ # noqa: E501 + auth: Optional[StrictStr] = None + account_index: StrictInt + market_id: Optional[StrictInt] = None + cursor: Optional[StrictStr] = None + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + side: Optional[StrictStr] = 'all' + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index", "market_id", "cursor", "limit", "side"] + + @field_validator('side') + def side_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['long', 'short', 'all']): + raise ValueError("must be one of enum values ('long', 'short', 'all')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetPositionFunding from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetPositionFunding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index"), + "market_id": obj.get("market_id"), + "cursor": obj.get("cursor"), + "limit": obj.get("limit"), + "side": obj.get("side") if obj.get("side") is not None else 'all' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_public_pools_metadata.py b/docs/lighter/lighter-python-main/lighter/models/req_get_public_pools_metadata.py new file mode 100644 index 0000000..ccb7397 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_public_pools_metadata.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetPublicPoolsMetadata(BaseModel): + """ + ReqGetPublicPoolsMetadata + """ # noqa: E501 + auth: Optional[StrictStr] = None + filter: Optional[StrictStr] = None + index: StrictInt + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + account_index: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "filter", "index", "limit", "account_index"] + + @field_validator('filter') + def filter_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'user', 'protocol', 'account_index']): + raise ValueError("must be one of enum values ('all', 'user', 'protocol', 'account_index')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetPublicPoolsMetadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetPublicPoolsMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "filter": obj.get("filter"), + "index": obj.get("index"), + "limit": obj.get("limit"), + "account_index": obj.get("account_index") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_cursor.py b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_cursor.py new file mode 100644 index 0000000..dc7821e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_cursor.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetRangeWithCursor(BaseModel): + """ + ReqGetRangeWithCursor + """ # noqa: E501 + cursor: Optional[StrictStr] = None + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["cursor", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetRangeWithCursor from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetRangeWithCursor from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cursor": obj.get("cursor"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index.py b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index.py new file mode 100644 index 0000000..e589449 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetRangeWithIndex(BaseModel): + """ + ReqGetRangeWithIndex + """ # noqa: E501 + index: Optional[StrictInt] = None + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["index", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetRangeWithIndex from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetRangeWithIndex from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "index": obj.get("index"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index_sortable.py b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index_sortable.py new file mode 100644 index 0000000..d22bbb2 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_range_with_index_sortable.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetRangeWithIndexSortable(BaseModel): + """ + ReqGetRangeWithIndexSortable + """ # noqa: E501 + index: Optional[StrictInt] = None + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None + sort: Optional[StrictStr] = 'asc' + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["index", "limit", "sort"] + + @field_validator('sort') + def sort_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['asc', 'desc']): + raise ValueError("must be one of enum values ('asc', 'desc')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetRangeWithIndexSortable from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetRangeWithIndexSortable from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "index": obj.get("index"), + "limit": obj.get("limit"), + "sort": obj.get("sort") if obj.get("sort") is not None else 'asc' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_recent_trades.py b/docs/lighter/lighter-python-main/lighter/models/req_get_recent_trades.py new file mode 100644 index 0000000..96dba79 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_recent_trades.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetRecentTrades(BaseModel): + """ + ReqGetRecentTrades + """ # noqa: E501 + market_id: StrictInt + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetRecentTrades from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetRecentTrades from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "limit": obj.get("limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_referral_points.py b/docs/lighter/lighter-python-main/lighter/models/req_get_referral_points.py new file mode 100644 index 0000000..19192ec --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_referral_points.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetReferralPoints(BaseModel): + """ + ReqGetReferralPoints + """ # noqa: E501 + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + account_index: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetReferralPoints from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetReferralPoints from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_trades.py b/docs/lighter/lighter-python-main/lighter/models/req_get_trades.py new file mode 100644 index 0000000..60a8b90 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_trades.py @@ -0,0 +1,162 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetTrades(BaseModel): + """ + ReqGetTrades + """ # noqa: E501 + auth: Optional[StrictStr] = None + market_id: Optional[StrictInt] = None + account_index: Optional[StrictInt] = -1 + order_index: Optional[StrictInt] = None + sort_by: StrictStr + sort_dir: Optional[StrictStr] = 'desc' + cursor: Optional[StrictStr] = None + var_from: Optional[StrictInt] = Field(default=-1, alias="from") + ask_filter: Optional[StrictInt] = None + role: Optional[StrictStr] = 'all' + type: Optional[StrictStr] = 'all' + limit: Annotated[int, Field(le=100, strict=True, ge=1)] + aggregate: Optional[StrictBool] = False + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "market_id", "account_index", "order_index", "sort_by", "sort_dir", "cursor", "from", "ask_filter", "role", "type", "limit", "aggregate"] + + @field_validator('sort_by') + def sort_by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['block_height', 'timestamp', 'trade_id']): + raise ValueError("must be one of enum values ('block_height', 'timestamp', 'trade_id')") + return value + + @field_validator('sort_dir') + def sort_dir_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['desc']): + raise ValueError("must be one of enum values ('desc')") + return value + + @field_validator('role') + def role_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'maker', 'taker']): + raise ValueError("must be one of enum values ('all', 'maker', 'taker')") + return value + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'trade', 'liquidation', 'deleverage', 'market-settlement']): + raise ValueError("must be one of enum values ('all', 'trade', 'liquidation', 'deleverage', 'market-settlement')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetTrades from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetTrades from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "market_id": obj.get("market_id"), + "account_index": obj.get("account_index") if obj.get("account_index") is not None else -1, + "order_index": obj.get("order_index"), + "sort_by": obj.get("sort_by"), + "sort_dir": obj.get("sort_dir") if obj.get("sort_dir") is not None else 'desc', + "cursor": obj.get("cursor"), + "from": obj.get("from") if obj.get("from") is not None else -1, + "ask_filter": obj.get("ask_filter"), + "role": obj.get("role") if obj.get("role") is not None else 'all', + "type": obj.get("type") if obj.get("type") is not None else 'all', + "limit": obj.get("limit"), + "aggregate": obj.get("aggregate") if obj.get("aggregate") is not None else False + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_fee_info.py b/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_fee_info.py new file mode 100644 index 0000000..1d053be --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_fee_info.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetTransferFeeInfo(BaseModel): + """ + ReqGetTransferFeeInfo + """ # noqa: E501 + auth: Optional[StrictStr] = None + account_index: StrictInt + to_account_index: Optional[StrictInt] = -1 + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["auth", "account_index", "to_account_index"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetTransferFeeInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetTransferFeeInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "auth": obj.get("auth"), + "account_index": obj.get("account_index"), + "to_account_index": obj.get("to_account_index") if obj.get("to_account_index") is not None else -1 + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_history.py b/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_history.py new file mode 100644 index 0000000..b6b75ba --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_transfer_history.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetTransferHistory(BaseModel): + """ + ReqGetTransferHistory + """ # noqa: E501 + account_index: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + cursor: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "auth", "cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetTransferHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetTransferHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "auth": obj.get("auth"), + "cursor": obj.get("cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_tx.py b/docs/lighter/lighter-python-main/lighter/models/req_get_tx.py new file mode 100644 index 0000000..275c4ff --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_tx.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetTx(BaseModel): + """ + ReqGetTx + """ # noqa: E501 + by: StrictStr + value: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["by", "value"] + + @field_validator('by') + def by_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['hash', 'sequence_index']): + raise ValueError("must be one of enum values ('hash', 'sequence_index')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetTx from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetTx from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "by": obj.get("by"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/req_get_withdraw_history.py b/docs/lighter/lighter-python-main/lighter/models/req_get_withdraw_history.py new file mode 100644 index 0000000..ecd05c7 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/req_get_withdraw_history.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ReqGetWithdrawHistory(BaseModel): + """ + ReqGetWithdrawHistory + """ # noqa: E501 + account_index: StrictInt + auth: Optional[StrictStr] = Field(default=None, description=" made optional to support header auth clients") + cursor: Optional[StrictStr] = None + filter: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["account_index", "auth", "cursor", "filter"] + + @field_validator('filter') + def filter_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'pending', 'claimable']): + raise ValueError("must be one of enum values ('all', 'pending', 'claimable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ReqGetWithdrawHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ReqGetWithdrawHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "account_index": obj.get("account_index"), + "auth": obj.get("auth"), + "cursor": obj.get("cursor"), + "filter": obj.get("filter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_change_account_tier.py b/docs/lighter/lighter-python-main/lighter/models/resp_change_account_tier.py new file mode 100644 index 0000000..35b6c15 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_change_account_tier.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespChangeAccountTier(BaseModel): + """ + RespChangeAccountTier + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespChangeAccountTier from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespChangeAccountTier from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_get_bridges_by_l1_addr.py b/docs/lighter/lighter-python-main/lighter/models/resp_get_bridges_by_l1_addr.py new file mode 100644 index 0000000..8d8961f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_get_bridges_by_l1_addr.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.bridge import Bridge +from typing import Optional, Set +from typing_extensions import Self + +class RespGetBridgesByL1Addr(BaseModel): + """ + RespGetBridgesByL1Addr + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + bridges: List[Bridge] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "bridges"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespGetBridgesByL1Addr from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in bridges (list) + _items = [] + if self.bridges: + for _item in self.bridges: + if _item: + _items.append(_item.to_dict()) + _dict['bridges'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespGetBridgesByL1Addr from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "bridges": [Bridge.from_dict(_item) for _item in obj["bridges"]] if obj.get("bridges") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_get_fast_bridge_info.py b/docs/lighter/lighter-python-main/lighter/models/resp_get_fast_bridge_info.py new file mode 100644 index 0000000..baf3922 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_get_fast_bridge_info.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespGetFastBridgeInfo(BaseModel): + """ + RespGetFastBridgeInfo + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + fast_bridge_limit: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "fast_bridge_limit"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespGetFastBridgeInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespGetFastBridgeInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "fast_bridge_limit": obj.get("fast_bridge_limit") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_get_is_next_bridge_fast.py b/docs/lighter/lighter-python-main/lighter/models/resp_get_is_next_bridge_fast.py new file mode 100644 index 0000000..31496a5 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_get_is_next_bridge_fast.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespGetIsNextBridgeFast(BaseModel): + """ + RespGetIsNextBridgeFast + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + is_next_bridge_fast: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "is_next_bridge_fast"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespGetIsNextBridgeFast from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespGetIsNextBridgeFast from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "is_next_bridge_fast": obj.get("is_next_bridge_fast") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_public_pools_metadata.py b/docs/lighter/lighter-python-main/lighter/models/resp_public_pools_metadata.py new file mode 100644 index 0000000..0719da8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_public_pools_metadata.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.public_pool_metadata import PublicPoolMetadata +from typing import Optional, Set +from typing_extensions import Self + +class RespPublicPoolsMetadata(BaseModel): + """ + RespPublicPoolsMetadata + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + public_pools: List[PublicPoolMetadata] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "public_pools"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespPublicPoolsMetadata from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in public_pools (list) + _items = [] + if self.public_pools: + for _item in self.public_pools: + if _item: + _items.append(_item.to_dict()) + _dict['public_pools'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespPublicPoolsMetadata from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "public_pools": [PublicPoolMetadata.from_dict(_item) for _item in obj["public_pools"]] if obj.get("public_pools") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_send_tx.py b/docs/lighter/lighter-python-main/lighter/models/resp_send_tx.py new file mode 100644 index 0000000..7a52c88 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_send_tx.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespSendTx(BaseModel): + """ + RespSendTx + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + tx_hash: StrictStr + predicted_execution_time_ms: StrictInt + volume_quota_remaining: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms", "volume_quota_remaining"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespSendTx from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespSendTx from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "tx_hash": obj.get("tx_hash"), + "predicted_execution_time_ms": obj.get("predicted_execution_time_ms"), + "volume_quota_remaining": obj.get("volume_quota_remaining") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_send_tx_batch.py b/docs/lighter/lighter-python-main/lighter/models/resp_send_tx_batch.py new file mode 100644 index 0000000..33b3d3d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_send_tx_batch.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespSendTxBatch(BaseModel): + """ + RespSendTxBatch + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + tx_hash: List[StrictStr] + predicted_execution_time_ms: StrictInt + volume_quota_remaining: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms", "volume_quota_remaining"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespSendTxBatch from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespSendTxBatch from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "tx_hash": obj.get("tx_hash"), + "predicted_execution_time_ms": obj.get("predicted_execution_time_ms"), + "volume_quota_remaining": obj.get("volume_quota_remaining") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_update_kickback.py b/docs/lighter/lighter-python-main/lighter/models/resp_update_kickback.py new file mode 100644 index 0000000..308cb5c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_update_kickback.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespUpdateKickback(BaseModel): + """ + RespUpdateKickback + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + success: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "success"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespUpdateKickback from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespUpdateKickback from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "success": obj.get("success") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_update_referral_code.py b/docs/lighter/lighter-python-main/lighter/models/resp_update_referral_code.py new file mode 100644 index 0000000..c1f215f --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_update_referral_code.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespUpdateReferralCode(BaseModel): + """ + RespUpdateReferralCode + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + success: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "success"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespUpdateReferralCode from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespUpdateReferralCode from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "success": obj.get("success") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/resp_withdrawal_delay.py b/docs/lighter/lighter-python-main/lighter/models/resp_withdrawal_delay.py new file mode 100644 index 0000000..3add899 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/resp_withdrawal_delay.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class RespWithdrawalDelay(BaseModel): + """ + RespWithdrawalDelay + """ # noqa: E501 + seconds: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["seconds"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RespWithdrawalDelay from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RespWithdrawalDelay from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "seconds": obj.get("seconds") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/result_code.py b/docs/lighter/lighter-python-main/lighter/models/result_code.py new file mode 100644 index 0000000..a29a276 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/result_code.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ResultCode(BaseModel): + """ + ResultCode + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ResultCode from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ResultCode from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/risk_info.py b/docs/lighter/lighter-python-main/lighter/models/risk_info.py new file mode 100644 index 0000000..93d571e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/risk_info.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from lighter.models.risk_parameters import RiskParameters +from typing import Optional, Set +from typing_extensions import Self + +class RiskInfo(BaseModel): + """ + RiskInfo + """ # noqa: E501 + cross_risk_parameters: RiskParameters + isolated_risk_parameters: List[RiskParameters] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["cross_risk_parameters", "isolated_risk_parameters"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RiskInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of cross_risk_parameters + if self.cross_risk_parameters: + _dict['cross_risk_parameters'] = self.cross_risk_parameters.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in isolated_risk_parameters (list) + _items = [] + if self.isolated_risk_parameters: + for _item in self.isolated_risk_parameters: + if _item: + _items.append(_item.to_dict()) + _dict['isolated_risk_parameters'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RiskInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cross_risk_parameters": RiskParameters.from_dict(obj["cross_risk_parameters"]) if obj.get("cross_risk_parameters") is not None else None, + "isolated_risk_parameters": [RiskParameters.from_dict(_item) for _item in obj["isolated_risk_parameters"]] if obj.get("isolated_risk_parameters") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/risk_parameters.py b/docs/lighter/lighter-python-main/lighter/models/risk_parameters.py new file mode 100644 index 0000000..2084032 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/risk_parameters.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class RiskParameters(BaseModel): + """ + RiskParameters + """ # noqa: E501 + market_id: StrictInt + collateral: StrictStr + total_account_value: StrictStr + initial_margin_req: StrictStr + maintenance_margin_req: StrictStr + close_out_margin_req: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_id", "collateral", "total_account_value", "initial_margin_req", "maintenance_margin_req", "close_out_margin_req"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of RiskParameters from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of RiskParameters from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_id": obj.get("market_id"), + "collateral": obj.get("collateral"), + "total_account_value": obj.get("total_account_value"), + "initial_margin_req": obj.get("initial_margin_req"), + "maintenance_margin_req": obj.get("maintenance_margin_req"), + "close_out_margin_req": obj.get("close_out_margin_req") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/share_price.py b/docs/lighter/lighter-python-main/lighter/models/share_price.py new file mode 100644 index 0000000..6f347b4 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/share_price.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class SharePrice(BaseModel): + """ + SharePrice + """ # noqa: E501 + timestamp: StrictInt + share_price: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["timestamp", "share_price"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SharePrice from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SharePrice from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "timestamp": obj.get("timestamp"), + "share_price": obj.get("share_price") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/simple_order.py b/docs/lighter/lighter-python-main/lighter/models/simple_order.py new file mode 100644 index 0000000..a10be5d --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/simple_order.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class SimpleOrder(BaseModel): + """ + SimpleOrder + """ # noqa: E501 + order_index: StrictInt + order_id: StrictStr + owner_account_index: StrictInt + initial_base_amount: StrictStr + remaining_base_amount: StrictStr + price: StrictStr + order_expiry: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["order_index", "order_id", "owner_account_index", "initial_base_amount", "remaining_base_amount", "price", "order_expiry"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SimpleOrder from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SimpleOrder from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "order_index": obj.get("order_index"), + "order_id": obj.get("order_id"), + "owner_account_index": obj.get("owner_account_index"), + "initial_base_amount": obj.get("initial_base_amount"), + "remaining_base_amount": obj.get("remaining_base_amount"), + "price": obj.get("price"), + "order_expiry": obj.get("order_expiry") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/spot_market_stats.py b/docs/lighter/lighter-python-main/lighter/models/spot_market_stats.py new file mode 100644 index 0000000..c060462 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/spot_market_stats.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class SpotMarketStats(BaseModel): + """ + SpotMarketStats + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + index_price: StrictStr + mid_price: StrictStr + last_trade_price: StrictStr + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + daily_price_low: Union[StrictFloat, StrictInt] + daily_price_high: Union[StrictFloat, StrictInt] + daily_price_change: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "index_price", "mid_price", "last_trade_price", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SpotMarketStats from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SpotMarketStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "index_price": obj.get("index_price"), + "mid_price": obj.get("mid_price"), + "last_trade_price": obj.get("last_trade_price"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "daily_price_low": obj.get("daily_price_low"), + "daily_price_high": obj.get("daily_price_high"), + "daily_price_change": obj.get("daily_price_change") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/spot_order_book_detail.py b/docs/lighter/lighter-python-main/lighter/models/spot_order_book_detail.py new file mode 100644 index 0000000..70cd0d8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/spot_order_book_detail.py @@ -0,0 +1,162 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class SpotOrderBookDetail(BaseModel): + """ + SpotOrderBookDetail + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt + status: StrictStr + taker_fee: StrictStr + maker_fee: StrictStr + liquidation_fee: StrictStr + min_base_amount: StrictStr + min_quote_amount: StrictStr + order_quote_limit: StrictStr + supported_size_decimals: StrictInt + supported_price_decimals: StrictInt + supported_quote_decimals: StrictInt + size_decimals: StrictInt + price_decimals: StrictInt + last_trade_price: Union[StrictFloat, StrictInt] + daily_trades_count: StrictInt + daily_base_token_volume: Union[StrictFloat, StrictInt] + daily_quote_token_volume: Union[StrictFloat, StrictInt] + daily_price_low: Union[StrictFloat, StrictInt] + daily_price_high: Union[StrictFloat, StrictInt] + daily_price_change: Union[StrictFloat, StrictInt] + daily_chart: Dict[str, Union[StrictFloat, StrictInt]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals", "size_decimals", "price_decimals", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change", "daily_chart"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SpotOrderBookDetail from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SpotOrderBookDetail from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), + "status": obj.get("status"), + "taker_fee": obj.get("taker_fee"), + "maker_fee": obj.get("maker_fee"), + "liquidation_fee": obj.get("liquidation_fee"), + "min_base_amount": obj.get("min_base_amount"), + "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), + "supported_size_decimals": obj.get("supported_size_decimals"), + "supported_price_decimals": obj.get("supported_price_decimals"), + "supported_quote_decimals": obj.get("supported_quote_decimals"), + "size_decimals": obj.get("size_decimals"), + "price_decimals": obj.get("price_decimals"), + "last_trade_price": obj.get("last_trade_price"), + "daily_trades_count": obj.get("daily_trades_count"), + "daily_base_token_volume": obj.get("daily_base_token_volume"), + "daily_quote_token_volume": obj.get("daily_quote_token_volume"), + "daily_price_low": obj.get("daily_price_low"), + "daily_price_high": obj.get("daily_price_high"), + "daily_price_change": obj.get("daily_price_change"), + "daily_chart": obj.get("daily_chart") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/status.py b/docs/lighter/lighter-python-main/lighter/models/status.py new file mode 100644 index 0000000..d2026f0 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/status.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Status(BaseModel): + """ + Status + """ # noqa: E501 + status: StrictInt + network_id: StrictInt + timestamp: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["status", "network_id", "timestamp"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Status from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Status from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "status": obj.get("status"), + "network_id": obj.get("network_id"), + "timestamp": obj.get("timestamp") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/sub_accounts.py b/docs/lighter/lighter-python-main/lighter/models/sub_accounts.py new file mode 100644 index 0000000..76f4c0c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/sub_accounts.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.account import Account +from typing import Optional, Set +from typing_extensions import Self + +class SubAccounts(BaseModel): + """ + SubAccounts + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + l1_address: StrictStr + sub_accounts: List[Account] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "l1_address", "sub_accounts"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SubAccounts from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in sub_accounts (list) + _items = [] + if self.sub_accounts: + for _item in self.sub_accounts: + if _item: + _items.append(_item.to_dict()) + _dict['sub_accounts'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SubAccounts from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "l1_address": obj.get("l1_address"), + "sub_accounts": [Account.from_dict(_item) for _item in obj["sub_accounts"]] if obj.get("sub_accounts") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/ticker.py b/docs/lighter/lighter-python-main/lighter/models/ticker.py new file mode 100644 index 0000000..96a5cd4 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/ticker.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from lighter.models.price_level import PriceLevel +from typing import Optional, Set +from typing_extensions import Self + +class Ticker(BaseModel): + """ + Ticker + """ # noqa: E501 + s: StrictStr + a: PriceLevel + b: PriceLevel + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["s", "a", "b"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Ticker from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of a + if self.a: + _dict['a'] = self.a.to_dict() + # override the default output from pydantic by calling `to_dict()` of b + if self.b: + _dict['b'] = self.b.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Ticker from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "s": obj.get("s"), + "a": PriceLevel.from_dict(obj["a"]) if obj.get("a") is not None else None, + "b": PriceLevel.from_dict(obj["b"]) if obj.get("b") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/trade.py b/docs/lighter/lighter-python-main/lighter/models/trade.py new file mode 100644 index 0000000..a8c1de4 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/trade.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Trade(BaseModel): + """ + Trade + """ # noqa: E501 + trade_id: StrictInt + tx_hash: StrictStr + type: StrictStr + market_id: StrictInt + size: StrictStr + price: StrictStr + usd_amount: StrictStr + ask_id: StrictInt + bid_id: StrictInt + ask_client_id: StrictInt + bid_client_id: StrictInt + ask_account_id: StrictInt + bid_account_id: StrictInt + is_maker_ask: StrictBool + block_height: StrictInt + timestamp: StrictInt + taker_fee: Optional[StrictInt] + taker_position_size_before: StrictStr + taker_entry_quote_before: StrictStr + taker_initial_margin_fraction_before: Optional[StrictInt] + taker_position_sign_changed: Optional[StrictBool] + maker_fee: Optional[StrictInt] + maker_position_size_before: StrictStr + maker_entry_quote_before: StrictStr + maker_initial_margin_fraction_before: Optional[StrictInt] + maker_position_sign_changed: Optional[StrictBool] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["trade_id", "tx_hash", "type", "market_id", "size", "price", "usd_amount", "ask_id", "bid_id", "ask_client_id", "bid_client_id", "ask_account_id", "bid_account_id", "is_maker_ask", "block_height", "timestamp", "taker_fee", "taker_position_size_before", "taker_entry_quote_before", "taker_initial_margin_fraction_before", "taker_position_sign_changed", "maker_fee", "maker_position_size_before", "maker_entry_quote_before", "maker_initial_margin_fraction_before", "maker_position_sign_changed"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['trade', 'liquidation', 'deleverage', 'market-settlement']): + raise ValueError("must be one of enum values ('trade', 'liquidation', 'deleverage', 'market-settlement')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Trade from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Trade from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "trade_id": obj.get("trade_id"), + "tx_hash": obj.get("tx_hash"), + "type": obj.get("type"), + "market_id": obj.get("market_id"), + "size": obj.get("size"), + "price": obj.get("price"), + "usd_amount": obj.get("usd_amount"), + "ask_id": obj.get("ask_id"), + "bid_id": obj.get("bid_id"), + "ask_client_id": obj.get("ask_client_id"), + "bid_client_id": obj.get("bid_client_id"), + "ask_account_id": obj.get("ask_account_id"), + "bid_account_id": obj.get("bid_account_id"), + "is_maker_ask": obj.get("is_maker_ask"), + "block_height": obj.get("block_height"), + "timestamp": obj.get("timestamp"), + "taker_fee": obj.get("taker_fee"), + "taker_position_size_before": obj.get("taker_position_size_before"), + "taker_entry_quote_before": obj.get("taker_entry_quote_before"), + "taker_initial_margin_fraction_before": obj.get("taker_initial_margin_fraction_before"), + "taker_position_sign_changed": obj.get("taker_position_sign_changed"), + "maker_fee": obj.get("maker_fee"), + "maker_position_size_before": obj.get("maker_position_size_before"), + "maker_entry_quote_before": obj.get("maker_entry_quote_before"), + "maker_initial_margin_fraction_before": obj.get("maker_initial_margin_fraction_before"), + "maker_position_sign_changed": obj.get("maker_position_sign_changed") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/trades.py b/docs/lighter/lighter-python-main/lighter/models/trades.py new file mode 100644 index 0000000..ea2097a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/trades.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.trade import Trade +from typing import Optional, Set +from typing_extensions import Self + +class Trades(BaseModel): + """ + Trades + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + next_cursor: Optional[StrictStr] = None + trades: List[Trade] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "next_cursor", "trades"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Trades from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in trades (list) + _items = [] + if self.trades: + for _item in self.trades: + if _item: + _items.append(_item.to_dict()) + _dict['trades'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Trades from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "next_cursor": obj.get("next_cursor"), + "trades": [Trade.from_dict(_item) for _item in obj["trades"]] if obj.get("trades") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/transfer_fee_info.py b/docs/lighter/lighter-python-main/lighter/models/transfer_fee_info.py new file mode 100644 index 0000000..b4ee332 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/transfer_fee_info.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class TransferFeeInfo(BaseModel): + """ + TransferFeeInfo + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + transfer_fee_usdc: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "transfer_fee_usdc"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of TransferFeeInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TransferFeeInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "transfer_fee_usdc": obj.get("transfer_fee_usdc") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/transfer_history.py b/docs/lighter/lighter-python-main/lighter/models/transfer_history.py new file mode 100644 index 0000000..9c415e6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/transfer_history.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.transfer_history_item import TransferHistoryItem +from typing import Optional, Set +from typing_extensions import Self + +class TransferHistory(BaseModel): + """ + TransferHistory + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + transfers: List[TransferHistoryItem] + cursor: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "transfers", "cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of TransferHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in transfers (list) + _items = [] + if self.transfers: + for _item in self.transfers: + if _item: + _items.append(_item.to_dict()) + _dict['transfers'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TransferHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "transfers": [TransferHistoryItem.from_dict(_item) for _item in obj["transfers"]] if obj.get("transfers") is not None else None, + "cursor": obj.get("cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/transfer_history_item.py b/docs/lighter/lighter-python-main/lighter/models/transfer_history_item.py new file mode 100644 index 0000000..5edf41c --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/transfer_history_item.py @@ -0,0 +1,143 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class TransferHistoryItem(BaseModel): + """ + TransferHistoryItem + """ # noqa: E501 + id: StrictStr + asset_id: StrictInt + amount: StrictStr + timestamp: StrictInt + type: StrictStr + from_l1_address: StrictStr + to_l1_address: StrictStr + from_account_index: StrictInt + to_account_index: StrictInt + from_route: StrictStr + to_route: StrictStr + tx_hash: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "type", "from_l1_address", "to_l1_address", "from_account_index", "to_account_index", "from_route", "to_route", "tx_hash"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['L2TransferInflow', 'L2TransferOutflow', 'L2BurnSharesInflow', 'L2BurnSharesOutflow', 'L2MintSharesInflow', 'L2MintSharesOutflow', 'L2SelfTransfer']): + raise ValueError("must be one of enum values ('L2TransferInflow', 'L2TransferOutflow', 'L2BurnSharesInflow', 'L2BurnSharesOutflow', 'L2MintSharesInflow', 'L2MintSharesOutflow', 'L2SelfTransfer')") + return value + + @field_validator('from_route') + def from_route_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['spot', 'perps']): + raise ValueError("must be one of enum values ('spot', 'perps')") + return value + + @field_validator('to_route') + def to_route_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['spot', 'perps']): + raise ValueError("must be one of enum values ('spot', 'perps')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of TransferHistoryItem from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TransferHistoryItem from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "asset_id": obj.get("asset_id"), + "amount": obj.get("amount"), + "timestamp": obj.get("timestamp"), + "type": obj.get("type"), + "from_l1_address": obj.get("from_l1_address"), + "to_l1_address": obj.get("to_l1_address"), + "from_account_index": obj.get("from_account_index"), + "to_account_index": obj.get("to_account_index"), + "from_route": obj.get("from_route"), + "to_route": obj.get("to_route"), + "tx_hash": obj.get("tx_hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/tx.py b/docs/lighter/lighter-python-main/lighter/models/tx.py new file mode 100644 index 0000000..be33ff6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/tx.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class Tx(BaseModel): + """ + Tx + """ # noqa: E501 + hash: StrictStr + type: Annotated[int, Field(le=64, strict=True, ge=1)] + info: StrictStr + event_info: StrictStr + status: StrictInt + transaction_index: StrictInt + l1_address: StrictStr + account_index: StrictInt + nonce: StrictInt + expire_at: StrictInt + block_height: StrictInt + queued_at: StrictInt + executed_at: StrictInt + sequence_index: StrictInt + parent_hash: StrictStr + api_key_index: StrictInt + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash", "api_key_index"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Tx from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Tx from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "hash": obj.get("hash"), + "type": obj.get("type"), + "info": obj.get("info"), + "event_info": obj.get("event_info"), + "status": obj.get("status"), + "transaction_index": obj.get("transaction_index"), + "l1_address": obj.get("l1_address"), + "account_index": obj.get("account_index"), + "nonce": obj.get("nonce"), + "expire_at": obj.get("expire_at"), + "block_height": obj.get("block_height"), + "queued_at": obj.get("queued_at"), + "executed_at": obj.get("executed_at"), + "sequence_index": obj.get("sequence_index"), + "parent_hash": obj.get("parent_hash"), + "api_key_index": obj.get("api_key_index") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/tx_hash.py b/docs/lighter/lighter-python-main/lighter/models/tx_hash.py new file mode 100644 index 0000000..86cb1ed --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/tx_hash.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class TxHash(BaseModel): + """ + TxHash + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + tx_hash: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of TxHash from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TxHash from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "tx_hash": obj.get("tx_hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/tx_hashes.py b/docs/lighter/lighter-python-main/lighter/models/tx_hashes.py new file mode 100644 index 0000000..807aa59 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/tx_hashes.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class TxHashes(BaseModel): + """ + TxHashes + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + tx_hash: List[StrictStr] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of TxHashes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of TxHashes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "tx_hash": obj.get("tx_hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/txs.py b/docs/lighter/lighter-python-main/lighter/models/txs.py new file mode 100644 index 0000000..8beafb5 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/txs.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.tx import Tx +from typing import Optional, Set +from typing_extensions import Self + +class Txs(BaseModel): + """ + Txs + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + txs: List[Tx] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "txs"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Txs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in txs (list) + _items = [] + if self.txs: + for _item in self.txs: + if _item: + _items.append(_item.to_dict()) + _dict['txs'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Txs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "txs": [Tx.from_dict(_item) for _item in obj["txs"]] if obj.get("txs") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/validator_info.py b/docs/lighter/lighter-python-main/lighter/models/validator_info.py new file mode 100644 index 0000000..ca08bdf --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/validator_info.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ValidatorInfo(BaseModel): + """ + ValidatorInfo + """ # noqa: E501 + address: StrictStr + is_active: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["address", "is_active"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ValidatorInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ValidatorInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "address": obj.get("address"), + "is_active": obj.get("is_active") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/withdraw_history.py b/docs/lighter/lighter-python-main/lighter/models/withdraw_history.py new file mode 100644 index 0000000..cdcb8c1 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/withdraw_history.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.withdraw_history_item import WithdrawHistoryItem +from typing import Optional, Set +from typing_extensions import Self + +class WithdrawHistory(BaseModel): + """ + WithdrawHistory + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + withdraws: List[WithdrawHistoryItem] + cursor: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "withdraws", "cursor"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WithdrawHistory from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in withdraws (list) + _items = [] + if self.withdraws: + for _item in self.withdraws: + if _item: + _items.append(_item.to_dict()) + _dict['withdraws'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WithdrawHistory from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "message": obj.get("message"), + "withdraws": [WithdrawHistoryItem.from_dict(_item) for _item in obj["withdraws"]] if obj.get("withdraws") is not None else None, + "cursor": obj.get("cursor") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/withdraw_history_item.py b/docs/lighter/lighter-python-main/lighter/models/withdraw_history_item.py new file mode 100644 index 0000000..abb5596 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/withdraw_history_item.py @@ -0,0 +1,126 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class WithdrawHistoryItem(BaseModel): + """ + WithdrawHistoryItem + """ # noqa: E501 + id: StrictStr + asset_id: StrictInt + amount: StrictStr + timestamp: StrictInt + status: StrictStr + type: StrictStr + l1_tx_hash: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "status", "type", "l1_tx_hash"] + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['failed', 'pending', 'claimable', 'refunded', 'completed']): + raise ValueError("must be one of enum values ('failed', 'pending', 'claimable', 'refunded', 'completed')") + return value + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['secure', 'fast']): + raise ValueError("must be one of enum values ('secure', 'fast')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WithdrawHistoryItem from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WithdrawHistoryItem from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "asset_id": obj.get("asset_id"), + "amount": obj.get("amount"), + "timestamp": obj.get("timestamp"), + "status": obj.get("status"), + "type": obj.get("type"), + "l1_tx_hash": obj.get("l1_tx_hash") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/models/ws_account_assets.py b/docs/lighter/lighter-python-main/lighter/models/ws_account_assets.py new file mode 100644 index 0000000..03520dd --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/ws_account_assets.py @@ -0,0 +1,86 @@ +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from lighter.models.account_asset import AccountAsset +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, Field +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set + +class WSAccountAssets(BaseModel): + type: StrictStr + channel: StrictStr + assets: Dict[StrictStr, AccountAsset] + account_id: StrictInt + + additional_properties: Dict[str, Any] = Field(default_factory=dict) + __properties: ClassVar[List[str]] = ["type", "channel", "assets"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional["WSAccountAssets"]: + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + excluded_fields: Set[str] = {"additional_properties"} + + # dump base fields + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + + # add extra fields + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional["WSAccountAssets"]: + if obj["type"] != "subscribed/account_all_assets" and obj["type"] != "update/account_all_assets": + raise ValueError(f"invalid type {obj['type']} for WSAccountAssets") + + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + # parse inner assets dict into AccountAsset objects + raw_assets = obj.get("assets") or {} + parsed_assets: Dict[str, AccountAsset] = { + k: AccountAsset.from_dict(v) for k, v in raw_assets.items() + } + + account_id = int(obj.get("channel").split(":")[1]) + + _obj = cls.model_validate( + { + "type": obj.get("type"), + "channel": obj.get("channel"), + "assets": parsed_assets, + "account_id": account_id + } + ) + + # store additional fields + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/lighter/models/zk_lighter_info.py b/docs/lighter/lighter-python-main/lighter/models/zk_lighter_info.py new file mode 100644 index 0000000..81fcb14 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/models/zk_lighter_info.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ZkLighterInfo(BaseModel): + """ + ZkLighterInfo + """ # noqa: E501 + contract_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["contract_address"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ZkLighterInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ZkLighterInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "contract_address": obj.get("contract_address") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/docs/lighter/lighter-python-main/lighter/nonce_manager.py b/docs/lighter/lighter-python-main/lighter/nonce_manager.py new file mode 100644 index 0000000..c2c6db6 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/nonce_manager.py @@ -0,0 +1,123 @@ +import abc +import enum +from typing import Optional, Tuple, List + +import requests + +from lighter.api_client import ApiClient +from lighter.errors import ValidationError + + +def get_nonce_from_api(client: ApiClient, account_index: int, api_key: int) -> int: + # uses request to avoid async initialization + req = requests.get( + client.configuration.host + "/api/v1/nextNonce", + params={"account_index": account_index, "api_key_index": api_key}, + ) + if req.status_code != 200: + raise Exception(f"couldn't get nonce {req.content}") + return req.json()["nonce"] + + +class NonceManager(abc.ABC): + def __init__( + self, + account_index: int, + api_client: ApiClient, + api_keys_list: List[int], + ): + if len(api_keys_list) == 0: + raise ValidationError(f"No API Key provided") + + self.current = 0 # cycle through api keys + self.account_index = account_index + self.api_client = api_client + self.api_keys_list = api_keys_list + self.nonce = { + api_keys_list[i]: get_nonce_from_api(api_client, account_index, api_keys_list[i]) - 1 + for i in range(len(api_keys_list)) + } + + def refresh_nonce(self, api_key: int) -> int: + self.nonce[api_key] = get_nonce_from_api(self.api_client, self.account_index, api_key) + return self.nonce[api_key] + + def hard_refresh_nonce(self, api_key: int): + self.nonce[api_key] = get_nonce_from_api(self.api_client, self.account_index, api_key) - 1 + + @abc.abstractmethod + def next_nonce(self, api_key: Optional[int] = None) -> Tuple[int, int]: + pass + + def acknowledge_failure(self, api_key: int) -> None: + pass + + +class OptimisticNonceManager(NonceManager): + def __init__( + self, + account_index: int, + api_client: ApiClient, + api_keys_list: List[int] + ) -> None: + super().__init__(account_index, api_client, api_keys_list) + + def next_nonce(self, api_key: Optional[int] = None) -> Tuple[int, int]: + if api_key is None: + self.current = (self.current + 1) % len(self.api_keys_list) + api_key = self.api_keys_list[self.current] + + self.nonce[api_key] += 1 + return api_key, self.nonce[api_key] + + def acknowledge_failure(self, api_key: int) -> None: + self.nonce[api_key] -= 1 + + +class ApiNonceManager(NonceManager): + def __init__( + self, + account_index: int, + api_client: ApiClient, + api_keys_list: List[int], + ) -> None: + super().__init__(account_index, api_client, api_keys_list) + + def next_nonce(self, api_key: Optional[int] = None) -> Tuple[int, int]: + """ + It is recommended to wait at least 350ms before using the same api key. + Please be mindful of your transaction frequency when using this nonce manager. + predicted_execution_time_ms from the response could give you a tighter bound. + """ + if api_key is None: + self.current = (self.current + 1) % len(self.api_keys_list) + api_key = self.api_keys_list[self.current] + + nonce = self.refresh_nonce(api_key) + return api_key, nonce + + +class NonceManagerType(enum.Enum): + OPTIMISTIC = 1 + API = 2 + + +def nonce_manager_factory( + nonce_manager_type: NonceManagerType, + account_index: int, + api_client: ApiClient, + api_keys_list: List[int], +) -> NonceManager: + if nonce_manager_type == NonceManagerType.OPTIMISTIC: + return OptimisticNonceManager( + account_index=account_index, + api_client=api_client, + api_keys_list=api_keys_list, + ) + elif nonce_manager_type == NonceManagerType.API: + return ApiNonceManager( + account_index=account_index, + api_client=api_client, + api_keys_list=api_keys_list, + ) + raise ValidationError("invalid nonce manager type") diff --git a/docs/lighter/lighter-python-main/lighter/py.typed b/docs/lighter/lighter-python-main/lighter/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/docs/lighter/lighter-python-main/lighter/rest.py b/docs/lighter/lighter-python-main/lighter/rest.py new file mode 100644 index 0000000..e996812 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/rest.py @@ -0,0 +1,215 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import io +import json +import re +import ssl +from typing import Optional, Union + +import aiohttp +import aiohttp_retry + +from lighter.exceptions import ApiException, ApiValueError + +RESTResponseType = aiohttp.ClientResponse + +ALLOW_RETRY_METHODS = frozenset({'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE'}) + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status + self.reason = resp.reason + self.data = None + + async def read(self): + if self.data is None: + self.data = await self.response.read() + return self.data + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration) -> None: + + # maxsize is number of requests to host that are allowed in parallel + maxsize = configuration.connection_pool_maxsize + + ssl_context = ssl.create_default_context( + cafile=configuration.ssl_ca_cert + ) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + + connector = aiohttp.TCPConnector( + limit=maxsize, + ssl=ssl_context + ) + + self.proxy = configuration.proxy + self.proxy_headers = configuration.proxy_headers + + # https pool manager + self.pool_manager = aiohttp.ClientSession( + connector=connector, + trust_env=True + ) + + retries = configuration.retries + self.retry_client: Optional[aiohttp_retry.RetryClient] + if retries is not None: + self.retry_client = aiohttp_retry.RetryClient( + client_session=self.pool_manager, + retry_options=aiohttp_retry.ExponentialRetry( + attempts=retries, + factor=0.0, + start_timeout=0.0, + max_timeout=120.0 + ) + ) + else: + self.retry_client = None + + async def close(self): + await self.pool_manager.close() + if self.retry_client is not None: + await self.retry_client.close() + + async def request( + self, + method, + url, + headers=None, + body=None, + post_params=None, + _request_timeout=None + ): + """Execute request + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in [ + 'GET', + 'HEAD', + 'DELETE', + 'POST', + 'PUT', + 'PATCH', + 'OPTIONS' + ] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + # url already contains the URL query string + timeout = _request_timeout or 5 * 60 + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + args = { + "method": method, + "url": url, + "timeout": timeout, + "headers": headers + } + + if self.proxy: + args["proxy"] = self.proxy + if self.proxy_headers: + args["proxy_headers"] = self.proxy_headers + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body is not None: + body = json.dumps(body) + args["data"] = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': + args["data"] = aiohttp.FormData(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by aiohttp + del headers['Content-Type'] + data = aiohttp.FormData() + for param in post_params: + k, v = param + if isinstance(v, tuple) and len(v) == 3: + data.add_field( + k, + value=v[1], + filename=v[0], + content_type=v[2] + ) + else: + data.add_field(k, v) + args["data"] = data + + # Pass a `bytes` or `str` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + args["data"] = body + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + + pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient] + if self.retry_client is not None and method in ALLOW_RETRY_METHODS: + pool_manager = self.retry_client + else: + pool_manager = self.pool_manager + + r = await pool_manager.request(**args) + + return RESTResponse(r) + + + + + diff --git a/docs/lighter/lighter-python-main/lighter/signer_client.py b/docs/lighter/lighter-python-main/lighter/signer_client.py new file mode 100644 index 0000000..a473042 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signer_client.py @@ -0,0 +1,918 @@ +import ctypes +from functools import wraps +import inspect +import json +import platform +import logging +import os +import time +from typing import Dict, List, Optional, Union, Tuple + +from eth_account import Account +from eth_account.messages import encode_defunct +from pydantic import StrictInt +import lighter +from lighter.configuration import Configuration +from lighter.errors import ValidationError +from lighter.models import TxHash +from lighter import nonce_manager +from lighter.models.resp_send_tx import RespSendTx +from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.transactions import CreateOrder, CancelOrder, Withdraw, CreateGroupedOrders + +CODE_OK = 200 + + +class ApiKeyResponse(ctypes.Structure): + _fields_ = [("privateKey", ctypes.c_char_p), ("publicKey", ctypes.c_char_p), ("err", ctypes.c_char_p)] + + +class CreateOrderTxReq(ctypes.Structure): + _fields_ = [ + ("MarketIndex", ctypes.c_uint8), + ("ClientOrderIndex", ctypes.c_longlong), + ("BaseAmount", ctypes.c_longlong), + ("Price", ctypes.c_uint32), + ("IsAsk", ctypes.c_uint8), + ("Type", ctypes.c_uint8), + ("TimeInForce", ctypes.c_uint8), + ("ReduceOnly", ctypes.c_uint8), + ("TriggerPrice", ctypes.c_uint32), + ("OrderExpiry", ctypes.c_longlong), + ] + + +class StrOrErr(ctypes.Structure): + _fields_ = [("str", ctypes.c_char_p), ("err", ctypes.c_char_p)] + + +class SignedTxResponse(ctypes.Structure): + _fields_ = [ + ("txType", ctypes.c_uint8), + ("txInfo", ctypes.c_char_p), + ("txHash", ctypes.c_char_p), + ("messageToSign", ctypes.c_char_p), + ("err", ctypes.c_char_p), + ] + + +__signer = None + + +def __get_shared_library(): + is_linux = platform.system() == "Linux" + is_mac = platform.system() == "Darwin" + is_windows = platform.system() == "Windows" + is_x64 = platform.machine().lower() in ("amd64", "x86_64") + is_arm = platform.machine().lower() == "arm64" + + current_file_directory = os.path.dirname(os.path.abspath(__file__)) + path_to_signer_folders = os.path.join(current_file_directory, "signers") + + if is_arm and is_mac: + return ctypes.CDLL(os.path.join(path_to_signer_folders, "lighter-signer-darwin-arm64.dylib")) + elif is_linux and is_x64: + return ctypes.CDLL(os.path.join(path_to_signer_folders, "lighter-signer-linux-amd64.so")) + elif is_linux and is_arm: + return ctypes.CDLL(os.path.join(path_to_signer_folders, "lighter-signer-linux-arm64.so")) + elif is_windows and is_x64: + return ctypes.CDLL(os.path.join(path_to_signer_folders, "lighter-signer-windows-amd64.dll")) + else: + raise Exception( + f"Unsupported platform/architecture: {platform.system()}/{platform.machine()}. " + "Currently supported: Linux(x86_64), macOS(arm64), and Windows(x86_64)." + ) + + +def __populate_shared_library_functions(signer): + signer.GenerateAPIKey.argtypes = [ctypes.c_char_p] + signer.GenerateAPIKey.restype = ApiKeyResponse + + signer.CreateClient.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ctypes.c_int, ctypes.c_longlong] + signer.CreateClient.restype = ctypes.c_char_p + + signer.CheckClient.argtypes = [ctypes.c_int, ctypes.c_longlong] + signer.CheckClient.restype = ctypes.c_char_p + + signer.SignChangePubKey.argtypes = [ctypes.c_char_p, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignChangePubKey.restype = SignedTxResponse + + signer.SignCreateOrder.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, + ctypes.c_int, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCreateOrder.restype = SignedTxResponse + + signer.SignCreateGroupedOrders.argtypes = [ctypes.c_uint8, ctypes.POINTER(CreateOrderTxReq), ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCreateGroupedOrders.restype = SignedTxResponse + + signer.SignCancelOrder.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCancelOrder.restype = SignedTxResponse + + signer.SignWithdraw.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignWithdraw.restype = SignedTxResponse + + signer.SignCreateSubAccount.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCreateSubAccount.restype = SignedTxResponse + + signer.SignCancelAllOrders.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCancelAllOrders.restype = SignedTxResponse + + signer.SignModifyOrder.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignModifyOrder.restype = SignedTxResponse + + signer.SignTransfer.argtypes = [ctypes.c_longlong, ctypes.c_int16, ctypes.c_int8, ctypes.c_int8, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_char_p, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignTransfer.restype = SignedTxResponse + + signer.SignCreatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCreatePublicPool.restype = SignedTxResponse + + signer.SignUpdatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignUpdatePublicPool.restype = SignedTxResponse + + signer.SignMintShares.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignMintShares.restype = SignedTxResponse + + signer.SignBurnShares.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignBurnShares.restype = SignedTxResponse + + signer.SignUpdateLeverage.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignUpdateLeverage.restype = SignedTxResponse + + signer.CreateAuthToken.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.CreateAuthToken.restype = StrOrErr + + # Note: SwitchAPIKey is no longer exported in the new binary + # All functions now take api_key_index directly, so switching is handled via parameters + + signer.SignUpdateMargin.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignUpdateMargin.restype = SignedTxResponse + + +def get_signer(): + # check if singleton exists already + global __signer + if __signer is not None: + return __signer + + # create shared library & populate methods + __signer = __get_shared_library() + __populate_shared_library_functions(__signer) + return __signer + + +def create_api_key(seed=""): + result = get_signer().GenerateAPIKey(ctypes.c_char_p(seed.encode("utf-8"))) + + private_key_str = result.privateKey.decode("utf-8") if result.privateKey else None + public_key_str = result.publicKey.decode("utf-8") if result.publicKey else None + error = result.err.decode("utf-8") if result.err else None + + return private_key_str, public_key_str, error + + +def trim_exc(exception_body: str): + return exception_body.strip().split("\n")[-1] + + +def process_api_key_and_nonce(func): + @wraps(func) + async def wrapper(self, *args, **kwargs): + # Get the signature + sig = inspect.signature(func) + + # Bind args and kwargs to the function's signature + bound_args = sig.bind(self, *args, **kwargs) + bound_args.apply_defaults() + # Extract api_key_index and nonce from kwargs or use defaults + api_key_index = bound_args.arguments.get("api_key_index", 255) + nonce = bound_args.arguments.get("nonce", -1) + if api_key_index == 255 and nonce == -1: + api_key_index, nonce = self.nonce_manager.next_nonce() + + # Call the original function with modified kwargs + ret: TxHash + try: + partial_arguments = {k: v for k, v in bound_args.arguments.items() if k not in ("self", "nonce", "api_key_index")} + created_tx, ret, err = await func(self, **partial_arguments, nonce=nonce, api_key_index=api_key_index) + if (ret is None and err) or (ret and ret.code != CODE_OK): + self.nonce_manager.acknowledge_failure(api_key_index) + except lighter.exceptions.BadRequestException as e: + if "invalid nonce" in str(e): + self.nonce_manager.hard_refresh_nonce(api_key_index) + return None, None, trim_exc(str(e)) + else: + self.nonce_manager.acknowledge_failure(api_key_index) + return None, None, trim_exc(str(e)) + + return created_tx, ret, err + + return wrapper + + +class SignerClient: + DEFAULT_NONCE = -1 + DEFAULT_API_KEY_INDEX = 255 + + USDC_TICKER_SCALE = 1e6 + ETH_TICKER_SCALE = 1e8 + + ORDER_TYPE_LIMIT = 0 + ORDER_TYPE_MARKET = 1 + ORDER_TYPE_STOP_LOSS = 2 + ORDER_TYPE_STOP_LOSS_LIMIT = 3 + ORDER_TYPE_TAKE_PROFIT = 4 + ORDER_TYPE_TAKE_PROFIT_LIMIT = 5 + ORDER_TYPE_TWAP = 6 + + ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL = 0 + ORDER_TIME_IN_FORCE_GOOD_TILL_TIME = 1 + ORDER_TIME_IN_FORCE_POST_ONLY = 2 + + CANCEL_ALL_TIF_IMMEDIATE = 0 + CANCEL_ALL_TIF_SCHEDULED = 1 + CANCEL_ALL_TIF_ABORT = 2 + + NIL_TRIGGER_PRICE = 0 + DEFAULT_28_DAY_ORDER_EXPIRY = -1 + DEFAULT_IOC_EXPIRY = 0 + DEFAULT_10_MIN_AUTH_EXPIRY = -1 + MINUTE = 60 + + CROSS_MARGIN_MODE = 0 + ISOLATED_MARGIN_MODE = 1 + + ISOLATED_MARGIN_REMOVE_COLLATERAL = 0 + ISOLATED_MARGIN_ADD_COLLATERAL = 1 + + GROUPING_TYPE_ONE_TRIGGERS_THE_OTHER = 1 + GROUPING_TYPE_ONE_CANCELS_THE_OTHER = 2 + GROUPING_TYPE_ONE_TRIGGERS_A_ONE_CANCELS_THE_OTHER = 3 + + ROUTE_PERP = 0 + ROUTE_SPOT = 1 + + ASSET_ID_USDC = 3 + ASSET_ID_ETH = 1 + + def __init__( + self, + url, + account_index, + api_private_keys: Dict[int, str], + nonce_management_type=nonce_manager.NonceManagerType.OPTIMISTIC, + ): + self.url = url + self.chain_id = 304 if "mainnet" in url else 300 + + self.validate_api_private_keys(api_private_keys) + self.api_key_dict = api_private_keys + self.account_index = account_index + self.signer = get_signer() + self.api_client = lighter.ApiClient(configuration=Configuration(host=url)) + self.tx_api = lighter.TransactionApi(self.api_client) + self.order_api = lighter.OrderApi(self.api_client) + + self.nonce_manager = nonce_manager.nonce_manager_factory( + nonce_manager_type=nonce_management_type, + account_index=account_index, + api_client=self.api_client, + api_keys_list=list(api_private_keys.keys()), + ) + for api_key_index in api_private_keys.keys(): + self.create_client(api_key_index) + + # === signer helpers === + @staticmethod + def __decode_tx_info(result: SignedTxResponse) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + if result.err: + error = result.err.decode("utf-8") + return None, None, None, error + + # Use txType from response if available, otherwise use the provided type + tx_type = result.txType + tx_info_str = result.txInfo.decode("utf-8") if result.txInfo else None + tx_hash_str = result.txHash.decode("utf-8") if result.txHash else None + + return tx_type, tx_info_str, tx_hash_str, None + + @staticmethod + def __decode_and_sign_tx_info(eth_private_key: str, result: SignedTxResponse) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + if result.err: + err = result.err.decode("utf-8") + return None, None, None, err + + tx_type = result.txType + tx_info_str = result.txInfo.decode("utf-8") if result.txInfo else None + tx_hash_str = result.txHash.decode("utf-8") if result.txHash else None + msg_to_sign = result.messageToSign.decode("utf-8") if result.messageToSign else None + + # sign the message + acct = Account.from_key(eth_private_key) + message = encode_defunct(text=msg_to_sign) + signature = acct.sign_message(message) + + # add signature to tx_info + tx_info = json.loads(tx_info_str) + tx_info["L1Sig"] = signature.signature.to_0x_hex() + return tx_type, json.dumps(tx_info), tx_hash_str, None + + def validate_api_private_keys(self, private_keys: Dict[int, str]): + if len(private_keys) == 0: + raise ValidationError("No API keys provided") + + # trim 0x + for api_key_index, private_key in private_keys.items(): + if private_key.startswith("0x"): + private_keys[api_key_index] = private_key[2:] + + def create_client(self, api_key_index): + err = self.signer.CreateClient( + self.url.encode("utf-8"), + self.api_key_dict[api_key_index].encode("utf-8"), + self.chain_id, + api_key_index, + self.account_index, + ) + + if err is None: + return + + if err is not None: + raise Exception(err.decode("utf-8")) + + def __signer_check_client( + self, + api_key_index: int, + account_index: int, + ) -> Optional[str]: + err = self.signer.CheckClient(api_key_index, account_index) + if err is None: + return None + + return err.decode("utf-8") + + # check_client verifies that the given API key associated with (api_key_index, account_index) matches the one on Lighter + def check_client(self): + for api_key in self.api_key_dict.keys(): + err = self.__signer_check_client(api_key, self.account_index) + if err is not None: + return err + f" on api key {api_key}" + return None + + @staticmethod + def create_api_key(self, seed=""): + return create_api_key(seed=seed) + + def get_api_key_nonce(self, api_key_index: int, nonce: int) -> Tuple[int, int]: + if api_key_index != self.DEFAULT_API_KEY_INDEX and nonce != self.DEFAULT_NONCE: + return api_key_index, nonce + + if nonce != self.DEFAULT_NONCE: + if len(self.api_key_dict) == 1: + return self.nonce_manager.next_nonce() + else: + raise Exception("ambiguous api key") + return self.nonce_manager.next_nonce() + + def create_auth_token_with_expiry(self, deadline: int = DEFAULT_10_MIN_AUTH_EXPIRY, *, timestamp: int = None, api_key_index: int = DEFAULT_API_KEY_INDEX): + if deadline == SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY: + deadline = 10 * SignerClient.MINUTE + if timestamp is None: + timestamp = int(time.time()) + + result = self.signer.CreateAuthToken(deadline+timestamp, api_key_index, self.account_index) + + auth = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + return auth, error + + def sign_change_api_key(self, eth_private_key: str, new_pubkey: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_and_sign_tx_info(eth_private_key, self.signer.SignChangePubKey( + ctypes.c_char_p(new_pubkey.encode("utf-8")), + nonce, + api_key_index, + self.account_index + )) + + async def change_api_key(self, eth_private_key: str, new_pubkey: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + tx_type, tx_info, tx_hash, error = self.sign_change_api_key(eth_private_key, new_pubkey, nonce, api_key_index) + if error is not None: + return None, error + + logging.debug(f"Change Pub Key TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Change Pub Key Send. TxResponse: {api_response}") + return api_response, None + + def sign_create_order( + self, + market_index, + client_order_index, + base_amount, + price, + is_ask, + order_type, + time_in_force, + reduce_only=False, + trigger_price=NIL_TRIGGER_PRICE, + order_expiry=DEFAULT_28_DAY_ORDER_EXPIRY, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignCreateOrder( + market_index, + client_order_index, + base_amount, + price, + int(is_ask), + order_type, + time_in_force, + reduce_only, + trigger_price, + order_expiry, + nonce, + api_key_index, + self.account_index, + )) + + def sign_create_grouped_orders( + self, + grouping_type: int, + orders: List[CreateOrderTxReq], + nonce: int = DEFAULT_NONCE, + api_key_index=DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + arr_type = CreateOrderTxReq * len(orders) + orders_arr = arr_type(*orders) + + return self.__decode_tx_info(self.signer.SignCreateGroupedOrders( + grouping_type, orders_arr, len(orders), nonce, api_key_index, self.account_index + )) + + def sign_cancel_order(self, market_index: int, order_index: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignCancelOrder(market_index, order_index, nonce, api_key_index, self.account_index)) + + def sign_withdraw(self, asset_index: int, route_type: int, amount: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignWithdraw(asset_index, route_type, amount, nonce, api_key_index, self.account_index)) + + def sign_create_sub_account(self, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignCreateSubAccount(nonce, api_key_index, self.account_index)) + + def sign_cancel_all_orders(self, time_in_force: int, timestamp_ms: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignCancelAllOrders(time_in_force, timestamp_ms, nonce, api_key_index, self.account_index)) + + def sign_modify_order(self, market_index: int, order_index: int, base_amount: int, price: int, trigger_price: int = NIL_TRIGGER_PRICE, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignModifyOrder(market_index, order_index, base_amount, price, trigger_price, nonce, api_key_index, self.account_index)) + + def sign_transfer(self, eth_private_key: str, to_account_index: int, asset_id: int, route_from: int, route_to: int, usdc_amount: int, fee: int, memo: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_and_sign_tx_info(eth_private_key, self.signer.SignTransfer(to_account_index, asset_id, route_from, route_to, usdc_amount, fee, ctypes.c_char_p(memo.encode("utf-8")), nonce, api_key_index, self.account_index)) + + def sign_create_public_pool(self, operator_fee: int, initial_total_shares: int, min_operator_share_rate: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignCreatePublicPool(operator_fee, initial_total_shares, min_operator_share_rate, nonce, api_key_index, self.account_index)) + + def sign_update_public_pool(self, public_pool_index: int, status: int, operator_fee: int, min_operator_share_rate: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignUpdatePublicPool(public_pool_index, status, operator_fee, min_operator_share_rate, nonce, api_key_index, self.account_index)) + + def sign_mint_shares(self, public_pool_index: int, share_amount: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignMintShares(public_pool_index, share_amount, nonce, api_key_index, self.account_index)) + + def sign_burn_shares(self, public_pool_index: int, share_amount: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignBurnShares(public_pool_index, share_amount, nonce, api_key_index, self.account_index)) + + def sign_update_leverage(self, market_index: int, fraction: int, margin_mode: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignUpdateLeverage(market_index, fraction, margin_mode, nonce, api_key_index, self.account_index)) + + def sign_update_margin(self, market_index: int, usdc_amount: int, direction: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignUpdateMargin(market_index, usdc_amount, direction, nonce, api_key_index, self.account_index)) + + @process_api_key_and_nonce + async def create_order( + self, + market_index, + client_order_index, + base_amount, + price, + is_ask, + order_type, + time_in_force, + reduce_only=False, + trigger_price=NIL_TRIGGER_PRICE, + order_expiry=DEFAULT_28_DAY_ORDER_EXPIRY, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + tx_type, tx_info, tx_hash, error = self.sign_create_order( + market_index, + client_order_index, + base_amount, + price, + int(is_ask), + order_type, + time_in_force, + reduce_only, + trigger_price, + order_expiry, + nonce, + api_key_index, + ) + if error is not None: + return None, None, error + + logging.debug(f"Create Order TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Create Order Send. TxResponse: {api_response}") + return CreateOrder.from_json(tx_info), api_response, None + + @process_api_key_and_nonce + async def create_grouped_orders( + self, + grouping_type: int, + orders: List[CreateOrderTxReq], + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) ->Union[Tuple[CreateGroupedOrders, RespSendTx, None], Tuple[None, None, str]]: + tx_type, tx_info, tx_hash, error = self.sign_create_grouped_orders( + grouping_type, + orders, + nonce, + api_key_index + ) + if error is not None: + return None, None, error + + logging.debug(f"Create Grouped Orders TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Create Grouped Orders Send. TxResponse: {api_response}") + return CreateGroupedOrders.from_json(tx_info), api_response, None + + async def create_market_order( + self, + market_index, + client_order_index, + base_amount, + avg_execution_price, + is_ask, + reduce_only: bool = False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + return await self.create_order( + market_index, + client_order_index, + base_amount, + avg_execution_price, + is_ask, + order_type=self.ORDER_TYPE_MARKET, + time_in_force=self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + order_expiry=self.DEFAULT_IOC_EXPIRY, + reduce_only=reduce_only, + nonce=nonce, + api_key_index=api_key_index, + ) + + # will only do the amount such that the slippage is limited to the value provided + async def create_market_order_limited_slippage( + self, + market_index, + client_order_index, + base_amount, + max_slippage, + is_ask, + reduce_only: bool = False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX, + ideal_price=None + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + if ideal_price is None: + order_book_orders = await self.order_api.order_book_orders(market_index, 1) + logging.debug( + "Create market order limited slippage is doing an API call to get the current ideal price. You can also provide it yourself to avoid this.") + ideal_price = int((order_book_orders.bids[0].price if is_ask else order_book_orders.asks[0].price).replace(".", "")) + + acceptable_execution_price = round(ideal_price * (1 + max_slippage * (-1 if is_ask else 1))) + return await self.create_order( + market_index, + client_order_index, + base_amount, + price=acceptable_execution_price, + is_ask=is_ask, + order_type=self.ORDER_TYPE_MARKET, + time_in_force=self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + order_expiry=self.DEFAULT_IOC_EXPIRY, + reduce_only=reduce_only, + nonce=nonce, + api_key_index=api_key_index, + ) + + # will only execute the order if it executes with slippage <= max_slippage + async def create_market_order_if_slippage( + self, + market_index, + client_order_index, + base_amount, + max_slippage, + is_ask, + reduce_only: bool = False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX, + ideal_price=None + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + order_book_orders = await self.order_api.order_book_orders(market_index, 100) + if ideal_price is None: + ideal_price = int((order_book_orders.bids[0].price if is_ask else order_book_orders.asks[0].price).replace(".", "")) + + matched_usd_amount, matched_size = 0, 0 + for order_book_order in (order_book_orders.bids if is_ask else order_book_orders.asks): + if matched_size == base_amount: + break + curr_order_price = int(order_book_order.price.replace(".", "")) + curr_order_size = int(order_book_order.remaining_base_amount.replace(".", "")) + to_be_used_order_size = min(base_amount - matched_size, curr_order_size) + matched_usd_amount += curr_order_price * to_be_used_order_size + matched_size += to_be_used_order_size + + potential_execution_price = matched_usd_amount / matched_size + acceptable_execution_price = ideal_price * (1 + max_slippage * (-1 if is_ask else 1)) + if (is_ask and potential_execution_price < acceptable_execution_price) or (not is_ask and potential_execution_price > acceptable_execution_price): + return None, None, "Excessive slippage" + + if matched_size < base_amount: + return None, None, "Cannot be sure slippage will be acceptable due to the high size" + + return await self.create_order( + market_index, + client_order_index, + base_amount, + price=round(acceptable_execution_price), + is_ask=is_ask, + order_type=self.ORDER_TYPE_MARKET, + time_in_force=self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + order_expiry=self.DEFAULT_IOC_EXPIRY, + reduce_only=reduce_only, + nonce=nonce, + api_key_index=api_key_index, + ) + + @process_api_key_and_nonce + async def cancel_order(self, market_index, order_index, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CancelOrder, RespSendTx, None], Tuple[None, None, str]]: + tx_type, tx_info, tx_hash, error = self.sign_cancel_order(market_index, order_index, nonce, api_key_index) + + if error is not None: + return None, None, error + + logging.debug(f"Cancel Order TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Cancel Order Send. TxResponse: {api_response}") + return CancelOrder.from_json(tx_info), api_response, None + + async def create_tp_order(self, market_index, client_order_index, base_amount, trigger_price, price, is_ask, reduce_only=False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + return await self.create_order( + market_index, + client_order_index, + base_amount, + price, + is_ask, + self.ORDER_TYPE_TAKE_PROFIT, + self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + reduce_only, + trigger_price, + self.DEFAULT_28_DAY_ORDER_EXPIRY, + nonce, + api_key_index, + ) + + async def create_tp_limit_order(self, market_index, client_order_index, base_amount, trigger_price, price, is_ask, reduce_only=False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + return await self.create_order( + market_index, + client_order_index, + base_amount, + price, + is_ask, + self.ORDER_TYPE_TAKE_PROFIT_LIMIT, + self.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only, + trigger_price, + self.DEFAULT_28_DAY_ORDER_EXPIRY, + nonce, + api_key_index, + ) + + async def create_sl_order(self, market_index, client_order_index, base_amount, trigger_price, price, is_ask, reduce_only=False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + return await self.create_order( + market_index, + client_order_index, + base_amount, + price, + is_ask, + self.ORDER_TYPE_STOP_LOSS, + self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + reduce_only, + trigger_price, + self.DEFAULT_28_DAY_ORDER_EXPIRY, + nonce, + api_key_index, + ) + + async def create_sl_limit_order(self, market_index, client_order_index, base_amount, trigger_price, price, is_ask, reduce_only=False, + nonce: int = DEFAULT_NONCE, + api_key_index: int = DEFAULT_API_KEY_INDEX + ) -> Union[Tuple[CreateOrder, RespSendTx, None], Tuple[None, None, str]]: + return await self.create_order( + market_index, + client_order_index, + base_amount, + price, + is_ask, + self.ORDER_TYPE_STOP_LOSS_LIMIT, + self.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, + reduce_only, + trigger_price, + self.DEFAULT_28_DAY_ORDER_EXPIRY, + nonce, + api_key_index, + ) + + @process_api_key_and_nonce + async def withdraw(self, asset_id: int, route_type: int, amount: float, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[Withdraw, RespSendTx, None], Tuple[None, None, str]]: + if asset_id == self.ASSET_ID_USDC: + amount = int(amount * self.USDC_TICKER_SCALE) + elif asset_id == self.ASSET_ID_ETH: + amount = int(amount * self.ETH_TICKER_SCALE) + else: + raise ValueError(f"Unsupported asset id: {asset_id}") + + tx_type, tx_info, tx_hash, error = self.sign_withdraw(asset_id, route_type, amount, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Withdraw TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Withdraw Send. TxResponse: {api_response}") + return Withdraw.from_json(tx_info), api_response, None + + @process_api_key_and_nonce + async def create_sub_account(self, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + tx_type, tx_info, tx_hash, error = self.sign_create_sub_account(nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Create Sub Account TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Create Sub Account Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def cancel_all_orders(self, time_in_force, timestamp_ms, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX)-> Union[Tuple[Withdraw, RespSendTx, None], Tuple[None, None, str]]: + tx_type, tx_info, tx_hash, error = self.sign_cancel_all_orders(time_in_force, timestamp_ms, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Cancel All Orders TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Cancel All Orders Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def modify_order( + self, market_index, order_index, base_amount, price, trigger_price=NIL_TRIGGER_PRICE, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX + ): + tx_type, tx_info, tx_hash, error = self.sign_modify_order(market_index, order_index, base_amount, price, trigger_price, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Modify Order TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Modify Order Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def transfer(self, eth_private_key: str, to_account_index: int, asset_id: int, route_from: int, route_to: int, amount: float, fee: int, memo: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + if asset_id == self.ASSET_ID_USDC: + amount = int(amount * self.USDC_TICKER_SCALE) + elif asset_id == self.ASSET_ID_ETH: + amount = int(amount * self.ETH_TICKER_SCALE) + else: + raise ValueError(f"Unsupported asset id: {asset_id}") + + tx_type, tx_info, tx_hash, error = self.sign_transfer(eth_private_key, to_account_index, asset_id, route_from, route_to, amount, fee, memo, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Transfer TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Transfer Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def create_public_pool( + self, operator_fee, initial_total_shares, min_operator_share_rate, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX + ): + tx_type, tx_info, tx_hash, error = self.sign_create_public_pool( + operator_fee, initial_total_shares, min_operator_share_rate, nonce, api_key_index + ) + if error is not None: + return None, None, error + + logging.debug(f"Create Public Pool TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Create Public Pool Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def update_public_pool( + self, public_pool_index, status, operator_fee, min_operator_share_rate, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX + ): + tx_type, tx_info, tx_hash, error = self.sign_update_public_pool( + public_pool_index, status, operator_fee, min_operator_share_rate, nonce, api_key_index + ) + if error is not None: + return None, None, error + + logging.debug(f"Update Public Pool TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Update Public Pool Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def mint_shares(self, public_pool_index, share_amount, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + tx_type, tx_info, tx_hash, error = self.sign_mint_shares(public_pool_index, share_amount, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Mint Shares TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Mint Shares Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def burn_shares(self, public_pool_index, share_amount, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + tx_type, tx_info, tx_hash, error = self.sign_burn_shares(public_pool_index, share_amount, nonce, api_key_index) + if error is not None: + return None, None, error + + logging.debug(f"Burn Shares TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Burn Shares Send. TxResponse: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def update_leverage(self, market_index, margin_mode, leverage, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + imf = int(10_000 / leverage) + tx_type, tx_info, tx_hash, error = self.sign_update_leverage(market_index, imf, margin_mode, nonce, api_key_index) + + if error is not None: + return None, None, error + + logging.debug(f"Update Leverage TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Update Leverage Tx Response: {api_response}") + return tx_info, api_response, None + + @process_api_key_and_nonce + async def update_margin(self, market_index: int, usdc_amount: float, direction: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + usdc_amount = int(usdc_amount * self.USDC_TICKER_SCALE) + tx_type, tx_info, tx_hash, error = self.sign_update_margin(market_index, usdc_amount, direction, nonce, api_key_index) + + if error is not None: + return None, None, error + + logging.debug(f"Update Margin TxHash: {tx_hash} TxInfo: {tx_info}") + api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info) + logging.debug(f"Update Margin Tx Response: {api_response}") + return tx_info, api_response, None + + async def send_tx(self, tx_type: StrictInt, tx_info: str) -> RespSendTx: + if tx_info[0] != "{": + raise Exception(tx_info) + return await self.tx_api.send_tx(tx_type=tx_type, tx_info=tx_info) + + async def send_tx_batch(self, tx_types: List[StrictInt], tx_infos: List[str]) -> RespSendTxBatch: + if len(tx_types) != len(tx_infos): + raise Exception("Tx types and tx infos must be of same length") + if len(tx_types) == 0: + raise Exception("Empty tx types and tx infos") + + if tx_infos[0][0] != "{": + raise Exception(tx_infos) + return await self.tx_api.send_tx_batch(tx_types=json.dumps(tx_types), tx_infos=json.dumps(tx_infos)) + + async def close(self): + await self.api_client.close() + + @staticmethod + def are_keys_equal(key1, key2) -> bool: + start_index1, start_index2 = 0, 0 + if key1.startswith("0x"): + start_index1 = 2 + if key2.startswith("0x"): + start_index2 = 2 + return key1[start_index1:] == key2[start_index2:] diff --git a/docs/lighter/lighter-python-main/lighter/signers/README.md b/docs/lighter/lighter-python-main/lighter/signers/README.md new file mode 100644 index 0000000..3408e2a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signers/README.md @@ -0,0 +1,25 @@ +# Lighter Signers + +This directory contains various signer implementations for the Lighter Protocol. + +## Usage + +The Python SDK automatically selects the correct native binary signer based on your platform: + + +| Platform | Architecture | Binary | +|----------|-----------------------|-------------------------------------| +| Linux | x86_64 | `lighter-signer-linux-amd64.so` | +| Linux | ARM64 | `lighter-signer-linux-amd64.so` | +| macOS | ARM64 (Apple Silicon) | `lighter-signer-darwin-arm64.dylib` | +| Windows | x86_64 | `lighter-signer-windows-amd64.dll` | + +No additional configuration is required - the SDK detects your platform and loads the appropriate signer. \ +If you encounter issues with missing binaries, ensure the appropriate signer binary is present in this directory. + +## Building Signers + +These binaries are compiled from the Go implementation in [lighter-go](https://github.com/elliottech/lighter-go) and +provide high-performance cryptographic operations for the Lighter Protocol. \ +There are `.h` files for easier integrations in other languages, like C, C++, Rust. \ +For building the signers yourself, you can find the steps in the lighter-go repo. diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.dylib b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.dylib new file mode 100644 index 0000000..0dd7cec Binary files /dev/null and b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.dylib differ diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.h b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.h new file mode 100644 index 0000000..15a6068 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-darwin-arm64.h @@ -0,0 +1,136 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 16 "main.go" + +#include +#include +typedef struct { + char* str; + char* err; +} StrOrErr; + +typedef struct { + uint8_t txType; + char* txInfo; + char* txHash; + char* messageToSign; + char* err; +} SignedTxResponse; + +typedef struct { + char* privateKey; + char* publicKey; + char* err; +} ApiKeyResponse; + +typedef struct { + uint8_t MarketIndex; + int64_t ClientOrderIndex; + int64_t BaseAmount; + uint32_t Price; + uint8_t IsAsk; + uint8_t Type; + uint8_t TimeInForce; + uint8_t ReduceOnly; + uint32_t TriggerPrice; + int64_t OrderExpiry; +} CreateOrderTxReq; + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern ApiKeyResponse GenerateAPIKey(char* cSeed); +extern char* CreateClient(char* cUrl, char* cPrivateKey, int cChainId, int cApiKeyIndex, long long cAccountIndex); +extern char* CheckClient(int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignChangePubKey(char* cPubKey, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long cClientOrderIndex, long long cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long cOrderExpiry, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long cOrderIndex, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, unsigned long long cAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCreateSubAccount(long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long cTime, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long cIndex, long long cBaseAmount, long long cPrice, long long cTriggerPrice, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignTransfer(long long cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long cAmount, long long cUsdcFee, char* cMemo, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long cOperatorFee, int cInitialTotalShares, long long cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long cPublicPoolIndex, int cStatus, long long cOperatorFee, int cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignMintShares(long long cPublicPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignBurnShares(long long cPublicPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern StrOrErr CreateAuthToken(long long cDeadline, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long cUSDCAmount, int cDirection, long long cNonce, int cApiKeyIndex, long long cAccountIndex); + +#ifdef __cplusplus +} +#endif diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.h b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.h new file mode 100644 index 0000000..887f09e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.h @@ -0,0 +1,136 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/elliottech/lighter-go/sharedlib */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 16 "main.go" + +#include +#include +typedef struct { + char* str; + char* err; +} StrOrErr; + +typedef struct { + uint8_t txType; + char* txInfo; + char* txHash; + char* messageToSign; + char* err; +} SignedTxResponse; + +typedef struct { + char* privateKey; + char* publicKey; + char* err; +} ApiKeyResponse; + +typedef struct { + uint8_t MarketIndex; + int64_t ClientOrderIndex; + int64_t BaseAmount; + uint32_t Price; + uint8_t IsAsk; + uint8_t Type; + uint8_t TimeInForce; + uint8_t ReduceOnly; + uint32_t TriggerPrice; + int64_t OrderExpiry; +} CreateOrderTxReq; + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern ApiKeyResponse GenerateAPIKey(char* cSeed); +extern char* CreateClient(char* cUrl, char* cPrivateKey, int cChainId, int cApiKeyIndex, long long int cAccountIndex); +extern char* CheckClient(int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignChangePubKey(char* cPubKey, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern StrOrErr CreateAuthToken(long long int cDeadline, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long int cUSDCAmount, int cDirection, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); + +#ifdef __cplusplus +} +#endif diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.so b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.so new file mode 100644 index 0000000..424cac5 Binary files /dev/null and b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-amd64.so differ diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.h b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.h new file mode 100644 index 0000000..887f09e --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.h @@ -0,0 +1,136 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/elliottech/lighter-go/sharedlib */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 16 "main.go" + +#include +#include +typedef struct { + char* str; + char* err; +} StrOrErr; + +typedef struct { + uint8_t txType; + char* txInfo; + char* txHash; + char* messageToSign; + char* err; +} SignedTxResponse; + +typedef struct { + char* privateKey; + char* publicKey; + char* err; +} ApiKeyResponse; + +typedef struct { + uint8_t MarketIndex; + int64_t ClientOrderIndex; + int64_t BaseAmount; + uint32_t Price; + uint8_t IsAsk; + uint8_t Type; + uint8_t TimeInForce; + uint8_t ReduceOnly; + uint32_t TriggerPrice; + int64_t OrderExpiry; +} CreateOrderTxReq; + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern ApiKeyResponse GenerateAPIKey(char* cSeed); +extern char* CreateClient(char* cUrl, char* cPrivateKey, int cChainId, int cApiKeyIndex, long long int cAccountIndex); +extern char* CheckClient(int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignChangePubKey(char* cPubKey, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern StrOrErr CreateAuthToken(long long int cDeadline, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long int cUSDCAmount, int cDirection, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); + +#ifdef __cplusplus +} +#endif diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.so b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.so new file mode 100644 index 0000000..30645c3 Binary files /dev/null and b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-linux-arm64.so differ diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.dll b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.dll new file mode 100644 index 0000000..7b3fb5d Binary files /dev/null and b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.dll differ diff --git a/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.h b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.h new file mode 100644 index 0000000..6ad24a1 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/signers/lighter-signer-windows-amd64.h @@ -0,0 +1,136 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/elliottech/lighter-go/sharedlib */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 16 "main.go" + +#include +#include +typedef struct { + char* str; + char* err; +} StrOrErr; + +typedef struct { + uint8_t txType; + char* txInfo; + char* txHash; + char* messageToSign; + char* err; +} SignedTxResponse; + +typedef struct { + char* privateKey; + char* publicKey; + char* err; +} ApiKeyResponse; + +typedef struct { + uint8_t MarketIndex; + int64_t ClientOrderIndex; + int64_t BaseAmount; + uint32_t Price; + uint8_t IsAsk; + uint8_t Type; + uint8_t TimeInForce; + uint8_t ReduceOnly; + uint32_t TriggerPrice; + int64_t OrderExpiry; +} CreateOrderTxReq; + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __declspec(dllexport) ApiKeyResponse GenerateAPIKey(char* cSeed); +extern __declspec(dllexport) char* CreateClient(char* cUrl, char* cPrivateKey, int cChainId, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) char* CheckClient(int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignChangePubKey(char* cPubKey, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) StrOrErr CreateAuthToken(long long int cDeadline, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignUpdateMargin(int cMarketIndex, long long int cUSDCAmount, int cDirection, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); + +#ifdef __cplusplus +} +#endif diff --git a/docs/lighter/lighter-python-main/lighter/transactions/__init__.py b/docs/lighter/lighter-python-main/lighter/transactions/__init__.py new file mode 100644 index 0000000..9cc7af3 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/transactions/__init__.py @@ -0,0 +1,4 @@ +from lighter.transactions.cancel_order import CancelOrder +from lighter.transactions.create_order import CreateOrder +from lighter.transactions.create_grouped_orders import CreateGroupedOrders +from lighter.transactions.withdraw import Withdraw diff --git a/docs/lighter/lighter-python-main/lighter/transactions/cancel_order.py b/docs/lighter/lighter-python-main/lighter/transactions/cancel_order.py new file mode 100644 index 0000000..ab00572 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/transactions/cancel_order.py @@ -0,0 +1,27 @@ +import json +from typing import Optional + + +class CancelOrder: + def __init__(self): + self.account_index: Optional[int] = None + self.order_book_index: Optional[int] = None + self.order_nonce: Optional[int] = None + self.expired_at: Optional[int] = None + self.nonce: Optional[int] = None + self.sig: Optional[str] = None + + @classmethod + def from_json(cls, json_str: str) -> 'CancelOrder': + params = json.loads(json_str) + self = cls() + self.account_index = params.get('AccountIndex') + self.order_book_index = params.get('OrderBookIndex') + self.order_nonce = params.get('OrderNonce') + self.expired_at = params.get('ExpiredAt') + self.nonce = params.get('Nonce') + self.sig = params.get('Sig') + return self + + def to_json(self) -> str: + return json.dumps(self.__dict__, default=str) diff --git a/docs/lighter/lighter-python-main/lighter/transactions/create_grouped_orders.py b/docs/lighter/lighter-python-main/lighter/transactions/create_grouped_orders.py new file mode 100644 index 0000000..f1dd0a8 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/transactions/create_grouped_orders.py @@ -0,0 +1,26 @@ +import json +from typing import Optional + +class CreateGroupedOrders: + def __init__(self): + self.account_index: Optional[int] = None + self.order_book_index: Optional[int] = None + self.grouping_type: Optional[int] = None + self.orders: Optional[list] = None + self.nonce: Optional[int] = None + self.sig: Optional[str] = None + + @classmethod + def from_json(cls, json_str: str) -> 'CreateGroupedOrders': + params = json.loads(json_str) + self = cls() + self.account_index = params.get('AccountIndex') + self.order_book_index = params.get('OrderBookIndex') + self.grouping_type = params.get('GroupingType') + self.orders = params.get('Orders') + self.nonce = params.get('Nonce') + self.sig = params.get('Sig') + return self + + def to_json(self) -> str: + return json.dumps(self.__dict__, default=str) diff --git a/docs/lighter/lighter-python-main/lighter/transactions/create_order.py b/docs/lighter/lighter-python-main/lighter/transactions/create_order.py new file mode 100644 index 0000000..f74363a --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/transactions/create_order.py @@ -0,0 +1,33 @@ +import json +from typing import Optional + + +class CreateOrder: + def __init__(self): + self.account_index: Optional[int] = None + self.order_book_index: Optional[int] = None + self.base_amount: Optional[int] = None + self.price: Optional[int] = None + self.is_ask: Optional[int] = None + self.order_type: Optional[int] = None + self.expired_at: Optional[int] = None + self.nonce: Optional[int] = None + self.sig: Optional[str] = None + + @classmethod + def from_json(cls, json_str: str) -> 'CreateOrder': + params = json.loads(json_str) + self = cls() + self.account_index = params.get('AccountIndex') + self.order_book_index = params.get('OrderBookIndex') + self.base_amount = params.get('BaseAmount') + self.price = params.get('Price') + self.is_ask = params.get('IsAsk') + self.order_type = params.get('OrderType') + self.expired_at = params.get('ExpiredAt') + self.nonce = params.get('Nonce') + self.sig = params.get('Sig') + return self + + def to_json(self) -> str: + return json.dumps(self.__dict__, default=str) diff --git a/docs/lighter/lighter-python-main/lighter/transactions/withdraw.py b/docs/lighter/lighter-python-main/lighter/transactions/withdraw.py new file mode 100644 index 0000000..aa49f46 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/transactions/withdraw.py @@ -0,0 +1,25 @@ +import json +from typing import Optional + + +class Withdraw: + def __init__(self): + self.from_account_index: Optional[int] = None + self.collateral_amount: Optional[int] = None + self.expired_at: Optional[int] = None + self.nonce: Optional[int] = None + self.sig: Optional[str] = None + + @classmethod + def from_json(cls, json_str: str) -> 'Withdraw': + params = json.loads(json_str) + instance = cls() + instance.from_account_index = params.get('FromAccountIndex') + instance.collateral_amount = params.get('CollateralAmount') + instance.expired_at = params.get('ExpiredAt') + instance.nonce = params.get('Nonce') + instance.sig = params.get('Sig') + return instance + + def to_json(self) -> str: + return json.dumps(self.__dict__, default=str) diff --git a/docs/lighter/lighter-python-main/lighter/ws_client.py b/docs/lighter/lighter-python-main/lighter/ws_client.py new file mode 100644 index 0000000..a6d5581 --- /dev/null +++ b/docs/lighter/lighter-python-main/lighter/ws_client.py @@ -0,0 +1,165 @@ +import json +from websockets.sync.client import connect +from websockets.client import connect as connect_async +from lighter.configuration import Configuration + +class WsClient: + def __init__( + self, + host=None, + path="/stream", + order_book_ids=[], + account_ids=[], + on_order_book_update=print, + on_account_update=print, + ): + if host is None: + host = Configuration.get_default().host.replace("https://", "") + + self.base_url = f"wss://{host}{path}" + + self.subscriptions = { + "order_books": order_book_ids, + "accounts": account_ids, + } + + if len(order_book_ids) == 0 and len(account_ids) == 0: + raise Exception("No subscriptions provided.") + + self.order_book_states = {} + self.account_states = {} + + self.on_order_book_update = on_order_book_update + self.on_account_update = on_account_update + + self.ws = None + + def on_message(self, ws, message): + if isinstance(message, str): + message = json.loads(message) + + message_type = message.get("type") + + if message_type == "connected": + self.handle_connected(ws) + elif message_type == "subscribed/order_book": + self.handle_subscribed_order_book(message) + elif message_type == "update/order_book": + self.handle_update_order_book(message) + elif message_type == "subscribed/account_all": + self.handle_subscribed_account(message) + elif message_type == "update/account_all": + self.handle_update_account(message) + elif message_type == "ping": + # Respond to ping with pong + ws.send(json.dumps({"type": "pong"})) + else: + self.handle_unhandled_message(message) + + async def on_message_async(self, ws, message): + message = json.loads(message) + message_type = message.get("type") + + if message_type == "connected": + await self.handle_connected_async(ws) + elif message_type == "ping": + # Respond to ping with pong + await ws.send(json.dumps({"type": "pong"})) + else: + self.on_message(ws, message) + + def handle_connected(self, ws): + for market_id in self.subscriptions["order_books"]: + ws.send( + json.dumps({"type": "subscribe", "channel": f"order_book/{market_id}"}) + ) + for account_id in self.subscriptions["accounts"]: + ws.send( + json.dumps( + {"type": "subscribe", "channel": f"account_all/{account_id}"} + ) + ) + + async def handle_connected_async(self, ws): + for market_id in self.subscriptions["order_books"]: + await ws.send( + json.dumps({"type": "subscribe", "channel": f"order_book/{market_id}"}) + ) + for account_id in self.subscriptions["accounts"]: + await ws.send( + json.dumps( + {"type": "subscribe", "channel": f"account_all/{account_id}"} + ) + ) + + def handle_subscribed_order_book(self, message): + market_id = message["channel"].split(":")[1] + self.order_book_states[market_id] = message["order_book"] + if self.on_order_book_update: + self.on_order_book_update(market_id, self.order_book_states[market_id]) + + def handle_update_order_book(self, message): + market_id = message["channel"].split(":")[1] + self.update_order_book_state(market_id, message["order_book"]) + if self.on_order_book_update: + self.on_order_book_update(market_id, self.order_book_states[market_id]) + + def update_order_book_state(self, market_id, order_book): + self.update_orders( + order_book["asks"], self.order_book_states[market_id]["asks"] + ) + self.update_orders( + order_book["bids"], self.order_book_states[market_id]["bids"] + ) + + def update_orders(self, new_orders, existing_orders): + for new_order in new_orders: + is_new_order = True + for existing_order in existing_orders: + if new_order["price"] == existing_order["price"]: + is_new_order = False + existing_order["size"] = new_order["size"] + if float(new_order["size"]) == 0: + existing_orders.remove(existing_order) + break + if is_new_order: + existing_orders.append(new_order) + + existing_orders = [ + order for order in existing_orders if float(order["size"]) > 0 + ] + + def handle_subscribed_account(self, message): + account_id = message["channel"].split(":")[1] + self.account_states[account_id] = message + if self.on_account_update: + self.on_account_update(account_id, self.account_states[account_id]) + + def handle_update_account(self, message): + account_id = message["channel"].split(":")[1] + self.account_states[account_id] = message + if self.on_account_update: + self.on_account_update(account_id, self.account_states[account_id]) + + def handle_unhandled_message(self, message): + raise Exception(f"Unhandled message: {message}") + + def on_error(self, ws, error): + raise Exception(f"Error: {error}") + + def on_close(self, ws, close_status_code, close_msg): + raise Exception(f"Closed: {close_status_code} {close_msg}") + + def run(self): + ws = connect(self.base_url) + self.ws = ws + + for message in ws: + self.on_message(ws, message) + + async def run_async(self): + ws = await connect_async(self.base_url) + self.ws = ws + + async for message in ws: + await self.on_message_async(ws, message) diff --git a/docs/lighter/lighter-python-main/openapi.json b/docs/lighter/lighter-python-main/openapi.json new file mode 100644 index 0000000..a30275b --- /dev/null +++ b/docs/lighter/lighter-python-main/openapi.json @@ -0,0 +1,8217 @@ +{ + "swagger": "2.0", + "info": { + "title": "", + "version": "" + }, + "host": "mainnet.zklighter.elliot.ai", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/": { + "get": { + "summary": "status", + "operationId": "status", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Status" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "root" + ], + "description": "Get status of zklighter" + } + }, + "/api/v1/account": { + "get": { + "summary": "account", + "operationId": "account", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/DetailedAccounts" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "index", + "l1_address" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account by account's index.
More details about account index: [Account Index](https://apidocs.lighter.xyz/docs/account-index)
**Response Description:**

1) **Status:** 1 is active 0 is inactive.
2) **Collateral:** The amount of collateral in the account.
**Position Details Description:**
1) **OOC:** Open order count in that market.
2) **Sign:** 1 for Long, -1 for Short.
3) **Position:** The amount of position in that market.
4) **Avg Entry Price:** The average entry price of the position.
5) **Position Value:** The value of the position.
6) **Unrealized PnL:** The unrealized profit and loss of the position.
7) **Realized PnL:** The realized profit and loss of the position." + } + }, + "/api/v1/accountActiveOrders": { + "get": { + "summary": "accountActiveOrders", + "operationId": "accountActiveOrders", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Orders" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "market_id", + "in": "query", + "required": true, + "type": "integer", + "format": "int16" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account active orders. `auth` can be generated using the SDK." + } + }, + "/api/v1/accountInactiveOrders": { + "get": { + "summary": "accountInactiveOrders", + "operationId": "accountInactiveOrders", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Orders" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "ask_filter", + "in": "query", + "required": false, + "type": "integer", + "format": "int8", + "default": "-1" + }, + { + "name": "between_timestamps", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account inactive orders" + } + }, + "/api/v1/accountLimits": { + "get": { + "summary": "accountLimits", + "operationId": "accountLimits", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AccountLimits" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account limits" + } + }, + "/api/v1/accountMetadata": { + "get": { + "summary": "accountMetadata", + "operationId": "accountMetadata", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AccountMetadatas" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "index", + "l1_address" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account metadatas" + } + }, + "/api/v1/accountTxs": { + "get": { + "summary": "accountTxs", + "operationId": "accountTxs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Txs" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "account_index" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + }, + { + "name": "types", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get transactions of a specific account" + } + }, + "/api/v1/accountsByL1Address": { + "get": { + "summary": "accountsByL1Address", + "operationId": "accountsByL1Address", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/SubAccounts" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get accounts by l1_address returns all accounts associated with the given L1 address" + } + }, + "/api/v1/announcement": { + "get": { + "summary": "announcement", + "operationId": "announcement", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Announcements" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "announcement" + ], + "description": "Get announcement" + } + }, + "/api/v1/apikeys": { + "get": { + "summary": "apikeys", + "operationId": "apikeys", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AccountApiKeys" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "api_key_index", + "in": "query", + "required": false, + "type": "integer", + "format": "uint8", + "default": "255" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account." + } + }, + "/api/v1/assetDetails": { + "get": { + "summary": "assetDetails", + "operationId": "assetDetails", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AssetDetails" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "asset_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "0" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get asset details" + } + }, + "/api/v1/block": { + "get": { + "summary": "block", + "operationId": "block", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Blocks" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "commitment", + "height" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "block" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get block by its height or commitment" + } + }, + "/api/v1/blockTxs": { + "get": { + "summary": "blockTxs", + "operationId": "blockTxs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Txs" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "block_height", + "block_commitment" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get transactions in a block" + } + }, + "/api/v1/blocks": { + "get": { + "summary": "blocks", + "operationId": "blocks", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Blocks" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "sort", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "asc", + "desc" + ], + "default": "asc" + } + ], + "tags": [ + "block" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get blocks" + } + }, + "/api/v1/bridges": { + "get": { + "summary": "bridges", + "operationId": "bridges", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespGetBridgesByL1Addr" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "bridge" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get bridges for given l1 address" + } + }, + "/api/v1/bridges/isNextBridgeFast": { + "get": { + "summary": "bridges_isNextBridgeFast", + "operationId": "bridges_isNextBridgeFast", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespGetIsNextBridgeFast" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "bridge" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get if next bridge is fast" + } + }, + "/api/v1/candlesticks": { + "get": { + "summary": "candlesticks", + "operationId": "candlesticks", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Candlesticks" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": true, + "type": "integer", + "format": "int16" + }, + { + "name": "resolution", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "1m", + "5m", + "15m", + "30m", + "1h", + "4h", + "12h", + "1d", + "1w" + ] + }, + { + "name": "start_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "end_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "count_back", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "set_timestamp_to_end", + "in": "query", + "required": false, + "type": "boolean", + "format": "boolean", + "default": "false" + } + ], + "tags": [ + "candlestick" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get candlesticks" + } + }, + "/api/v1/changeAccountTier": { + "post": { + "summary": "changeAccountTier", + "operationId": "changeAccountTier", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespChangeAccountTier" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqChangeAccountTier" + } + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Change account tier" + } + }, + "/api/v1/currentHeight": { + "get": { + "summary": "currentHeight", + "operationId": "currentHeight", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/CurrentHeight" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "block" + ], + "description": "Get current height" + } + }, + "/api/v1/deposit/history": { + "get": { + "summary": "deposit_history", + "operationId": "deposit_history", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/DepositHistory" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "pending", + "claimable" + ] + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get deposit history" + } + }, + "/api/v1/exchangeStats": { + "get": { + "summary": "exchangeStats", + "operationId": "exchangeStats", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ExchangeStats" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "order" + ], + "description": "Get exchange stats" + } + }, + "/api/v1/export": { + "get": { + "summary": "export", + "operationId": "export", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ExportData" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64", + "default": "-1" + }, + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "type", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "funding", + "trade" + ] + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Export data" + } + }, + "/api/v1/fastbridge/info": { + "get": { + "summary": "fastbridge_info", + "operationId": "fastbridge_info", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespGetFastBridgeInfo" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "bridge" + ], + "description": "Get fast bridge info" + } + }, + "/api/v1/funding-rates": { + "get": { + "summary": "funding-rates", + "operationId": "funding-rates", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/FundingRates" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "funding" + ], + "description": "Get funding rates" + } + }, + "/api/v1/fundings": { + "get": { + "summary": "fundings", + "operationId": "fundings", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Fundings" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": true, + "type": "integer", + "format": "int16" + }, + { + "name": "resolution", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "1h", + "1d" + ] + }, + { + "name": "start_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "end_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "count_back", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "tags": [ + "candlestick" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get fundings" + } + }, + "/api/v1/l1Metadata": { + "get": { + "summary": "l1Metadata", + "operationId": "l1Metadata", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/L1Metadata" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get L1 metadata" + } + }, + "/api/v1/liquidations": { + "get": { + "summary": "liquidations", + "operationId": "liquidations", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/LiquidationInfos" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get liquidation infos" + } + }, + "/api/v1/nextNonce": { + "get": { + "summary": "nextNonce", + "operationId": "nextNonce", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/NextNonce" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "api_key_index", + "in": "query", + "required": true, + "type": "integer", + "format": "uint8" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get next nonce for a specific account and api key" + } + }, + "/api/v1/notification/ack": { + "post": { + "summary": "notification_ack", + "operationId": "notification_ack", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ResultCode" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqAckNotif" + } + } + ], + "tags": [ + "notification" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Ack notification" + } + }, + "/api/v1/orderBookDetails": { + "get": { + "summary": "orderBookDetails", + "operationId": "orderBookDetails", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/OrderBookDetails" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get order books metadata" + } + }, + "/api/v1/orderBookOrders": { + "get": { + "summary": "orderBookOrders", + "operationId": "orderBookOrders", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/OrderBookOrders" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": true, + "type": "integer", + "format": "int16" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 250 + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get order book orders" + } + }, + "/api/v1/orderBooks": { + "get": { + "summary": "orderBooks", + "operationId": "orderBooks", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/OrderBooks" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get order books metadata.
**Response Description:**

1) **Taker and maker fees** are in percentage.
2) **Min base amount:** The amount of base token that can be traded in a single order.
3) **Min quote amount:** The amount of quote token that can be traded in a single order.
4) **Supported size decimals:** The number of decimal places that can be used for the size of the order.
5) **Supported price decimals:** The number of decimal places that can be used for the price of the order.
6) **Supported quote decimals:** Size Decimals + Quote Decimals." + } + }, + "/api/v1/pnl": { + "get": { + "summary": "pnl", + "operationId": "pnl", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AccountPnL" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "index" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + }, + { + "name": "resolution", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "1m", + "5m", + "15m", + "1h", + "4h", + "1d" + ] + }, + { + "name": "start_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "end_timestamp", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 + }, + { + "name": "count_back", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "ignore_transfers", + "in": "query", + "required": false, + "type": "boolean", + "format": "boolean", + "default": "false" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get account PnL chart" + } + }, + "/api/v1/positionFunding": { + "get": { + "summary": "positionFunding", + "operationId": "positionFunding", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/PositionFundings" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "side", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "long", + "short", + "all" + ], + "default": "all" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get accounts position fundings" + } + }, + "/api/v1/publicPoolsMetadata": { + "get": { + "summary": "publicPoolsMetadata", + "operationId": "publicPoolsMetadata", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespPublicPoolsMetadata" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "user", + "protocol", + "account_index" + ] + }, + { + "name": "index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "account_index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + } + ], + "tags": [ + "account" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get public pools metadata" + } + }, + "/api/v1/recentTrades": { + "get": { + "summary": "recentTrades", + "operationId": "recentTrades", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Trades" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "market_id", + "in": "query", + "required": true, + "type": "integer", + "format": "int16" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get recent trades" + } + }, + "/api/v1/referral/kickback/update": { + "post": { + "summary": "referral_kickback_update", + "operationId": "referral_kickback_update", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespUpdateKickback" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqUpdateKickback" + } + } + ], + "tags": [ + "referral" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Update kickback percentage for referral rewards" + } + }, + "/api/v1/referral/points": { + "get": { + "summary": "referral_points", + "operationId": "referral_points", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ReferralPoints" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "tags": [ + "referral" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get referral points" + } + }, + "/api/v1/referral/update": { + "post": { + "summary": "referral_update", + "operationId": "referral_update", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespUpdateReferralCode" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqUpdateReferralCode" + } + } + ], + "tags": [ + "referral" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Update referral code (allowed once per account)" + } + }, + "/api/v1/sendTx": { + "post": { + "summary": "sendTx", + "operationId": "sendTx", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespSendTx" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqSendTx" + } + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers)" + } + }, + "/api/v1/sendTxBatch": { + "post": { + "summary": "sendTxBatch", + "operationId": "sendTxBatch", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespSendTxBatch" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqSendTxBatch" + } + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "You need to sign the transaction body before sending it to the server. More details can be found in the Get Started docs: [Get Started For Programmers](https://apidocs.lighter.xyz/docs/get-started-for-programmers)" + } + }, + "/api/v1/trades": { + "get": { + "summary": "trades", + "operationId": "trades", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Trades" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "market_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "255" + }, + { + "name": "account_index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64", + "default": "-1" + }, + { + "name": "order_index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "sort_by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "block_height", + "timestamp", + "trade_id" + ] + }, + { + "name": "sort_dir", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "desc" + ], + "default": "desc" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "from", + "in": "query", + "required": false, + "type": "integer", + "format": "int64", + "default": "-1" + }, + { + "name": "ask_filter", + "in": "query", + "required": false, + "type": "integer", + "format": "int8", + "default": "-1" + }, + { + "name": "role", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "maker", + "taker" + ], + "default": "all" + }, + { + "name": "type", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "trade", + "liquidation", + "deleverage", + "market-settlement" + ], + "default": "all" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "aggregate", + "in": "query", + "required": false, + "type": "boolean", + "format": "boolean", + "default": "false" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get trades" + } + }, + "/api/v1/transfer/history": { + "get": { + "summary": "transfer_history", + "operationId": "transfer_history", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/TransferHistory" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get transfer history" + } + }, + "/api/v1/transferFeeInfo": { + "get": { + "summary": "transferFeeInfo", + "operationId": "transferFeeInfo", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/TransferFeeInfo" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "auth", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "to_account_index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64", + "default": "-1" + } + ], + "tags": [ + "info" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Transfer fee info" + } + }, + "/api/v1/tx": { + "get": { + "summary": "tx", + "operationId": "tx", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/EnrichedTx" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "by", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "hash", + "sequence_index" + ] + }, + { + "name": "value", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get transaction by hash or sequence index" + } + }, + "/api/v1/txFromL1TxHash": { + "get": { + "summary": "txFromL1TxHash", + "operationId": "txFromL1TxHash", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/EnrichedTx" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "hash", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get L1 transaction by L1 transaction hash" + } + }, + "/api/v1/txs": { + "get": { + "summary": "txs", + "operationId": "txs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Txs" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "index", + "in": "query", + "required": false, + "type": "integer", + "format": "int64" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get transactions which are already packed into blocks" + } + }, + "/api/v1/withdraw/history": { + "get": { + "summary": "withdraw_history", + "operationId": "withdraw_history", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/WithdrawHistory" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "auth", + "description": " made optional to support header auth clients", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "cursor", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "pending", + "claimable" + ] + } + ], + "tags": [ + "transaction" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get withdraw history" + } + }, + "/api/v1/withdrawalDelay": { + "get": { + "summary": "withdrawalDelay", + "operationId": "withdrawalDelay", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespWithdrawalDelay" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "info" + ], + "description": "Withdrawal delay in seconds" + } + }, + "/info": { + "get": { + "summary": "info", + "operationId": "info", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ZkLighterInfo" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "tags": [ + "root" + ], + "description": "Get info of zklighter" + } + } + }, + "definitions": { + "Account": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "account_type": { + "type": "integer", + "format": "uint8", + "example": "1" + }, + "index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "cancel_all_time": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "total_order_count": { + "type": "integer", + "format": "int64", + "example": "100" + }, + "pending_order_count": { + "type": "integer", + "format": "int64", + "example": "100" + }, + "available_balance": { + "type": "string", + "example": "19995" + }, + "status": { + "type": "integer", + "format": "uint8", + "example": "1" + }, + "collateral": { + "type": "string", + "example": "46342" + } + }, + "title": "Account", + "required": [ + "code", + "account_type", + "index", + "l1_address", + "cancel_all_time", + "total_order_count", + "pending_order_count", + "available_balance", + "status", + "collateral" + ] + }, + "AccountApiKeys": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "api_keys": { + "type": "array", + "items": { + "$ref": "#/definitions/ApiKey" + } + } + }, + "title": "AccountApiKeys", + "required": [ + "code", + "api_keys" + ] + }, + "AccountAsset": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "USDC" + }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "balance": { + "type": "string", + "example": "1000" + }, + "locked_balance": { + "type": "string", + "example": "1000" + } + }, + "title": "AccountAsset", + "required": [ + "symbol", + "asset_id", + "balance", + "locked_balance" + ] + }, + "AccountLimits": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "max_llp_percentage": { + "type": "integer", + "format": "int32", + "example": "25" + }, + "max_llp_amount": { + "type": "string", + "example": "1000000" + }, + "user_tier": { + "type": "string", + "example": "std" + }, + "can_create_public_pool": { + "type": "boolean", + "format": "boolean", + "example": "true" + } + }, + "title": "AccountLimits", + "required": [ + "code", + "max_llp_percentage", + "max_llp_amount", + "user_tier", + "can_create_public_pool" + ] + }, + "AccountMarginStats": { + "type": "object", + "properties": { + "collateral": { + "type": "string", + "example": "199955" + }, + "portfolio_value": { + "type": "string", + "example": "199955" + }, + "leverage": { + "type": "string", + "example": "1.0" + }, + "available_balance": { + "type": "string", + "example": "199955" + }, + "margin_usage": { + "type": "string", + "example": "0.0" + }, + "buying_power": { + "type": "string", + "example": "199955" + } + }, + "title": "AccountMarginStats", + "required": [ + "collateral", + "portfolio_value", + "leverage", + "available_balance", + "margin_usage", + "buying_power" + ] + }, + "AccountMarketStats": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "weekly_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "weekly_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "weekly_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "monthly_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "monthly_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "monthly_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "total_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "total_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "total_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + } + }, + "title": "AccountMarketStats", + "required": [ + "market_id", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "weekly_trades_count", + "weekly_base_token_volume", + "weekly_quote_token_volume", + "monthly_trades_count", + "monthly_base_token_volume", + "monthly_quote_token_volume", + "total_trades_count", + "total_base_token_volume", + "total_quote_token_volume" + ] + }, + "AccountMetadata": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "can_invite": { + "type": "boolean", + "format": "boolean", + "description": " Remove After FE uses L1 meta endpoint" + }, + "referral_points_percentage": { + "type": "string", + "description": " Remove After FE uses L1 meta endpoint" + } + }, + "title": "AccountMetadata", + "required": [ + "account_index", + "name", + "description", + "can_invite", + "referral_points_percentage" + ] + }, + "AccountMetadatas": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "account_metadatas": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountMetadata" + } + } + }, + "title": "AccountMetadatas", + "required": [ + "code", + "account_metadatas" + ] + }, + "AccountPnL": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "resolution": { + "type": "string", + "example": "15m" + }, + "pnl": { + "type": "array", + "items": { + "$ref": "#/definitions/PnLEntry" + } + } + }, + "title": "AccountPnL", + "required": [ + "code", + "resolution", + "pnl" + ] + }, + "AccountPosition": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "symbol": { + "type": "string", + "example": "ETH" + }, + "initial_margin_fraction": { + "type": "string", + "example": "20.00" + }, + "open_order_count": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "pending_order_count": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "position_tied_order_count": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "sign": { + "type": "integer", + "format": "int32", + "example": "1" + }, + "position": { + "type": "string", + "example": "3.6956" + }, + "avg_entry_price": { + "type": "string", + "example": "3024.66" + }, + "position_value": { + "type": "string", + "example": "3019.92" + }, + "unrealized_pnl": { + "type": "string", + "example": "17.521309" + }, + "realized_pnl": { + "type": "string", + "example": "2.000000" + }, + "liquidation_price": { + "type": "string", + "example": "3024.66" + }, + "total_funding_paid_out": { + "type": "string", + "example": "34.2" + }, + "margin_mode": { + "type": "integer", + "format": "int32", + "example": "1" + }, + "allocated_margin": { + "type": "string", + "example": "46342" + } + }, + "title": "AccountPosition", + "required": [ + "market_id", + "symbol", + "initial_margin_fraction", + "open_order_count", + "pending_order_count", + "position_tied_order_count", + "sign", + "position", + "avg_entry_price", + "position_value", + "unrealized_pnl", + "realized_pnl", + "liquidation_price", + "margin_mode", + "allocated_margin" + ] + }, + "AccountStats": { + "type": "object", + "properties": { + "collateral": { + "type": "string", + "example": "199955" + }, + "portfolio_value": { + "type": "string", + "example": "199955" + }, + "leverage": { + "type": "string", + "example": "1.0" + }, + "available_balance": { + "type": "string", + "example": "199955" + }, + "margin_usage": { + "type": "string", + "example": "0.0" + }, + "buying_power": { + "type": "string", + "example": "199955" + }, + "cross_stats": { + "$ref": "#/definitions/AccountMarginStats" + }, + "total_stats": { + "$ref": "#/definitions/AccountMarginStats" + } + }, + "title": "AccountStats", + "required": [ + "collateral", + "portfolio_value", + "leverage", + "available_balance", + "margin_usage", + "buying_power", + "cross_stats", + "total_stats" + ] + }, + "AccountTradeStats": { + "type": "object", + "properties": { + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "weekly_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "weekly_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "monthly_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "monthly_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "total_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "total_volume": { + "type": "number", + "format": "double", + "example": "235.25" + } + }, + "title": "AccountTradeStats", + "required": [ + "daily_trades_count", + "daily_volume", + "weekly_trades_count", + "weekly_volume", + "monthly_trades_count", + "monthly_volume", + "total_trades_count", + "total_volume" + ] + }, + "Announcement": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "content": { + "type": "string" + }, + "created_at": { + "type": "integer", + "format": "int64" + }, + "expired_at": { + "type": "integer", + "format": "int64" + } + }, + "title": "Announcement", + "required": [ + "title", + "content", + "created_at", + "expired_at" + ] + }, + "Announcements": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "announcements": { + "type": "array", + "items": { + "$ref": "#/definitions/Announcement" + } + } + }, + "title": "Announcements", + "required": [ + "code", + "announcements" + ] + }, + "ApiKey": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "example": "0" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "722" + }, + "public_key": { + "type": "string" + } + }, + "title": "ApiKey", + "required": [ + "account_index", + "api_key_index", + "nonce", + "public_key" + ] + }, + "Asset": { + "type": "object", + "properties": { + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "symbol": { + "type": "string", + "example": "ETH" + }, + "l1_decimals": { + "type": "integer", + "format": "uint8", + "example": "18" + }, + "decimals": { + "type": "integer", + "format": "uint8", + "example": "2" + }, + "min_transfer_amount": { + "type": "string", + "example": "0.01" + }, + "min_withdrawal_amount": { + "type": "string", + "example": "0.01" + }, + "margin_mode": { + "type": "string", + "example": "enabled", + "enum": [ + "enabled", + "disabled" + ] + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "l1_address": { + "type": "string", + "example": "0x0000000000000000000000000000000000000000" + } + }, + "title": "Asset", + "required": [ + "asset_id", + "symbol", + "l1_decimals", + "decimals", + "min_transfer_amount", + "min_withdrawal_amount", + "margin_mode", + "index_price", + "l1_address" + ] + }, + "AssetDetails": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "asset_details": { + "type": "array", + "items": { + "$ref": "#/definitions/Asset" + } + } + }, + "title": "AssetDetails", + "required": [ + "code", + "asset_details" + ] + }, + "Block": { + "type": "object", + "properties": { + "commitment": { + "type": "string" + }, + "height": { + "type": "integer", + "format": "int64" + }, + "state_root": { + "type": "string" + }, + "priority_operations": { + "type": "integer", + "format": "int32" + }, + "on_chain_l2_operations": { + "type": "integer", + "format": "int32" + }, + "pending_on_chain_operations_pub_data": { + "type": "string" + }, + "committed_tx_hash": { + "type": "string" + }, + "committed_at": { + "type": "integer", + "format": "int64" + }, + "verified_tx_hash": { + "type": "string" + }, + "verified_at": { + "type": "integer", + "format": "int64" + }, + "txs": { + "type": "array", + "items": { + "$ref": "#/definitions/Tx" + } + }, + "status": { + "type": "integer", + "format": "int64" + }, + "size": { + "type": "integer", + "format": "uin16" + } + }, + "title": "Block", + "required": [ + "commitment", + "height", + "state_root", + "priority_operations", + "on_chain_l2_operations", + "pending_on_chain_operations_pub_data", + "committed_tx_hash", + "committed_at", + "verified_tx_hash", + "verified_at", + "txs", + "status", + "size" + ] + }, + "Blocks": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "total": { + "type": "integer", + "format": "int64" + }, + "blocks": { + "type": "array", + "items": { + "$ref": "#/definitions/Block" + } + } + }, + "title": "Blocks", + "required": [ + "code", + "total", + "blocks" + ] + }, + "Bridge": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "version": { + "type": "integer", + "format": "int32", + "enum": [ + "1", + "2" + ] + }, + "source": { + "type": "string", + "example": "Arbitrum" + }, + "source_chain_id": { + "type": "string", + "example": "42161" + }, + "fast_bridge_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "batch_claim_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "cctp_burn_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "amount": { + "type": "string" + }, + "intent_address": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "pending", + "bridging", + "completed" + ] + }, + "step": { + "type": "string" + }, + "description": { + "type": "string" + }, + "created_at": { + "type": "integer", + "format": "int64" + }, + "updated_at": { + "type": "integer", + "format": "int64" + }, + "is_external_deposit": { + "type": "boolean", + "format": "boolean" + } + }, + "title": "Bridge", + "required": [ + "id", + "version", + "source", + "source_chain_id", + "fast_bridge_tx_hash", + "batch_claim_tx_hash", + "cctp_burn_tx_hash", + "amount", + "intent_address", + "status", + "step", + "description", + "created_at", + "updated_at", + "is_external_deposit" + ] + }, + "BridgeSupportedNetwork": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "Arbitrum" + }, + "chain_id": { + "type": "string", + "example": "4164" + }, + "explorer": { + "type": "string", + "example": "https://arbiscan.io/" + } + }, + "title": "BridgeSupportedNetwork", + "required": [ + "name", + "chain_id", + "explorer" + ] + }, + "Candlestick": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "open": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "open_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high_raw": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low_raw": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "volume0": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "volume1": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "last_trade_id": { + "type": "integer", + "format": "int64", + "example": "1" + } + }, + "title": "Candlestick", + "required": [ + "timestamp", + "open", + "high", + "low", + "close", + "open_raw", + "high_raw", + "low_raw", + "close_raw", + "volume0", + "volume1", + "last_trade_id" + ] + }, + "Candlesticks": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "resolution": { + "type": "string", + "example": "15m" + }, + "candlesticks": { + "type": "array", + "items": { + "$ref": "#/definitions/Candlestick" + } + } + }, + "title": "Candlesticks", + "required": [ + "code", + "resolution", + "candlesticks" + ] + }, + "ContractAddress": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "1" + }, + "address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "ContractAddress", + "required": [ + "name", + "address" + ] + }, + "CurrentHeight": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "height": { + "type": "integer", + "format": "int64" + } + }, + "title": "CurrentHeight", + "required": [ + "code", + "height" + ] + }, + "Cursor": { + "type": "object", + "properties": { + "next_cursor": { + "type": "string" + } + }, + "title": "Cursor" + }, + "DailyReturn": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "daily_return": { + "type": "number", + "format": "double", + "example": "0.0001" + } + }, + "title": "DailyReturn", + "required": [ + "timestamp", + "daily_return" + ] + }, + "DepositHistory": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "deposits": { + "type": "array", + "items": { + "$ref": "#/definitions/DepositHistoryItem" + } + }, + "cursor": { + "type": "string" + } + }, + "title": "DepositHistory", + "required": [ + "code", + "deposits", + "cursor" + ] + }, + "DepositHistoryItem": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "amount": { + "type": "string", + "example": "0.1" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "pending", + "completed", + "claimable" + ] + }, + "l1_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "DepositHistoryItem", + "required": [ + "id", + "asset_id", + "amount", + "timestamp", + "status", + "l1_tx_hash" + ] + }, + "DetailedAccount": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "account_type": { + "type": "integer", + "format": "uint8", + "example": "1" + }, + "index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "cancel_all_time": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "total_order_count": { + "type": "integer", + "format": "int64", + "example": "100" + }, + "pending_order_count": { + "type": "integer", + "format": "int64", + "example": "100" + }, + "available_balance": { + "type": "string", + "example": "19995" + }, + "status": { + "type": "integer", + "format": "uint8", + "example": "1" + }, + "collateral": { + "type": "string", + "example": "46342" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "can_invite": { + "type": "boolean", + "format": "boolean", + "description": " Remove After FE uses L1 meta endpoint" + }, + "referral_points_percentage": { + "type": "string", + "description": " Remove After FE uses L1 meta endpoint" + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountPosition" + } + }, + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountAsset" + } + }, + "total_asset_value": { + "type": "string", + "example": "19995" + }, + "cross_asset_value": { + "type": "string", + "example": "19995" + }, + "pool_info": { + "$ref": "#/definitions/PublicPoolInfo" + }, + "shares": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicPoolShare" + } + } + }, + "title": "DetailedAccount", + "required": [ + "code", + "account_type", + "index", + "l1_address", + "cancel_all_time", + "total_order_count", + "pending_order_count", + "available_balance", + "status", + "collateral", + "account_index", + "name", + "description", + "can_invite", + "referral_points_percentage", + "positions", + "assets", + "total_asset_value", + "cross_asset_value", + "pool_info", + "shares" + ] + }, + "DetailedAccounts": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "total": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "accounts": { + "type": "array", + "items": { + "$ref": "#/definitions/DetailedAccount" + } + } + }, + "title": "DetailedAccounts", + "required": [ + "code", + "total", + "accounts" + ] + }, + "DetailedCandlestick": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "open": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "open_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high_raw": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low_raw": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "volume0": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "volume1": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "last_trade_id": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "trade_count": { + "type": "integer", + "format": "int64", + "example": "1503241" + } + }, + "title": "DetailedCandlestick", + "required": [ + "timestamp", + "open", + "high", + "low", + "close", + "open_raw", + "high_raw", + "low_raw", + "close_raw", + "volume0", + "volume1", + "last_trade_id", + "trade_count" + ] + }, + "EnrichedTx": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "type": { + "type": "integer", + "format": "uint8", + "example": "1", + "maximum": 64, + "minimum": 1 + }, + "info": { + "type": "string", + "example": "{}" + }, + "event_info": { + "type": "string", + "example": "{}" + }, + "status": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "transaction_index": { + "type": "integer", + "format": "int64", + "example": "8761" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "722" + }, + "expire_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "block_height": { + "type": "integer", + "format": "int64", + "example": "45434" + }, + "queued_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "executed_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "sequence_index": { + "type": "integer", + "format": "int64", + "example": "8761" + }, + "parent_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "example": "0" + }, + "committed_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "verified_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + } + }, + "title": "EnrichedTx", + "required": [ + "code", + "hash", + "type", + "info", + "event_info", + "status", + "transaction_index", + "l1_address", + "account_index", + "nonce", + "expire_at", + "block_height", + "queued_at", + "executed_at", + "sequence_index", + "parent_hash", + "api_key_index", + "committed_at", + "verified_at" + ] + }, + "ExchangeStats": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "total": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "order_book_stats": { + "type": "array", + "example": "1", + "items": { + "$ref": "#/definitions/OrderBookStats" + } + }, + "daily_usd_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + } + }, + "title": "ExchangeStats", + "required": [ + "code", + "total", + "order_book_stats", + "daily_usd_volume", + "daily_trades_count" + ] + }, + "ExportData": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "data_url": { + "type": "string" + } + }, + "title": "ExportData", + "required": [ + "code", + "data_url" + ] + }, + "Funding": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "value": { + "type": "string", + "example": "0.0001" + }, + "rate": { + "type": "string", + "example": "0.0001" + }, + "direction": { + "type": "string", + "example": "long" + } + }, + "title": "Funding", + "required": [ + "timestamp", + "value", + "rate", + "direction" + ] + }, + "FundingRate": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "exchange": { + "type": "string", + "enum": [ + "binance", + "bybit", + "hyperliquid", + "lighter" + ] + }, + "symbol": { + "type": "string" + }, + "rate": { + "type": "number", + "format": "double" + } + }, + "title": "FundingRate", + "required": [ + "market_id", + "exchange", + "symbol", + "rate" + ] + }, + "FundingRates": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "funding_rates": { + "type": "array", + "items": { + "$ref": "#/definitions/FundingRate" + } + } + }, + "title": "FundingRates", + "required": [ + "code", + "funding_rates" + ] + }, + "Fundings": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "resolution": { + "type": "string", + "example": "1h" + }, + "fundings": { + "type": "array", + "items": { + "$ref": "#/definitions/Funding" + } + } + }, + "title": "Fundings", + "required": [ + "code", + "resolution", + "fundings" + ] + }, + "L1Metadata": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + }, + "can_invite": { + "type": "boolean", + "format": "boolean" + }, + "referral_points_percentage": { + "type": "string" + } + }, + "title": "L1Metadata", + "required": [ + "l1_address", + "can_invite", + "referral_points_percentage" + ] + }, + "L1ProviderInfo": { + "type": "object", + "properties": { + "chainId": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "networkId": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "latestBlockNumber": { + "type": "integer", + "format": "int64", + "example": "45434" + } + }, + "title": "L1ProviderInfo", + "required": [ + "chainId", + "networkId", + "latestBlockNumber" + ] + }, + "LiqTrade": { + "type": "object", + "properties": { + "price": { + "type": "string" + }, + "size": { + "type": "string" + }, + "taker_fee": { + "type": "string" + }, + "maker_fee": { + "type": "string" + } + }, + "title": "LiqTrade", + "required": [ + "price", + "size", + "taker_fee", + "maker_fee" + ] + }, + "Liquidation": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "market_id": { + "type": "integer", + "format": "int16" + }, + "type": { + "type": "string", + "enum": [ + "partial", + "deleverage" + ] + }, + "trade": { + "$ref": "#/definitions/LiqTrade" + }, + "info": { + "$ref": "#/definitions/LiquidationInfo" + }, + "executed_at": { + "type": "integer", + "format": "int64" + } + }, + "title": "Liquidation", + "required": [ + "id", + "market_id", + "type", + "trade", + "info", + "executed_at" + ] + }, + "LiquidationInfo": { + "type": "object", + "properties": { + "positions": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountPosition" + } + }, + "risk_info_before": { + "$ref": "#/definitions/RiskInfo" + }, + "risk_info_after": { + "$ref": "#/definitions/RiskInfo" + }, + "mark_prices": { + "type": "object", + "additionalProperties": { + "type": "number", + "format": "double" + } + } + }, + "title": "LiquidationInfo", + "required": [ + "positions", + "risk_info_before", + "risk_info_after", + "mark_prices" + ] + }, + "LiquidationInfos": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "liquidations": { + "type": "array", + "items": { + "$ref": "#/definitions/Liquidation" + } + }, + "next_cursor": { + "type": "string" + } + }, + "title": "LiquidationInfos", + "required": [ + "code", + "liquidations" + ] + }, + "MarketConfig": { + "type": "object", + "properties": { + "market_margin_mode": { + "type": "integer", + "format": "int32" + }, + "insurance_fund_account_index": { + "type": "integer", + "format": "int64" + }, + "liquidation_mode": { + "type": "integer", + "format": "int32" + }, + "force_reduce_only": { + "type": "boolean", + "format": "boolean" + }, + "trading_hours": { + "type": "string" + } + }, + "title": "MarketConfig", + "required": [ + "market_margin_mode", + "insurance_fund_account_index", + "liquidation_mode", + "force_reduce_only", + "trading_hours" + ] + }, + "NextNonce": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "722" + } + }, + "title": "NextNonce", + "required": [ + "code", + "nonce" + ] + }, + "Order": { + "type": "object", + "properties": { + "order_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "client_order_index": { + "type": "integer", + "format": "int64", + "example": "234" + }, + "order_id": { + "type": "string", + "example": "1" + }, + "client_order_id": { + "type": "string", + "example": "234" + }, + "market_index": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "owner_account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "initial_base_amount": { + "type": "string", + "example": "0.1" + }, + "price": { + "type": "string", + "example": "3024.66" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "722" + }, + "remaining_base_amount": { + "type": "string", + "example": "0.1" + }, + "is_ask": { + "type": "boolean", + "format": "boolean", + "example": "true" + }, + "base_size": { + "type": "integer", + "format": "int64", + "example": "12354" + }, + "base_price": { + "type": "integer", + "format": "int32", + "example": "3024" + }, + "filled_base_amount": { + "type": "string", + "example": "0.1" + }, + "filled_quote_amount": { + "type": "string", + "example": "0.1" + }, + "side": { + "type": "string", + "example": "buy", + "default": "buy", + "description": " TODO: remove this" + }, + "type": { + "type": "string", + "example": "limit", + "enum": [ + "limit", + "market", + "stop-loss", + "stop-loss-limit", + "take-profit", + "take-profit-limit", + "twap", + "twap-sub", + "liquidation" + ] + }, + "time_in_force": { + "type": "string", + "enum": [ + "good-till-time", + "immediate-or-cancel", + "post-only", + "Unknown" + ], + "default": "good-till-time" + }, + "reduce_only": { + "type": "boolean", + "format": "boolean", + "example": "true" + }, + "trigger_price": { + "type": "string", + "example": "3024.66" + }, + "order_expiry": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "status": { + "type": "string", + "example": "open", + "enum": [ + "in-progress", + "pending", + "open", + "filled", + "canceled", + "canceled-post-only", + "canceled-reduce-only", + "canceled-position-not-allowed", + "canceled-margin-not-allowed", + "canceled-too-much-slippage", + "canceled-not-enough-liquidity", + "canceled-self-trade", + "canceled-expired", + "canceled-oco", + "canceled-child", + "canceled-liquidation", + "canceled-invalid-balance" + ] + }, + "trigger_status": { + "type": "string", + "example": "twap", + "enum": [ + "na", + "ready", + "mark-price", + "twap", + "parent-order" + ] + }, + "trigger_time": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "parent_order_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "parent_order_id": { + "type": "string", + "example": "1" + }, + "to_trigger_order_id_0": { + "type": "string", + "example": "1" + }, + "to_trigger_order_id_1": { + "type": "string", + "example": "1" + }, + "to_cancel_order_id_0": { + "type": "string", + "example": "1" + }, + "block_height": { + "type": "integer", + "format": "int64", + "example": "45434" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "created_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "updated_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + } + }, + "title": "Order", + "required": [ + "order_index", + "client_order_index", + "order_id", + "client_order_id", + "market_index", + "owner_account_index", + "initial_base_amount", + "price", + "nonce", + "remaining_base_amount", + "is_ask", + "base_size", + "base_price", + "filled_base_amount", + "filled_quote_amount", + "side", + "type", + "time_in_force", + "reduce_only", + "trigger_price", + "order_expiry", + "status", + "trigger_status", + "trigger_time", + "parent_order_index", + "parent_order_id", + "to_trigger_order_id_0", + "to_trigger_order_id_1", + "to_cancel_order_id_0", + "block_height", + "timestamp", + "created_at", + "updated_at" + ] + }, + "OrderBook": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] + }, + "base_asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" + }, + "status": { + "type": "string", + "example": "active", + "enum": [ + "inactive", + "active" + ] + }, + "taker_fee": { + "type": "string", + "example": "0.0001" + }, + "maker_fee": { + "type": "string", + "example": "0.0000" + }, + "liquidation_fee": { + "type": "string", + "example": "0.01" + }, + "min_base_amount": { + "type": "string", + "example": "0.01" + }, + "min_quote_amount": { + "type": "string", + "example": "0.1" + }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, + "supported_size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_quote_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + } + }, + "title": "OrderBook", + "required": [ + "symbol", + "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", + "status", + "taker_fee", + "maker_fee", + "liquidation_fee", + "min_base_amount", + "min_quote_amount", + "order_quote_limit", + "supported_size_decimals", + "supported_price_decimals", + "supported_quote_decimals" + ] + }, + "OrderBookDepth": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "asks": { + "type": "array", + "items": { + "$ref": "#/definitions/PriceLevel" + } + }, + "bids": { + "type": "array", + "items": { + "$ref": "#/definitions/PriceLevel" + } + }, + "offset": { + "type": "integer", + "format": "int64", + "example": "0" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "0" + } + }, + "title": "OrderBookDepth", + "required": [ + "code", + "asks", + "bids", + "offset", + "nonce" + ] + }, + "OrderBookDetails": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "order_book_details": { + "type": "array", + "items": { + "$ref": "#/definitions/PerpsOrderBookDetail" + } + }, + "spot_order_book_details": { + "type": "array", + "items": { + "$ref": "#/definitions/SpotOrderBookDetail" + } + } + }, + "title": "OrderBookDetails", + "required": [ + "code", + "order_book_details", + "spot_order_book_details" + ] + }, + "OrderBookOrders": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "total_asks": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "asks": { + "type": "array", + "items": { + "$ref": "#/definitions/SimpleOrder" + } + }, + "total_bids": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "bids": { + "type": "array", + "items": { + "$ref": "#/definitions/SimpleOrder" + } + } + }, + "title": "OrderBookOrders", + "required": [ + "code", + "total_asks", + "asks", + "total_bids", + "bids" + ] + }, + "OrderBookStats": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "last_trade_price": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + } + }, + "title": "OrderBookStats", + "required": [ + "symbol", + "last_trade_price", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_change" + ] + }, + "OrderBooks": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "order_books": { + "type": "array", + "items": { + "$ref": "#/definitions/OrderBook" + } + } + }, + "title": "OrderBooks", + "required": [ + "code", + "order_books" + ] + }, + "Orders": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "next_cursor": { + "type": "string" + }, + "orders": { + "type": "array", + "items": { + "$ref": "#/definitions/Order" + } + } + }, + "title": "Orders", + "required": [ + "code", + "orders" + ] + }, + "PerpsMarketStats": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "mark_price": { + "type": "string", + "example": "3024.66" + }, + "open_interest": { + "type": "string", + "example": "235.25" + }, + "open_interest_limit": { + "type": "string", + "example": "235.25" + }, + "funding_clamp_small": { + "type": "string", + "example": "0.005" + }, + "funding_clamp_big": { + "type": "string", + "example": "0.4" + }, + "last_trade_price": { + "type": "string", + "example": "3024.66" + }, + "current_funding_rate": { + "type": "string", + "example": "0.0001" + }, + "funding_rate": { + "type": "string", + "example": "0.0001" + }, + "funding_timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + } + }, + "title": "PerpsMarketStats", + "required": [ + "symbol", + "market_id", + "index_price", + "mark_price", + "open_interest", + "open_interest_limit", + "funding_clamp_small", + "funding_clamp_big", + "last_trade_price", + "current_funding_rate", + "funding_rate", + "funding_timestamp", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change" + ] + }, + "PerpsOrderBookDetail": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] + }, + "base_asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" + }, + "status": { + "type": "string", + "example": "active", + "enum": [ + "inactive", + "active" + ] + }, + "taker_fee": { + "type": "string", + "example": "0.0001" + }, + "maker_fee": { + "type": "string", + "example": "0.0000" + }, + "liquidation_fee": { + "type": "string", + "example": "0.01" + }, + "min_base_amount": { + "type": "string", + "example": "0.01" + }, + "min_quote_amount": { + "type": "string", + "example": "0.1" + }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, + "supported_size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_quote_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "quote_multiplier": { + "type": "integer", + "format": "int64", + "example": "10000" + }, + "default_initial_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "min_initial_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "maintenance_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "50" + }, + "closeout_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "last_trade_price": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + }, + "open_interest": { + "type": "number", + "format": "double", + "example": "93.0" + }, + "daily_chart": { + "type": "object", + "example": "{1640995200:3024.66}", + "additionalProperties": { + "type": "number", + "format": "double" + } + }, + "market_config": { + "$ref": "#/definitions/MarketConfig" + } + }, + "title": "PerpsOrderBookDetail", + "required": [ + "symbol", + "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", + "status", + "taker_fee", + "maker_fee", + "liquidation_fee", + "min_base_amount", + "min_quote_amount", + "order_quote_limit", + "supported_size_decimals", + "supported_price_decimals", + "supported_quote_decimals", + "size_decimals", + "price_decimals", + "quote_multiplier", + "default_initial_margin_fraction", + "min_initial_margin_fraction", + "maintenance_margin_fraction", + "closeout_margin_fraction", + "last_trade_price", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change", + "open_interest", + "daily_chart", + "market_config" + ] + }, + "PnLEntry": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "trade_pnl": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "trade_spot_pnl": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "inflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "outflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "spot_outflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "spot_inflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "pool_pnl": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "pool_inflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "pool_outflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "pool_total_shares": { + "type": "number", + "format": "double", + "example": "12.0" + } + }, + "title": "PnLEntry", + "required": [ + "timestamp", + "trade_pnl", + "trade_spot_pnl", + "inflow", + "outflow", + "spot_outflow", + "spot_inflow", + "pool_pnl", + "pool_inflow", + "pool_outflow", + "pool_total_shares" + ] + }, + "PositionFunding": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "funding_id": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "change": { + "type": "string", + "example": "1" + }, + "rate": { + "type": "string", + "example": "1" + }, + "position_size": { + "type": "string", + "example": "1" + }, + "position_side": { + "type": "string", + "example": "long", + "enum": [ + "long", + "short" + ] + } + }, + "title": "PositionFunding", + "required": [ + "timestamp", + "market_id", + "funding_id", + "change", + "rate", + "position_size", + "position_side" + ] + }, + "PositionFundings": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "position_fundings": { + "type": "array", + "items": { + "$ref": "#/definitions/PositionFunding" + } + }, + "next_cursor": { + "type": "string" + } + }, + "title": "PositionFundings", + "required": [ + "code", + "position_fundings" + ] + }, + "PriceLevel": { + "type": "object", + "properties": { + "price": { + "type": "string", + "example": "3024.66" + }, + "size": { + "type": "string", + "example": "0.1" + } + }, + "title": "PriceLevel", + "required": [ + "price", + "size" + ] + }, + "PublicPoolInfo": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "uint8", + "example": "0" + }, + "operator_fee": { + "type": "string", + "example": "100" + }, + "min_operator_share_rate": { + "type": "string", + "example": "200" + }, + "total_shares": { + "type": "integer", + "format": "int64", + "example": "100000" + }, + "operator_shares": { + "type": "integer", + "format": "int64", + "example": "20000" + }, + "annual_percentage_yield": { + "type": "number", + "format": "double", + "example": "20.5000" + }, + "sharpe_ratio": { + "type": "number", + "format": "double", + "example": "1.5" + }, + "daily_returns": { + "type": "array", + "items": { + "$ref": "#/definitions/DailyReturn" + } + }, + "share_prices": { + "type": "array", + "items": { + "$ref": "#/definitions/SharePrice" + } + } + }, + "title": "PublicPoolInfo", + "required": [ + "status", + "operator_fee", + "min_operator_share_rate", + "total_shares", + "operator_shares", + "annual_percentage_yield", + "sharpe_ratio", + "daily_returns", + "share_prices" + ] + }, + "PublicPoolMetadata": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "account_index": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "created_at": { + "type": "integer", + "format": "int64" + }, + "master_account_index": { + "type": "integer", + "format": "int64", + "example": "61" + }, + "account_type": { + "type": "integer", + "format": "uint8", + "example": "1" + }, + "name": { + "type": "string" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "annual_percentage_yield": { + "type": "number", + "format": "double", + "example": "20.5000" + }, + "sharpe_ratio": { + "type": "number", + "format": "double", + "example": "1.5" + }, + "status": { + "type": "integer", + "format": "uint8", + "example": "0" + }, + "operator_fee": { + "type": "string", + "example": "100" + }, + "total_asset_value": { + "type": "string", + "example": "19995" + }, + "total_shares": { + "type": "integer", + "format": "int64", + "example": "100000" + }, + "account_share": { + "$ref": "#/definitions/PublicPoolShare" + } + }, + "title": "PublicPoolMetadata", + "required": [ + "code", + "account_index", + "created_at", + "master_account_index", + "account_type", + "name", + "l1_address", + "annual_percentage_yield", + "sharpe_ratio", + "status", + "operator_fee", + "total_asset_value", + "total_shares" + ] + }, + "PublicPoolShare": { + "type": "object", + "properties": { + "public_pool_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "shares_amount": { + "type": "integer", + "format": "int64", + "example": "3000" + }, + "entry_usdc": { + "type": "string", + "example": "3000" + } + }, + "title": "PublicPoolShare", + "required": [ + "public_pool_index", + "shares_amount", + "entry_usdc" + ] + }, + "ReferralPointEntry": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + }, + "total_points": { + "type": "number", + "format": "float", + "example": "1000.01" + }, + "week_points": { + "type": "number", + "format": "float", + "example": "1000.01" + }, + "total_reward_points": { + "type": "number", + "format": "float", + "example": "200" + }, + "week_reward_points": { + "type": "number", + "format": "float", + "example": "200" + }, + "reward_point_multiplier": { + "type": "string", + "example": "0.1" + } + }, + "title": "ReferralPointEntry", + "required": [ + "l1_address", + "total_points", + "week_points", + "total_reward_points", + "week_reward_points", + "reward_point_multiplier" + ] + }, + "ReferralPoints": { + "type": "object", + "properties": { + "referrals": { + "type": "array", + "items": { + "$ref": "#/definitions/ReferralPointEntry" + } + }, + "user_total_points": { + "type": "number", + "format": "float", + "example": "1000" + }, + "user_last_week_points": { + "type": "number", + "format": "float", + "example": "1000" + }, + "user_total_referral_reward_points": { + "type": "number", + "format": "float", + "example": "1000" + }, + "user_last_week_referral_reward_points": { + "type": "number", + "format": "float", + "example": "1000" + }, + "reward_point_multiplier": { + "type": "string", + "example": "0.1" + } + }, + "title": "ReferralPoints", + "required": [ + "referrals", + "user_total_points", + "user_last_week_points", + "user_total_referral_reward_points", + "user_last_week_referral_reward_points", + "reward_point_multiplier" + ] + }, + "ReqAckNotif": { + "type": "object", + "properties": { + "notif_id": { + "type": "string", + "example": "'liq:17:5898'" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + } + }, + "title": "ReqAckNotif", + "required": [ + "notif_id", + "account_index" + ] + }, + "ReqChangeAccountTier": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "new_tier": { + "type": "string" + } + }, + "title": "ReqChangeAccountTier", + "required": [ + "account_index", + "new_tier" + ] + }, + "ReqExportData": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "account_index": { + "type": "integer", + "format": "int64", + "default": "-1" + }, + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "type": { + "type": "string", + "enum": [ + "funding", + "trade" + ] + } + }, + "title": "ReqExportData", + "required": [ + "type" + ] + }, + "ReqGetAccount": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "index", + "l1_address" + ] + }, + "value": { + "type": "string" + } + }, + "title": "ReqGetAccount", + "required": [ + "by", + "value" + ] + }, + "ReqGetAccountActiveOrders": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "market_id": { + "type": "integer", + "format": "int16" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + } + }, + "title": "ReqGetAccountActiveOrders", + "required": [ + "account_index", + "market_id" + ] + }, + "ReqGetAccountApiKeys": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "default": "255" + } + }, + "title": "ReqGetAccountApiKeys", + "required": [ + "account_index" + ] + }, + "ReqGetAccountByL1Address": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + } + }, + "title": "ReqGetAccountByL1Address", + "required": [ + "l1_address" + ] + }, + "ReqGetAccountInactiveOrders": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "ask_filter": { + "type": "integer", + "format": "int8", + "default": "-1" + }, + "between_timestamps": { + "type": "string" + }, + "cursor": { + "type": "string" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + } + }, + "title": "ReqGetAccountInactiveOrders", + "required": [ + "account_index", + "limit" + ] + }, + "ReqGetAccountLimits": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + } + }, + "title": "ReqGetAccountLimits", + "required": [ + "account_index" + ] + }, + "ReqGetAccountMetadata": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "index", + "l1_address" + ] + }, + "value": { + "type": "string" + }, + "auth": { + "type": "string" + } + }, + "title": "ReqGetAccountMetadata", + "required": [ + "by", + "value" + ] + }, + "ReqGetAccountPnL": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "by": { + "type": "string", + "enum": [ + "index" + ] + }, + "value": { + "type": "string" + }, + "resolution": { + "type": "string", + "enum": [ + "1m", + "5m", + "15m", + "1h", + "4h", + "1d" + ] + }, + "start_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "end_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "count_back": { + "type": "integer", + "format": "int64" + }, + "ignore_transfers": { + "type": "boolean", + "format": "boolean", + "default": "false" + } + }, + "title": "ReqGetAccountPnL", + "required": [ + "by", + "value", + "resolution", + "start_timestamp", + "end_timestamp", + "count_back" + ] + }, + "ReqGetAccountTxs": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "format": "int64" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + }, + "by": { + "type": "string", + "enum": [ + "account_index" + ] + }, + "value": { + "type": "string" + }, + "types": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + "auth": { + "type": "string" + } + }, + "title": "ReqGetAccountTxs" + }, + "ReqGetAssetDetails": { + "type": "object", + "properties": { + "asset_id": { + "type": "integer", + "format": "int16", + "default": "0" + } + }, + "title": "ReqGetAssetDetails" + }, + "ReqGetBlock": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "commitment", + "height" + ] + }, + "value": { + "type": "string" + } + }, + "title": "ReqGetBlock", + "required": [ + "by", + "value" + ] + }, + "ReqGetBlockTxs": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "block_height", + "block_commitment" + ] + }, + "value": { + "type": "string" + } + }, + "title": "ReqGetBlockTxs", + "required": [ + "by", + "value" + ] + }, + "ReqGetBridgesByL1Addr": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + } + }, + "title": "ReqGetBridgesByL1Addr", + "required": [ + "l1_address" + ] + }, + "ReqGetByAccount": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "account_index" + ] + }, + "value": { + "type": "string" + } + }, + "title": "ReqGetByAccount", + "required": [ + "by", + "value" + ] + }, + "ReqGetCandlesticks": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "resolution": { + "type": "string", + "enum": [ + "1m", + "5m", + "15m", + "30m", + "1h", + "4h", + "12h", + "1d", + "1w" + ] + }, + "start_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "end_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "count_back": { + "type": "integer", + "format": "int64" + }, + "set_timestamp_to_end": { + "type": "boolean", + "format": "boolean", + "default": "false" + } + }, + "title": "ReqGetCandlesticks", + "required": [ + "market_id", + "resolution", + "start_timestamp", + "end_timestamp", + "count_back" + ] + }, + "ReqGetDepositHistory": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "l1_address": { + "type": "string" + }, + "cursor": { + "type": "string" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "pending", + "claimable" + ] + } + }, + "title": "ReqGetDepositHistory", + "required": [ + "account_index", + "l1_address" + ] + }, + "ReqGetExchangeStats": { + "type": "object", + "title": "ReqGetExchangeStats" + }, + "ReqGetFastWithdrawInfo": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + } + }, + "title": "ReqGetFastWithdrawInfo", + "required": [ + "account_index" + ] + }, + "ReqGetFundings": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "resolution": { + "type": "string", + "enum": [ + "1h", + "1d" + ] + }, + "start_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "end_timestamp": { + "type": "integer", + "format": "int64", + "maximum": 5000000000000 + }, + "count_back": { + "type": "integer", + "format": "int64" + } + }, + "title": "ReqGetFundings", + "required": [ + "market_id", + "resolution", + "start_timestamp", + "end_timestamp", + "count_back" + ] + }, + "ReqGetL1Metadata": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "l1_address": { + "type": "string" + } + }, + "title": "ReqGetL1Metadata", + "required": [ + "l1_address" + ] + }, + "ReqGetL1Tx": { + "type": "object", + "properties": { + "hash": { + "type": "string" + } + }, + "title": "ReqGetL1Tx", + "required": [ + "hash" + ] + }, + "ReqGetLatestDeposit": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + } + }, + "title": "ReqGetLatestDeposit", + "required": [ + "l1_address" + ] + }, + "ReqGetLiquidationInfos": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "cursor": { + "type": "string" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + } + }, + "title": "ReqGetLiquidationInfos", + "required": [ + "account_index", + "limit" + ] + }, + "ReqGetNextNonce": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "api_key_index": { + "type": "integer", + "format": "uint8" + } + }, + "title": "ReqGetNextNonce", + "required": [ + "account_index", + "api_key_index" + ] + }, + "ReqGetOrderBookDetails": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" + } + }, + "title": "ReqGetOrderBookDetails" + }, + "ReqGetOrderBookOrders": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 250, + "minimum": 1 + } + }, + "title": "ReqGetOrderBookOrders", + "required": [ + "market_id", + "limit" + ] + }, + "ReqGetOrderBooks": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" + } + }, + "title": "ReqGetOrderBooks" + }, + "ReqGetPositionFunding": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "cursor": { + "type": "string" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + }, + "side": { + "type": "string", + "enum": [ + "long", + "short", + "all" + ], + "default": "all" + } + }, + "title": "ReqGetPositionFunding", + "required": [ + "account_index", + "limit" + ] + }, + "ReqGetPublicPoolsMetadata": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "user", + "protocol", + "account_index" + ] + }, + "index": { + "type": "integer", + "format": "int64" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + }, + "account_index": { + "type": "integer", + "format": "int64" + } + }, + "title": "ReqGetPublicPoolsMetadata", + "required": [ + "index", + "limit" + ] + }, + "ReqGetRangeWithCursor": { + "type": "object", + "properties": { + "cursor": { + "type": "string" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + } + }, + "title": "ReqGetRangeWithCursor", + "required": [ + "limit" + ] + }, + "ReqGetRangeWithIndex": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "format": "int64" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + } + }, + "title": "ReqGetRangeWithIndex", + "required": [ + "limit" + ] + }, + "ReqGetRangeWithIndexSortable": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "format": "int64" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + }, + "sort": { + "type": "string", + "enum": [ + "asc", + "desc" + ], + "default": "asc" + } + }, + "title": "ReqGetRangeWithIndexSortable" + }, + "ReqGetRecentTrades": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + } + }, + "title": "ReqGetRecentTrades", + "required": [ + "market_id", + "limit" + ] + }, + "ReqGetReferralPoints": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + } + }, + "title": "ReqGetReferralPoints", + "required": [ + "account_index" + ] + }, + "ReqGetTrades": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "market_id": { + "type": "integer", + "format": "int16", + "default": "255" + }, + "account_index": { + "type": "integer", + "format": "int64", + "default": "-1" + }, + "order_index": { + "type": "integer", + "format": "int64" + }, + "sort_by": { + "type": "string", + "enum": [ + "block_height", + "timestamp", + "trade_id" + ] + }, + "sort_dir": { + "type": "string", + "enum": [ + "desc" + ], + "default": "desc" + }, + "cursor": { + "type": "string" + }, + "from": { + "type": "integer", + "format": "int64", + "default": "-1" + }, + "ask_filter": { + "type": "integer", + "format": "int8", + "default": "-1" + }, + "role": { + "type": "string", + "enum": [ + "all", + "maker", + "taker" + ], + "default": "all" + }, + "type": { + "type": "string", + "enum": [ + "all", + "trade", + "liquidation", + "deleverage", + "market-settlement" + ], + "default": "all" + }, + "limit": { + "type": "integer", + "format": "int64", + "maximum": 100, + "minimum": 1 + }, + "aggregate": { + "type": "boolean", + "format": "boolean", + "default": "false" + } + }, + "title": "ReqGetTrades", + "required": [ + "sort_by", + "limit" + ] + }, + "ReqGetTransferFeeInfo": { + "type": "object", + "properties": { + "auth": { + "type": "string" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "to_account_index": { + "type": "integer", + "format": "int64", + "default": "-1" + } + }, + "title": "ReqGetTransferFeeInfo", + "required": [ + "account_index" + ] + }, + "ReqGetTransferHistory": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "cursor": { + "type": "string" + } + }, + "title": "ReqGetTransferHistory", + "required": [ + "account_index" + ] + }, + "ReqGetTx": { + "type": "object", + "properties": { + "by": { + "type": "string", + "enum": [ + "hash", + "sequence_index" + ] + }, + "value": { + "type": "string" + } + }, + "title": "ReqGetTx", + "required": [ + "by", + "value" + ] + }, + "ReqGetWithdrawHistory": { + "type": "object", + "properties": { + "account_index": { + "type": "integer", + "format": "int64" + }, + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "cursor": { + "type": "string" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "pending", + "claimable" + ] + } + }, + "title": "ReqGetWithdrawHistory", + "required": [ + "account_index" + ] + }, + "ReqSendTx": { + "type": "object", + "properties": { + "tx_type": { + "type": "integer", + "format": "uint8" + }, + "tx_info": { + "type": "string" + }, + "price_protection": { + "type": "boolean", + "format": "boolean", + "default": "true" + } + }, + "title": "ReqSendTx", + "required": [ + "tx_type", + "tx_info" + ] + }, + "ReqSendTxBatch": { + "type": "object", + "properties": { + "tx_types": { + "type": "string" + }, + "tx_infos": { + "type": "string" + } + }, + "title": "ReqSendTxBatch", + "required": [ + "tx_types", + "tx_infos" + ] + }, + "ReqUpdateKickback": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "kickback_percentage": { + "type": "number", + "format": "double", + "maximum": 100 + } + }, + "title": "ReqUpdateKickback", + "required": [ + "account_index", + "kickback_percentage" + ] + }, + "ReqUpdateReferralCode": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "new_referral_code": { + "type": "string" + } + }, + "title": "ReqUpdateReferralCode", + "required": [ + "account_index", + "new_referral_code" + ] + }, + "RespChangeAccountTier": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + } + }, + "title": "RespChangeAccountTier", + "required": [ + "code" + ] + }, + "RespGetBridgesByL1Addr": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "bridges": { + "type": "array", + "items": { + "$ref": "#/definitions/Bridge" + } + } + }, + "title": "RespGetBridgesByL1Addr", + "required": [ + "code", + "bridges" + ] + }, + "RespGetFastBridgeInfo": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "fast_bridge_limit": { + "type": "string" + } + }, + "title": "RespGetFastBridgeInfo", + "required": [ + "code", + "fast_bridge_limit" + ] + }, + "RespGetIsNextBridgeFast": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "is_next_bridge_fast": { + "type": "boolean", + "format": "boolean" + } + }, + "title": "RespGetIsNextBridgeFast", + "required": [ + "code", + "is_next_bridge_fast" + ] + }, + "RespPublicPoolsMetadata": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "public_pools": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicPoolMetadata" + } + } + }, + "title": "RespPublicPoolsMetadata", + "required": [ + "code", + "public_pools" + ] + }, + "RespSendTx": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "predicted_execution_time_ms": { + "type": "integer", + "format": "int64", + "example": "1751465474" + }, + "volume_quota_remaining": { + "type": "integer", + "format": "int64" + } + }, + "title": "RespSendTx", + "required": [ + "code", + "tx_hash", + "predicted_execution_time_ms", + "volume_quota_remaining" + ] + }, + "RespSendTxBatch": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "tx_hash": { + "type": "array", + "items": { + "type": "string" + } + }, + "predicted_execution_time_ms": { + "type": "integer", + "format": "int64", + "example": "1751465474" + }, + "volume_quota_remaining": { + "type": "integer", + "format": "int64" + } + }, + "title": "RespSendTxBatch", + "required": [ + "code", + "tx_hash", + "predicted_execution_time_ms", + "volume_quota_remaining" + ] + }, + "RespUpdateKickback": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "success": { + "type": "boolean", + "format": "boolean", + "example": "true" + } + }, + "title": "RespUpdateKickback", + "required": [ + "code", + "success" + ] + }, + "RespUpdateReferralCode": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "success": { + "type": "boolean", + "format": "boolean", + "example": "true" + } + }, + "title": "RespUpdateReferralCode", + "required": [ + "code", + "success" + ] + }, + "RespWithdrawalDelay": { + "type": "object", + "properties": { + "seconds": { + "type": "integer", + "format": "int64", + "example": "86400" + } + }, + "title": "RespWithdrawalDelay", + "required": [ + "seconds" + ] + }, + "ResultCode": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + } + }, + "title": "ResultCode", + "required": [ + "code" + ] + }, + "RiskInfo": { + "type": "object", + "properties": { + "cross_risk_parameters": { + "$ref": "#/definitions/RiskParameters" + }, + "isolated_risk_parameters": { + "type": "array", + "items": { + "$ref": "#/definitions/RiskParameters" + } + } + }, + "title": "RiskInfo", + "required": [ + "cross_risk_parameters", + "isolated_risk_parameters" + ] + }, + "RiskParameters": { + "type": "object", + "properties": { + "market_id": { + "type": "integer", + "format": "int16" + }, + "collateral": { + "type": "string" + }, + "total_account_value": { + "type": "string" + }, + "initial_margin_req": { + "type": "string" + }, + "maintenance_margin_req": { + "type": "string" + }, + "close_out_margin_req": { + "type": "string" + } + }, + "title": "RiskParameters", + "required": [ + "market_id", + "collateral", + "total_account_value", + "initial_margin_req", + "maintenance_margin_req", + "close_out_margin_req" + ] + }, + "SharePrice": { + "type": "object", + "properties": { + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "share_price": { + "type": "number", + "format": "double", + "example": "0.0001" + } + }, + "title": "SharePrice", + "required": [ + "timestamp", + "share_price" + ] + }, + "SimpleOrder": { + "type": "object", + "properties": { + "order_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "order_id": { + "type": "string", + "example": "1" + }, + "owner_account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "initial_base_amount": { + "type": "string", + "example": "0.1" + }, + "remaining_base_amount": { + "type": "string", + "example": "0.1" + }, + "price": { + "type": "string", + "example": "3024.66" + }, + "order_expiry": { + "type": "integer", + "format": "int64", + "example": "1640995200" + } + }, + "title": "SimpleOrder", + "required": [ + "order_index", + "order_id", + "owner_account_index", + "initial_base_amount", + "remaining_base_amount", + "price", + "order_expiry" + ] + }, + "SpotMarketStats": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH/USDC" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "mid_price": { + "type": "string", + "example": "3024.66" + }, + "last_trade_price": { + "type": "string", + "example": "3024.66" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + } + }, + "title": "SpotMarketStats", + "required": [ + "symbol", + "market_id", + "index_price", + "mid_price", + "last_trade_price", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change" + ] + }, + "SpotOrderBookDetail": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] + }, + "base_asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" + }, + "status": { + "type": "string", + "example": "active", + "enum": [ + "inactive", + "active" + ] + }, + "taker_fee": { + "type": "string", + "example": "0.0001" + }, + "maker_fee": { + "type": "string", + "example": "0.0000" + }, + "liquidation_fee": { + "type": "string", + "example": "0.01" + }, + "min_base_amount": { + "type": "string", + "example": "0.01" + }, + "min_quote_amount": { + "type": "string", + "example": "0.1" + }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, + "supported_size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_quote_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "last_trade_price": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + }, + "daily_chart": { + "type": "object", + "example": "{1640995200:3024.66}", + "additionalProperties": { + "type": "number", + "format": "double" + } + } + }, + "title": "SpotOrderBookDetail", + "required": [ + "symbol", + "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", + "status", + "taker_fee", + "maker_fee", + "liquidation_fee", + "min_base_amount", + "min_quote_amount", + "order_quote_limit", + "supported_size_decimals", + "supported_price_decimals", + "supported_quote_decimals", + "size_decimals", + "price_decimals", + "last_trade_price", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change", + "daily_chart" + ] + }, + "Status": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": "1" + }, + "network_id": { + "type": "integer", + "format": "int32", + "example": "1" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1717777777" + } + }, + "title": "Status", + "required": [ + "status", + "network_id", + "timestamp" + ] + }, + "SubAccounts": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "sub_accounts": { + "type": "array", + "example": "1", + "items": { + "$ref": "#/definitions/Account" + } + } + }, + "title": "SubAccounts", + "required": [ + "code", + "l1_address", + "sub_accounts" + ] + }, + "Ticker": { + "type": "object", + "properties": { + "s": { + "type": "string", + "example": "ETH" + }, + "a": { + "$ref": "#/definitions/PriceLevel" + }, + "b": { + "$ref": "#/definitions/PriceLevel" + } + }, + "title": "Ticker", + "required": [ + "s", + "a", + "b" + ] + }, + "Trade": { + "type": "object", + "properties": { + "trade_id": { + "type": "integer", + "format": "int64", + "example": "145" + }, + "tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "type": { + "type": "string", + "example": "trade", + "enum": [ + "trade", + "liquidation", + "deleverage", + "market-settlement" + ] + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "size": { + "type": "string", + "example": "0.1" + }, + "price": { + "type": "string", + "example": "3024.66" + }, + "usd_amount": { + "type": "string", + "example": "3024.66" + }, + "ask_id": { + "type": "integer", + "format": "int64", + "example": "145" + }, + "bid_id": { + "type": "integer", + "format": "int64", + "example": "245" + }, + "ask_client_id": { + "type": "integer", + "format": "int64", + "example": "145" + }, + "bid_client_id": { + "type": "integer", + "format": "int64", + "example": "245" + }, + "ask_account_id": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "bid_account_id": { + "type": "integer", + "format": "int64", + "example": "3" + }, + "is_maker_ask": { + "type": "boolean", + "format": "boolean", + "example": "true" + }, + "block_height": { + "type": "integer", + "format": "int64", + "example": "45434" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "taker_fee": { + "type": "integer", + "format": "int32", + "example": "0" + }, + "taker_position_size_before": { + "type": "string", + "example": "0" + }, + "taker_entry_quote_before": { + "type": "string", + "example": "0" + }, + "taker_initial_margin_fraction_before": { + "type": "integer", + "format": "uin16", + "example": "0" + }, + "taker_position_sign_changed": { + "type": "boolean", + "format": "boolean", + "example": "true" + }, + "maker_fee": { + "type": "integer", + "format": "int32", + "example": "0" + }, + "maker_position_size_before": { + "type": "string", + "example": "0" + }, + "maker_entry_quote_before": { + "type": "string", + "example": "0" + }, + "maker_initial_margin_fraction_before": { + "type": "integer", + "format": "uin16", + "example": "0" + }, + "maker_position_sign_changed": { + "type": "boolean", + "format": "boolean", + "example": "true" + } + }, + "title": "Trade", + "required": [ + "trade_id", + "tx_hash", + "type", + "market_id", + "size", + "price", + "usd_amount", + "ask_id", + "bid_id", + "ask_client_id", + "bid_client_id", + "ask_account_id", + "bid_account_id", + "is_maker_ask", + "block_height", + "timestamp", + "taker_fee", + "taker_position_size_before", + "taker_entry_quote_before", + "taker_initial_margin_fraction_before", + "taker_position_sign_changed", + "maker_fee", + "maker_position_size_before", + "maker_entry_quote_before", + "maker_initial_margin_fraction_before", + "maker_position_sign_changed" + ] + }, + "Trades": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "next_cursor": { + "type": "string" + }, + "trades": { + "type": "array", + "items": { + "$ref": "#/definitions/Trade" + } + } + }, + "title": "Trades", + "required": [ + "code", + "trades" + ] + }, + "TransferFeeInfo": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "transfer_fee_usdc": { + "type": "integer", + "format": "int64" + } + }, + "title": "TransferFeeInfo", + "required": [ + "code", + "transfer_fee_usdc" + ] + }, + "TransferHistory": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "transfers": { + "type": "array", + "items": { + "$ref": "#/definitions/TransferHistoryItem" + } + }, + "cursor": { + "type": "string" + } + }, + "title": "TransferHistory", + "required": [ + "code", + "transfers", + "cursor" + ] + }, + "TransferHistoryItem": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "amount": { + "type": "string", + "example": "0.1" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "type": { + "type": "string", + "enum": [ + "L2TransferInflow", + "L2TransferOutflow", + "L2BurnSharesInflow", + "L2BurnSharesOutflow", + "L2MintSharesInflow", + "L2MintSharesOutflow", + "L2SelfTransfer" + ] + }, + "from_l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "to_l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "from_account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "to_account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "from_route": { + "type": "string", + "enum": [ + "spot", + "perps" + ] + }, + "to_route": { + "type": "string", + "enum": [ + "spot", + "perps" + ] + }, + "tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "TransferHistoryItem", + "required": [ + "id", + "asset_id", + "amount", + "timestamp", + "type", + "from_l1_address", + "to_l1_address", + "from_account_index", + "to_account_index", + "from_route", + "to_route", + "tx_hash" + ] + }, + "Tx": { + "type": "object", + "properties": { + "hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "type": { + "type": "integer", + "format": "uint8", + "example": "1", + "maximum": 64, + "minimum": 1 + }, + "info": { + "type": "string", + "example": "{}" + }, + "event_info": { + "type": "string", + "example": "{}" + }, + "status": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "transaction_index": { + "type": "integer", + "format": "int64", + "example": "8761" + }, + "l1_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "account_index": { + "type": "integer", + "format": "int64", + "example": "1" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "722" + }, + "expire_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "block_height": { + "type": "integer", + "format": "int64", + "example": "45434" + }, + "queued_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "executed_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "sequence_index": { + "type": "integer", + "format": "int64", + "example": "8761" + }, + "parent_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "example": "0" + } + }, + "title": "Tx", + "required": [ + "hash", + "type", + "info", + "event_info", + "status", + "transaction_index", + "l1_address", + "account_index", + "nonce", + "expire_at", + "block_height", + "queued_at", + "executed_at", + "sequence_index", + "parent_hash", + "api_key_index" + ] + }, + "TxHash": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "TxHash", + "required": [ + "code", + "tx_hash" + ] + }, + "TxHashes": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "tx_hash": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "title": "TxHashes", + "required": [ + "code", + "tx_hash" + ] + }, + "Txs": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "txs": { + "type": "array", + "items": { + "$ref": "#/definitions/Tx" + } + } + }, + "title": "Txs", + "required": [ + "code", + "txs" + ] + }, + "ValidatorInfo": { + "type": "object", + "properties": { + "address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "is_active": { + "type": "boolean", + "format": "boolean", + "example": "true" + } + }, + "title": "ValidatorInfo", + "required": [ + "address", + "is_active" + ] + }, + "WithdrawHistory": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "withdraws": { + "type": "array", + "items": { + "$ref": "#/definitions/WithdrawHistoryItem" + } + }, + "cursor": { + "type": "string" + } + }, + "title": "WithdrawHistory", + "required": [ + "code", + "withdraws", + "cursor" + ] + }, + "WithdrawHistoryItem": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "amount": { + "type": "string", + "example": "0.1" + }, + "timestamp": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "pending", + "claimable", + "refunded", + "completed" + ] + }, + "type": { + "type": "string", + "enum": [ + "secure", + "fast" + ] + }, + "l1_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "WithdrawHistoryItem", + "required": [ + "id", + "asset_id", + "amount", + "timestamp", + "status", + "type", + "l1_tx_hash" + ] + }, + "ZkLighterInfo": { + "type": "object", + "properties": { + "contract_address": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + } + }, + "title": "ZkLighterInfo", + "required": [ + "contract_address" + ] + } + }, + "securityDefinitions": { + "apiKey": { + "type": "apiKey", + "description": "Enter JWT Bearer token **_only_**", + "name": "Authorization", + "in": "header" + } + } +} diff --git a/docs/lighter/lighter-python-main/pyproject.toml b/docs/lighter/lighter-python-main/pyproject.toml new file mode 100644 index 0000000..aa40f0e --- /dev/null +++ b/docs/lighter/lighter-python-main/pyproject.toml @@ -0,0 +1,79 @@ +[tool.poetry] +name = "lighter-sdk" +version = "1.0.1" +description = "Python client for Lighter" +authors = ["elliot"] +license = "NoLicense" +readme = "README.md" +repository = "https://github.com/elliottech/lighter-python" +keywords = ["OpenAPI", "OpenAPI-Generator"] +include = ["lighter/py.typed"] + +[tool.poetry.packages] +python = ["lighter"] + +[tool.poetry.dependencies] +python = "^3.8" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +aiohttp = ">= 3.8.4" +aiohttp-retry = ">= 2.8.3" +pydantic = ">=2" +typing-extensions = ">=4.7.1" +websockets = ">= 12.0.0" +eth-account = ">=0.13.4" +requests = ">=2.31.0" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "lighter", + #"test", # auto-generated tests + "tests", # hand-written tests +] +# TODO: enable "strict" once all these individual checks are passing +# strict = true + +# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + +## Getting these passing should be easy +strict_equality = true +strict_concatenate = true + +## Strongly recommend enabling this one as soon as you can +check_untyped_defs = true + +## These shouldn't be too much additional work, but may be tricky to +## get passing if you use a lot of untyped libraries +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true + +### These next few are various gradations of forcing use of type annotations +#disallow_untyped_calls = true +#disallow_incomplete_defs = true +#disallow_untyped_defs = true +# +### This one isn't too hard to get passing, but return on investment is lower +#no_implicit_reexport = true +# +### This one can be tricky to get passing if you use a lot of untyped libraries +#warn_return_any = true diff --git a/docs/lighter/lighter-python-main/requirements.txt b/docs/lighter/lighter-python-main/requirements.txt new file mode 100644 index 0000000..a21c5cd --- /dev/null +++ b/docs/lighter/lighter-python-main/requirements.txt @@ -0,0 +1,10 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3, < 2.1.0 +pydantic >= 2 +typing-extensions >= 4.7.1 +aiohttp >= 3.0.0 +aiohttp-retry >= 2.8.3 +websockets >= 12.0.0 +eth-account >= 0.13.4 +requests >= 2.31.0 \ No newline at end of file diff --git a/docs/lighter/lighter-python-main/setup.cfg b/docs/lighter/lighter-python-main/setup.cfg new file mode 100644 index 0000000..11433ee --- /dev/null +++ b/docs/lighter/lighter-python-main/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/docs/lighter/lighter-python-main/setup.py b/docs/lighter/lighter-python-main/setup.py new file mode 100644 index 0000000..e490927 --- /dev/null +++ b/docs/lighter/lighter-python-main/setup.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from setuptools import setup, find_packages # noqa: H301 + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools +NAME = "lighter-sdk" +VERSION = "1.0.1" +PYTHON_REQUIRES = ">=3.7" +REQUIRES = [ + "urllib3 >= 1.25.3, < 2.1.0", + "python-dateutil", + "aiohttp >= 3.0.0", + "aiohttp-retry >= 2.8.3", + "pydantic >= 2", + "typing-extensions >= 4.7.1", + "websockets >= 12.0.0", + "eth-account >= 0.13.4", + "requests >= 2.31.0", +] + +setup( + name=NAME, + version=VERSION, + description="Python SDK for lighter.xyz", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", ""], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description_content_type="text/markdown", + long_description="""\ + Python SDK for Lighter trading. Includes api clients and signer. + """, # noqa: E501 + package_data={"lighter": ["py.typed", "signers/*"]}, +) diff --git a/docs/lighter/lighter-python-main/test-requirements.txt b/docs/lighter/lighter-python-main/test-requirements.txt new file mode 100644 index 0000000..057e6ec --- /dev/null +++ b/docs/lighter/lighter-python-main/test-requirements.txt @@ -0,0 +1,7 @@ +pytest~=7.1.3 +pytest-cov>=2.8.1 +pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 +eth-account>=0.13.4 + diff --git a/docs/lighter/lighter-python-main/test/__init__.py b/docs/lighter/lighter-python-main/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/docs/lighter/lighter-python-main/test/test_account.py b/docs/lighter/lighter-python-main/test/test_account.py new file mode 100644 index 0000000..5c9f3d6 --- /dev/null +++ b/docs/lighter/lighter-python-main/test/test_account.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + Lighter API + + Public APIs for Lighter + + The version of the OpenAPI document: 1.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from lighter.models.account import Account + +class TestAccount(unittest.TestCase): + """Account unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Account: + """Test Account + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Account` + """ + model = Account() + if include_optional: + return Account( + code = 100, + total = 1, + accounts = [ + lighter.models.single_account.SingleAccount( + code = 56, + index = 56, + l1_address = '0x70997970C51812dc3A010C7d01b50e0d17dc79C8', + pk = '3ad126b9f0a2cc8cb367ef67a6c77389a85e18e20ce8da2edf34d022e9bf1aa8', + status = 1, + nonce = 722, + collateral = '', + positions = [ + lighter.models.account_position.AccountPosition( + market_id = 0, + name = 'Ethereum', + symbol = 'ETH', + sign = -1, + position = '3.6955', + ask_order_size = '58933.9753', + bid_order_size = '59010.2588', + avg_entry_price = '3024.66', + market_value = '3019.92', + unrealized_pnl = '17.521309', + realized_pnl = '0.000000', ) + ], + total_asset_value = '199955234976240000000000000', + market_stats = [ + lighter.models.account_market_stats.AccountMarketStats( + market_id = 1, + daily_trades_count = 68, + daily_base_token_volume = 235.25, + daily_quote_token_volume = 93566.25, + open_position_base = 93.0, + open_position_quote = 1276.0, ) + ], ) + ] + ) + else: + return Account( + ) + """ + + def testAccount(self): + """Test Account""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/docs/lighter/lighter-python-main/tox.ini b/docs/lighter/lighter-python-main/tox.ini new file mode 100644 index 0000000..8941ca0 --- /dev/null +++ b/docs/lighter/lighter-python-main/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=lighter --ignore-glob *api.py diff --git a/docs/lighter/websocket.md b/docs/lighter/websocket.md index df22448..6183327 100644 --- a/docs/lighter/websocket.md +++ b/docs/lighter/websocket.md @@ -1,5 +1,5 @@ # WebSocket -URL: `wss://mainnet.zklighter.elliot.ai/stream` +URL: `wss://mainnet.zklighter.elliot.ai/stream`; `wss://testnet.zklighter.elliot.ai/stream` You can directly connect to the WebSocket server using wscat: @@ -88,7 +88,7 @@ Example: ``` -Used in: [Transaction](https://apibetadocs.lighter.xyz/docs/websocket-reference#transaction), [Executed Transaction](https://apibetadocs.lighter.xyz/docs/websocket-reference#executed-transaction), [Account Tx](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-tx). +Used in: [Account Tx](about:/docs/websocket-reference#account-tx). ``` Order = { @@ -127,7 +127,7 @@ Order = { ``` -Used in: [Account Market](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-market), [Account All Orders](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all-orders), [Account Orders](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-orders). +Used in: [Account Market](about:/docs/websocket-reference#account-market), [Account All Orders](about:/docs/websocket-reference#account-all-orders), [Account Orders](about:/docs/websocket-reference#account-orders). ``` Trade = { @@ -187,7 +187,7 @@ Example: ``` -Used in: [Trade](https://apibetadocs.lighter.xyz/docs/websocket-reference#trade), [Account All](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all), [Account Market](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-market), [Account All Trades](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all-trades). +Used in: [Trade](about:/docs/websocket-reference#trade), [Account All](about:/docs/websocket-reference#account-all), [Account Market](about:/docs/websocket-reference#account-market), [Account All Trades](about:/docs/websocket-reference#account-all-trades). ``` Position = { @@ -235,7 +235,7 @@ Example: ``` -Used in: [Account All](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all), [Account Market](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-market), [Account All Positions](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all-positions). +Used in: [Account All](about:/docs/websocket-reference#account-all), [Account Market](about:/docs/websocket-reference#account-market), [Account All Positions](about:/docs/websocket-reference#account-all-positions). ``` PoolShares = { @@ -257,7 +257,7 @@ Example: ``` -Used in: [Account All](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all), [Account All Positions](https://apibetadocs.lighter.xyz/docs/websocket-reference#account-all-positions). +Used in: [Account All](about:/docs/websocket-reference#account-all), [Account All Positions](about:/docs/websocket-reference#account-all-positions). The order book channel sends the new ask and bid orders for the given market. @@ -299,7 +299,9 @@ The order book channel sends the new ask and bid orders for the given market. "size": STRING } ], - "offset": INTEGER + "offset": INTEGER, + "nonce": INTEGER, + "timestamp": INTEGER }, "type": "update/order_book" } @@ -644,7 +646,7 @@ The account market channel sends specific account market data for a market. ``` { "account": INTEGER, - "channel": "account_all/{MARKET_ID}/{ACCOUNT_ID}", + "channel": "account_market/{MARKET_ID}/{ACCOUNT_ID}", "funding_history": { "timestamp": INTEGER, "market_id": INTEGER, @@ -751,12 +753,13 @@ The account stats channel sends account stats data for the specific account. ``` -The transaction channel sends all new transactions. +This channel sends transactions related to a specific account. ``` { "type": "subscribe", - "channel": "transaction" + "channel": "account_tx/{ACCOUNT_ID}", + "auth": "{AUTH_TOKEN}" } ``` @@ -765,30 +768,9 @@ The transaction channel sends all new transactions. ``` { - "channel": "transaction", - "txs": [Transaction], - "type": "update/transaction" -} -``` - - -The structure is the same as with [Transaction](#transaction) channel. But this channel sends only executed transactions. - -``` -{ - "type": "subscribe", - "channel": "executed_transaction" -} -``` - - -The structure is the same as with [Transaction](#transaction) channel. But this channel sends only transactions related to a specific account. - -``` -{ - "type": "subscribe", - "channel": "account_tx/{ACCOUNT_ID}", - "auth": "{AUTH_TOKEN}" + "channel": "account_tx:{ACCOUNT_ID}", + "txs": [Account_tx], + "type": "update/account_tx" } ``` @@ -1115,6 +1097,6 @@ The account all orders channel sends data about all the order of an account. ``` -Updated 30 days ago +Updated 9 days ago * * * \ No newline at end of file diff --git a/src/strategy/offset-maker-engine.ts b/src/strategy/offset-maker-engine.ts index e23284d..035e248 100644 --- a/src/strategy/offset-maker-engine.ts +++ b/src/strategy/offset-maker-engine.ts @@ -84,6 +84,12 @@ export class OffsetMakerEngine { private lastImbalance: "balanced" | "buy_dominant" | "sell_dominant" = "balanced"; private lastBuyPriceViable = true; private lastSellPriceViable = true; + private feedStatus = { + account: false, + depth: false, + ticker: false, + orders: false, + }; // Reprice suppression for fast-ticking Lighter order book private readonly repriceDwellMs: number; @@ -139,6 +145,7 @@ export class OffsetMakerEngine { this.exchange.watchAccount.bind(this.exchange), (snapshot) => { this.accountSnapshot = snapshot; + this.feedStatus.account = true; const totalUnrealized = Number(snapshot.totalUnrealizedProfit ?? "0"); if (Number.isFinite(totalUnrealized)) { this.accountUnrealized = totalUnrealized; @@ -158,6 +165,7 @@ export class OffsetMakerEngine { this.exchange.watchOrders.bind(this.exchange), (orders) => { this.syncLocksWithOrders(orders); + this.feedStatus.orders = true; this.openOrders = Array.isArray(orders) ? orders.filter((order) => order.type !== "MARKET" && order.symbol === this.config.symbol) : []; @@ -181,6 +189,7 @@ export class OffsetMakerEngine { this.exchange.watchDepth.bind(this.exchange, this.config.symbol), (depth) => { this.depthSnapshot = depth; + this.feedStatus.depth = true; this.emitUpdate(); }, log, @@ -194,6 +203,7 @@ export class OffsetMakerEngine { this.exchange.watchTicker.bind(this.exchange, this.config.symbol), (ticker) => { this.tickerSnapshot = ticker; + this.feedStatus.ticker = true; this.emitUpdate(); }, log, @@ -734,6 +744,7 @@ export class OffsetMakerEngine { desiredOrders: this.desiredOrders, tradeLog: this.tradeLog.all(), lastUpdated: Date.now(), + feedStatus: { ...this.feedStatus }, buyDepthSum10: this.lastBuyDepthSum10, sellDepthSum10: this.lastSellDepthSum10, depthImbalance: this.lastImbalance,