@polyester/sdk 0.36.0-devnet-20261120015159 → 0.36.0-devnet-20261120040128
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 +3 -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 +3 -3
- 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/balances/balances.schemas.d.ts +3 -3
- package/dist/services/candles/candles.js +1 -1
- 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/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 +4 -4
- 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 +66 -66
- package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
- package/dist/services/market-data/market-data.js +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/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 +97 -97
- package/dist/services/orders/orders-batch.schemas.js +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +16 -16
- 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 +16 -16
- 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/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 +1 -1
- package/dist/services/subaccounts/subaccounts.js +2 -2
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +16 -16
- 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/transfers/transfers.schemas.d.ts +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
|
@@ -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"}
|