diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 722ca2d..f6aa081 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,5 +1,7 @@ README.md docs/Account.md +docs/AccountAccountTradingModeEnum.md +docs/AccountAccountTypeEnum.md docs/AccountApi.md docs/AccountApiKeys.md docs/AccountAsset.md @@ -8,6 +10,7 @@ docs/AccountMetadata.md docs/AccountMetadatas.md docs/AccountPnL.md docs/AccountPosition.md +docs/AccountPositionMarginModeEnum.md docs/Announcement.md docs/AnnouncementApi.md docs/Announcements.md @@ -33,6 +36,8 @@ docs/Deposit.md docs/DepositHistory.md docs/DepositHistoryItem.md docs/DetailedAccount.md +docs/DetailedAccountAccountTradingModeEnum.md +docs/DetailedAccountAccountTypeEnum.md docs/DetailedAccounts.md docs/EnrichedTx.md docs/ExchangeMetric.md @@ -61,6 +66,7 @@ docs/LivepointsApi.md docs/MarkPriceCandle.md docs/MarkPriceCandles.md docs/MarketConfig.md +docs/MarketConfigMarketMarginModeEnum.md docs/MarketPriceChart.md docs/MarketPriceCharts.md docs/NextNonce.md @@ -80,9 +86,13 @@ docs/PnLEntry.md docs/PositionFunding.md docs/PositionFundings.md docs/PublicPoolInfo.md +docs/PublicPoolInfoStatusEnum.md docs/PublicPoolMetadata.md +docs/PublicPoolMetadataAccountTypeEnum.md +docs/PublicPoolMetadataStatusEnum.md docs/PublicPoolShare.md docs/RFQEntry.md +docs/RFQEntryDirectionEnum.md docs/RFQMetadata.md docs/RFQResponseEntry.md docs/Referral.md @@ -95,6 +105,7 @@ docs/ReferralTotals.md docs/ReqSetAccountMetadata.md docs/RespChangeAccountTier.md docs/RespCreateRFQ.md +docs/RespCreateRFQDirectionEnum.md docs/RespGetApiTokens.md docs/RespGetExchangeMetrics.md docs/RespGetExecuteStats.md @@ -104,10 +115,12 @@ docs/RespGetLeaseOptions.md docs/RespGetLeases.md docs/RespGetMakerOnlyApiKeys.md docs/RespGetRFQ.md +docs/RespGetRFQDirectionEnum.md docs/RespListRFQs.md docs/RespPostApiToken.md docs/RespPublicPoolsMetadata.md docs/RespRespondToRFQ.md +docs/RespRespondToRFQDirectionEnum.md docs/RespRevokeApiToken.md docs/RespSendTx.md docs/RespSendTxBatch.md @@ -115,6 +128,7 @@ docs/RespSetMakerOnlyApiKeys.md docs/RespSyntheticSpotInfo.md docs/RespUpdateKickback.md docs/RespUpdateRFQ.md +docs/RespUpdateRFQDirectionEnum.md docs/RespUpdateReferralCode.md docs/RespWithdrawalDelay.md docs/ResultCode.md @@ -170,6 +184,8 @@ lighter/configuration.py lighter/exceptions.py lighter/models/__init__.py lighter/models/account.py +lighter/models/account_account_trading_mode_enum.py +lighter/models/account_account_type_enum.py lighter/models/account_api_keys.py lighter/models/account_asset.py lighter/models/account_limits.py @@ -177,6 +193,7 @@ lighter/models/account_metadata.py lighter/models/account_metadatas.py lighter/models/account_pn_l.py lighter/models/account_position.py +lighter/models/account_position_margin_mode_enum.py lighter/models/announcement.py lighter/models/announcements.py lighter/models/api_key.py @@ -198,6 +215,8 @@ lighter/models/deposit.py lighter/models/deposit_history.py lighter/models/deposit_history_item.py lighter/models/detailed_account.py +lighter/models/detailed_account_account_trading_mode_enum.py +lighter/models/detailed_account_account_type_enum.py lighter/models/detailed_accounts.py lighter/models/enriched_tx.py lighter/models/exchange_metric.py @@ -223,6 +242,7 @@ lighter/models/live_points_total.py lighter/models/mark_price_candle.py lighter/models/mark_price_candles.py lighter/models/market_config.py +lighter/models/market_config_market_margin_mode_enum.py lighter/models/market_price_chart.py lighter/models/market_price_charts.py lighter/models/next_nonce.py @@ -240,7 +260,10 @@ lighter/models/pn_l_entry.py lighter/models/position_funding.py lighter/models/position_fundings.py lighter/models/public_pool_info.py +lighter/models/public_pool_info_status_enum.py lighter/models/public_pool_metadata.py +lighter/models/public_pool_metadata_account_type_enum.py +lighter/models/public_pool_metadata_status_enum.py lighter/models/public_pool_share.py lighter/models/referral.py lighter/models/referral_code.py @@ -251,6 +274,7 @@ lighter/models/referral_totals.py lighter/models/req_set_account_metadata.py lighter/models/resp_change_account_tier.py lighter/models/resp_create_rfq.py +lighter/models/resp_create_rfq_direction_enum.py lighter/models/resp_get_api_tokens.py lighter/models/resp_get_exchange_metrics.py lighter/models/resp_get_execute_stats.py @@ -260,10 +284,12 @@ lighter/models/resp_get_lease_options.py lighter/models/resp_get_leases.py lighter/models/resp_get_maker_only_api_keys.py lighter/models/resp_get_rfq.py +lighter/models/resp_get_rfq_direction_enum.py lighter/models/resp_list_rfqs.py lighter/models/resp_post_api_token.py lighter/models/resp_public_pools_metadata.py lighter/models/resp_respond_to_rfq.py +lighter/models/resp_respond_to_rfq_direction_enum.py lighter/models/resp_revoke_api_token.py lighter/models/resp_send_tx.py lighter/models/resp_send_tx_batch.py @@ -272,9 +298,11 @@ lighter/models/resp_synthetic_spot_info.py lighter/models/resp_update_kickback.py lighter/models/resp_update_referral_code.py lighter/models/resp_update_rfq.py +lighter/models/resp_update_rfq_direction_enum.py lighter/models/resp_withdrawal_delay.py lighter/models/result_code.py lighter/models/rfq_entry.py +lighter/models/rfq_entry_direction_enum.py lighter/models/rfq_metadata.py lighter/models/rfq_response_entry.py lighter/models/risk_info.py diff --git a/README.md b/README.md index 48444b3..fbc725e 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ Class | Method | HTTP request | Description - [Account](docs/Account.md) + - [AccountAccountTradingModeEnum](docs/AccountAccountTradingModeEnum.md) + - [AccountAccountTypeEnum](docs/AccountAccountTypeEnum.md) - [AccountApiKeys](docs/AccountApiKeys.md) - [AccountAsset](docs/AccountAsset.md) - [AccountLimits](docs/AccountLimits.md) @@ -149,6 +151,7 @@ Class | Method | HTTP request | Description - [AccountMetadatas](docs/AccountMetadatas.md) - [AccountPnL](docs/AccountPnL.md) - [AccountPosition](docs/AccountPosition.md) + - [AccountPositionMarginModeEnum](docs/AccountPositionMarginModeEnum.md) - [Announcement](docs/Announcement.md) - [Announcements](docs/Announcements.md) - [ApiKey](docs/ApiKey.md) @@ -170,6 +173,8 @@ Class | Method | HTTP request | Description - [DepositHistory](docs/DepositHistory.md) - [DepositHistoryItem](docs/DepositHistoryItem.md) - [DetailedAccount](docs/DetailedAccount.md) + - [DetailedAccountAccountTradingModeEnum](docs/DetailedAccountAccountTradingModeEnum.md) + - [DetailedAccountAccountTypeEnum](docs/DetailedAccountAccountTypeEnum.md) - [DetailedAccounts](docs/DetailedAccounts.md) - [EnrichedTx](docs/EnrichedTx.md) - [ExchangeMetric](docs/ExchangeMetric.md) @@ -195,6 +200,7 @@ Class | Method | HTTP request | Description - [MarkPriceCandle](docs/MarkPriceCandle.md) - [MarkPriceCandles](docs/MarkPriceCandles.md) - [MarketConfig](docs/MarketConfig.md) + - [MarketConfigMarketMarginModeEnum](docs/MarketConfigMarketMarginModeEnum.md) - [MarketPriceChart](docs/MarketPriceChart.md) - [MarketPriceCharts](docs/MarketPriceCharts.md) - [NextNonce](docs/NextNonce.md) @@ -212,9 +218,13 @@ Class | Method | HTTP request | Description - [PositionFunding](docs/PositionFunding.md) - [PositionFundings](docs/PositionFundings.md) - [PublicPoolInfo](docs/PublicPoolInfo.md) + - [PublicPoolInfoStatusEnum](docs/PublicPoolInfoStatusEnum.md) - [PublicPoolMetadata](docs/PublicPoolMetadata.md) + - [PublicPoolMetadataAccountTypeEnum](docs/PublicPoolMetadataAccountTypeEnum.md) + - [PublicPoolMetadataStatusEnum](docs/PublicPoolMetadataStatusEnum.md) - [PublicPoolShare](docs/PublicPoolShare.md) - [RFQEntry](docs/RFQEntry.md) + - [RFQEntryDirectionEnum](docs/RFQEntryDirectionEnum.md) - [RFQMetadata](docs/RFQMetadata.md) - [RFQResponseEntry](docs/RFQResponseEntry.md) - [Referral](docs/Referral.md) @@ -226,6 +236,7 @@ Class | Method | HTTP request | Description - [ReqSetAccountMetadata](docs/ReqSetAccountMetadata.md) - [RespChangeAccountTier](docs/RespChangeAccountTier.md) - [RespCreateRFQ](docs/RespCreateRFQ.md) + - [RespCreateRFQDirectionEnum](docs/RespCreateRFQDirectionEnum.md) - [RespGetApiTokens](docs/RespGetApiTokens.md) - [RespGetExchangeMetrics](docs/RespGetExchangeMetrics.md) - [RespGetExecuteStats](docs/RespGetExecuteStats.md) @@ -235,10 +246,12 @@ Class | Method | HTTP request | Description - [RespGetLeases](docs/RespGetLeases.md) - [RespGetMakerOnlyApiKeys](docs/RespGetMakerOnlyApiKeys.md) - [RespGetRFQ](docs/RespGetRFQ.md) + - [RespGetRFQDirectionEnum](docs/RespGetRFQDirectionEnum.md) - [RespListRFQs](docs/RespListRFQs.md) - [RespPostApiToken](docs/RespPostApiToken.md) - [RespPublicPoolsMetadata](docs/RespPublicPoolsMetadata.md) - [RespRespondToRFQ](docs/RespRespondToRFQ.md) + - [RespRespondToRFQDirectionEnum](docs/RespRespondToRFQDirectionEnum.md) - [RespRevokeApiToken](docs/RespRevokeApiToken.md) - [RespSendTx](docs/RespSendTx.md) - [RespSendTxBatch](docs/RespSendTxBatch.md) @@ -246,6 +259,7 @@ Class | Method | HTTP request | Description - [RespSyntheticSpotInfo](docs/RespSyntheticSpotInfo.md) - [RespUpdateKickback](docs/RespUpdateKickback.md) - [RespUpdateRFQ](docs/RespUpdateRFQ.md) + - [RespUpdateRFQDirectionEnum](docs/RespUpdateRFQDirectionEnum.md) - [RespUpdateReferralCode](docs/RespUpdateReferralCode.md) - [RespWithdrawalDelay](docs/RespWithdrawalDelay.md) - [ResultCode](docs/ResultCode.md) @@ -280,3 +294,22 @@ Class | Method | HTTP request | Description + +## Regenerating from openapi.json + +`openapi.json` comes from the backend `server.api` (goctl-swagger). Before running +openapi-generator (7.7.0, `-g python -c config.yaml`), normalize it with: + +```sh +python3 scripts/openapi_postprocess.py openapi.json +``` + +goctl-swagger emits integer `options=` as strings (`["Cross:0", "Isolated:1"]`); +the script converts them to integer enums and, for named ones, adds a +`Enum` `IntEnum` schema (e.g. `AccountPositionMarginModeEnum`) whose +members can be compared against the plain `int` field: + +```python +if position.margin_mode == lighter.AccountPositionMarginModeEnum.Isolated: + ... +``` diff --git a/docs/Account.md b/docs/Account.md index e2dc303..e1a73c3 100644 --- a/docs/Account.md +++ b/docs/Account.md @@ -7,8 +7,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**account_type** | **int** | | -**account_trading_mode** | **int** | Classic=0 and Unified=1 | +**account_type** | **int** | See AccountAccountTypeEnum | +**account_trading_mode** | **int** | See AccountAccountTradingModeEnum | **index** | **int** | | **l1_address** | **str** | | **cancel_all_time** | **int** | | diff --git a/docs/AccountAccountTradingModeEnum.md b/docs/AccountAccountTradingModeEnum.md new file mode 100644 index 0000000..e4519d3 --- /dev/null +++ b/docs/AccountAccountTradingModeEnum.md @@ -0,0 +1,13 @@ +# AccountAccountTradingModeEnum + +Named values of Account.account_trading_mode + +## Enum + +* `Simple` (value: `0`) + +* `Unified` (value: `1`) + +[[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/AccountAccountTypeEnum.md b/docs/AccountAccountTypeEnum.md new file mode 100644 index 0000000..376558a --- /dev/null +++ b/docs/AccountAccountTypeEnum.md @@ -0,0 +1,21 @@ +# AccountAccountTypeEnum + +Named values of Account.account_type + +## Enum + +* `Master` (value: `0`) + +* `Sub` (value: `1`) + +* `PublicPool` (value: `2`) + +* `InsuranceFund` (value: `3`) + +* `LighterStakingPool` (value: `4`) + +* `TreasurySub` (value: `5`) + +[[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/AccountPosition.md b/docs/AccountPosition.md index fe5d1df..a3f98b3 100644 --- a/docs/AccountPosition.md +++ b/docs/AccountPosition.md @@ -19,7 +19,7 @@ Name | Type | Description | Notes **realized_pnl** | **str** | | **liquidation_price** | **str** | | **total_funding_paid_out** | **str** | | [optional] -**margin_mode** | **int** | | +**margin_mode** | **int** | See AccountPositionMarginModeEnum | **allocated_margin** | **str** | | **total_discount** | **str** | | **margin_set_flag** | **int** | | diff --git a/docs/AccountPositionMarginModeEnum.md b/docs/AccountPositionMarginModeEnum.md new file mode 100644 index 0000000..82ef236 --- /dev/null +++ b/docs/AccountPositionMarginModeEnum.md @@ -0,0 +1,13 @@ +# AccountPositionMarginModeEnum + +Named values of AccountPosition.margin_mode + +## Enum + +* `Cross` (value: `0`) + +* `Isolated` (value: `1`) + +[[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/DetailedAccount.md b/docs/DetailedAccount.md index 08b8080..fde7de5 100644 --- a/docs/DetailedAccount.md +++ b/docs/DetailedAccount.md @@ -7,8 +7,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**account_type** | **int** | | -**account_trading_mode** | **int** | Classic=0 and Unified=1 | [optional] +**account_type** | **int** | See DetailedAccountAccountTypeEnum | +**account_trading_mode** | **int** | See DetailedAccountAccountTradingModeEnum | [optional] **index** | **int** | | **l1_address** | **str** | | **cancel_all_time** | **int** | | diff --git a/docs/DetailedAccountAccountTradingModeEnum.md b/docs/DetailedAccountAccountTradingModeEnum.md new file mode 100644 index 0000000..0a4bd22 --- /dev/null +++ b/docs/DetailedAccountAccountTradingModeEnum.md @@ -0,0 +1,13 @@ +# DetailedAccountAccountTradingModeEnum + +Named values of DetailedAccount.account_trading_mode + +## Enum + +* `Simple` (value: `0`) + +* `Unified` (value: `1`) + +[[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/DetailedAccountAccountTypeEnum.md b/docs/DetailedAccountAccountTypeEnum.md new file mode 100644 index 0000000..520217b --- /dev/null +++ b/docs/DetailedAccountAccountTypeEnum.md @@ -0,0 +1,21 @@ +# DetailedAccountAccountTypeEnum + +Named values of DetailedAccount.account_type + +## Enum + +* `Master` (value: `0`) + +* `Sub` (value: `1`) + +* `PublicPool` (value: `2`) + +* `InsuranceFund` (value: `3`) + +* `LighterStakingPool` (value: `4`) + +* `TreasurySub` (value: `5`) + +[[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/MarketConfig.md b/docs/MarketConfig.md index 66442d1..207b02a 100644 --- a/docs/MarketConfig.md +++ b/docs/MarketConfig.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**market_margin_mode** | **int** | | +**market_margin_mode** | **int** | See MarketConfigMarketMarginModeEnum | **insurance_fund_account_index** | **int** | | **liquidation_mode** | **int** | | **force_reduce_only** | **bool** | | diff --git a/docs/MarketConfigMarketMarginModeEnum.md b/docs/MarketConfigMarketMarginModeEnum.md new file mode 100644 index 0000000..c702722 --- /dev/null +++ b/docs/MarketConfigMarketMarginModeEnum.md @@ -0,0 +1,13 @@ +# MarketConfigMarketMarginModeEnum + +Named values of MarketConfig.market_margin_mode + +## Enum + +* `All` (value: `0`) + +* `IsolatedForNonPools` (value: `1`) + +[[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/PublicPoolInfo.md b/docs/PublicPoolInfo.md index 15e2b39..41c373f 100644 --- a/docs/PublicPoolInfo.md +++ b/docs/PublicPoolInfo.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**status** | **int** | | +**status** | **int** | See PublicPoolInfoStatusEnum | **operator_fee** | **str** | | **min_operator_share_rate** | **str** | | **total_shares** | **int** | | diff --git a/docs/PublicPoolInfoStatusEnum.md b/docs/PublicPoolInfoStatusEnum.md new file mode 100644 index 0000000..7e2ddbb --- /dev/null +++ b/docs/PublicPoolInfoStatusEnum.md @@ -0,0 +1,13 @@ +# PublicPoolInfoStatusEnum + +Named values of PublicPoolInfo.status + +## Enum + +* `Active` (value: `0`) + +* `Frozen` (value: `1`) + +[[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/PublicPoolMetadata.md b/docs/PublicPoolMetadata.md index 8cf999d..f07dfb0 100644 --- a/docs/PublicPoolMetadata.md +++ b/docs/PublicPoolMetadata.md @@ -8,11 +8,11 @@ Name | Type | Description | Notes **code** | **int** | | **message** | **str** | | [optional] **account_index** | **int** | | -**account_type** | **int** | | +**account_type** | **int** | See PublicPoolMetadataAccountTypeEnum | **name** | **str** | | **l1_address** | **str** | | **annual_percentage_yield** | **float** | | -**status** | **int** | | +**status** | **int** | See PublicPoolMetadataStatusEnum | **operator_fee** | **str** | | **total_asset_value** | **str** | | **total_shares** | **int** | | diff --git a/docs/PublicPoolMetadataAccountTypeEnum.md b/docs/PublicPoolMetadataAccountTypeEnum.md new file mode 100644 index 0000000..5d5c487 --- /dev/null +++ b/docs/PublicPoolMetadataAccountTypeEnum.md @@ -0,0 +1,21 @@ +# PublicPoolMetadataAccountTypeEnum + +Named values of PublicPoolMetadata.account_type + +## Enum + +* `Master` (value: `0`) + +* `Sub` (value: `1`) + +* `PublicPool` (value: `2`) + +* `InsuranceFund` (value: `3`) + +* `LighterStakingPool` (value: `4`) + +* `TreasurySub` (value: `5`) + +[[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/PublicPoolMetadataStatusEnum.md b/docs/PublicPoolMetadataStatusEnum.md new file mode 100644 index 0000000..577963e --- /dev/null +++ b/docs/PublicPoolMetadataStatusEnum.md @@ -0,0 +1,13 @@ +# PublicPoolMetadataStatusEnum + +Named values of PublicPoolMetadata.status + +## Enum + +* `Active` (value: `0`) + +* `Frozen` (value: `1`) + +[[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/RFQEntry.md b/docs/RFQEntry.md index ebc6109..5e77b88 100644 --- a/docs/RFQEntry.md +++ b/docs/RFQEntry.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **id** | **int** | | **account_index** | **int** | | **market_index** | **int** | | -**direction** | **int** | | +**direction** | **int** | See RFQEntryDirectionEnum | **base_amount** | **str** | | **quote_amount** | **str** | | **status** | **str** | | diff --git a/docs/RFQEntryDirectionEnum.md b/docs/RFQEntryDirectionEnum.md new file mode 100644 index 0000000..f02b627 --- /dev/null +++ b/docs/RFQEntryDirectionEnum.md @@ -0,0 +1,15 @@ +# RFQEntryDirectionEnum + +Named values of RFQEntry.direction + +## Enum + +* `Hidden` (value: `-1`) + +* `Sell` (value: `0`) + +* `Buy` (value: `1`) + +[[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/RespCreateRFQ.md b/docs/RespCreateRFQ.md index 968e368..68c6312 100644 --- a/docs/RespCreateRFQ.md +++ b/docs/RespCreateRFQ.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **id** | **int** | | **account_index** | **int** | | **market_index** | **int** | | -**direction** | **int** | | +**direction** | **int** | See RespCreateRFQDirectionEnum | **base_amount** | **str** | | **quote_amount** | **str** | | **status** | **str** | | diff --git a/docs/RespCreateRFQDirectionEnum.md b/docs/RespCreateRFQDirectionEnum.md new file mode 100644 index 0000000..c114bb8 --- /dev/null +++ b/docs/RespCreateRFQDirectionEnum.md @@ -0,0 +1,15 @@ +# RespCreateRFQDirectionEnum + +Named values of RespCreateRFQ.direction + +## Enum + +* `Hidden` (value: `-1`) + +* `Sell` (value: `0`) + +* `Buy` (value: `1`) + +[[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/RespGetRFQ.md b/docs/RespGetRFQ.md index 20f004a..ae8cdf9 100644 --- a/docs/RespGetRFQ.md +++ b/docs/RespGetRFQ.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **id** | **int** | | **account_index** | **int** | | **market_index** | **int** | | -**direction** | **int** | | +**direction** | **int** | See RespGetRFQDirectionEnum | **base_amount** | **str** | | **quote_amount** | **str** | | **status** | **str** | | diff --git a/docs/RespGetRFQDirectionEnum.md b/docs/RespGetRFQDirectionEnum.md new file mode 100644 index 0000000..7046ca4 --- /dev/null +++ b/docs/RespGetRFQDirectionEnum.md @@ -0,0 +1,15 @@ +# RespGetRFQDirectionEnum + +Named values of RespGetRFQ.direction + +## Enum + +* `Hidden` (value: `-1`) + +* `Sell` (value: `0`) + +* `Buy` (value: `1`) + +[[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/RespRespondToRFQ.md b/docs/RespRespondToRFQ.md index 706372c..e6d3d9b 100644 --- a/docs/RespRespondToRFQ.md +++ b/docs/RespRespondToRFQ.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **id** | **int** | | **account_index** | **int** | | **market_index** | **int** | | -**direction** | **int** | | +**direction** | **int** | See RespRespondToRFQDirectionEnum | **base_amount** | **str** | | **quote_amount** | **str** | | **status** | **str** | | diff --git a/docs/RespRespondToRFQDirectionEnum.md b/docs/RespRespondToRFQDirectionEnum.md new file mode 100644 index 0000000..6b52342 --- /dev/null +++ b/docs/RespRespondToRFQDirectionEnum.md @@ -0,0 +1,15 @@ +# RespRespondToRFQDirectionEnum + +Named values of RespRespondToRFQ.direction + +## Enum + +* `Hidden` (value: `-1`) + +* `Sell` (value: `0`) + +* `Buy` (value: `1`) + +[[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/RespUpdateRFQ.md b/docs/RespUpdateRFQ.md index 05f5fb6..4bd8ca0 100644 --- a/docs/RespUpdateRFQ.md +++ b/docs/RespUpdateRFQ.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **id** | **int** | | **account_index** | **int** | | **market_index** | **int** | | -**direction** | **int** | | +**direction** | **int** | See RespUpdateRFQDirectionEnum | **base_amount** | **str** | | **quote_amount** | **str** | | **status** | **str** | | diff --git a/docs/RespUpdateRFQDirectionEnum.md b/docs/RespUpdateRFQDirectionEnum.md new file mode 100644 index 0000000..c0a29ad --- /dev/null +++ b/docs/RespUpdateRFQDirectionEnum.md @@ -0,0 +1,15 @@ +# RespUpdateRFQDirectionEnum + +Named values of RespUpdateRFQ.direction + +## Enum + +* `Hidden` (value: `-1`) + +* `Sell` (value: `0`) + +* `Buy` (value: `1`) + +[[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/lighter/__init__.py b/lighter/__init__.py index 941282f..ff53bb2 100644 --- a/lighter/__init__.py +++ b/lighter/__init__.py @@ -45,6 +45,8 @@ # import models into sdk package from lighter.models.account import Account +from lighter.models.account_account_trading_mode_enum import AccountAccountTradingModeEnum +from lighter.models.account_account_type_enum import AccountAccountTypeEnum from lighter.models.account_api_keys import AccountApiKeys from lighter.models.account_asset import AccountAsset from lighter.models.account_limits import AccountLimits @@ -52,6 +54,7 @@ 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_position_margin_mode_enum import AccountPositionMarginModeEnum from lighter.models.announcement import Announcement from lighter.models.announcements import Announcements from lighter.models.api_key import ApiKey @@ -73,6 +76,8 @@ 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_account_account_trading_mode_enum import DetailedAccountAccountTradingModeEnum +from lighter.models.detailed_account_account_type_enum import DetailedAccountAccountTypeEnum from lighter.models.detailed_accounts import DetailedAccounts from lighter.models.enriched_tx import EnrichedTx from lighter.models.exchange_metric import ExchangeMetric @@ -98,6 +103,7 @@ from lighter.models.mark_price_candle import MarkPriceCandle from lighter.models.mark_price_candles import MarkPriceCandles from lighter.models.market_config import MarketConfig +from lighter.models.market_config_market_margin_mode_enum import MarketConfigMarketMarginModeEnum from lighter.models.market_price_chart import MarketPriceChart from lighter.models.market_price_charts import MarketPriceCharts from lighter.models.next_nonce import NextNonce @@ -115,9 +121,13 @@ from lighter.models.position_funding import PositionFunding from lighter.models.position_fundings import PositionFundings from lighter.models.public_pool_info import PublicPoolInfo +from lighter.models.public_pool_info_status_enum import PublicPoolInfoStatusEnum from lighter.models.public_pool_metadata import PublicPoolMetadata +from lighter.models.public_pool_metadata_account_type_enum import PublicPoolMetadataAccountTypeEnum +from lighter.models.public_pool_metadata_status_enum import PublicPoolMetadataStatusEnum from lighter.models.public_pool_share import PublicPoolShare from lighter.models.rfq_entry import RFQEntry +from lighter.models.rfq_entry_direction_enum import RFQEntryDirectionEnum from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry from lighter.models.referral import Referral @@ -129,6 +139,7 @@ from lighter.models.req_set_account_metadata import ReqSetAccountMetadata from lighter.models.resp_change_account_tier import RespChangeAccountTier from lighter.models.resp_create_rfq import RespCreateRFQ +from lighter.models.resp_create_rfq_direction_enum import RespCreateRFQDirectionEnum from lighter.models.resp_get_api_tokens import RespGetApiTokens from lighter.models.resp_get_exchange_metrics import RespGetExchangeMetrics from lighter.models.resp_get_execute_stats import RespGetExecuteStats @@ -138,10 +149,12 @@ from lighter.models.resp_get_leases import RespGetLeases from lighter.models.resp_get_maker_only_api_keys import RespGetMakerOnlyApiKeys from lighter.models.resp_get_rfq import RespGetRFQ +from lighter.models.resp_get_rfq_direction_enum import RespGetRFQDirectionEnum from lighter.models.resp_list_rfqs import RespListRFQs from lighter.models.resp_post_api_token import RespPostApiToken from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.models.resp_respond_to_rfq import RespRespondToRFQ +from lighter.models.resp_respond_to_rfq_direction_enum import RespRespondToRFQDirectionEnum from lighter.models.resp_revoke_api_token import RespRevokeApiToken from lighter.models.resp_send_tx import RespSendTx from lighter.models.resp_send_tx_batch import RespSendTxBatch @@ -149,6 +162,7 @@ from lighter.models.resp_synthetic_spot_info import RespSyntheticSpotInfo from lighter.models.resp_update_kickback import RespUpdateKickback from lighter.models.resp_update_rfq import RespUpdateRFQ +from lighter.models.resp_update_rfq_direction_enum import RespUpdateRFQDirectionEnum from lighter.models.resp_update_referral_code import RespUpdateReferralCode from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay from lighter.models.result_code import ResultCode @@ -183,4 +197,4 @@ # manual additions from lighter.ws_client import WsClient -from lighter.signer_client import SignerClient, create_api_key \ No newline at end of file +from lighter.signer_client import SignerClient, create_api_key diff --git a/lighter/models/__init__.py b/lighter/models/__init__.py index 0219538..32413f2 100644 --- a/lighter/models/__init__.py +++ b/lighter/models/__init__.py @@ -15,6 +15,8 @@ # import models into model package from lighter.models.account import Account +from lighter.models.account_account_trading_mode_enum import AccountAccountTradingModeEnum +from lighter.models.account_account_type_enum import AccountAccountTypeEnum from lighter.models.account_api_keys import AccountApiKeys from lighter.models.account_asset import AccountAsset from lighter.models.account_limits import AccountLimits @@ -22,6 +24,7 @@ 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_position_margin_mode_enum import AccountPositionMarginModeEnum from lighter.models.announcement import Announcement from lighter.models.announcements import Announcements from lighter.models.api_key import ApiKey @@ -43,6 +46,8 @@ 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_account_account_trading_mode_enum import DetailedAccountAccountTradingModeEnum +from lighter.models.detailed_account_account_type_enum import DetailedAccountAccountTypeEnum from lighter.models.detailed_accounts import DetailedAccounts from lighter.models.enriched_tx import EnrichedTx from lighter.models.exchange_metric import ExchangeMetric @@ -68,6 +73,7 @@ from lighter.models.mark_price_candle import MarkPriceCandle from lighter.models.mark_price_candles import MarkPriceCandles from lighter.models.market_config import MarketConfig +from lighter.models.market_config_market_margin_mode_enum import MarketConfigMarketMarginModeEnum from lighter.models.market_price_chart import MarketPriceChart from lighter.models.market_price_charts import MarketPriceCharts from lighter.models.next_nonce import NextNonce @@ -85,9 +91,13 @@ from lighter.models.position_funding import PositionFunding from lighter.models.position_fundings import PositionFundings from lighter.models.public_pool_info import PublicPoolInfo +from lighter.models.public_pool_info_status_enum import PublicPoolInfoStatusEnum from lighter.models.public_pool_metadata import PublicPoolMetadata +from lighter.models.public_pool_metadata_account_type_enum import PublicPoolMetadataAccountTypeEnum +from lighter.models.public_pool_metadata_status_enum import PublicPoolMetadataStatusEnum from lighter.models.public_pool_share import PublicPoolShare from lighter.models.rfq_entry import RFQEntry +from lighter.models.rfq_entry_direction_enum import RFQEntryDirectionEnum from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry from lighter.models.referral import Referral @@ -99,6 +109,7 @@ from lighter.models.req_set_account_metadata import ReqSetAccountMetadata from lighter.models.resp_change_account_tier import RespChangeAccountTier from lighter.models.resp_create_rfq import RespCreateRFQ +from lighter.models.resp_create_rfq_direction_enum import RespCreateRFQDirectionEnum from lighter.models.resp_get_api_tokens import RespGetApiTokens from lighter.models.resp_get_exchange_metrics import RespGetExchangeMetrics from lighter.models.resp_get_execute_stats import RespGetExecuteStats @@ -108,10 +119,12 @@ from lighter.models.resp_get_leases import RespGetLeases from lighter.models.resp_get_maker_only_api_keys import RespGetMakerOnlyApiKeys from lighter.models.resp_get_rfq import RespGetRFQ +from lighter.models.resp_get_rfq_direction_enum import RespGetRFQDirectionEnum from lighter.models.resp_list_rfqs import RespListRFQs from lighter.models.resp_post_api_token import RespPostApiToken from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.models.resp_respond_to_rfq import RespRespondToRFQ +from lighter.models.resp_respond_to_rfq_direction_enum import RespRespondToRFQDirectionEnum from lighter.models.resp_revoke_api_token import RespRevokeApiToken from lighter.models.resp_send_tx import RespSendTx from lighter.models.resp_send_tx_batch import RespSendTxBatch @@ -119,6 +132,7 @@ from lighter.models.resp_synthetic_spot_info import RespSyntheticSpotInfo from lighter.models.resp_update_kickback import RespUpdateKickback from lighter.models.resp_update_rfq import RespUpdateRFQ +from lighter.models.resp_update_rfq_direction_enum import RespUpdateRFQDirectionEnum from lighter.models.resp_update_referral_code import RespUpdateReferralCode from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay from lighter.models.result_code import ResultCode diff --git a/lighter/models/account.py b/lighter/models/account.py index 87c11b0..a68097d 100644 --- a/lighter/models/account.py +++ b/lighter/models/account.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +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 @@ -28,8 +28,8 @@ class Account(BaseModel): """ # noqa: E501 code: StrictInt message: Optional[StrictStr] = None - account_type: StrictInt - account_trading_mode: StrictInt = Field(description="Classic=0 and Unified=1") + account_type: StrictInt = Field(description="See AccountAccountTypeEnum") + account_trading_mode: StrictInt = Field(description="See AccountAccountTradingModeEnum") index: StrictInt l1_address: StrictStr cancel_all_time: StrictInt @@ -43,6 +43,20 @@ class Account(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "account_type", "account_trading_mode", "index", "l1_address", "cancel_all_time", "total_order_count", "total_isolated_order_count", "pending_order_count", "available_balance", "status", "collateral", "transaction_time"] + @field_validator('account_type') + def account_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1, 2, 3, 4, 5]): + raise ValueError("must be one of enum values (0, 1, 2, 3, 4, 5)") + return value + + @field_validator('account_trading_mode') + def account_trading_mode_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/account_account_trading_mode_enum.py b/lighter/models/account_account_trading_mode_enum.py new file mode 100644 index 0000000..934f37b --- /dev/null +++ b/lighter/models/account_account_trading_mode_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class AccountAccountTradingModeEnum(int, Enum): + """ + Named values of Account.account_trading_mode + """ + + """ + allowed enum values + """ + Simple = 0 + Unified = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of AccountAccountTradingModeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/account_account_type_enum.py b/lighter/models/account_account_type_enum.py new file mode 100644 index 0000000..e50711b --- /dev/null +++ b/lighter/models/account_account_type_enum.py @@ -0,0 +1,41 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class AccountAccountTypeEnum(int, Enum): + """ + Named values of Account.account_type + """ + + """ + allowed enum values + """ + Master = 0 + Sub = 1 + PublicPool = 2 + InsuranceFund = 3 + LighterStakingPool = 4 + TreasurySub = 5 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of AccountAccountTypeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/account_position.py b/lighter/models/account_position.py index 93cc661..b61ab8d 100644 --- a/lighter/models/account_position.py +++ b/lighter/models/account_position.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +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 @@ -40,13 +40,20 @@ class AccountPosition(BaseModel): realized_pnl: StrictStr liquidation_price: StrictStr total_funding_paid_out: Optional[StrictStr] = None - margin_mode: StrictInt + margin_mode: StrictInt = Field(description="See AccountPositionMarginModeEnum") allocated_margin: StrictStr total_discount: StrictStr margin_set_flag: StrictInt 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", "total_discount", "margin_set_flag"] + @field_validator('margin_mode') + def margin_mode_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/account_position_margin_mode_enum.py b/lighter/models/account_position_margin_mode_enum.py new file mode 100644 index 0000000..0225fd4 --- /dev/null +++ b/lighter/models/account_position_margin_mode_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class AccountPositionMarginModeEnum(int, Enum): + """ + Named values of AccountPosition.margin_mode + """ + + """ + allowed enum values + """ + Cross = 0 + Isolated = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of AccountPositionMarginModeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/detailed_account.py b/lighter/models/detailed_account.py index 866349d..5fc6c50 100644 --- a/lighter/models/detailed_account.py +++ b/lighter/models/detailed_account.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from lighter.models.account_asset import AccountAsset from lighter.models.account_position import AccountPosition @@ -35,8 +35,8 @@ class DetailedAccount(BaseModel): """ # noqa: E501 code: StrictInt message: Optional[StrictStr] = None - account_type: StrictInt - account_trading_mode: Optional[StrictInt] = Field(default=None, description="Classic=0 and Unified=1") + account_type: StrictInt = Field(description="See DetailedAccountAccountTypeEnum") + account_trading_mode: Optional[StrictInt] = Field(default=None, description="See DetailedAccountAccountTradingModeEnum") index: StrictInt l1_address: StrictStr cancel_all_time: StrictInt @@ -69,6 +69,23 @@ class DetailedAccount(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "account_type", "account_trading_mode", "index", "l1_address", "cancel_all_time", "total_order_count", "total_isolated_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", "created_at", "transaction_time", "pending_unlocks", "approved_integrators", "can_rfq", "cross_initial_margin_requirement", "cross_maintenance_margin_requirement", "can_rfq_market_ids", "metadata"] + @field_validator('account_type') + def account_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1, 2, 3, 4, 5]): + raise ValueError("must be one of enum values (0, 1, 2, 3, 4, 5)") + return value + + @field_validator('account_trading_mode') + def account_trading_mode_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/detailed_account_account_trading_mode_enum.py b/lighter/models/detailed_account_account_trading_mode_enum.py new file mode 100644 index 0000000..aa928b2 --- /dev/null +++ b/lighter/models/detailed_account_account_trading_mode_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class DetailedAccountAccountTradingModeEnum(int, Enum): + """ + Named values of DetailedAccount.account_trading_mode + """ + + """ + allowed enum values + """ + Simple = 0 + Unified = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of DetailedAccountAccountTradingModeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/detailed_account_account_type_enum.py b/lighter/models/detailed_account_account_type_enum.py new file mode 100644 index 0000000..0f5a28d --- /dev/null +++ b/lighter/models/detailed_account_account_type_enum.py @@ -0,0 +1,41 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class DetailedAccountAccountTypeEnum(int, Enum): + """ + Named values of DetailedAccount.account_type + """ + + """ + allowed enum values + """ + Master = 0 + Sub = 1 + PublicPool = 2 + InsuranceFund = 3 + LighterStakingPool = 4 + TreasurySub = 5 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of DetailedAccountAccountTypeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/market_config.py b/lighter/models/market_config.py index 767d405..8217d24 100644 --- a/lighter/models/market_config.py +++ b/lighter/models/market_config.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self @@ -26,7 +26,7 @@ class MarketConfig(BaseModel): """ MarketConfig """ # noqa: E501 - market_margin_mode: StrictInt + market_margin_mode: StrictInt = Field(description="See MarketConfigMarketMarginModeEnum") insurance_fund_account_index: StrictInt liquidation_mode: StrictInt force_reduce_only: StrictBool @@ -37,6 +37,13 @@ class MarketConfig(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["market_margin_mode", "insurance_fund_account_index", "liquidation_mode", "force_reduce_only", "funding_fee_discounts_enabled", "trading_hours", "hidden", "rfq_enabled"] + @field_validator('market_margin_mode') + def market_margin_mode_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/market_config_market_margin_mode_enum.py b/lighter/models/market_config_market_margin_mode_enum.py new file mode 100644 index 0000000..bae817f --- /dev/null +++ b/lighter/models/market_config_market_margin_mode_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class MarketConfigMarketMarginModeEnum(int, Enum): + """ + Named values of MarketConfig.market_margin_mode + """ + + """ + allowed enum values + """ + All = 0 + IsolatedForNonPools = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of MarketConfigMarketMarginModeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/public_pool_info.py b/lighter/models/public_pool_info.py index d7587cd..3cac458 100644 --- a/lighter/models/public_pool_info.py +++ b/lighter/models/public_pool_info.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Union from lighter.models.daily_return import DailyReturn from lighter.models.share_price import SharePrice @@ -29,7 +29,7 @@ class PublicPoolInfo(BaseModel): """ PublicPoolInfo """ # noqa: E501 - status: StrictInt + status: StrictInt = Field(description="See PublicPoolInfoStatusEnum") operator_fee: StrictStr min_operator_share_rate: StrictStr total_shares: StrictInt @@ -42,6 +42,13 @@ class PublicPoolInfo(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares", "annual_percentage_yield", "daily_returns", "share_prices", "sharpe_ratio", "strategies"] + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/public_pool_info_status_enum.py b/lighter/models/public_pool_info_status_enum.py new file mode 100644 index 0000000..1cbbc67 --- /dev/null +++ b/lighter/models/public_pool_info_status_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class PublicPoolInfoStatusEnum(int, Enum): + """ + Named values of PublicPoolInfo.status + """ + + """ + allowed enum values + """ + Active = 0 + Frozen = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of PublicPoolInfoStatusEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/public_pool_metadata.py b/lighter/models/public_pool_metadata.py index 68c8b74..ba0daed 100644 --- a/lighter/models/public_pool_metadata.py +++ b/lighter/models/public_pool_metadata.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional, Union from lighter.models.account_asset import AccountAsset from lighter.models.public_pool_share import PublicPoolShare @@ -31,11 +31,11 @@ class PublicPoolMetadata(BaseModel): code: StrictInt message: Optional[StrictStr] = None account_index: StrictInt - account_type: StrictInt + account_type: StrictInt = Field(description="See PublicPoolMetadataAccountTypeEnum") name: StrictStr l1_address: StrictStr annual_percentage_yield: Union[StrictFloat, StrictInt] - status: StrictInt + status: StrictInt = Field(description="See PublicPoolMetadataStatusEnum") operator_fee: StrictStr total_asset_value: StrictStr total_shares: StrictInt @@ -49,6 +49,20 @@ class PublicPoolMetadata(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "account_index", "account_type", "name", "l1_address", "annual_percentage_yield", "status", "operator_fee", "total_asset_value", "total_shares", "account_share", "assets", "created_at", "master_account_index", "sharpe_ratio", "total_perps_value", "total_spot_value"] + @field_validator('account_type') + def account_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1, 2, 3, 4, 5]): + raise ValueError("must be one of enum values (0, 1, 2, 3, 4, 5)") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set([0, 1]): + raise ValueError("must be one of enum values (0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/public_pool_metadata_account_type_enum.py b/lighter/models/public_pool_metadata_account_type_enum.py new file mode 100644 index 0000000..af3b4d5 --- /dev/null +++ b/lighter/models/public_pool_metadata_account_type_enum.py @@ -0,0 +1,41 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class PublicPoolMetadataAccountTypeEnum(int, Enum): + """ + Named values of PublicPoolMetadata.account_type + """ + + """ + allowed enum values + """ + Master = 0 + Sub = 1 + PublicPool = 2 + InsuranceFund = 3 + LighterStakingPool = 4 + TreasurySub = 5 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of PublicPoolMetadataAccountTypeEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/public_pool_metadata_status_enum.py b/lighter/models/public_pool_metadata_status_enum.py new file mode 100644 index 0000000..b9cd5cc --- /dev/null +++ b/lighter/models/public_pool_metadata_status_enum.py @@ -0,0 +1,37 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class PublicPoolMetadataStatusEnum(int, Enum): + """ + Named values of PublicPoolMetadata.status + """ + + """ + allowed enum values + """ + Active = 0 + Frozen = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of PublicPoolMetadataStatusEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/resp_create_rfq.py b/lighter/models/resp_create_rfq.py index 89dd8de..f632151 100644 --- a/lighter/models/resp_create_rfq.py +++ b/lighter/models/resp_create_rfq.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry @@ -33,7 +33,7 @@ class RespCreateRFQ(BaseModel): id: StrictInt account_index: StrictInt market_index: StrictInt - direction: StrictInt + direction: StrictInt = Field(description="See RespCreateRFQDirectionEnum") base_amount: StrictStr quote_amount: StrictStr status: StrictStr @@ -44,6 +44,13 @@ class RespCreateRFQ(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "id", "account_index", "market_index", "direction", "base_amount", "quote_amount", "status", "metadata", "responses", "created_at", "updated_at"] + @field_validator('direction') + def direction_validate_enum(cls, value): + """Validates the enum""" + if value not in set([-1, 0, 1]): + raise ValueError("must be one of enum values (-1, 0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/resp_create_rfq_direction_enum.py b/lighter/models/resp_create_rfq_direction_enum.py new file mode 100644 index 0000000..c1303f1 --- /dev/null +++ b/lighter/models/resp_create_rfq_direction_enum.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class RespCreateRFQDirectionEnum(int, Enum): + """ + Named values of RespCreateRFQ.direction + """ + + """ + allowed enum values + """ + Hidden = -1 + Sell = 0 + Buy = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of RespCreateRFQDirectionEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/resp_get_rfq.py b/lighter/models/resp_get_rfq.py index 47fde13..e61ee57 100644 --- a/lighter/models/resp_get_rfq.py +++ b/lighter/models/resp_get_rfq.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry @@ -33,7 +33,7 @@ class RespGetRFQ(BaseModel): id: StrictInt account_index: StrictInt market_index: StrictInt - direction: StrictInt + direction: StrictInt = Field(description="See RespGetRFQDirectionEnum") base_amount: StrictStr quote_amount: StrictStr status: StrictStr @@ -44,6 +44,13 @@ class RespGetRFQ(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "id", "account_index", "market_index", "direction", "base_amount", "quote_amount", "status", "metadata", "responses", "created_at", "updated_at"] + @field_validator('direction') + def direction_validate_enum(cls, value): + """Validates the enum""" + if value not in set([-1, 0, 1]): + raise ValueError("must be one of enum values (-1, 0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/resp_get_rfq_direction_enum.py b/lighter/models/resp_get_rfq_direction_enum.py new file mode 100644 index 0000000..7bdd0f2 --- /dev/null +++ b/lighter/models/resp_get_rfq_direction_enum.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class RespGetRFQDirectionEnum(int, Enum): + """ + Named values of RespGetRFQ.direction + """ + + """ + allowed enum values + """ + Hidden = -1 + Sell = 0 + Buy = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of RespGetRFQDirectionEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/resp_respond_to_rfq.py b/lighter/models/resp_respond_to_rfq.py index d05b953..c8fc1ec 100644 --- a/lighter/models/resp_respond_to_rfq.py +++ b/lighter/models/resp_respond_to_rfq.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry @@ -33,7 +33,7 @@ class RespRespondToRFQ(BaseModel): id: StrictInt account_index: StrictInt market_index: StrictInt - direction: StrictInt + direction: StrictInt = Field(description="See RespRespondToRFQDirectionEnum") base_amount: StrictStr quote_amount: StrictStr status: StrictStr @@ -44,6 +44,13 @@ class RespRespondToRFQ(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "id", "account_index", "market_index", "direction", "base_amount", "quote_amount", "status", "metadata", "responses", "created_at", "updated_at"] + @field_validator('direction') + def direction_validate_enum(cls, value): + """Validates the enum""" + if value not in set([-1, 0, 1]): + raise ValueError("must be one of enum values (-1, 0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/resp_respond_to_rfq_direction_enum.py b/lighter/models/resp_respond_to_rfq_direction_enum.py new file mode 100644 index 0000000..af05e30 --- /dev/null +++ b/lighter/models/resp_respond_to_rfq_direction_enum.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class RespRespondToRFQDirectionEnum(int, Enum): + """ + Named values of RespRespondToRFQ.direction + """ + + """ + allowed enum values + """ + Hidden = -1 + Sell = 0 + Buy = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of RespRespondToRFQDirectionEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/resp_update_rfq.py b/lighter/models/resp_update_rfq.py index ed77bdd..4637c29 100644 --- a/lighter/models/resp_update_rfq.py +++ b/lighter/models/resp_update_rfq.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry @@ -33,7 +33,7 @@ class RespUpdateRFQ(BaseModel): id: StrictInt account_index: StrictInt market_index: StrictInt - direction: StrictInt + direction: StrictInt = Field(description="See RespUpdateRFQDirectionEnum") base_amount: StrictStr quote_amount: StrictStr status: StrictStr @@ -44,6 +44,13 @@ class RespUpdateRFQ(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["code", "message", "id", "account_index", "market_index", "direction", "base_amount", "quote_amount", "status", "metadata", "responses", "created_at", "updated_at"] + @field_validator('direction') + def direction_validate_enum(cls, value): + """Validates the enum""" + if value not in set([-1, 0, 1]): + raise ValueError("must be one of enum values (-1, 0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/resp_update_rfq_direction_enum.py b/lighter/models/resp_update_rfq_direction_enum.py new file mode 100644 index 0000000..4b79316 --- /dev/null +++ b/lighter/models/resp_update_rfq_direction_enum.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class RespUpdateRFQDirectionEnum(int, Enum): + """ + Named values of RespUpdateRFQ.direction + """ + + """ + allowed enum values + """ + Hidden = -1 + Sell = 0 + Buy = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of RespUpdateRFQDirectionEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/lighter/models/rfq_entry.py b/lighter/models/rfq_entry.py index 8465419..a9afea1 100644 --- a/lighter/models/rfq_entry.py +++ b/lighter/models/rfq_entry.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from lighter.models.rfq_metadata import RFQMetadata from lighter.models.rfq_response_entry import RFQResponseEntry @@ -31,7 +31,7 @@ class RFQEntry(BaseModel): id: StrictInt account_index: StrictInt market_index: StrictInt - direction: StrictInt + direction: StrictInt = Field(description="See RFQEntryDirectionEnum") base_amount: StrictStr quote_amount: StrictStr status: StrictStr @@ -42,6 +42,13 @@ class RFQEntry(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "account_index", "market_index", "direction", "base_amount", "quote_amount", "status", "metadata", "responses", "created_at", "updated_at"] + @field_validator('direction') + def direction_validate_enum(cls, value): + """Validates the enum""" + if value not in set([-1, 0, 1]): + raise ValueError("must be one of enum values (-1, 0, 1)") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/lighter/models/rfq_entry_direction_enum.py b/lighter/models/rfq_entry_direction_enum.py new file mode 100644 index 0000000..0b9fa57 --- /dev/null +++ b/lighter/models/rfq_entry_direction_enum.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class RFQEntryDirectionEnum(int, Enum): + """ + Named values of RFQEntry.direction + """ + + """ + allowed enum values + """ + Hidden = -1 + Sell = 0 + Buy = 1 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of RFQEntryDirectionEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/openapi.json b/openapi.json index 4c4656d..2c000eb 100644 --- a/openapi.json +++ b/openapi.json @@ -5057,13 +5057,24 @@ "account_type": { "type": "integer", "format": "uint8", - "example": "1" + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "description": "See AccountAccountTypeEnum" }, "account_trading_mode": { "type": "integer", "format": "uint8", - "example": "1", - "description": "Classic=0 and Unified=1" + "enum": [ + 0, + 1 + ], + "description": "See AccountAccountTradingModeEnum" }, "index": { "type": "integer", @@ -5447,7 +5458,11 @@ "margin_mode": { "type": "integer", "format": "int32", - "example": "1" + "enum": [ + 0, + 1 + ], + "description": "See AccountPositionMarginModeEnum" }, "allocated_margin": { "type": "string", @@ -6085,13 +6100,24 @@ "account_type": { "type": "integer", "format": "uint8", - "example": "1" + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "description": "See DetailedAccountAccountTypeEnum" }, "account_trading_mode": { "type": "integer", "format": "uint8", - "example": "1", - "description": "Classic=0 and Unified=1" + "enum": [ + 0, + 1 + ], + "description": "See DetailedAccountAccountTradingModeEnum" }, "index": { "type": "integer", @@ -6803,7 +6829,11 @@ "market_margin_mode": { "type": "integer", "format": "int32", - "example": 0 + "enum": [ + 0, + 1 + ], + "description": "See MarketConfigMarketMarginModeEnum" }, "insurance_fund_account_index": { "type": "integer", @@ -8040,7 +8070,11 @@ "status": { "type": "integer", "format": "uint8", - "example": "0" + "enum": [ + 0, + 1 + ], + "description": "See PublicPoolInfoStatusEnum" }, "operator_fee": { "type": "string", @@ -8121,7 +8155,15 @@ "account_type": { "type": "integer", "format": "uint8", - "example": "1" + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "description": "See PublicPoolMetadataAccountTypeEnum" }, "name": { "type": "string" @@ -8138,7 +8180,11 @@ "status": { "type": "integer", "format": "uint8", - "example": "0" + "enum": [ + 0, + 1 + ], + "description": "See PublicPoolMetadataStatusEnum" }, "operator_fee": { "type": "string", @@ -10966,7 +11012,13 @@ }, "direction": { "type": "integer", - "format": "int16" + "format": "int16", + "enum": [ + -1, + 0, + 1 + ], + "description": "See RespRespondToRFQDirectionEnum" }, "base_amount": { "type": "string" @@ -11115,7 +11167,13 @@ }, "direction": { "type": "integer", - "format": "int16" + "format": "int16", + "enum": [ + -1, + 0, + 1 + ], + "description": "See RFQEntryDirectionEnum" }, "base_amount": { "type": "string" @@ -11184,7 +11242,13 @@ }, "direction": { "type": "integer", - "format": "int16" + "format": "int16", + "enum": [ + -1, + 0, + 1 + ], + "description": "See RespGetRFQDirectionEnum" }, "base_amount": { "type": "string" @@ -11246,8 +11310,8 @@ "type": "integer", "format": "int16", "enum": [ - "0", - "1" + 0, + 1 ] }, "metadata": { @@ -11285,7 +11349,13 @@ }, "direction": { "type": "integer", - "format": "int16" + "format": "int16", + "enum": [ + -1, + 0, + 1 + ], + "description": "See RespCreateRFQDirectionEnum" }, "base_amount": { "type": "string" @@ -11376,7 +11446,13 @@ }, "direction": { "type": "integer", - "format": "int16" + "format": "int16", + "enum": [ + -1, + 0, + 1 + ], + "description": "See RespUpdateRFQDirectionEnum" }, "base_amount": { "type": "string" @@ -11691,6 +11767,222 @@ "entryId", "metadata" ] + }, + "AccountAccountTypeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "Master", + "Sub", + "PublicPool", + "InsuranceFund", + "LighterStakingPool", + "TreasurySub" + ], + "description": "Named values of Account.account_type" + }, + "AccountAccountTradingModeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "Simple", + "Unified" + ], + "description": "Named values of Account.account_trading_mode" + }, + "AccountPositionMarginModeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "Cross", + "Isolated" + ], + "description": "Named values of AccountPosition.margin_mode" + }, + "DetailedAccountAccountTypeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "Master", + "Sub", + "PublicPool", + "InsuranceFund", + "LighterStakingPool", + "TreasurySub" + ], + "description": "Named values of DetailedAccount.account_type" + }, + "DetailedAccountAccountTradingModeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "Simple", + "Unified" + ], + "description": "Named values of DetailedAccount.account_trading_mode" + }, + "MarketConfigMarketMarginModeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "All", + "IsolatedForNonPools" + ], + "description": "Named values of MarketConfig.market_margin_mode" + }, + "PublicPoolInfoStatusEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "Active", + "Frozen" + ], + "description": "Named values of PublicPoolInfo.status" + }, + "PublicPoolMetadataAccountTypeEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "Master", + "Sub", + "PublicPool", + "InsuranceFund", + "LighterStakingPool", + "TreasurySub" + ], + "description": "Named values of PublicPoolMetadata.account_type" + }, + "PublicPoolMetadataStatusEnum": { + "type": "integer", + "format": "int32", + "enum": [ + 0, + 1 + ], + "x-enum-varnames": [ + "Active", + "Frozen" + ], + "description": "Named values of PublicPoolMetadata.status" + }, + "RespRespondToRFQDirectionEnum": { + "type": "integer", + "format": "int32", + "enum": [ + -1, + 0, + 1 + ], + "x-enum-varnames": [ + "Hidden", + "Sell", + "Buy" + ], + "description": "Named values of RespRespondToRFQ.direction" + }, + "RFQEntryDirectionEnum": { + "type": "integer", + "format": "int32", + "enum": [ + -1, + 0, + 1 + ], + "x-enum-varnames": [ + "Hidden", + "Sell", + "Buy" + ], + "description": "Named values of RFQEntry.direction" + }, + "RespGetRFQDirectionEnum": { + "type": "integer", + "format": "int32", + "enum": [ + -1, + 0, + 1 + ], + "x-enum-varnames": [ + "Hidden", + "Sell", + "Buy" + ], + "description": "Named values of RespGetRFQ.direction" + }, + "RespCreateRFQDirectionEnum": { + "type": "integer", + "format": "int32", + "enum": [ + -1, + 0, + 1 + ], + "x-enum-varnames": [ + "Hidden", + "Sell", + "Buy" + ], + "description": "Named values of RespCreateRFQ.direction" + }, + "RespUpdateRFQDirectionEnum": { + "type": "integer", + "format": "int32", + "enum": [ + -1, + 0, + 1 + ], + "x-enum-varnames": [ + "Hidden", + "Sell", + "Buy" + ], + "description": "Named values of RespUpdateRFQ.direction" } } } diff --git a/scripts/openapi_postprocess.py b/scripts/openapi_postprocess.py new file mode 100644 index 0000000..75ce695 --- /dev/null +++ b/scripts/openapi_postprocess.py @@ -0,0 +1,106 @@ +"""Normalize integer enums in openapi.json before running openapi-generator. + +goctl-swagger emits every `options=` tag as a list of strings, even on integer +fields. Named members (`options=Cross:0|Isolated:1` in server.api) therefore +arrive as `"enum": ["Cross:0", "Isolated:1"]`, which the Python generator turns +into `set([null, null])` validators. + +This script rewrites those into real integer enums: + +* every integer enum keeps its shape but its members become ints; +* fully named integer enums additionally get a standalone + `Enum` component schema (`enum: [0, 1]`, + `x-enum-varnames: ["Cross", "Isolated"]`), so the generator emits an + `IntEnum` class such as `AccountPositionMarginModeEnum`. The property itself + stays an integer (rather than a `$ref`) because models are built with + `model_construct`, which would leave raw ints in an enum-typed field and make + pydantic warn on every `to_json()`; +* mixing named and unnamed members is an error. + +Usage: python3 scripts/openapi_postprocess.py [openapi.json] +""" + +import json +import re +import sys + +FILE = sys.argv[1] if len(sys.argv) > 1 else "openapi.json" + +INTEGER_ENUM_FORMATS = { + "int8": "int32", + "uint8": "int32", + "int16": "int32", + "uint16": "int32", + "uin16": "int32", + "int32": "int32", + "uint32": "int64", + "int64": "int64", + "uint64": "int64", +} + +ENUM_MEMBER_RE = re.compile(r"^(?:(?P[A-Za-z_]\w*):)?(?P-?\d+)$") + + +def _pascal(snake): + return "".join(part[:1].upper() + part[1:] for part in snake.split("_")) + + +def _parse_members(schema, path): + values = [] + names = [] + for raw in schema["enum"]: + match = ENUM_MEMBER_RE.match(str(raw)) + if not match: + raise ValueError(f"{path}: invalid integer enum member {raw!r}") + values.append(int(match.group("value"))) + names.append(match.group("name")) + if any(names) and not all(names): + raise ValueError(f"{path}: every enum member must be named, or none") + return values, names + + +def normalize_integer_enums(spec): + if "components" in spec: + schemas = spec["components"].setdefault("schemas", {}) + else: + schemas = spec.setdefault("definitions", {}) + + named_enums = {} + for schema_name, schema in schemas.items(): + for prop_name, prop in schema.get("properties", {}).items(): + if prop.get("type") != "integer" or "enum" not in prop: + continue + path = f"{schema_name}.{prop_name}" + values, names = _parse_members(prop, path) + prop["enum"] = values + if not any(names): + continue + + enum_name = f"{schema_name}{_pascal(prop_name)}Enum" + if enum_name in schemas or enum_name in named_enums: + raise ValueError(f"{path}: enum schema {enum_name} already exists") + named_enums[enum_name] = { + "type": "integer", + "format": INTEGER_ENUM_FORMATS.get(prop.get("format"), "int64"), + "enum": values, + "x-enum-varnames": names, + "description": f"Named values of {schema_name}.{prop_name}", + } + prop["description"] = f"See {enum_name}" + + schemas.update(named_enums) + return spec + + +def main(): + with open(FILE, "r", encoding="utf-8") as f: + spec = json.load(f) + + normalize_integer_enums(spec) + + with open(FILE, "w", encoding="utf-8") as f: + json.dump(spec, f, indent=2, ensure_ascii=False) + + +if __name__ == "__main__": + main()