@polyester/sdk 0.36.0-devnet-20261120015159 → 0.36.0-devnet-20261121035512
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 +5 -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 +1 -1
- package/dist/gen/ai/v1/assistant_pb.js +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +1 -1
- package/dist/gen/auth/v1/activity_pb.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.js +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/auth_pb.js +1 -1
- package/dist/gen/auth/v1/connected_apps_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 +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 +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +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 +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 +1 -1
- package/dist/gen/index.js +27 -27
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
- package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/asset_info_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 +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
- package/dist/gen/polyester/api/v1/request_error_pb.d.ts +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/strategies/v1/strategies_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +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 +1 -1
- package/dist/gen/transfer/v1/dust_conversion_pb.d.ts +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +1 -1
- package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/services/account-activity/account-activity.js +1 -1
- package/dist/services/account-activity/account-activity.schemas.d.ts +6 -6
- 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/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/api-keys/api-keys.js +1 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts +6 -6
- package/dist/services/assistant/assistant-events.schemas.d.ts +28 -28
- package/dist/services/assistant/assistant.js +1 -1
- package/dist/services/assistant/assistant.schemas.d.ts +1 -1
- package/dist/services/auth/profile/profile.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +5 -12
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/candles/candles.js +1 -1
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/chain-analytics/chain-analytics.js +1 -1
- package/dist/services/changelog/changelog.js +1 -1
- package/dist/services/changelog/changelog.schemas.d.ts +38 -38
- 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.d.ts +2 -2
- package/dist/services/claims/claims.schemas.js +1 -1
- package/dist/services/connected-apps/connected-apps.js +1 -1
- package/dist/services/deposit/deposit.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +8 -8
- package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
- package/dist/services/fees/fees.js +1 -1
- package/dist/services/guard-signer/guard-signer.js +1 -1
- package/dist/services/heatmap/heatmap.js +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +3 -3
- package/dist/services/internal-transfers/internal-transfers.js +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +6 -6
- package/dist/services/lifecycle/lifecycle.js +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +52 -52
- package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
- package/dist/services/market-data/market-data.d.ts +20 -0
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +94 -2
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-overview/market-overview.js +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +1 -1
- package/dist/services/notifications/notifications.js +1 -1
- package/dist/services/notifications/notifications.schemas.d.ts +5 -25
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +9 -9
- package/dist/services/orders/order-errors.schemas.js +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +95 -95
- package/dist/services/orders/orders-batch.schemas.js +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +15 -15
- package/dist/services/orders/orders-input.schemas.js +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +8 -8
- package/dist/services/orders/orders-risk.schemas.js +2 -2
- package/dist/services/orders/orders.js +2 -2
- package/dist/services/policies/api-key-policies/api-key-policies.js +1 -1
- package/dist/services/policies/shared.codecs.js +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +1 -1
- package/dist/services/price-alerts/price-alerts.js +1 -1
- package/dist/services/price-alerts/price-alerts.schemas.d.ts +10 -10
- 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/statement-exports/statement-exports.js +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +6 -6
- package/dist/services/strategies/strategies.js +1 -1
- package/dist/services/strategies/strategies.schemas.d.ts +5 -5
- package/dist/services/subaccounts/subaccounts.js +2 -2
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +18 -18
- package/dist/services/swap/service.d.ts +8 -0
- package/dist/services/swap/service.d.ts.map +1 -0
- package/dist/services/swap/service.js +9 -0
- package/dist/services/swap/service.js.map +1 -0
- package/dist/services/swap/swap.codecs.d.ts +19 -0
- package/dist/services/swap/swap.codecs.d.ts.map +1 -0
- package/dist/services/swap/swap.codecs.js +39 -0
- package/dist/services/swap/swap.codecs.js.map +1 -0
- package/dist/services/swap/swap.d.ts +51 -0
- package/dist/services/swap/swap.d.ts.map +1 -0
- package/dist/services/swap/swap.js +71 -0
- package/dist/services/swap/swap.js.map +1 -0
- package/dist/services/swap/swap.schemas.d.ts +520 -0
- package/dist/services/swap/swap.schemas.d.ts.map +1 -0
- package/dist/services/swap/swap.schemas.js +213 -0
- package/dist/services/swap/swap.schemas.js.map +1 -0
- package/dist/services/swap/swap.types.d.ts +3 -0
- package/dist/services/system/system.js +1 -1
- package/dist/services/system/system.schemas.d.ts +13 -13
- package/dist/services/trades/trades.js +1 -1
- 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 +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js +2 -2
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.js +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +53 -53
- package/dist/services/triggers/triggers.js +1 -1
- package/dist/services/vip/vip.js +1 -1
- package/dist/services/vip/vip.schemas.d.ts +3 -3
- 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/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +1 -0
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js +11 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/error-detail.d.ts +16 -4
- 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 +1 -1
- 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/strategies.js +1 -1
- package/dist/shared/error-details/swap.js +22 -0
- package/dist/shared/error-details/swap.js.map +1 -0
- package/dist/shared/error-details/withdraw.js +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +1 -1
- package/dist/shared/rate-limit.schemas.js +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +23 -21
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ declare const SubaccountPermissionDefinitionSchema: v.ObjectSchema<{
|
|
|
13
13
|
}, undefined>;
|
|
14
14
|
type SubaccountPermissionDefinition = v.InferOutput<typeof SubaccountPermissionDefinitionSchema>;
|
|
15
15
|
declare const SubaccountRoleDefinitionSchema: v.ObjectSchema<{
|
|
16
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
16
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
17
17
|
readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
18
18
|
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
19
19
|
readonly assignable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -28,7 +28,7 @@ declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
|
|
|
28
28
|
readonly policyAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-notifications" | "read-account-activity" | "read-strategies" | "draft-strategies" | "propose-strategy-deploy" | "manage-api-keys" | "manage-api-key-policies" | "manage-subaccount-policies">]>;
|
|
29
29
|
}, undefined>, undefined>, readonly []>;
|
|
30
30
|
readonly roles: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
31
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
31
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
32
32
|
readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
33
33
|
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
34
34
|
readonly assignable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -37,7 +37,7 @@ declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
|
|
|
37
37
|
}, undefined>;
|
|
38
38
|
type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;
|
|
39
39
|
declare const EffectiveSubaccountPermissionsSchema: v.ObjectSchema<{
|
|
40
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
40
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
41
41
|
readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "convert_dust" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw" | "read_statements" | "read_funding_flows">]>, undefined>, readonly []>;
|
|
42
42
|
readonly subaccountPolicyId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
43
43
|
}, undefined>;
|
|
@@ -129,7 +129,7 @@ type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;
|
|
|
129
129
|
declare const InviteSubaccountMemberInputSchema: v.StrictObjectSchema<{
|
|
130
130
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
131
131
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
132
|
-
readonly role: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>, v.TransformAction<"
|
|
132
|
+
readonly role: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>, v.TransformAction<"admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer", SubaccountRole$1.VIEWER | SubaccountRole$1.TRADER | SubaccountRole$1.LEVERAGED_TRADER | SubaccountRole$1.TREASURY | SubaccountRole$1.ADMIN | SubaccountRole$1.OWNER>]>;
|
|
133
133
|
}, undefined>;
|
|
134
134
|
type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;
|
|
135
135
|
declare const RemoveSubaccountMemberInputSchema: v.StrictObjectSchema<{
|
|
@@ -140,7 +140,7 @@ type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInp
|
|
|
140
140
|
declare const UpdateSubaccountMemberRoleInputSchema: v.StrictObjectSchema<{
|
|
141
141
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
142
142
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
143
|
-
readonly role: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>, v.TransformAction<"
|
|
143
|
+
readonly role: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>, v.TransformAction<"admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer", SubaccountRole$1.VIEWER | SubaccountRole$1.TRADER | SubaccountRole$1.LEVERAGED_TRADER | SubaccountRole$1.TREASURY | SubaccountRole$1.ADMIN | SubaccountRole$1.OWNER>]>;
|
|
144
144
|
}, undefined>;
|
|
145
145
|
type UpdateSubaccountMemberRoleInput = v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>;
|
|
146
146
|
declare const SetSubaccountMemberMfaRequirementInputSchema: v.StrictObjectSchema<{
|
|
@@ -163,7 +163,7 @@ declare const ProtoSubaccountStatusSchema: v.SchemaWithPipe<readonly [v.NumberSc
|
|
|
163
163
|
type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;
|
|
164
164
|
declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
165
165
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
166
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
166
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
167
167
|
readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
168
168
|
readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
169
169
|
readonly color: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -189,7 +189,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
189
189
|
readonly removed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
190
190
|
}, undefined>, v.TransformAction<{
|
|
191
191
|
id: string;
|
|
192
|
-
role: "
|
|
192
|
+
role: "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
193
193
|
label: string;
|
|
194
194
|
icon: string;
|
|
195
195
|
color: string;
|
|
@@ -211,7 +211,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
211
211
|
updatedAt: number | undefined;
|
|
212
212
|
updatedAtNs: string | undefined;
|
|
213
213
|
id: string;
|
|
214
|
-
role: "
|
|
214
|
+
role: "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
215
215
|
label: string;
|
|
216
216
|
icon: string;
|
|
217
217
|
color: string;
|
|
@@ -229,7 +229,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
229
229
|
type Subaccount = v.InferOutput<typeof SubaccountSchema>;
|
|
230
230
|
declare const SubaccountMemberSchema: v.ObjectSchema<{
|
|
231
231
|
readonly accountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
232
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
232
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
233
233
|
readonly username: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
234
234
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
235
235
|
readonly avatarUrl: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -241,8 +241,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
241
241
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
242
242
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
243
243
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
244
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
245
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "canceled" | "
|
|
244
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
245
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "canceled" | "pending" | "accepted" | "declined">]>;
|
|
246
246
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
247
247
|
readonly seconds: v.BigintSchema<undefined>;
|
|
248
248
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -268,8 +268,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
268
268
|
subaccountId: string;
|
|
269
269
|
granteeAccountId: string;
|
|
270
270
|
inviterAccountId: string;
|
|
271
|
-
role: "
|
|
272
|
-
status: "unspecified" | "canceled" | "
|
|
271
|
+
role: "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
272
|
+
status: "unspecified" | "canceled" | "pending" | "accepted" | "declined";
|
|
273
273
|
createdAt?: number | undefined;
|
|
274
274
|
respondedAt?: number | undefined;
|
|
275
275
|
granteeUsername: string;
|
|
@@ -286,8 +286,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
286
286
|
id: string;
|
|
287
287
|
granteeAccountId: string;
|
|
288
288
|
inviterAccountId: string;
|
|
289
|
-
role: "
|
|
290
|
-
status: "unspecified" | "canceled" | "
|
|
289
|
+
role: "unspecified" | "admin" | "owner" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
290
|
+
status: "unspecified" | "canceled" | "pending" | "accepted" | "declined";
|
|
291
291
|
createdAt?: number | undefined;
|
|
292
292
|
respondedAt?: number | undefined;
|
|
293
293
|
granteeUsername: string;
|
|
@@ -309,9 +309,9 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
309
309
|
seconds: bigint;
|
|
310
310
|
nanos: number;
|
|
311
311
|
} | undefined, number | undefined>]>;
|
|
312
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
313
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "
|
|
314
|
-
readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
312
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api_key" | "account" | "subaccount" | "policy" | "destination" | "session" | "member" | "invite" | "security">]>;
|
|
313
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "revoked" | "removed" | "applied" | "failed" | "created" | "enabled" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released" | "requested">]>;
|
|
314
|
+
readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api" | "web" | "mobile">]>;
|
|
315
315
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
316
316
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
317
317
|
readonly actorAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SwapService } from "./swap.js";
|
|
2
|
+
import { PolyesterCore } from "../../core-client.js";
|
|
3
|
+
//#region src/services/swap/service.d.ts
|
|
4
|
+
/** Returns the client's SwapService, creating it on first use. */
|
|
5
|
+
declare const swapService: (client: PolyesterCore) => SwapService;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { swapService };
|
|
8
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","names":[],"sources":["../../../src/services/swap/service.ts"],"mappings":";;;;cAIa,cAAW,QAAX,kBAAW"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineService } from "../../core-client.js";
|
|
2
|
+
import { SwapService } from "./swap.js";
|
|
3
|
+
//#region src/services/swap/service.ts
|
|
4
|
+
/** Returns the client's SwapService, creating it on first use. */
|
|
5
|
+
const swapService = defineService((context) => new SwapService(context.transports, context.resolver));
|
|
6
|
+
//#endregion
|
|
7
|
+
export { swapService };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","names":[],"sources":["../../../src/services/swap/service.ts"],"sourcesContent":["import { defineService } from \"../../core-client.js\";\nimport { SwapService } from \"./swap.js\";\n\n/** Returns the client's SwapService, creating it on first use. */\nexport const swapService = defineService(\n (context) => new SwapService(context.transports, context.resolver),\n);\n"],"mappings":";;;;AAIA,MAAa,cAAc,eACtB,YAAY,IAAI,YAAY,QAAQ,YAAY,QAAQ,QAAQ,CACrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ErrorCode } from "../../gen/swap/v1/swap_pb.js";
|
|
2
|
+
//#region src/services/swap/swap.codecs.d.ts
|
|
3
|
+
declare const SWAP_STATUS_VALUES: readonly ["executing", "completed", "partially_completed", "failed", "reconciling"];
|
|
4
|
+
/**
|
|
5
|
+
* `executing` places, fills and settles orders; `reconciling` is establishing an order's outcome
|
|
6
|
+
* (balances already show settled fills). `completed`, `partially_completed` and `failed` are
|
|
7
|
+
* terminal: anything not traded stays on the account.
|
|
8
|
+
*/
|
|
9
|
+
type SwapStatus = (typeof SWAP_STATUS_VALUES)[number];
|
|
10
|
+
declare const SWAP_REASON_VALUES: readonly ["insufficient_balance", "price_protection", "market_unavailable", "order_size_out_of_range", "rate_limited", "order_rejected", "expired", "minimum_not_met", "max_order_quantity"];
|
|
11
|
+
/** Why a `partially_completed` or `failed` swap did not trade its whole amount. */
|
|
12
|
+
type SwapReason = (typeof SWAP_REASON_VALUES)[number];
|
|
13
|
+
declare const SWAP_ORDER_STATUS_VALUES: readonly ["placing", "placed", "refused", "not_placed", "unconfirmed"];
|
|
14
|
+
type SwapOrderStatus = (typeof SWAP_ORDER_STATUS_VALUES)[number];
|
|
15
|
+
/** Swap API error code on a rejected call's `detail` (service `swap`), e.g. `QUOTE_EXPIRED`. */
|
|
16
|
+
type SwapErrorCode = keyof typeof ErrorCode;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SWAP_ORDER_STATUS_VALUES, SWAP_REASON_VALUES, SWAP_STATUS_VALUES, SwapErrorCode, SwapOrderStatus, SwapReason, SwapStatus };
|
|
19
|
+
//# sourceMappingURL=swap.codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.codecs.d.ts","names":[],"sources":["../../../src/services/swap/swap.codecs.ts"],"mappings":";;cAGa;;;;;;KAYD,qBAAqB;cAEpB;;KAYD,qBAAqB;cAEpB;KAOD,0BAA0B;;KAG1B,6BAA6B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "../../gen/swap/v1/swap_pb.js";
|
|
2
|
+
//#region src/services/swap/swap.codecs.ts
|
|
3
|
+
const SwapStatusCodec = { protoToOutput: {
|
|
4
|
+
[0]: "unspecified",
|
|
5
|
+
[1]: "executing",
|
|
6
|
+
[2]: "completed",
|
|
7
|
+
[3]: "partially_completed",
|
|
8
|
+
[4]: "failed",
|
|
9
|
+
[5]: "reconciling"
|
|
10
|
+
} };
|
|
11
|
+
const SwapReasonCodec = { protoToOutput: {
|
|
12
|
+
[0]: "unspecified",
|
|
13
|
+
[1]: "insufficient_balance",
|
|
14
|
+
[2]: "price_protection",
|
|
15
|
+
[3]: "market_unavailable",
|
|
16
|
+
[4]: "order_size_out_of_range",
|
|
17
|
+
[5]: "rate_limited",
|
|
18
|
+
[6]: "order_rejected",
|
|
19
|
+
[7]: "expired",
|
|
20
|
+
[8]: "minimum_not_met",
|
|
21
|
+
[9]: "max_order_quantity"
|
|
22
|
+
} };
|
|
23
|
+
const SwapOrderStatusCodec = { protoToOutput: {
|
|
24
|
+
[0]: "unspecified",
|
|
25
|
+
[1]: "placing",
|
|
26
|
+
[2]: "placed",
|
|
27
|
+
[3]: "refused",
|
|
28
|
+
[4]: "not_placed",
|
|
29
|
+
[5]: "unconfirmed"
|
|
30
|
+
} };
|
|
31
|
+
const SwapSideCodec = { protoToOutput: {
|
|
32
|
+
[0]: "unspecified",
|
|
33
|
+
[1]: "buy",
|
|
34
|
+
[2]: "sell"
|
|
35
|
+
} };
|
|
36
|
+
//#endregion
|
|
37
|
+
export { SwapOrderStatusCodec, SwapReasonCodec, SwapSideCodec, SwapStatusCodec };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=swap.codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.codecs.js","names":[],"sources":["../../../src/services/swap/swap.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/swap/v1/swap_pb.js\";\nimport type { ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SWAP_STATUS_VALUES = [\n \"executing\",\n \"completed\",\n \"partially_completed\",\n \"failed\",\n \"reconciling\",\n] as const;\n/**\n * `executing` places, fills and settles orders; `reconciling` is establishing an order's outcome\n * (balances already show settled fills). `completed`, `partially_completed` and `failed` are\n * terminal: anything not traded stays on the account.\n */\nexport type SwapStatus = (typeof SWAP_STATUS_VALUES)[number];\n\nexport const SWAP_REASON_VALUES = [\n \"insufficient_balance\",\n \"price_protection\",\n \"market_unavailable\",\n \"order_size_out_of_range\",\n \"rate_limited\",\n \"order_rejected\",\n \"expired\",\n \"minimum_not_met\",\n \"max_order_quantity\",\n] as const;\n/** Why a `partially_completed` or `failed` swap did not trade its whole amount. */\nexport type SwapReason = (typeof SWAP_REASON_VALUES)[number];\n\nexport const SWAP_ORDER_STATUS_VALUES = [\n \"placing\",\n \"placed\",\n \"refused\",\n \"not_placed\",\n \"unconfirmed\",\n] as const;\nexport type SwapOrderStatus = (typeof SWAP_ORDER_STATUS_VALUES)[number];\n\n/** Swap API error code on a rejected call's `detail` (service `swap`), e.g. `QUOTE_EXPIRED`. */\nexport type SwapErrorCode = keyof typeof Proto.ErrorCode;\n\nexport const SwapStatusCodec = {\n protoToOutput: {\n [Proto.SwapStatus.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapStatus.EXECUTING]: \"executing\",\n [Proto.SwapStatus.COMPLETED]: \"completed\",\n [Proto.SwapStatus.PARTIALLY_COMPLETED]: \"partially_completed\",\n [Proto.SwapStatus.FAILED]: \"failed\",\n [Proto.SwapStatus.RECONCILING]: \"reconciling\",\n } satisfies ProtoToOutput<Proto.SwapStatus, SwapStatus>,\n} as const;\n\nexport const SwapReasonCodec = {\n protoToOutput: {\n [Proto.SwapReason.REASON_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapReason.INSUFFICIENT_BALANCE]: \"insufficient_balance\",\n [Proto.SwapReason.PRICE_PROTECTION]: \"price_protection\",\n [Proto.SwapReason.MARKET_UNAVAILABLE]: \"market_unavailable\",\n [Proto.SwapReason.ORDER_SIZE_OUT_OF_RANGE]: \"order_size_out_of_range\",\n [Proto.SwapReason.RATE_LIMITED]: \"rate_limited\",\n [Proto.SwapReason.ORDER_REJECTED]: \"order_rejected\",\n [Proto.SwapReason.EXPIRED]: \"expired\",\n [Proto.SwapReason.MINIMUM_NOT_MET]: \"minimum_not_met\",\n [Proto.SwapReason.MAX_ORDER_QUANTITY]: \"max_order_quantity\",\n } satisfies ProtoToOutput<Proto.SwapReason, SwapReason>,\n} as const;\n\nexport const SwapOrderStatusCodec = {\n protoToOutput: {\n [Proto.SwapOrderStatus.ORDER_STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapOrderStatus.PLACING]: \"placing\",\n [Proto.SwapOrderStatus.PLACED]: \"placed\",\n [Proto.SwapOrderStatus.REFUSED]: \"refused\",\n [Proto.SwapOrderStatus.NOT_PLACED]: \"not_placed\",\n [Proto.SwapOrderStatus.UNCONFIRMED]: \"unconfirmed\",\n } satisfies ProtoToOutput<Proto.SwapOrderStatus, SwapOrderStatus>,\n} as const;\n\nexport const SwapSideCodec = {\n protoToOutput: {\n [Proto.Side.SIDE_UNSPECIFIED]: \"unspecified\",\n [Proto.Side.BUY]: \"buy\",\n [Proto.Side.SELL]: \"sell\",\n } satisfies ProtoToOutput<Proto.Side, \"buy\" | \"sell\">,\n} as const;\n"],"mappings":";;AA2CA,MAAa,kBAAkB,EAC3B,eAAe;EAC4B,IAAA;EACT,IAAA;EACA,IAAA;EACU,IAAA;EACb,IAAA;EACK,IAAA;AACpC,EACJ;AAEA,MAAa,kBAAkB,EAC3B,eAAe;EAC4B,IAAA;EACE,IAAA;EACJ,IAAA;EACE,IAAA;EACK,IAAA;EACX,IAAA;EACE,IAAA;EACP,IAAA;EACQ,IAAA;EACG,IAAA;AAC3C,EACJ;AAEA,MAAa,uBAAuB,EAChC,eAAe;EACuC,IAAA;EACjB,IAAA;EACD,IAAA;EACC,IAAA;EACG,IAAA;EACC,IAAA;AACzC,EACJ;AAEA,MAAa,gBAAgB,EACzB,eAAe;EACoB,IAAA;EACb,IAAA;EACC,IAAA;AACvB,EACJ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
2
|
+
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
|
+
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
4
|
+
import { CreateSwapInput, GetSwapInput, QuoteSwapInput, Swap, SwapQuote } from "./swap.schemas.js";
|
|
5
|
+
//#region src/services/swap/swap.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Converts one asset of an account's Trading balance into another with immediate-or-cancel spot
|
|
8
|
+
* orders on that account, at its spot taker fee and no other fee. Every part that trades nets at
|
|
9
|
+
* least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by
|
|
10
|
+
* source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and
|
|
11
|
+
* `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.
|
|
12
|
+
*
|
|
13
|
+
* Needs a session or a signed API key with the `swap` policy action; subaccount members need the
|
|
14
|
+
* `swap` permission. The swap's orders also follow the subaccount's spot trading policy.
|
|
15
|
+
* Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.
|
|
16
|
+
*/
|
|
17
|
+
declare class SwapService {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(transports: AuthApiTransports, resolver?: SubaccountResolver);
|
|
20
|
+
/**
|
|
21
|
+
* Prices a swap against current order-book depth and the account's taker fee. Reserves
|
|
22
|
+
* nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and
|
|
23
|
+
* `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and
|
|
24
|
+
* `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws
|
|
25
|
+
* `ServiceUnavailableError` (retry later).
|
|
26
|
+
*/
|
|
27
|
+
quote(input: QuoteSwapInput, options?: PolyesterRequestOptions): Promise<SwapQuote>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is
|
|
30
|
+
* created only while the quote is unexpired and `minAmountOut` is achievable. The result is
|
|
31
|
+
* usually still `executing`; follow it with `get`.
|
|
32
|
+
*
|
|
33
|
+
* Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,
|
|
34
|
+
* `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,
|
|
35
|
+
* which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly
|
|
36
|
+
* (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends
|
|
37
|
+
* the same request. Reusing the key with
|
|
38
|
+
* different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original
|
|
39
|
+
* `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw
|
|
40
|
+
* `PreconditionFailedError` and create nothing: quote again with a new key.
|
|
41
|
+
*/
|
|
42
|
+
create(input: CreateSwapInput, options?: PolyesterRequestOptions): Promise<Swap>;
|
|
43
|
+
/**
|
|
44
|
+
* Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.
|
|
45
|
+
* An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).
|
|
46
|
+
*/
|
|
47
|
+
get(input: GetSwapInput, options?: PolyesterRequestOptions): Promise<Swap>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { SwapService };
|
|
51
|
+
//# sourceMappingURL=swap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.d.ts","names":[],"sources":["../../../src/services/swap/swap.ts"],"mappings":";;;;;;;;;;;;;;;;cAkCa;;EAIG,YAAA,YAAY,mBAAmB,WAAW;;;;;;;;EAYhD,MAAM,OAAO,gBAAgB,UAAU,0BAA0B,QAAQ;;;;;;;;;;;;;;;EA0BzE,OAAO,OAAO,iBAAiB,UAAU,0BAA0B,QAAQ;;;;;EAgB3E,IAAI,OAAO,cAAc,UAAU,0BAA0B,QAAQ"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SwapService as SwapService$1 } from "../../gen/swap/v1/swap_pb.js";
|
|
2
|
+
import { parse } from "../../shared/validation.js";
|
|
3
|
+
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
4
|
+
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
5
|
+
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
6
|
+
import { CreateSwapInputSchema, GetSwapInputSchema, QuoteSwapInputSchema, SwapQuoteSchema, SwapSchema } from "./swap.schemas.js";
|
|
7
|
+
import { createClient } from "@connectrpc/connect";
|
|
8
|
+
//#region src/services/swap/swap.ts
|
|
9
|
+
/**
|
|
10
|
+
* Converts one asset of an account's Trading balance into another with immediate-or-cancel spot
|
|
11
|
+
* orders on that account, at its spot taker fee and no other fee. Every part that trades nets at
|
|
12
|
+
* least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by
|
|
13
|
+
* source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and
|
|
14
|
+
* `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.
|
|
15
|
+
*
|
|
16
|
+
* Needs a session or a signed API key with the `swap` policy action; subaccount members need the
|
|
17
|
+
* `swap` permission. The swap's orders also follow the subaccount's spot trading policy.
|
|
18
|
+
* Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.
|
|
19
|
+
*/
|
|
20
|
+
var SwapService = class {
|
|
21
|
+
#client;
|
|
22
|
+
#resolver;
|
|
23
|
+
constructor(transports, resolver) {
|
|
24
|
+
this.#client = createClient(SwapService$1, transports.authApi);
|
|
25
|
+
this.#resolver = resolver;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Prices a swap against current order-book depth and the account's taker fee. Reserves
|
|
29
|
+
* nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and
|
|
30
|
+
* `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and
|
|
31
|
+
* `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws
|
|
32
|
+
* `ServiceUnavailableError` (retry later).
|
|
33
|
+
*/
|
|
34
|
+
async quote(input, options) {
|
|
35
|
+
const request = parse(QuoteSwapInputSchema, resolveAccountScopedInput(input, this.#resolver));
|
|
36
|
+
const response = await this.#client.quoteSwap(removeUndefined(request), toConnectCallOptions(options));
|
|
37
|
+
return parse(SwapQuoteSchema, response.quote);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is
|
|
41
|
+
* created only while the quote is unexpired and `minAmountOut` is achievable. The result is
|
|
42
|
+
* usually still `executing`; follow it with `get`.
|
|
43
|
+
*
|
|
44
|
+
* Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,
|
|
45
|
+
* `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,
|
|
46
|
+
* which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly
|
|
47
|
+
* (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends
|
|
48
|
+
* the same request. Reusing the key with
|
|
49
|
+
* different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original
|
|
50
|
+
* `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw
|
|
51
|
+
* `PreconditionFailedError` and create nothing: quote again with a new key.
|
|
52
|
+
*/
|
|
53
|
+
async create(input, options) {
|
|
54
|
+
const request = parse(CreateSwapInputSchema, resolveAccountScopedInput(input, this.#resolver));
|
|
55
|
+
const response = await this.#client.createSwap(removeUndefined(request), toConnectCallOptions(options));
|
|
56
|
+
return parse(SwapSchema, response.swap);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.
|
|
60
|
+
* An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).
|
|
61
|
+
*/
|
|
62
|
+
async get(input, options) {
|
|
63
|
+
const request = parse(GetSwapInputSchema, input);
|
|
64
|
+
const response = await this.#client.getSwap(request, toConnectCallOptions(options));
|
|
65
|
+
return parse(SwapSchema, response.swap);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { SwapService };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=swap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.js","names":["#client","Proto.SwapService","#resolver"],"sources":["../../../src/services/swap/swap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/swap/v1/swap_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { resolveAccountScopedInput, type SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSwapInputSchema,\n GetSwapInputSchema,\n QuoteSwapInputSchema,\n SwapQuoteSchema,\n SwapSchema,\n type CreateSwapInput,\n type GetSwapInput,\n type QuoteSwapInput,\n type Swap,\n type SwapQuote,\n} from \"./swap.schemas.js\";\n\n/**\n * Converts one asset of an account's Trading balance into another with immediate-or-cancel spot\n * orders on that account, at its spot taker fee and no other fee. Every part that trades nets at\n * least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by\n * source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and\n * `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.\n *\n * Needs a session or a signed API key with the `swap` policy action; subaccount members need the\n * `swap` permission. The swap's orders also follow the subaccount's spot trading policy.\n * Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.\n */\nexport class SwapService {\n #client: Client<typeof Proto.SwapService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthApiTransports, resolver?: SubaccountResolver) {\n this.#client = createClient(Proto.SwapService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /**\n * Prices a swap against current order-book depth and the account's taker fee. Reserves\n * nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and\n * `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and\n * `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws\n * `ServiceUnavailableError` (retry later).\n */\n async quote(input: QuoteSwapInput, options?: PolyesterRequestOptions): Promise<SwapQuote> {\n const request = parse(\n QuoteSwapInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.quoteSwap(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(SwapQuoteSchema, response.quote);\n }\n\n /**\n * Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is\n * created only while the quote is unexpired and `minAmountOut` is achievable. The result is\n * usually still `executing`; follow it with `get`.\n *\n * Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,\n * `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,\n * which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly\n * (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends\n * the same request. Reusing the key with\n * different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original\n * `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw\n * `PreconditionFailedError` and create nothing: quote again with a new key.\n */\n async create(input: CreateSwapInput, options?: PolyesterRequestOptions): Promise<Swap> {\n const request = parse(\n CreateSwapInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.createSwap(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(SwapSchema, response.swap);\n }\n\n /**\n * Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.\n * An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).\n */\n async get(input: GetSwapInput, options?: PolyesterRequestOptions): Promise<Swap> {\n const request = parse(GetSwapInputSchema, input);\n const response = await this.#client.getSwap(request, toConnectCallOptions(options));\n return parse(SwapSchema, response.swap);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,IAAa,cAAb,MAAyB;CACrB;CACA;CAEA,YAAY,YAA+B,UAA+B;EACtE,KAAKA,UAAU,aAAaC,eAAmB,WAAW,OAAO;EACjE,KAAKC,YAAY;CACrB;;;;;;;;CASA,MAAM,MAAM,OAAuB,SAAuD;EACtF,MAAM,UAAU,MACZ,sBACA,0BAA0B,OAAO,KAAKA,SAAS,CACnD;EACA,MAAM,WAAW,MAAM,KAAKF,QAAQ,UAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iBAAiB,SAAS,KAAK;CAChD;;;;;;;;;;;;;;;CAgBA,MAAM,OAAO,OAAwB,SAAkD;EACnF,MAAM,UAAU,MACZ,uBACA,0BAA0B,OAAO,KAAKE,SAAS,CACnD;EACA,MAAM,WAAW,MAAM,KAAKF,QAAQ,WAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,YAAY,SAAS,IAAI;CAC1C;;;;;CAMA,MAAM,IAAI,OAAqB,SAAkD;EAC7E,MAAM,UAAU,MAAM,oBAAoB,KAAK;EAC/C,MAAM,WAAW,MAAM,KAAKA,QAAQ,QAAQ,SAAS,qBAAqB,OAAO,CAAC;EAClF,OAAO,MAAM,YAAY,SAAS,IAAI;CAC1C;AACJ"}
|