@polyester/sdk 0.35.0 → 0.36.0-devnet-20261112202000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/browser-core.js +1 -1
- package/dist/catalogs/snapshot-validation.js +5 -0
- package/dist/catalogs/snapshot-validation.js.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +145 -3
- package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.js +33 -3
- package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +12 -6
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts.map +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.js +3 -1
- package/dist/gen/alerts/v1/price_alerts_pb.js.map +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
- package/dist/gen/auth/v1/api_keys_pb.d.ts +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +1 -1
- package/dist/gen/auth/v1/mfa_pb.d.ts +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +15 -2
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +14 -1
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/auth/v1/profile_pb.d.ts +1 -1
- package/dist/gen/auth/v1/resolve_pb.d.ts +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +15 -2
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +15 -2
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/chain/analytics/v1/analytics_read_pb.d.ts +1 -1
- package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +1 -1
- package/dist/gen/chain/zipper/v1/reason_pb.d.ts +1 -1
- package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +1 -1
- package/dist/gen/changelog/v1/changelog_pb.d.ts +8 -2
- package/dist/gen/changelog/v1/changelog_pb.d.ts.map +1 -1
- package/dist/gen/changelog/v1/changelog_pb.js +7 -1
- package/dist/gen/changelog/v1/changelog_pb.js.map +1 -1
- package/dist/gen/checkpoints/v1/checkpoints_pb.d.ts +1 -1
- package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
- package/dist/gen/fees/v1/fees_pb.d.ts +1 -1
- package/dist/gen/index.d.ts +2 -1
- package/dist/gen/index.js +22 -21
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/heatmap_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts +58 -6
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts.map +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.js +10 -4
- package/dist/gen/marketdata/v1/marketdata_pb.js.map +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +827 -0
- package/dist/gen/notifications/v1/notifications_pb.d.ts.map +1 -0
- package/dist/gen/notifications/v1/notifications_pb.js +346 -0
- package/dist/gen/notifications/v1/notifications_pb.js.map +1 -0
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +248 -20
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +188 -66
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +74 -6
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js +40 -5
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +1 -1
- package/dist/gen/polyester/type/v1/u128_pb.d.ts +1 -1
- package/dist/gen/privatews/v1/private_ws_pb.d.ts +1 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +1 -1
- package/dist/gen/rewards/v1/rewards_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +1195 -190
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +317 -7
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +370 -7
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js +237 -14
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +1 -1
- package/dist/gen/swap/v1/swap_pb.d.ts +1 -1
- package/dist/gen/system/v1/system_pb.d.ts +1 -1
- package/dist/gen/tradews/v1/trade_ws_pb.d.ts +40 -2
- package/dist/gen/tradews/v1/trade_ws_pb.d.ts.map +1 -1
- package/dist/gen/tradews/v1/trade_ws_pb.js +2 -1
- package/dist/gen/tradews/v1/trade_ws_pb.js.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +527 -14
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +126 -26
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +1 -1
- package/dist/realtime/snapshot-then-stream.js +1 -1
- package/dist/server-core.js +3 -3
- package/dist/services/accounts/accounts.js +1 -1
- package/dist/services/accounts/accounts.schemas.js +1 -1
- package/dist/services/address-book/address-book.js +1 -1
- package/dist/services/api-keys/api-keys.js +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +1 -1
- package/dist/services/assistant/assistant-events.schemas.d.ts +63 -45
- package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -1
- package/dist/services/assistant/assistant.codecs.d.ts +1 -1
- package/dist/services/assistant/assistant.codecs.js +1 -1
- package/dist/services/assistant/assistant.codecs.js.map +1 -1
- package/dist/services/assistant/assistant.d.ts +18 -3
- package/dist/services/assistant/assistant.d.ts.map +1 -1
- package/dist/services/assistant/assistant.js +27 -4
- package/dist/services/assistant/assistant.js.map +1 -1
- package/dist/services/assistant/assistant.schemas.d.ts +14 -2
- package/dist/services/assistant/assistant.schemas.d.ts.map +1 -1
- package/dist/services/assistant/assistant.schemas.js +16 -2
- package/dist/services/assistant/assistant.schemas.js.map +1 -1
- package/dist/services/assistant/assistant.types.d.ts +2 -2
- package/dist/services/auth/account-signer-auth.js +2 -2
- package/dist/services/auth/auth.js +1 -1
- package/dist/services/auth/profile/profile.js +2 -2
- package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +22 -22
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -1
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/candles/candles.js +2 -2
- package/dist/services/chain-analytics/chain-analytics.js +1 -1
- package/dist/services/changelog/changelog.codecs.d.ts +1 -1
- package/dist/services/changelog/changelog.codecs.d.ts.map +1 -1
- package/dist/services/changelog/changelog.codecs.js +6 -3
- package/dist/services/changelog/changelog.codecs.js.map +1 -1
- package/dist/services/changelog/changelog.js +1 -1
- package/dist/services/changelog/changelog.schemas.d.ts +19 -19
- package/dist/services/checkpoints/checkpoints.js +1 -1
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
- package/dist/services/claims/claims.js +1 -1
- package/dist/services/claims/claims.schemas.js +1 -1
- package/dist/services/deposit/deposit.js +1 -1
- package/dist/services/fees/fees.js +1 -1
- package/dist/services/guard-signer/guard-signer.js +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +1 -1
- package/dist/services/heatmap/heatmap.js +2 -2
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.js +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
- package/dist/services/lifecycle/lifecycle.js +3 -3
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +15 -15
- package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
- package/dist/services/market-data/market-data.js +2 -2
- package/dist/services/market-data/market-data.schemas.js +16 -1
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.js +2 -2
- package/dist/services/market-overview/market-overview.schemas.js +1 -1
- package/dist/services/notifications/notifications.codecs.d.ts +16 -0
- package/dist/services/notifications/notifications.codecs.d.ts.map +1 -0
- package/dist/services/notifications/notifications.codecs.js +40 -0
- package/dist/services/notifications/notifications.codecs.js.map +1 -0
- package/dist/services/notifications/notifications.d.ts +41 -0
- package/dist/services/notifications/notifications.d.ts.map +1 -0
- package/dist/services/notifications/notifications.js +67 -0
- package/dist/services/notifications/notifications.js.map +1 -0
- package/dist/services/notifications/notifications.schemas.d.ts +162 -0
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -0
- package/dist/services/notifications/notifications.schemas.js +116 -0
- package/dist/services/notifications/notifications.schemas.js.map +1 -0
- package/dist/services/notifications/notifications.types.d.ts +3 -0
- package/dist/services/notifications/service.d.ts +8 -0
- package/dist/services/notifications/service.d.ts.map +1 -0
- package/dist/services/notifications/service.js +9 -0
- package/dist/services/notifications/service.js.map +1 -0
- package/dist/services/orderbook/orderbook.js +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/order-enums.codecs.js +12 -4
- package/dist/services/orders/order-enums.codecs.js.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +1 -1
- package/dist/services/orders/order-errors.schemas.js +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +2688 -417
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +7 -5
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +4827 -1264
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +105 -33
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-modify.schemas.js +2 -2
- package/dist/services/orders/orders-output.schemas.d.ts +44 -26
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +9 -1
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +4 -4
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/orders/orders.codecs.js +3 -0
- package/dist/services/orders/orders.codecs.js.map +1 -1
- package/dist/services/orders/orders.d.ts +3 -1
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +7 -14
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.js +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
- package/dist/services/policies/shared.codecs.js +10 -4
- package/dist/services/policies/shared.codecs.js.map +1 -1
- package/dist/services/policies/shared.d.ts +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +3 -3
- package/dist/services/price-alerts/price-alerts.codecs.d.ts +1 -1
- package/dist/services/price-alerts/price-alerts.codecs.js +3 -3
- package/dist/services/price-alerts/price-alerts.codecs.js.map +1 -1
- package/dist/services/price-alerts/price-alerts.d.ts +11 -6
- package/dist/services/price-alerts/price-alerts.d.ts.map +1 -1
- package/dist/services/price-alerts/price-alerts.js +12 -7
- package/dist/services/price-alerts/price-alerts.js.map +1 -1
- package/dist/services/price-alerts/price-alerts.schemas.d.ts +11 -11
- package/dist/services/rate-limits/rate-limits.js +1 -1
- package/dist/services/rewards/rewards.js +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/social-verification/social-verification.js +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +1 -1
- package/dist/services/subaccounts/subaccounts.codecs.js +3 -1
- package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +3 -3
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +7 -7
- package/dist/services/system/system.js +1 -1
- package/dist/services/trades/trades.js +2 -2
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +1 -1
- package/dist/services/trading-withdraws/wallet-message.js +1 -1
- package/dist/services/transfers/transfers.js +2 -2
- package/dist/services/triggers/trigger-child-order.schemas.js +3 -3
- package/dist/services/triggers/trigger-input.schemas.d.ts +272 -42
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +53 -5
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +240 -29
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +49 -2
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/services/triggers/triggers.codecs.js +7 -2
- package/dist/services/triggers/triggers.codecs.js.map +1 -1
- package/dist/services/triggers/triggers.d.ts +25 -3
- package/dist/services/triggers/triggers.d.ts.map +1 -1
- package/dist/services/triggers/triggers.js +51 -5
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/services/triggers/triggers.schemas.d.ts +3 -3
- package/dist/services/triggers/triggers.types.d.ts +3 -3
- package/dist/services/vip/vip.js +1 -1
- package/dist/services/vip/vip.schemas.js +1 -1
- package/dist/services/zipper/zipper.js +1 -1
- package/dist/services/zipper/zipper.schemas.js +1 -1
- package/dist/shared/catalog-config.d.ts +6 -0
- package/dist/shared/catalog-config.d.ts.map +1 -1
- package/dist/shared/catalog-config.js.map +1 -1
- package/dist/shared/error-detail.d.ts +6 -2
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js +1 -0
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/error-details/alerts.js +1 -1
- package/dist/shared/error-details/assistant.js +1 -1
- package/dist/shared/error-details/auth.js +1 -1
- package/dist/shared/error-details/claims.js +1 -1
- package/dist/shared/error-details/internal-transfer.js +1 -1
- package/dist/shared/error-details/ledger.js +1 -1
- package/dist/shared/error-details/market-overview.js +1 -1
- package/dist/shared/error-details/notifications.js +15 -0
- package/dist/shared/error-details/notifications.js.map +1 -0
- package/dist/shared/error-details/orders.js +1 -1
- package/dist/shared/error-details/profile.js +1 -1
- package/dist/shared/error-details/rate-limit.js +1 -1
- package/dist/shared/error-details/withdraw.js +1 -1
- package/dist/shared/rate-limit.schemas.js +1 -1
- package/dist/shared/request-id.d.ts +6 -0
- package/dist/shared/request-id.d.ts.map +1 -0
- package/dist/shared/request-id.js +17 -0
- package/dist/shared/request-id.js.map +1 -0
- package/dist/utils/cookies.js +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +19 -17
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ declare const LifecycleAssetIdsSchema: v.ObjectSchema<{
|
|
|
7
7
|
readonly zippedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
8
8
|
readonly unifiedAssetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
9
9
|
}, undefined>;
|
|
10
|
-
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
10
|
+
declare const LifecycleFlowStateEnumSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "failed" | "pending_source" | "pending_polyester_chain" | "pending_ledger" | "dropped" | "refunded">]>;
|
|
11
11
|
declare const LifecycleZipperReasonSchema: v.ObjectSchema<{
|
|
12
12
|
readonly code: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
13
13
|
readonly reasonId: v.StringSchema<undefined>;
|
|
@@ -17,7 +17,7 @@ declare const ListLifecycleFlowsInputSchema: v.SchemaWithPipe<readonly [v.Strict
|
|
|
17
17
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 500, undefined>]>, 100>;
|
|
18
18
|
readonly sort: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["newest", "oldest"], undefined>, "newest">, v.TransformAction<"newest" | "oldest", Sort.NEWEST | Sort.OLDEST>]>;
|
|
19
19
|
readonly flowKind: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["deposit", "withdraw", "transfer"], undefined>, undefined>, v.TransformAction<"deposit" | "withdraw" | "transfer" | undefined, FlowKind>]>;
|
|
20
|
-
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"
|
|
20
|
+
readonly flowState: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["pending_source", "pending_polyester_chain", "pending_ledger", "completed", "failed", "dropped", "refunded"], undefined>, undefined>, v.TransformAction<"completed" | "failed" | "pending_source" | "pending_polyester_chain" | "pending_ledger" | "dropped" | "refunded" | undefined, FlowState>]>;
|
|
21
21
|
readonly txRef: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, "txHash is required.">, v.CheckAction<string, "txHash must be a valid EVM hash or chain-native transaction id.">, v.TransformAction<string, string>]>, undefined>;
|
|
22
22
|
readonly scope: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["all", "open", "terminal"], undefined>, "all">, v.TransformAction<"open" | "all" | "terminal", ListScope.LIST_ALL | ListScope.LIST_OPEN_ONLY | ListScope.LIST_TERMINAL_ONLY>]>;
|
|
23
23
|
readonly accountSelector: v.OptionalSchema<v.SchemaWithPipe<readonly [v.VariantSchema<"kind", [v.StrictObjectSchema<{
|
|
@@ -522,7 +522,7 @@ declare const LifecycleFlowStepSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
|
|
|
522
522
|
declare const LifecycleFlowTimelineItemSchema: v.ObjectSchema<{
|
|
523
523
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
524
524
|
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
525
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
525
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "completed" | "current">]>;
|
|
526
526
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
527
527
|
}, undefined>;
|
|
528
528
|
declare const LifecycleFlowSummaryProgressSchema: v.ObjectSchema<{
|
|
@@ -622,7 +622,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
622
622
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
623
623
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
624
624
|
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
625
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
625
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "completed" | "current">]>;
|
|
626
626
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
627
627
|
}, undefined>, undefined>, readonly []>;
|
|
628
628
|
readonly estimatedCompletionUnixMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -692,7 +692,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
692
692
|
progressTimeline: {
|
|
693
693
|
sequence: number;
|
|
694
694
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
695
|
-
status: "unspecified" | "
|
|
695
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
696
696
|
expectedDurationMs: number;
|
|
697
697
|
}[];
|
|
698
698
|
estimatedCompletionUnixMs: number;
|
|
@@ -756,7 +756,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
|
|
|
756
756
|
progressTimeline: {
|
|
757
757
|
sequence: number;
|
|
758
758
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
759
|
-
status: "unspecified" | "
|
|
759
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
760
760
|
expectedDurationMs: number;
|
|
761
761
|
}[];
|
|
762
762
|
estimatedCompletionUnixMs: number;
|
|
@@ -852,7 +852,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
852
852
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
853
853
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
854
854
|
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
855
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
855
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "completed" | "current">]>;
|
|
856
856
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
857
857
|
}, undefined>, undefined>, readonly []>;
|
|
858
858
|
readonly estimatedCompletionUnixMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -922,7 +922,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
922
922
|
progressTimeline: {
|
|
923
923
|
sequence: number;
|
|
924
924
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
925
|
-
status: "unspecified" | "
|
|
925
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
926
926
|
expectedDurationMs: number;
|
|
927
927
|
}[];
|
|
928
928
|
estimatedCompletionUnixMs: number;
|
|
@@ -986,7 +986,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
|
|
|
986
986
|
progressTimeline: {
|
|
987
987
|
sequence: number;
|
|
988
988
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
989
|
-
status: "unspecified" | "
|
|
989
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
990
990
|
expectedDurationMs: number;
|
|
991
991
|
}[];
|
|
992
992
|
estimatedCompletionUnixMs: number;
|
|
@@ -1364,7 +1364,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1364
1364
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1365
1365
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1366
1366
|
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1367
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
1367
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "completed" | "current">]>;
|
|
1368
1368
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1369
1369
|
}, undefined>, undefined>, readonly []>;
|
|
1370
1370
|
readonly estimatedCompletionUnixMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -1434,7 +1434,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1434
1434
|
progressTimeline: {
|
|
1435
1435
|
sequence: number;
|
|
1436
1436
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1437
|
-
status: "unspecified" | "
|
|
1437
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
1438
1438
|
expectedDurationMs: number;
|
|
1439
1439
|
}[];
|
|
1440
1440
|
estimatedCompletionUnixMs: number;
|
|
@@ -1498,7 +1498,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
|
|
|
1498
1498
|
progressTimeline: {
|
|
1499
1499
|
sequence: number;
|
|
1500
1500
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1501
|
-
status: "unspecified" | "
|
|
1501
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
1502
1502
|
expectedDurationMs: number;
|
|
1503
1503
|
}[];
|
|
1504
1504
|
estimatedCompletionUnixMs: number;
|
|
@@ -1597,7 +1597,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1597
1597
|
readonly progressTimeline: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1598
1598
|
readonly sequence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1599
1599
|
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement">]>;
|
|
1600
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
1600
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "planned" | "completed" | "current">]>;
|
|
1601
1601
|
readonly expectedDurationMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
1602
1602
|
}, undefined>, undefined>, readonly []>;
|
|
1603
1603
|
readonly estimatedCompletionUnixMs: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
|
|
@@ -1667,7 +1667,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1667
1667
|
progressTimeline: {
|
|
1668
1668
|
sequence: number;
|
|
1669
1669
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1670
|
-
status: "unspecified" | "
|
|
1670
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
1671
1671
|
expectedDurationMs: number;
|
|
1672
1672
|
}[];
|
|
1673
1673
|
estimatedCompletionUnixMs: number;
|
|
@@ -1731,7 +1731,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
|
|
|
1731
1731
|
progressTimeline: {
|
|
1732
1732
|
sequence: number;
|
|
1733
1733
|
step: "validation" | "unspecified" | "failed" | "execution" | "source" | "transfer" | "dropped" | "refunded" | "request" | "bridge_fulfillment" | "fulfilling" | "settlement";
|
|
1734
|
-
status: "unspecified" | "
|
|
1734
|
+
status: "unspecified" | "planned" | "completed" | "current";
|
|
1735
1735
|
expectedDurationMs: number;
|
|
1736
1736
|
}[];
|
|
1737
1737
|
estimatedCompletionUnixMs: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import "../../gen/chain/lifecycle/v1/types_pb.js";
|
|
2
|
+
import "../../gen/chain/lifecycle/v1/lifecycle_read_pb.js";
|
|
1
3
|
import { idToBigInt } from "../../utils/base58-id.js";
|
|
2
4
|
import { PublicIdSchema } from "../../shared/schemas.js";
|
|
3
5
|
import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
|
|
4
6
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
5
7
|
import { fromU128 } from "../../utils/u128.js";
|
|
6
|
-
import "../../gen/chain/lifecycle/v1/types_pb.js";
|
|
7
|
-
import "../../gen/chain/lifecycle/v1/lifecycle_read_pb.js";
|
|
8
8
|
import { LIFECYCLE_FLOW_KIND_VALUES, LIFECYCLE_FLOW_PARTICIPATION_VALUES, LIFECYCLE_FLOW_STATE_VALUES, LIFECYCLE_LIST_ORDER_BY_VALUES, LIFECYCLE_LIST_SCOPE_VALUES, LIFECYCLE_SORT_VALUES, LIFECYCLE_TX_LOOKUP_KIND_VALUES, LifecycleFlowDomainCodec, LifecycleFlowKindCodec, LifecycleFlowParticipationCodec, LifecycleFlowStateCodec, LifecycleFlowStepActivityKindCodec, LifecycleFlowStepCodec, LifecycleFlowTimelineStatusCodec, LifecycleListOrderByCodec, LifecycleListScopeCodec, LifecycleRequestFeeStatusCodec, LifecycleSortCodec, LifecycleSourceCodec, LifecycleTxLookupKindCodec, lifecycleReasonFromCode } from "./lifecycle.codecs.js";
|
|
9
9
|
import * as v from "valibot";
|
|
10
10
|
//#region src/services/lifecycle/lifecycle.schemas.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { isDev } from "../../utils/is-dev.js";
|
|
2
|
+
import { MarketDataService as MarketDataService$1, MarketTradeBatchSchema } from "../../gen/marketdata/v1/marketdata_pb.js";
|
|
1
3
|
import { parse } from "../../shared/validation.js";
|
|
2
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
5
|
import { deliverBatch } from "../../shared/subscription-errors.js";
|
|
4
6
|
import { SymbolIdInputSchema } from "../shared.js";
|
|
5
|
-
import { MarketDataService as MarketDataService$1, MarketTradeBatchSchema } from "../../gen/marketdata/v1/marketdata_pb.js";
|
|
6
7
|
import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
|
|
7
|
-
import { isDev } from "../../utils/is-dev.js";
|
|
8
8
|
import { GetMarketTradesInputSchema, SpotConfigSchema, TradeBackfillSchema, formatMarketTrade } from "./market-data.schemas.js";
|
|
9
9
|
import { createClient } from "@connectrpc/connect";
|
|
10
10
|
//#region src/services/market-data/market-data.ts
|
|
@@ -61,7 +61,8 @@ const TradeBackfillSchema = v.object({
|
|
|
61
61
|
/** Integer wire scales are protocol-bounded to 0..18 decimal places. */
|
|
62
62
|
const WireScaleSchema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(18));
|
|
63
63
|
const OptionalDecimalLimitSchema = v.optional(v.pipe(v.string(), v.regex(/^\d+(\.\d+)?$/)));
|
|
64
|
-
const
|
|
64
|
+
const Uint32Schema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX));
|
|
65
|
+
const OpenOrdersLimitSchema = v.optional(Uint32Schema, 0);
|
|
65
66
|
const AssetConfigSchema = v.pipe(v.object({
|
|
66
67
|
/**
|
|
67
68
|
* Asset identifier/symbol, e.g. 'USDT', 'BTC'.
|
|
@@ -170,6 +171,20 @@ const PairConfigSchema = v.pipe(v.object({
|
|
|
170
171
|
*/
|
|
171
172
|
maxOpenOrdersPerPair: OpenOrdersLimitSchema,
|
|
172
173
|
/**
|
|
174
|
+
* How far from the reference price (the last trade, or the index when they diverge
|
|
175
|
+
* by more than the band) an order may be priced or trade, in basis points. A buy limit
|
|
176
|
+
* above `reference × (1 + upperBps / 10000)` rounded down to the tick, or a sell limit
|
|
177
|
+
* below `reference × (1 − lowerBps / 10000)` rounded up, is rejected with
|
|
178
|
+
* `PRICE_BAND_VIOLATION`; a market order trades up to the limit and its remainder is
|
|
179
|
+
* canceled with `price_band`. The reference stays fixed for `referenceWindowMs` (zero
|
|
180
|
+
* moves it with every order). Absent when the pair has no band.
|
|
181
|
+
*/
|
|
182
|
+
priceBand: v.optional(v.object({
|
|
183
|
+
lowerBps: Uint32Schema,
|
|
184
|
+
upperBps: Uint32Schema,
|
|
185
|
+
referenceWindowMs: Uint32Schema
|
|
186
|
+
})),
|
|
187
|
+
/**
|
|
173
188
|
* Controls whether trading fee can be deducted from what you receive when buying.
|
|
174
189
|
* Example
|
|
175
190
|
* - You buy 1 ETH, fee is 0.1%
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market-data.schemas.js","names":[],"sources":["../../../src/services/market-data/market-data.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { SideSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n PAIR_STATUSES,\n type AssetConfig,\n type PairConfig,\n type PairMarketDataConfig,\n type PairStatus,\n type SpotConfig,\n} from \"../../shared/catalog-config.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { timestampToMs, tsNsToTimestamp } from \"../../utils/timestamp.js\";\nimport { optionalUint64DecimalFilterSchema } from \"../../shared/schemas.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { PairStatusCodec, SideFilterCodec } from \"./market-data.codecs.js\";\n\nexport type { AssetConfig, PairConfig, PairMarketDataConfig, PairStatus, SpotConfig };\nexport { PAIR_STATUSES };\n\nconst MarketTradeFieldsSchema = v.object({\n symbolId: v.number(),\n matchId: v.bigint(),\n isBuy: v.boolean(),\n priceTicks: v.bigint(),\n qtyScaled: v.bigint(),\n tsNs: v.optional(v.bigint(), 0n),\n});\n\n/** Formats a market trade; protobuf-decoded trades can be passed directly, they need no re-validation. */\nexport function formatMarketTrade(\n scales: SdkScales,\n t: v.InferOutput<typeof MarketTradeFieldsSchema>,\n) {\n const sideLabel: v.InferOutput<typeof SideSchema> = t.isBuy ? \"buy\" : \"sell\";\n return {\n symbolId: t.symbolId,\n matchId: t.matchId.toString(),\n isBuy: t.isBuy,\n sideLabel,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n price: scaledToDecimalOutput(t.priceTicks, scales.price()),\n tsNs: t.tsNs.toString(),\n tsMs: tsNsToMs(t.tsNs),\n };\n}\n\nexport function createMarketTradeSchema(scales: SdkScales) {\n return v.pipe(\n MarketTradeFieldsSchema,\n v.transform((t) => formatMarketTrade(scales, t)),\n );\n}\n\nexport type MarketTrade = v.InferOutput<ReturnType<typeof createMarketTradeSchema>>;\n\nexport const GetMarketTradesInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n side: v.optional(SideSchema),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1_000))),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n afterTradeId: optionalUint64DecimalFilterSchema(\"afterTradeId\"),\n }),\n v.check(\n (input) =>\n input.afterTradeId === undefined ||\n (input.side === undefined &&\n input.startTsNs === undefined &&\n input.endTsNs === undefined &&\n input.pageToken === \"\"),\n \"afterTradeId cannot be combined with side, startTsNs, endTsNs or pageToken\",\n ),\n v.transform((input) => ({\n symbolId: input.symbolId,\n side: input.side ? SideFilterCodec.inputToProto[input.side] : undefined,\n startTime: tsNsToTimestamp(input.startTsNs),\n endTime: tsNsToTimestamp(input.endTsNs),\n limit: input.limit,\n pageToken: input.pageToken,\n afterTradeId: input.afterTradeId,\n })),\n);\n\n/** Cursor fields of a gap-free `afterTradeId` backfill page. */\nexport const TradeBackfillSchema = v.object({\n completeThroughTradeId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n nextAfterTradeId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n epochEnds: v.array(\n v.pipe(\n v.object({ epoch: v.bigint(), lastTradeId: v.bigint() }),\n v.transform(({ epoch, lastTradeId }) => ({\n epoch: epoch.toString(),\n lastTradeId: lastTradeId.toString(),\n })),\n ),\n ),\n});\n\nexport type TradeBackfill = v.InferOutput<typeof TradeBackfillSchema>;\n\nexport function createGetMarketTradesInputSchema() {\n return GetMarketTradesInputSchema;\n}\n\nexport type GetMarketTradesInput = v.InferInput<\n ReturnType<typeof createGetMarketTradesInputSchema>\n>;\nexport type GetMarketTradesRequest = v.InferOutput<\n ReturnType<typeof createGetMarketTradesInputSchema>\n>;\n\n/** Integer wire scales are protocol-bounded to 0..18 decimal places. */\nconst WireScaleSchema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(18));\nconst OptionalDecimalLimitSchema = v.optional(v.pipe(v.string(), v.regex(/^\\d+(\\.\\d+)?$/)));\nconst OpenOrdersLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX)),\n 0,\n);\n\nexport const AssetConfigSchema = v.pipe(\n v.object({\n /**\n * Asset identifier/symbol, e.g. 'USDT', 'BTC'.\n */\n asset: v.string(),\n /**\n * Internal ledger identifier for settlement systems.\n */\n ledgerId: v.number(),\n /**\n * The friendly display name for the asset (e.g. 'Bitcoin').\n */\n name: v.string(),\n /**\n * UI-only display precision for asset amounts/balances.\n */\n quantityDisplayDecimals: v.number(),\n /**\n * Fixed integer scaling for quantities/amounts in this asset (0..18).\n */\n quantityScale: v.number(),\n /**\n * Integer scale for public candle and market-overview base volume (0..18).\n */\n marketDataVolumeScale: v.optional(WireScaleSchema, 0),\n /**\n * Whether the asset counts toward total equity; absent means unknown, never false.\n */\n includedInEquity: v.optional(v.boolean()),\n }),\n v.transform((a) => ({\n symbol: a.asset,\n ledgerId: a.ledgerId,\n name: a.name,\n quantityDisplayDecimals: a.quantityDisplayDecimals,\n quantityScale: a.quantityScale,\n marketDataVolumeScale: a.marketDataVolumeScale,\n ...(a.includedInEquity === undefined ? {} : { includedInEquity: a.includedInEquity }),\n })),\n);\n\nexport const PairMarketDataConfigSchema = v.optional(\n v.object({\n /**\n * Available price grouping sizes for the orderbook in quote units.\n * Allows viewing orders bucketed by larger increments (e.g., [0.01, 0.1, 1, 10]).\n */\n orderbookPriceBuckets: v.array(v.number()),\n }),\n {\n orderbookPriceBuckets: [] as number[],\n },\n);\n\nfunction bpsToPercent(bps: number): number {\n return bps / 100;\n}\n\nexport const PairConfigSchema = v.pipe(\n v.object({\n /**\n * Internal engine symbol id for the pair.\n */\n symbolId: v.number(),\n /**\n * Pair symbol string, e.g. 'BTC-USDT'\n */\n symbol: v.string(),\n /**\n * Base asset symbol, e.g. 'BTC'\n */\n baseAsset: v.string(),\n /**\n * Quote asset symbol, e.g. 'USDT'\n */\n quoteAsset: v.string(),\n /**\n * (e.g., \"0.01\") - The smallest price increment allowed. If tick size is 0.01, you can price at $100.00, $100.01, $100.02... but NOT $100.005.\n */\n tickSize: v.string(),\n /**\n * (e.g., \"0.0001\") - The smallest quantity increment allowed. If step size is 0.0001, you can order 100.0000, 100.0001, 100.0002... but NOT 100.00005.\n */\n stepSize: v.string(),\n /**\n * (e.g., \"1\") - Minimum order value in quote currency. If it's \"1\" and quote is USD, your order must be worth at least $1. So you can't buy $0.50 worth of something.\n */\n minNotionalQuote: v.string(),\n /**\n * Minimum quantity you can order in base currency terms. If it's \"0.001\" for BTC, smallest order is 0.001 BTC.\n */\n minQtyBase: v.string(),\n /**\n * Largest quantity of one limit order in base units. A replace is checked on its\n * new total less the filled quantity. Absent when the pair has no maximum.\n */\n maxLimitQtyBase: OptionalDecimalLimitSchema,\n /**\n * Largest quantity of one market order in base units, after converting a\n * quote-sized order to base. Absent when the pair has no maximum.\n */\n maxMarketQtyBase: OptionalDecimalLimitSchema,\n /**\n * Largest notional of one order in quote units: quantity times limit price, or\n * times protection price for a market order. Absent when the pair has no maximum.\n */\n maxOrderNotionalQuote: OptionalDecimalLimitSchema,\n /**\n * Largest notional of one market order in quote units, compared exactly with no\n * rounding. A buy is valued at its protection price and a sell at its reference\n * price (the touch or the client's reference price), before slippage. An order\n * above it is rejected with `MAX_NOTIONAL`. Absent when the pair has no maximum.\n */\n maxMarketNotionalQuote: OptionalDecimalLimitSchema,\n /**\n * Default resting-order limit (GTC and GTD) for a typical account on this pair.\n * An account may have a lower limit of its own.\n */\n maxOpenOrdersPerPair: OpenOrdersLimitSchema,\n\n /**\n * Controls whether trading fee can be deducted from what you receive when buying.\n * Example\n * - You buy 1 ETH, fee is 0.1%\n * - if `true`, you receive 0.999 ETH (fee taken from ETH you're getting)\n * - if `false`, you receive 1 ETH, but you pay the fee separately in the quote currency (e.g., extra USDT)\n */\n allowBuyFeeFromBase: v.boolean(),\n /**\n * Default market slippage for buy orders in basis points from proto.\n */\n defaultMarketSlippageBpsBuy: v.optional(v.number(), 0),\n /**\n * Default market slippage for sell orders in basis points from proto.\n */\n defaultMarketSlippageBpsSell: v.optional(v.number(), 0),\n /**\n * Maximum server/client reference-price drift in basis points from proto.\n */\n maxClientRefDriftBps: v.optional(v.number(), 0),\n\n /**\n * Market-data configuration for this pair (orderbook bucket sizes, depths).\n */\n marketdata: v.optional(PairMarketDataConfigSchema),\n /**\n * Base asset quantity scale copied from AssetConfig.quantityScale.\n */\n baseQuantityScale: v.number(),\n /**\n * Quote asset quantity scale copied from AssetConfig.quantityScale.\n */\n quoteQuantityScale: v.number(),\n /**\n * Integer scale for composite reference prices in candle responses (0..18).\n * Primary market and execution prices use the fixed scale 9.\n */\n referencePriceScale: v.optional(WireScaleSchema, 0),\n /**\n * Optional scheduled listing timestamp (UTC).\n */\n listingAt: v.pipe(v.optional(v.unknown()), v.transform(timestampToMs)),\n /**\n * Optional scheduled delisting timestamp (UTC).\n */\n delistingAt: v.pipe(v.optional(v.unknown()), v.transform(timestampToMs)),\n /**\n * Operational status of the pair.\n */\n status: v.pipe(\n v.number(),\n v.transform(\n (status): PairStatus =>\n PairStatusCodec.protoToOutput[\n status as keyof typeof PairStatusCodec.protoToOutput\n ] ?? \"unknown\",\n ),\n ),\n }),\n v.transform(\n ({\n defaultMarketSlippageBpsBuy,\n defaultMarketSlippageBpsSell,\n maxClientRefDriftBps,\n ...pair\n }) => ({\n ...pair,\n defaultMarketSlippagePctBuy: bpsToPercent(defaultMarketSlippageBpsBuy),\n defaultMarketSlippagePctSell: bpsToPercent(defaultMarketSlippageBpsSell),\n maxClientRefDriftPct: bpsToPercent(maxClientRefDriftBps),\n }),\n ),\n);\n\nexport const SpotConfigSchema = v.object({\n assets: v.array(AssetConfigSchema),\n pairs: v.array(PairConfigSchema),\n /**\n * Default resting-order limit (GTC and GTD) for a typical account across all pairs.\n * An account may have a lower limit of its own.\n */\n maxOpenOrdersTotal: OpenOrdersLimitSchema,\n tsSec: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v) * 1000),\n ),\n});\n"],"mappings":";;;;;;;;;AAoBgC,EAAE,OAAO;CACrC,UAAU,EAAE,OAAO;CACnB,SAAS,EAAE,OAAO;CAClB,OAAO,EAAE,QAAQ;CACjB,YAAY,EAAE,OAAO;CACrB,WAAW,EAAE,OAAO;CACpB,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AACnC,CAAC;;AAGD,SAAgB,kBACZ,QACA,GACF;CACE,MAAM,YAA8C,EAAE,QAAQ,QAAQ;CACtE,OAAO;EACH,UAAU,EAAE;EACZ,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ACJ;AAEA,MAAa,mBAAmB,EAAE,OAAO;CACrC,QAAQ,EAAE,MAAM,iBAAiB;CACjC,OAAO,EAAE,MAAM,gBAAgB;;;;;CAK/B,oBAAoB;CACpB,OAAO,EAAE,KACL,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,OAAO,CAAC,IAAI,GAAI,CACvC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"market-data.schemas.js","names":[],"sources":["../../../src/services/market-data/market-data.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { SideSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n PAIR_STATUSES,\n type AssetConfig,\n type PairConfig,\n type PairMarketDataConfig,\n type PairStatus,\n type SpotConfig,\n} from \"../../shared/catalog-config.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport { timestampToMs, tsNsToTimestamp } from \"../../utils/timestamp.js\";\nimport { optionalUint64DecimalFilterSchema } from \"../../shared/schemas.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { PairStatusCodec, SideFilterCodec } from \"./market-data.codecs.js\";\n\nexport type { AssetConfig, PairConfig, PairMarketDataConfig, PairStatus, SpotConfig };\nexport { PAIR_STATUSES };\n\nconst MarketTradeFieldsSchema = v.object({\n symbolId: v.number(),\n matchId: v.bigint(),\n isBuy: v.boolean(),\n priceTicks: v.bigint(),\n qtyScaled: v.bigint(),\n tsNs: v.optional(v.bigint(), 0n),\n});\n\n/** Formats a market trade; protobuf-decoded trades can be passed directly, they need no re-validation. */\nexport function formatMarketTrade(\n scales: SdkScales,\n t: v.InferOutput<typeof MarketTradeFieldsSchema>,\n) {\n const sideLabel: v.InferOutput<typeof SideSchema> = t.isBuy ? \"buy\" : \"sell\";\n return {\n symbolId: t.symbolId,\n matchId: t.matchId.toString(),\n isBuy: t.isBuy,\n sideLabel,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n price: scaledToDecimalOutput(t.priceTicks, scales.price()),\n tsNs: t.tsNs.toString(),\n tsMs: tsNsToMs(t.tsNs),\n };\n}\n\nexport function createMarketTradeSchema(scales: SdkScales) {\n return v.pipe(\n MarketTradeFieldsSchema,\n v.transform((t) => formatMarketTrade(scales, t)),\n );\n}\n\nexport type MarketTrade = v.InferOutput<ReturnType<typeof createMarketTradeSchema>>;\n\nexport const GetMarketTradesInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n side: v.optional(SideSchema),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1_000))),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n afterTradeId: optionalUint64DecimalFilterSchema(\"afterTradeId\"),\n }),\n v.check(\n (input) =>\n input.afterTradeId === undefined ||\n (input.side === undefined &&\n input.startTsNs === undefined &&\n input.endTsNs === undefined &&\n input.pageToken === \"\"),\n \"afterTradeId cannot be combined with side, startTsNs, endTsNs or pageToken\",\n ),\n v.transform((input) => ({\n symbolId: input.symbolId,\n side: input.side ? SideFilterCodec.inputToProto[input.side] : undefined,\n startTime: tsNsToTimestamp(input.startTsNs),\n endTime: tsNsToTimestamp(input.endTsNs),\n limit: input.limit,\n pageToken: input.pageToken,\n afterTradeId: input.afterTradeId,\n })),\n);\n\n/** Cursor fields of a gap-free `afterTradeId` backfill page. */\nexport const TradeBackfillSchema = v.object({\n completeThroughTradeId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n nextAfterTradeId: v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n ),\n epochEnds: v.array(\n v.pipe(\n v.object({ epoch: v.bigint(), lastTradeId: v.bigint() }),\n v.transform(({ epoch, lastTradeId }) => ({\n epoch: epoch.toString(),\n lastTradeId: lastTradeId.toString(),\n })),\n ),\n ),\n});\n\nexport type TradeBackfill = v.InferOutput<typeof TradeBackfillSchema>;\n\nexport function createGetMarketTradesInputSchema() {\n return GetMarketTradesInputSchema;\n}\n\nexport type GetMarketTradesInput = v.InferInput<\n ReturnType<typeof createGetMarketTradesInputSchema>\n>;\nexport type GetMarketTradesRequest = v.InferOutput<\n ReturnType<typeof createGetMarketTradesInputSchema>\n>;\n\n/** Integer wire scales are protocol-bounded to 0..18 decimal places. */\nconst WireScaleSchema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(18));\nconst OptionalDecimalLimitSchema = v.optional(v.pipe(v.string(), v.regex(/^\\d+(\\.\\d+)?$/)));\nconst Uint32Schema = v.pipe(\n v.number(),\n v.integer(),\n v.minValue(0),\n v.maxValue(PROTOBUF_UINT32_MAX),\n);\nconst OpenOrdersLimitSchema = v.optional(Uint32Schema, 0);\n\nexport const AssetConfigSchema = v.pipe(\n v.object({\n /**\n * Asset identifier/symbol, e.g. 'USDT', 'BTC'.\n */\n asset: v.string(),\n /**\n * Internal ledger identifier for settlement systems.\n */\n ledgerId: v.number(),\n /**\n * The friendly display name for the asset (e.g. 'Bitcoin').\n */\n name: v.string(),\n /**\n * UI-only display precision for asset amounts/balances.\n */\n quantityDisplayDecimals: v.number(),\n /**\n * Fixed integer scaling for quantities/amounts in this asset (0..18).\n */\n quantityScale: v.number(),\n /**\n * Integer scale for public candle and market-overview base volume (0..18).\n */\n marketDataVolumeScale: v.optional(WireScaleSchema, 0),\n /**\n * Whether the asset counts toward total equity; absent means unknown, never false.\n */\n includedInEquity: v.optional(v.boolean()),\n }),\n v.transform((a) => ({\n symbol: a.asset,\n ledgerId: a.ledgerId,\n name: a.name,\n quantityDisplayDecimals: a.quantityDisplayDecimals,\n quantityScale: a.quantityScale,\n marketDataVolumeScale: a.marketDataVolumeScale,\n ...(a.includedInEquity === undefined ? {} : { includedInEquity: a.includedInEquity }),\n })),\n);\n\nexport const PairMarketDataConfigSchema = v.optional(\n v.object({\n /**\n * Available price grouping sizes for the orderbook in quote units.\n * Allows viewing orders bucketed by larger increments (e.g., [0.01, 0.1, 1, 10]).\n */\n orderbookPriceBuckets: v.array(v.number()),\n }),\n {\n orderbookPriceBuckets: [] as number[],\n },\n);\n\nfunction bpsToPercent(bps: number): number {\n return bps / 100;\n}\n\nexport const PairConfigSchema = v.pipe(\n v.object({\n /**\n * Internal engine symbol id for the pair.\n */\n symbolId: v.number(),\n /**\n * Pair symbol string, e.g. 'BTC-USDT'\n */\n symbol: v.string(),\n /**\n * Base asset symbol, e.g. 'BTC'\n */\n baseAsset: v.string(),\n /**\n * Quote asset symbol, e.g. 'USDT'\n */\n quoteAsset: v.string(),\n /**\n * (e.g., \"0.01\") - The smallest price increment allowed. If tick size is 0.01, you can price at $100.00, $100.01, $100.02... but NOT $100.005.\n */\n tickSize: v.string(),\n /**\n * (e.g., \"0.0001\") - The smallest quantity increment allowed. If step size is 0.0001, you can order 100.0000, 100.0001, 100.0002... but NOT 100.00005.\n */\n stepSize: v.string(),\n /**\n * (e.g., \"1\") - Minimum order value in quote currency. If it's \"1\" and quote is USD, your order must be worth at least $1. So you can't buy $0.50 worth of something.\n */\n minNotionalQuote: v.string(),\n /**\n * Minimum quantity you can order in base currency terms. If it's \"0.001\" for BTC, smallest order is 0.001 BTC.\n */\n minQtyBase: v.string(),\n /**\n * Largest quantity of one limit order in base units. A replace is checked on its\n * new total less the filled quantity. Absent when the pair has no maximum.\n */\n maxLimitQtyBase: OptionalDecimalLimitSchema,\n /**\n * Largest quantity of one market order in base units, after converting a\n * quote-sized order to base. Absent when the pair has no maximum.\n */\n maxMarketQtyBase: OptionalDecimalLimitSchema,\n /**\n * Largest notional of one order in quote units: quantity times limit price, or\n * times protection price for a market order. Absent when the pair has no maximum.\n */\n maxOrderNotionalQuote: OptionalDecimalLimitSchema,\n /**\n * Largest notional of one market order in quote units, compared exactly with no\n * rounding. A buy is valued at its protection price and a sell at its reference\n * price (the touch or the client's reference price), before slippage. An order\n * above it is rejected with `MAX_NOTIONAL`. Absent when the pair has no maximum.\n */\n maxMarketNotionalQuote: OptionalDecimalLimitSchema,\n /**\n * Default resting-order limit (GTC and GTD) for a typical account on this pair.\n * An account may have a lower limit of its own.\n */\n maxOpenOrdersPerPair: OpenOrdersLimitSchema,\n /**\n * How far from the reference price (the last trade, or the index when they diverge\n * by more than the band) an order may be priced or trade, in basis points. A buy limit\n * above `reference × (1 + upperBps / 10000)` rounded down to the tick, or a sell limit\n * below `reference × (1 − lowerBps / 10000)` rounded up, is rejected with\n * `PRICE_BAND_VIOLATION`; a market order trades up to the limit and its remainder is\n * canceled with `price_band`. The reference stays fixed for `referenceWindowMs` (zero\n * moves it with every order). Absent when the pair has no band.\n */\n priceBand: v.optional(\n v.object({\n lowerBps: Uint32Schema,\n upperBps: Uint32Schema,\n referenceWindowMs: Uint32Schema,\n }),\n ),\n\n /**\n * Controls whether trading fee can be deducted from what you receive when buying.\n * Example\n * - You buy 1 ETH, fee is 0.1%\n * - if `true`, you receive 0.999 ETH (fee taken from ETH you're getting)\n * - if `false`, you receive 1 ETH, but you pay the fee separately in the quote currency (e.g., extra USDT)\n */\n allowBuyFeeFromBase: v.boolean(),\n /**\n * Default market slippage for buy orders in basis points from proto.\n */\n defaultMarketSlippageBpsBuy: v.optional(v.number(), 0),\n /**\n * Default market slippage for sell orders in basis points from proto.\n */\n defaultMarketSlippageBpsSell: v.optional(v.number(), 0),\n /**\n * Maximum server/client reference-price drift in basis points from proto.\n */\n maxClientRefDriftBps: v.optional(v.number(), 0),\n\n /**\n * Market-data configuration for this pair (orderbook bucket sizes, depths).\n */\n marketdata: v.optional(PairMarketDataConfigSchema),\n /**\n * Base asset quantity scale copied from AssetConfig.quantityScale.\n */\n baseQuantityScale: v.number(),\n /**\n * Quote asset quantity scale copied from AssetConfig.quantityScale.\n */\n quoteQuantityScale: v.number(),\n /**\n * Integer scale for composite reference prices in candle responses (0..18).\n * Primary market and execution prices use the fixed scale 9.\n */\n referencePriceScale: v.optional(WireScaleSchema, 0),\n /**\n * Optional scheduled listing timestamp (UTC).\n */\n listingAt: v.pipe(v.optional(v.unknown()), v.transform(timestampToMs)),\n /**\n * Optional scheduled delisting timestamp (UTC).\n */\n delistingAt: v.pipe(v.optional(v.unknown()), v.transform(timestampToMs)),\n /**\n * Operational status of the pair.\n */\n status: v.pipe(\n v.number(),\n v.transform(\n (status): PairStatus =>\n PairStatusCodec.protoToOutput[\n status as keyof typeof PairStatusCodec.protoToOutput\n ] ?? \"unknown\",\n ),\n ),\n }),\n v.transform(\n ({\n defaultMarketSlippageBpsBuy,\n defaultMarketSlippageBpsSell,\n maxClientRefDriftBps,\n ...pair\n }) => ({\n ...pair,\n defaultMarketSlippagePctBuy: bpsToPercent(defaultMarketSlippageBpsBuy),\n defaultMarketSlippagePctSell: bpsToPercent(defaultMarketSlippageBpsSell),\n maxClientRefDriftPct: bpsToPercent(maxClientRefDriftBps),\n }),\n ),\n);\n\nexport const SpotConfigSchema = v.object({\n assets: v.array(AssetConfigSchema),\n pairs: v.array(PairConfigSchema),\n /**\n * Default resting-order limit (GTC and GTD) for a typical account across all pairs.\n * An account may have a lower limit of its own.\n */\n maxOpenOrdersTotal: OpenOrdersLimitSchema,\n tsSec: v.pipe(\n v.bigint(),\n v.transform((v) => Number(v) * 1000),\n ),\n});\n"],"mappings":";;;;;;;;;AAoBgC,EAAE,OAAO;CACrC,UAAU,EAAE,OAAO;CACnB,SAAS,EAAE,OAAO;CAClB,OAAO,EAAE,QAAQ;CACjB,YAAY,EAAE,OAAO;CACrB,WAAW,EAAE,OAAO;CACpB,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AACnC,CAAC;;AAGD,SAAgB,kBACZ,QACA,GACF;CACE,MAAM,YAA8C,EAAE,QAAQ,QAAQ;CACtE,OAAO;EACH,UAAU,EAAE;EACZ,SAAS,EAAE,QAAQ,SAAS;EAC5B,OAAO,EAAE;EACT;EACA,KAAK,sBAAsB,EAAE,WAAW,OAAO,QAAQ,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;AAC3D,EACJ,CACJ;AAEA,MAAa,mBAAmB,EAAE,OAAO;CACrC,QAAQ,EAAE,MAAM,iBAAiB;CACjC,OAAO,EAAE,MAAM,gBAAgB;;;;;CAK/B,oBAAoB;CACpB,OAAO,EAAE,KACL,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,OAAO,CAAC,IAAI,GAAI,CACvC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { isDev } from "../../utils/is-dev.js";
|
|
2
|
+
import { MarketOverviewBatchSchema, MarketOverviewService as MarketOverviewService$1 } from "../../gen/marketoverview/v1/marketoverview_pb.js";
|
|
1
3
|
import { parse } from "../../shared/validation.js";
|
|
2
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
5
|
import { CatalogLookupError } from "../../catalogs/types.js";
|
|
4
|
-
import { isDev } from "../../utils/is-dev.js";
|
|
5
|
-
import { MarketOverviewBatchSchema, MarketOverviewService as MarketOverviewService$1 } from "../../gen/marketoverview/v1/marketoverview_pb.js";
|
|
6
6
|
import { snapshotThenStream } from "../../realtime/snapshot-then-stream.js";
|
|
7
7
|
import { CurrencyConversionConfigSchema, CurrencyConversionRatesSchema, ListMarketOverviewInputSchema, SpotVolumeHistoryInputSchema, SpotVolumeHistoryResponseSchema, createMarketOverviewSchema } from "./market-overview.schemas.js";
|
|
8
8
|
import { createClient } from "@connectrpc/connect";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import "../../gen/marketoverview/v1/marketoverview_pb.js";
|
|
1
2
|
import { tsNsToMs } from "../../utils/time.js";
|
|
2
3
|
import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
|
|
3
4
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
4
5
|
import { PositiveUint32InputSchema, SymbolIdInputSchema } from "../shared.js";
|
|
5
|
-
import "../../gen/marketoverview/v1/marketoverview_pb.js";
|
|
6
6
|
import { MARKET_OVERVIEW_ORDER_BY_VALUES, MARKET_OVERVIEW_SORT_VALUES, MarketOverviewOrderByCodec, MarketOverviewSortCodec, SPARKLINE_INTERVAL_VALUES, SparklineIntervalCodec } from "./market-overview.codecs.js";
|
|
7
7
|
import * as v from "valibot";
|
|
8
8
|
//#region src/services/market-overview/market-overview.schemas.ts
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../../gen/notifications/v1/notifications_pb.js";
|
|
2
|
+
//#region src/services/notifications/notifications.codecs.d.ts
|
|
3
|
+
declare const NOTIFICATION_TYPE_VALUES: readonly ["price_alert", "telegram_approval"];
|
|
4
|
+
/** What a notification reports; each type belongs to one category. */
|
|
5
|
+
type NotificationType = (typeof NOTIFICATION_TYPE_VALUES)[number];
|
|
6
|
+
declare const NOTIFICATION_CATEGORY_VALUES: readonly ["alerts", "security"];
|
|
7
|
+
/** `alerts` holds alerts the caller set; `security` holds account security events. */
|
|
8
|
+
type NotificationCategory = (typeof NOTIFICATION_CATEGORY_VALUES)[number];
|
|
9
|
+
declare const NOTIFICATION_READ_STATE_VALUES: readonly ["unread", "read"];
|
|
10
|
+
type NotificationReadState = (typeof NOTIFICATION_READ_STATE_VALUES)[number];
|
|
11
|
+
declare const TELEGRAM_APPROVAL_ACTION_VALUES: readonly ["place_order", "place_orders", "modify_orders", "cancel_order", "cancel_all_orders", "modify_trigger", "pause_trigger", "resume_trigger", "swap"];
|
|
12
|
+
/** What an approval from the linked Telegram account approved. */
|
|
13
|
+
type TelegramApprovalAction = (typeof TELEGRAM_APPROVAL_ACTION_VALUES)[number];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { NOTIFICATION_CATEGORY_VALUES, NOTIFICATION_READ_STATE_VALUES, NOTIFICATION_TYPE_VALUES, NotificationCategory, NotificationReadState, NotificationType, TELEGRAM_APPROVAL_ACTION_VALUES, TelegramApprovalAction };
|
|
16
|
+
//# sourceMappingURL=notifications.codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.codecs.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.codecs.ts"],"mappings":";;cAGa;;KAED,2BAA2B;cAE1B;;KAED,+BAA+B;cAE9B;KACD,gCAAgC;cAE/B;;KAYD,iCAAiC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "../../gen/notifications/v1/notifications_pb.js";
|
|
2
|
+
//#region src/services/notifications/notifications.codecs.ts
|
|
3
|
+
const NOTIFICATION_CATEGORY_VALUES = ["alerts", "security"];
|
|
4
|
+
const NOTIFICATION_READ_STATE_VALUES = ["unread", "read"];
|
|
5
|
+
const NotificationTypeCodec = { protoToOutput: {
|
|
6
|
+
[0]: "unspecified",
|
|
7
|
+
[1]: "price_alert",
|
|
8
|
+
[2]: "telegram_approval"
|
|
9
|
+
} };
|
|
10
|
+
const NotificationCategoryCodec = {
|
|
11
|
+
inputToProto: {
|
|
12
|
+
alerts: 1,
|
|
13
|
+
security: 2
|
|
14
|
+
},
|
|
15
|
+
protoToOutput: {
|
|
16
|
+
[0]: "unspecified",
|
|
17
|
+
[1]: "alerts",
|
|
18
|
+
[2]: "security"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const NotificationReadStateCodec = { inputToProto: {
|
|
22
|
+
unread: 1,
|
|
23
|
+
read: 2
|
|
24
|
+
} };
|
|
25
|
+
const TelegramApprovalActionCodec = { protoToOutput: {
|
|
26
|
+
[0]: "unspecified",
|
|
27
|
+
[1]: "place_order",
|
|
28
|
+
[2]: "place_orders",
|
|
29
|
+
[3]: "modify_orders",
|
|
30
|
+
[4]: "cancel_order",
|
|
31
|
+
[5]: "cancel_all_orders",
|
|
32
|
+
[6]: "modify_trigger",
|
|
33
|
+
[7]: "pause_trigger",
|
|
34
|
+
[8]: "resume_trigger",
|
|
35
|
+
[9]: "swap"
|
|
36
|
+
} };
|
|
37
|
+
//#endregion
|
|
38
|
+
export { NOTIFICATION_CATEGORY_VALUES, NOTIFICATION_READ_STATE_VALUES, NotificationCategoryCodec, NotificationReadStateCodec, NotificationTypeCodec, TelegramApprovalActionCodec };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=notifications.codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.codecs.js","names":[],"sources":["../../../src/services/notifications/notifications.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const NOTIFICATION_TYPE_VALUES = [\"price_alert\", \"telegram_approval\"] as const;\n/** What a notification reports; each type belongs to one category. */\nexport type NotificationType = (typeof NOTIFICATION_TYPE_VALUES)[number];\n\nexport const NOTIFICATION_CATEGORY_VALUES = [\"alerts\", \"security\"] as const;\n/** `alerts` holds alerts the caller set; `security` holds account security events. */\nexport type NotificationCategory = (typeof NOTIFICATION_CATEGORY_VALUES)[number];\n\nexport const NOTIFICATION_READ_STATE_VALUES = [\"unread\", \"read\"] as const;\nexport type NotificationReadState = (typeof NOTIFICATION_READ_STATE_VALUES)[number];\n\nexport const TELEGRAM_APPROVAL_ACTION_VALUES = [\n \"place_order\",\n \"place_orders\",\n \"modify_orders\",\n \"cancel_order\",\n \"cancel_all_orders\",\n \"modify_trigger\",\n \"pause_trigger\",\n \"resume_trigger\",\n \"swap\",\n] as const;\n/** What an approval from the linked Telegram account approved. */\nexport type TelegramApprovalAction = (typeof TELEGRAM_APPROVAL_ACTION_VALUES)[number];\n\nexport const NotificationTypeCodec = {\n protoToOutput: {\n [Proto.NotificationType.TYPE_UNSPECIFIED]: \"unspecified\",\n [Proto.NotificationType.PRICE_ALERT]: \"price_alert\",\n [Proto.NotificationType.TELEGRAM_APPROVAL]: \"telegram_approval\",\n } satisfies ProtoToOutput<Proto.NotificationType, NotificationType>,\n} as const;\n\nexport const NotificationCategoryCodec = {\n inputToProto: {\n alerts: Proto.NotificationCategory.ALERTS,\n security: Proto.NotificationCategory.SECURITY,\n } satisfies InputToProto<NotificationCategory, Proto.NotificationCategory>,\n protoToOutput: {\n [Proto.NotificationCategory.CATEGORY_UNSPECIFIED]: \"unspecified\",\n [Proto.NotificationCategory.ALERTS]: \"alerts\",\n [Proto.NotificationCategory.SECURITY]: \"security\",\n } satisfies ProtoToOutput<Proto.NotificationCategory, NotificationCategory>,\n} as const;\n\nexport const NotificationReadStateCodec = {\n inputToProto: {\n unread: Proto.ReadState.UNREAD,\n read: Proto.ReadState.READ,\n } satisfies InputToProto<NotificationReadState, Proto.ReadState>,\n} as const;\n\nexport const TelegramApprovalActionCodec = {\n protoToOutput: {\n [Proto.TelegramApprovalAction.ACTION_UNSPECIFIED]: \"unspecified\",\n [Proto.TelegramApprovalAction.PLACE_ORDER]: \"place_order\",\n [Proto.TelegramApprovalAction.PLACE_ORDERS]: \"place_orders\",\n [Proto.TelegramApprovalAction.MODIFY_ORDERS]: \"modify_orders\",\n [Proto.TelegramApprovalAction.CANCEL_ORDER]: \"cancel_order\",\n [Proto.TelegramApprovalAction.CANCEL_ALL_ORDERS]: \"cancel_all_orders\",\n [Proto.TelegramApprovalAction.MODIFY_TRIGGER]: \"modify_trigger\",\n [Proto.TelegramApprovalAction.PAUSE_TRIGGER]: \"pause_trigger\",\n [Proto.TelegramApprovalAction.RESUME_TRIGGER]: \"resume_trigger\",\n [Proto.TelegramApprovalAction.SWAP]: \"swap\",\n } satisfies ProtoToOutput<Proto.TelegramApprovalAction, TelegramApprovalAction>,\n} as const;\n"],"mappings":";;AAOA,MAAa,+BAA+B,CAAC,UAAU,UAAU;AAIjE,MAAa,iCAAiC,CAAC,UAAU,MAAM;AAiB/D,MAAa,wBAAwB,EACjC,eAAe;EACgC,IAAA;EACL,IAAA;EACM,IAAA;AAChD,EACJ;AAEA,MAAa,4BAA4B;CACrC,cAAc;EACV,QAAA;EACA,UAAA;CACJ;CACA,eAAe;GACwC,IAAA;GACd,IAAA;GACE,IAAA;CAC3C;AACJ;AAEA,MAAa,6BAA6B,EACtC,cAAc;CACV,QAAA;CACA,MAAA;AACJ,EACJ;AAEA,MAAa,8BAA8B,EACvC,eAAe;EACwC,IAAA;EACP,IAAA;EACC,IAAA;EACC,IAAA;EACD,IAAA;EACK,IAAA;EACH,IAAA;EACD,IAAA;EACC,IAAA;EACV,IAAA;AACzC,EACJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
2
|
+
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
|
+
import { AccountNotification, GetNotificationInput, ListNotificationsInput, ListNotificationsResult, MarkAllNotificationsReadInput, MarkNotificationsInput, NotificationCounts } from "./notifications.schemas.js";
|
|
4
|
+
//#region src/services/notifications/notifications.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads and marks the caller's notification center. Available on devnet only. Session JWT only:
|
|
7
|
+
* API keys are refused. An unknown notification ID, including another account's, throws
|
|
8
|
+
* `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`
|
|
9
|
+
* means retry the same request.
|
|
10
|
+
*/
|
|
11
|
+
declare class NotificationsService {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(transports: AuthApiTransports);
|
|
14
|
+
/** Lists the caller's notifications, newest first. */
|
|
15
|
+
list(input?: ListNotificationsInput, options?: PolyesterRequestOptions): Promise<ListNotificationsResult>;
|
|
16
|
+
/** Reads one notification. */
|
|
17
|
+
get(input: GetNotificationInput, options?: PolyesterRequestOptions): Promise<AccountNotification>;
|
|
18
|
+
/** Counts the caller's notifications and unread notifications, in total and by type. */
|
|
19
|
+
getCounts(options?: PolyesterRequestOptions): Promise<NotificationCounts>;
|
|
20
|
+
/**
|
|
21
|
+
* Marks notifications read. All or nothing: one unknown ID throws `ResourceNotFoundError`
|
|
22
|
+
* and marks none. `changed` leaves out notifications already read.
|
|
23
|
+
*/
|
|
24
|
+
markRead(input: MarkNotificationsInput, options?: PolyesterRequestOptions): Promise<{
|
|
25
|
+
changed: number;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Marks notifications unread. All or nothing: one unknown ID throws `ResourceNotFoundError`
|
|
29
|
+
* and marks none. `changed` leaves out notifications already unread.
|
|
30
|
+
*/
|
|
31
|
+
markUnread(input: MarkNotificationsInput, options?: PolyesterRequestOptions): Promise<{
|
|
32
|
+
changed: number;
|
|
33
|
+
}>;
|
|
34
|
+
/** Marks every unread notification read, within the given categories and up to the given one. */
|
|
35
|
+
markAllRead(input?: MarkAllNotificationsReadInput, options?: PolyesterRequestOptions): Promise<{
|
|
36
|
+
changed: number;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { NotificationsService };
|
|
41
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.ts"],"mappings":";;;;;;;;;;cAgCa;;EAGG,YAAA,YAAY;;EAKlB,KACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;EAaL,IACF,OAAO,sBACP,UAAU,0BACX,QAAQ;;EAWL,UAAU,UAAU,0BAA0B,QAAQ;;;;;EAYtD,SACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;;;;EAaP,WACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;EAUP,YACF,QAAO,+BACP,UAAU,0BACX;IAAU"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NotificationService } from "../../gen/notifications/v1/notifications_pb.js";
|
|
2
|
+
import { InternalServerError } from "../../shared/errors.js";
|
|
3
|
+
import { parse } from "../../shared/validation.js";
|
|
4
|
+
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
5
|
+
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
6
|
+
import { GetNotificationInputSchema, ListNotificationsInputSchema, MarkAllNotificationsReadInputSchema, MarkNotificationsInputSchema, formatNotification, formatNotificationCounts } from "./notifications.schemas.js";
|
|
7
|
+
import { createClient } from "@connectrpc/connect";
|
|
8
|
+
//#region src/services/notifications/notifications.ts
|
|
9
|
+
/**
|
|
10
|
+
* Reads and marks the caller's notification center. Available on devnet only. Session JWT only:
|
|
11
|
+
* API keys are refused. An unknown notification ID, including another account's, throws
|
|
12
|
+
* `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`
|
|
13
|
+
* means retry the same request.
|
|
14
|
+
*/
|
|
15
|
+
var NotificationsService = class {
|
|
16
|
+
#client;
|
|
17
|
+
constructor(transports) {
|
|
18
|
+
this.#client = createClient(NotificationService, transports.authApi);
|
|
19
|
+
}
|
|
20
|
+
/** Lists the caller's notifications, newest first. */
|
|
21
|
+
async list(input = {}, options) {
|
|
22
|
+
const request = parse(ListNotificationsInputSchema, input);
|
|
23
|
+
const response = await this.#client.listNotifications(removeUndefined(request), toConnectCallOptions(options));
|
|
24
|
+
return {
|
|
25
|
+
notifications: response.notifications.map(formatNotification),
|
|
26
|
+
nextPageToken: response.nextPageToken
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Reads one notification. */
|
|
30
|
+
async get(input, options) {
|
|
31
|
+
const request = parse(GetNotificationInputSchema, input);
|
|
32
|
+
const { notification } = await this.#client.getNotification(request, toConnectCallOptions(options));
|
|
33
|
+
if (!notification) throw new InternalServerError("Response has no notification.");
|
|
34
|
+
return formatNotification(notification);
|
|
35
|
+
}
|
|
36
|
+
/** Counts the caller's notifications and unread notifications, in total and by type. */
|
|
37
|
+
async getCounts(options) {
|
|
38
|
+
const response = await this.#client.getNotificationCounts({}, toConnectCallOptions(options));
|
|
39
|
+
return formatNotificationCounts(response);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Marks notifications read. All or nothing: one unknown ID throws `ResourceNotFoundError`
|
|
43
|
+
* and marks none. `changed` leaves out notifications already read.
|
|
44
|
+
*/
|
|
45
|
+
async markRead(input, options) {
|
|
46
|
+
const request = parse(MarkNotificationsInputSchema, input);
|
|
47
|
+
return { changed: (await this.#client.markNotificationsRead(request, toConnectCallOptions(options))).changed };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Marks notifications unread. All or nothing: one unknown ID throws `ResourceNotFoundError`
|
|
51
|
+
* and marks none. `changed` leaves out notifications already unread.
|
|
52
|
+
*/
|
|
53
|
+
async markUnread(input, options) {
|
|
54
|
+
const request = parse(MarkNotificationsInputSchema, input);
|
|
55
|
+
return { changed: (await this.#client.markNotificationsUnread(request, toConnectCallOptions(options))).changed };
|
|
56
|
+
}
|
|
57
|
+
/** Marks every unread notification read, within the given categories and up to the given one. */
|
|
58
|
+
async markAllRead(input = {}, options) {
|
|
59
|
+
const request = parse(MarkAllNotificationsReadInputSchema, input);
|
|
60
|
+
const response = await this.#client.markAllNotificationsRead(removeUndefined(request), toConnectCallOptions(options));
|
|
61
|
+
return { changed: Number(response.changed) };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { NotificationsService };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","names":["#client","Proto.NotificationService"],"sources":["../../../src/services/notifications/notifications.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { InternalServerError } from \"../../shared/errors.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n formatNotification,\n formatNotificationCounts,\n GetNotificationInputSchema,\n ListNotificationsInputSchema,\n MarkAllNotificationsReadInputSchema,\n MarkNotificationsInputSchema,\n type AccountNotification,\n type GetNotificationInput,\n type ListNotificationsInput,\n type ListNotificationsResult,\n type MarkAllNotificationsReadInput,\n type MarkNotificationsInput,\n type NotificationCounts,\n} from \"./notifications.schemas.js\";\n\n/**\n * Reads and marks the caller's notification center. Available on devnet only. Session JWT only:\n * API keys are refused. An unknown notification ID, including another account's, throws\n * `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`\n * means retry the same request.\n */\nexport class NotificationsService {\n #client: Client<typeof Proto.NotificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.NotificationService, transports.authApi);\n }\n\n /** Lists the caller's notifications, newest first. */\n async list(\n input: ListNotificationsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListNotificationsResult> {\n const request = parse(ListNotificationsInputSchema, input);\n const response = await this.#client.listNotifications(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n notifications: response.notifications.map(formatNotification),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Reads one notification. */\n async get(\n input: GetNotificationInput,\n options?: PolyesterRequestOptions,\n ): Promise<AccountNotification> {\n const request = parse(GetNotificationInputSchema, input);\n const { notification } = await this.#client.getNotification(\n request,\n toConnectCallOptions(options),\n );\n if (!notification) throw new InternalServerError(\"Response has no notification.\");\n return formatNotification(notification);\n }\n\n /** Counts the caller's notifications and unread notifications, in total and by type. */\n async getCounts(options?: PolyesterRequestOptions): Promise<NotificationCounts> {\n const response = await this.#client.getNotificationCounts(\n {},\n toConnectCallOptions(options),\n );\n return formatNotificationCounts(response);\n }\n\n /**\n * Marks notifications read. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already read.\n */\n async markRead(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsRead(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /**\n * Marks notifications unread. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already unread.\n */\n async markUnread(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsUnread(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /** Marks every unread notification read, within the given categories and up to the given one. */\n async markAllRead(\n input: MarkAllNotificationsReadInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkAllNotificationsReadInputSchema, input);\n const response = await this.#client.markAllNotificationsRead(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return { changed: Number(response.changed) };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,IAAa,uBAAb,MAAkC;CAC9B;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,qBAA2B,WAAW,OAAO;CAC7E;;CAGA,MAAM,KACF,QAAgC,CAAC,GACjC,SACgC;EAChC,MAAM,UAAU,MAAM,8BAA8B,KAAK;EACzD,MAAM,WAAW,MAAM,KAAKD,QAAQ,kBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,eAAe,SAAS,cAAc,IAAI,kBAAkB;GAC5D,eAAe,SAAS;EAC5B;CACJ;;CAGA,MAAM,IACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,4BAA4B,KAAK;EACvD,MAAM,EAAE,iBAAiB,MAAM,KAAKA,QAAQ,gBACxC,SACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,cAAc,MAAM,IAAI,oBAAoB,+BAA+B;EAChF,OAAO,mBAAmB,YAAY;CAC1C;;CAGA,MAAM,UAAU,SAAgE;EAC5E,MAAM,WAAW,MAAM,KAAKA,QAAQ,sBAChC,CAAC,GACD,qBAAqB,OAAO,CAChC;EACA,OAAO,yBAAyB,QAAQ;CAC5C;;;;;CAMA,MAAM,SACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,8BAA8B,KAAK;EAKzD,OAAO,EAAE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