@polyester/sdk 0.14.2 → 0.15.1
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 +20 -0
- package/dist/core-client.js +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +8 -0
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
- package/dist/services/address-book/address-book.schemas.js +2 -1
- package/dist/services/address-book/address-book.schemas.js.map +1 -1
- package/dist/services/candles/candles.d.ts.map +1 -1
- package/dist/services/candles/candles.js +2 -1
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/candles/candles.schemas.d.ts +1 -1
- package/dist/services/candles/candles.schemas.d.ts.map +1 -1
- package/dist/services/candles/candles.schemas.js +3 -2
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.js +5 -5
- package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
- package/dist/services/deposit/deposit.schemas.d.ts +3 -3
- package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
- package/dist/services/deposit/deposit.schemas.js +4 -4
- package/dist/services/deposit/deposit.schemas.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.d.ts +2 -2
- package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +2 -1
- package/dist/services/guard-signer/guard-signer.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.js +2 -1
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +2 -1
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +2 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +3 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +2 -1
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +1 -1
- package/dist/services/market-data/market-data.schemas.js +2 -2
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +2 -2
- package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +3 -4
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +17 -8
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/shared.js +4 -2
- package/dist/services/shared.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +3 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trailing-oneof-inputs.js +3 -1
- package/dist/services/trailing-oneof-inputs.js.map +1 -1
- package/dist/services/transfers/transfers.schemas.d.ts +7 -0
- package/dist/services/transfers/transfers.schemas.d.ts.map +1 -1
- package/dist/services/transfers/transfers.schemas.js +2 -1
- package/dist/services/transfers/transfers.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +3 -3
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/schemas.js +4 -4
- package/dist/shared/schemas.js.map +1 -1
- package/dist/utils/numbers.js +1 -10
- package/dist/utils/numbers.js.map +1 -1
- package/package.json +1 -1
|
@@ -216,7 +216,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
216
216
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
217
217
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
218
218
|
readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
219
|
-
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "
|
|
219
|
+
readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "cancelled" | "accepted" | "declined">]>;
|
|
220
220
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
221
221
|
readonly seconds: v.BigintSchema<undefined>;
|
|
222
222
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -243,7 +243,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
243
243
|
granteeAccountId: string;
|
|
244
244
|
inviterAccountId: string;
|
|
245
245
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
246
|
-
status: "unspecified" | "pending" | "
|
|
246
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
247
247
|
createdAt?: number | undefined;
|
|
248
248
|
respondedAt?: number | undefined;
|
|
249
249
|
granteeUsername: string;
|
|
@@ -261,7 +261,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
261
261
|
granteeAccountId: string;
|
|
262
262
|
inviterAccountId: string;
|
|
263
263
|
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
264
|
-
status: "unspecified" | "pending" | "
|
|
264
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
265
265
|
createdAt?: number | undefined;
|
|
266
266
|
respondedAt?: number | undefined;
|
|
267
267
|
granteeUsername: string;
|
|
@@ -283,8 +283,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
283
283
|
seconds: bigint;
|
|
284
284
|
nanos: number;
|
|
285
285
|
} | undefined, number | undefined>]>;
|
|
286
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
287
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "
|
|
286
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
|
|
287
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "failed" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
288
288
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
289
289
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
290
290
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -19,7 +19,7 @@ type CreateTradingWithdrawRequestBase = {
|
|
|
19
19
|
payloadSignature?: Uint8Array;
|
|
20
20
|
};
|
|
21
21
|
declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
22
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
22
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
23
23
|
readonly quantity: v.StringSchema<undefined>;
|
|
24
24
|
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
25
25
|
readonly destinationAddress: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -40,7 +40,7 @@ declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScal
|
|
|
40
40
|
} | undefined;
|
|
41
41
|
}, CreateTradingWithdrawRequestBase>]>;
|
|
42
42
|
declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
43
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
43
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
44
44
|
readonly quantity: v.StringSchema<undefined>;
|
|
45
45
|
readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
|
|
46
46
|
readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAiBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAoCP,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
1
2
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
2
3
|
import { quantityInputToE18 } from "../../shared/decimal-surface.js";
|
|
3
4
|
import { toU128 } from "../../utils/u128.js";
|
|
@@ -32,7 +33,7 @@ function createTradingWithdrawPayload(input) {
|
|
|
32
33
|
function createCreateTradingWithdrawToFundingInputSchema(scales) {
|
|
33
34
|
return v.pipe(v.strictObject({
|
|
34
35
|
...AccountScopeInputEntries,
|
|
35
|
-
assetId:
|
|
36
|
+
assetId: PositiveUint32InputSchema,
|
|
36
37
|
quantity: v.string(),
|
|
37
38
|
idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),
|
|
38
39
|
destinationAddress: v.optional(v.pipe(v.string(), v.trim()), ""),
|
|
@@ -61,7 +62,7 @@ function createCreateTradingWithdrawToFundingInputSchema(scales) {
|
|
|
61
62
|
function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
|
|
62
63
|
return v.pipe(v.strictObject({
|
|
63
64
|
...AccountScopeInputEntries,
|
|
64
|
-
assetId:
|
|
65
|
+
assetId: PositiveUint32InputSchema,
|
|
65
66
|
quantity: v.string(),
|
|
66
67
|
destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
|
|
67
68
|
destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;AAcA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IA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AAyC,EAAE,KACpD,EAAE,aAAa;CACX,oBAAoB,EAAE,KAClB,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,QAAQ,CAAC,GACX,EAAE,SAAS,OAAO,gBAAgB,CACtC;CACA,oBAAoB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC,GACD,EAAE,WAAW,WAAW;CACpB,oBAAoB,OAAO,MAAM,kBAAkB;CACnD,oBAAoB,MAAM;AAC9B,EAAE,CACN;AASA,MAAM,uCAAuC,EAAE,KAC3C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,IAAI;CACrB,MAAM,EAAE,QAAA,CAA+C;CACvD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;;AAeA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAOE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,oBAAoB,MAAM;EAC1B,WAAW,OAAO,MAAM,cAAc;EACtC,eAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,w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AE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
|
|
@@ -3,6 +3,8 @@ import { PROTOBUF_INT32_MAX } from "../shared/wire-bounds.js";
|
|
|
3
3
|
import { CatalogConversionError } from "../catalogs/types.js";
|
|
4
4
|
import { positiveDecimalInputToScaled } from "../shared/decimal-surface.js";
|
|
5
5
|
//#region src/services/trailing-oneof-inputs.ts
|
|
6
|
+
/** Product-wide cap for bps slippage inputs (market IOC, attached and standalone trailing stops). */
|
|
7
|
+
const MAX_SLIPPAGE_BPS = 1e4;
|
|
6
8
|
function parseTrailingDistanceInput(scales, distance, fieldName) {
|
|
7
9
|
if (distance.kind === "none") return {
|
|
8
10
|
case: void 0,
|
|
@@ -43,6 +45,6 @@ function exceedsMax(value, max) {
|
|
|
43
45
|
return max !== void 0 && value > max;
|
|
44
46
|
}
|
|
45
47
|
//#endregion
|
|
46
|
-
export { parseSlippageInput, parseTrailingDistanceInput };
|
|
48
|
+
export { MAX_SLIPPAGE_BPS, parseSlippageInput, parseTrailingDistanceInput };
|
|
47
49
|
|
|
48
50
|
//# sourceMappingURL=trailing-oneof-inputs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trailing-oneof-inputs.js","names":[],"sources":["../../src/services/trailing-oneof-inputs.ts"],"sourcesContent":["import { positiveDecimalInputToScaled, type SdkScales } from \"../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../catalogs/types.js\";\nimport { parseOptionalPositiveIntLike } from \"../utils/numbers.js\";\nimport { PROTOBUF_INT32_MAX } from \"../shared/wire-bounds.js\";\n\ntype PositiveIntLikeInput = string | number;\n\n/**\n * Trailing distance and slippage inputs: absolute price distances and\n * slippages are decimal price strings (e.g. \"0.50\"), converted to wire ticks\n * via the price scale; basis points are integers.\n */\nexport type TrailingDistanceInput =\n | { kind: \"distance\"; distance: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\nexport type SlippageInput =\n | { kind: \"slippage\"; slippage: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\ntype UnsetOneof = { case: undefined; value: undefined };\n\ntype TrailingDistanceOneof =\n | { case: \"trailingDistanceTicks\"; value: bigint }\n | { case: \"trailingDistanceBps\"; value: number }\n | UnsetOneof;\n\ntype SlippageOneof<TicksCase extends string, BpsCase extends string> =\n | { case: TicksCase; value: number }\n | { case: BpsCase; value: number }\n | UnsetOneof;\n\ntype SlippageOptions<TicksCase extends string, BpsCase extends string> = {\n fieldName: string;\n ticksCase: TicksCase;\n bpsCase: BpsCase;\n maxBps?: number;\n};\n\nexport function parseTrailingDistanceInput(\n scales: SdkScales,\n distance: TrailingDistanceInput,\n fieldName: string,\n): TrailingDistanceOneof {\n if (distance.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (distance.kind === \"distance\") {\n return {\n case: \"trailingDistanceTicks\",\n value: positiveDecimalInputToScaled(\n `${fieldName}.distance`,\n distance.distance,\n scales.price(),\n ),\n };\n }\n\n const bps = parseOptionalPositiveIntLike(distance.bps);\n if (bps === undefined || bps > Number(PROTOBUF_INT32_MAX)) {\n throw new CatalogConversionError(\n `${fieldName}.bps`,\n `${fieldName}Bps must be a positive integer no greater than ${PROTOBUF_INT32_MAX}`,\n );\n }\n return { case: \"trailingDistanceBps\", value: bps };\n}\n\nexport function parseSlippageInput<const TicksCase extends string, const BpsCase extends string>(\n scales: SdkScales,\n slippage: SlippageInput | undefined,\n options: SlippageOptions<TicksCase, BpsCase>,\n): SlippageOneof<TicksCase, BpsCase> {\n if (!slippage || slippage.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (slippage.kind === \"slippage\") {\n const ticks = positiveDecimalInputToScaled(\n `${options.fieldName}.slippage`,\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n `${options.fieldName}.slippage`,\n `${options.fieldName}.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: options.ticksCase, value: Number(ticks) };\n }\n\n const bps = parseOptionalPositiveIntLike(slippage.bps);\n if (bps === undefined || bps <= 0 || exceedsMax(bps, options.maxBps)) {\n throw new CatalogConversionError(\n `${options.fieldName}.bps`,\n `${options.fieldName}Bps must be ${\n options.maxBps === undefined\n ? \"a positive integer\"\n : `between 1 and ${options.maxBps}`\n }`,\n );\n }\n return { case: options.bpsCase, value: bps };\n}\n\nfunction exceedsMax(value: number, max: number | undefined): boolean {\n return max !== undefined && value > max;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"trailing-oneof-inputs.js","names":[],"sources":["../../src/services/trailing-oneof-inputs.ts"],"sourcesContent":["import { positiveDecimalInputToScaled, type SdkScales } from \"../shared/decimal-surface.js\";\nimport { CatalogConversionError } from \"../catalogs/types.js\";\nimport { parseOptionalPositiveIntLike } from \"../utils/numbers.js\";\nimport { PROTOBUF_INT32_MAX } from \"../shared/wire-bounds.js\";\n\ntype PositiveIntLikeInput = string | number;\n\n/** Product-wide cap for bps slippage inputs (market IOC, attached and standalone trailing stops). */\nexport const MAX_SLIPPAGE_BPS = 10_000;\n\n/**\n * Trailing distance and slippage inputs: absolute price distances and\n * slippages are decimal price strings (e.g. \"0.50\"), converted to wire ticks\n * via the price scale; basis points are integers.\n */\nexport type TrailingDistanceInput =\n | { kind: \"distance\"; distance: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\nexport type SlippageInput =\n | { kind: \"slippage\"; slippage: string }\n | { kind: \"bps\"; bps: PositiveIntLikeInput }\n | { kind: \"none\" };\n\ntype UnsetOneof = { case: undefined; value: undefined };\n\ntype TrailingDistanceOneof =\n | { case: \"trailingDistanceTicks\"; value: bigint }\n | { case: \"trailingDistanceBps\"; value: number }\n | UnsetOneof;\n\ntype SlippageOneof<TicksCase extends string, BpsCase extends string> =\n | { case: TicksCase; value: number }\n | { case: BpsCase; value: number }\n | UnsetOneof;\n\ntype SlippageOptions<TicksCase extends string, BpsCase extends string> = {\n fieldName: string;\n ticksCase: TicksCase;\n bpsCase: BpsCase;\n maxBps?: number;\n};\n\nexport function parseTrailingDistanceInput(\n scales: SdkScales,\n distance: TrailingDistanceInput,\n fieldName: string,\n): TrailingDistanceOneof {\n if (distance.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (distance.kind === \"distance\") {\n return {\n case: \"trailingDistanceTicks\",\n value: positiveDecimalInputToScaled(\n `${fieldName}.distance`,\n distance.distance,\n scales.price(),\n ),\n };\n }\n\n const bps = parseOptionalPositiveIntLike(distance.bps);\n if (bps === undefined || bps > Number(PROTOBUF_INT32_MAX)) {\n throw new CatalogConversionError(\n `${fieldName}.bps`,\n `${fieldName}Bps must be a positive integer no greater than ${PROTOBUF_INT32_MAX}`,\n );\n }\n return { case: \"trailingDistanceBps\", value: bps };\n}\n\nexport function parseSlippageInput<const TicksCase extends string, const BpsCase extends string>(\n scales: SdkScales,\n slippage: SlippageInput | undefined,\n options: SlippageOptions<TicksCase, BpsCase>,\n): SlippageOneof<TicksCase, BpsCase> {\n if (!slippage || slippage.kind === \"none\") {\n return { case: undefined, value: undefined };\n }\n if (slippage.kind === \"slippage\") {\n const ticks = positiveDecimalInputToScaled(\n `${options.fieldName}.slippage`,\n slippage.slippage,\n scales.price(),\n );\n if (ticks > PROTOBUF_INT32_MAX) {\n throw new CatalogConversionError(\n `${options.fieldName}.slippage`,\n `${options.fieldName}.slippage exceeds the maximum supported price distance: ${slippage.slippage}`,\n );\n }\n return { case: options.ticksCase, value: Number(ticks) };\n }\n\n const bps = parseOptionalPositiveIntLike(slippage.bps);\n if (bps === undefined || bps <= 0 || exceedsMax(bps, options.maxBps)) {\n throw new CatalogConversionError(\n `${options.fieldName}.bps`,\n `${options.fieldName}Bps must be ${\n options.maxBps === undefined\n ? \"a positive integer\"\n : `between 1 and ${options.maxBps}`\n }`,\n );\n }\n return { case: options.bpsCase, value: bps };\n}\n\nfunction exceedsMax(value: number, max: number | undefined): boolean {\n return max !== undefined && value > max;\n}\n"],"mappings":";;;;;;AAQA,MAAa,mBAAmB;AAoChC,SAAgB,2BACZ,QACA,UACA,WACqB;CACrB,IAAI,SAAS,SAAS,QAClB,OAAO;EAAE,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU;CAE/C,IAAI,SAAS,SAAS,YAClB,OAAO;EACH,MAAM;EACN,OAAO,6BACH,GAAG,UAAU,YACb,SAAS,UACT,OAAO,MAAM,CACjB;CACJ;CAGJ,MAAM,MAAM,6BAA6B,SAAS,GAAG;CACrD,IAAI,QAAQ,KAAA,KAAa,MAAM,OAAA,WAAyB,GACpD,MAAM,IAAI,uBACN,GAAG,UAAU,OACb,GAAG,UAAU,iDAAiD,oBAClE;CAEJ,OAAO;EAAE,MAAM;EAAuB,OAAO;CAAI;AACrD;AAEA,SAAgB,mBACZ,QACA,UACA,SACiC;CACjC,IAAI,CAAC,YAAY,SAAS,SAAS,QAC/B,OAAO;EAAE,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU;CAE/C,IAAI,SAAS,SAAS,YAAY;EAC9B,MAAM,QAAQ,6BACV,GAAG,QAAQ,UAAU,YACrB,SAAS,UACT,OAAO,MAAM,CACjB;EACA,IAAI,QAAA,aACA,MAAM,IAAI,uBACN,GAAG,QAAQ,UAAU,YACrB,GAAG,QAAQ,UAAU,0DAA0D,SAAS,UAC5F;EAEJ,OAAO;GAAE,MAAM,QAAQ;GAAW,OAAO,OAAO,KAAK;EAAE;CAC3D;CAEA,MAAM,MAAM,6BAA6B,SAAS,GAAG;CACrD,IAAI,QAAQ,KAAA,KAAa,OAAO,KAAK,WAAW,KAAK,QAAQ,MAAM,GAC/D,MAAM,IAAI,uBACN,GAAG,QAAQ,UAAU,OACrB,GAAG,QAAQ,UAAU,cACjB,QAAQ,WAAW,KAAA,IACb,uBACA,iBAAiB,QAAQ,UAEvC;CAEJ,OAAO;EAAE,MAAM,QAAQ;EAAS,OAAO;CAAI;AAC/C;AAEA,SAAS,WAAW,OAAe,KAAkC;CACjE,OAAO,QAAQ,KAAA,KAAa,QAAQ;AACxC"}
|
|
@@ -6,6 +6,7 @@ declare const LedgerTransferSideSchema: v.ObjectSchema<{
|
|
|
6
6
|
readonly kind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TransferSideKind, undefined>, v.TransformAction<TransferSideKind, "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account">]>;
|
|
7
7
|
readonly accountId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
|
|
8
8
|
readonly address: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
9
|
+
readonly chainId: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
9
10
|
}, undefined>;
|
|
10
11
|
type LedgerTransferSide = v.InferOutput<typeof LedgerTransferSideSchema>;
|
|
11
12
|
/** Parses ledger transfer rows whose monetary fields use the protocol's fixed E18 scale. */
|
|
@@ -29,11 +30,13 @@ declare const LedgerTransferSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
29
30
|
readonly kind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TransferSideKind, undefined>, v.TransformAction<TransferSideKind, "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account">]>;
|
|
30
31
|
readonly accountId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
|
|
31
32
|
readonly address: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
33
|
+
readonly chainId: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
32
34
|
}, undefined>, undefined>;
|
|
33
35
|
readonly destination: v.OptionalSchema<v.ObjectSchema<{
|
|
34
36
|
readonly kind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TransferSideKind, undefined>, v.TransformAction<TransferSideKind, "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account">]>;
|
|
35
37
|
readonly accountId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
|
|
36
38
|
readonly address: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
39
|
+
readonly chainId: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
37
40
|
}, undefined>, undefined>;
|
|
38
41
|
}, undefined>, v.TransformAction<{
|
|
39
42
|
assetId: number;
|
|
@@ -55,22 +58,26 @@ declare const LedgerTransferSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
55
58
|
kind: "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account";
|
|
56
59
|
accountId?: string | undefined;
|
|
57
60
|
address: string;
|
|
61
|
+
chainId?: number | undefined;
|
|
58
62
|
} | undefined;
|
|
59
63
|
destination?: {
|
|
60
64
|
kind: "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account";
|
|
61
65
|
accountId?: string | undefined;
|
|
62
66
|
address: string;
|
|
67
|
+
chainId?: number | undefined;
|
|
63
68
|
} | undefined;
|
|
64
69
|
}, {
|
|
65
70
|
destination?: {
|
|
66
71
|
kind: "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account";
|
|
67
72
|
accountId?: string | undefined;
|
|
68
73
|
address: string;
|
|
74
|
+
chainId?: number | undefined;
|
|
69
75
|
} | undefined;
|
|
70
76
|
source?: {
|
|
71
77
|
kind: "unspecified" | "funding_account" | "trading_account" | "external_address" | "private_counterparty" | "fee_account" | "system_account";
|
|
72
78
|
accountId?: string | undefined;
|
|
73
79
|
address: string;
|
|
80
|
+
chainId?: number | undefined;
|
|
74
81
|
} | undefined;
|
|
75
82
|
assetId: number;
|
|
76
83
|
amount: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.schemas.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.schemas.ts"],"mappings":";;;;cA2Ca,0BAAwB,EAAA
|
|
1
|
+
{"version":3,"file":"transfers.schemas.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.schemas.ts"],"mappings":";;;;cA2Ca,0BAAwB,EAAA;;;;;;KAOzB,qBAAqB,EAAE,mBAAmB;;cAGzC,sBAAoB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmDrB,iBAAiB,EAAE,mBAAmB;cAErC,0BAAwB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwBzB,qBAAqB,EAAE,kBAAkB"}
|
|
@@ -22,7 +22,8 @@ const TransferSideKindSchema = v.pipe(v.enum(TransferSideKind), v.transform((kin
|
|
|
22
22
|
const LedgerTransferSideSchema = v.object({
|
|
23
23
|
kind: TransferSideKindSchema,
|
|
24
24
|
accountId: OptionalPublicIdSchema,
|
|
25
|
-
address: v.optional(v.string(), "")
|
|
25
|
+
address: v.optional(v.string(), ""),
|
|
26
|
+
chainId: v.optional(v.number())
|
|
26
27
|
});
|
|
27
28
|
/** Parses ledger transfer rows whose monetary fields use the protocol's fixed E18 scale. */
|
|
28
29
|
const LedgerTransferSchema = v.pipe(v.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.schemas.js","names":["Proto.TransferSideKind"],"sources":["../../../src/services/transfers/transfers.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport * as Proto from \"../../gen/ledger/read/v1/ledger_read_pb.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport {\n AccountCodeCodec,\n TRANSFER_CODE_VALUES,\n TransferCodeCodec,\n} from \"../../shared/ledger-codes.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { wireTimestampToMs } from \"../../utils/time.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsToUsInputSchema,\n} from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { E18_SCALE, scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { TransferSideKindCodec } from \"./transfers.codecs.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\nconst WireTimestampInputSchema = v.union([\n v.bigint(),\n v.number(),\n v.pipe(\n v.string(),\n v.regex(/^\\d+$/),\n v.transform((value) => BigInt(value)),\n ),\n]);\n\nconst TransferSideKindSchema = v.pipe(\n v.enum(Proto.TransferSideKind),\n v.transform((kind) =>\n requiredEnumLabel(TransferSideKindCodec.protoToOutput, kind, \"TransferSideSchema\", \"kind\"),\n ),\n);\n\nexport const LedgerTransferSideSchema = v.object({\n kind: TransferSideKindSchema,\n accountId: OptionalPublicIdSchema,\n address: v.optional(v.string(), \"\"),\n});\n\nexport type LedgerTransferSide = v.InferOutput<typeof LedgerTransferSideSchema>;\n\n/** Parses ledger transfer rows whose monetary fields use the protocol's fixed E18 scale. */\nexport const LedgerTransferSchema = v.pipe(\n v.object({\n assetId: v.number(),\n amountE18: v.optional(U128Schema),\n balanceAfterE18: v.optional(U128Schema),\n isDebit: v.boolean(),\n transferCode: v.number(),\n accountCode: v.number(),\n tsUs: WireTimestampInputSchema,\n linkId: v.optional(v.bigint()),\n flowId: v.optional(v.string()),\n source: v.optional(LedgerTransferSideSchema),\n destination: v.optional(LedgerTransferSideSchema),\n }),\n v.transform((tr) => {\n const amount = fromU128(tr.amountE18);\n const linkId = tr.linkId && tr.linkId > 0n ? tr.linkId.toString() : undefined;\n\n const output = {\n assetId: tr.assetId,\n amount: scaledToDecimalOutput(amount, E18_SCALE),\n balanceAfter:\n tr.balanceAfterE18 !== undefined\n ? scaledToDecimalOutput(fromU128(tr.balanceAfterE18), E18_SCALE)\n : undefined,\n type: requiredEnumLabel(\n TransferCodeCodec.protoToOutput,\n tr.transferCode,\n \"LedgerTransferSchema\",\n \"transfer code\",\n ),\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n tr.accountCode,\n \"LedgerTransferSchema\",\n \"account code\",\n ),\n timestamp: wireTimestampToMs(tr.tsUs),\n isDebit: tr.isDebit,\n linkId,\n flowId: tr.flowId?.trim() ?? \"\",\n };\n\n return {\n ...output,\n ...(tr.source ? { source: tr.source } : {}),\n ...(tr.destination ? { destination: tr.destination } : {}),\n };\n }),\n);\n\nexport type LedgerTransfer = v.InferOutput<typeof LedgerTransferSchema>;\n\nexport const ListTransfersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n ledger: v.optional(v.number(), 0),\n limit: v.optional(v.number()),\n reversed: v.optional(v.boolean(), false),\n timestampMin: OptionalTimestampMsToUsInputSchema,\n timestampMax: OptionalTimestampMsToUsInputSchema,\n transferCode: v.optional(\n v.pipe(\n v.picklist(TRANSFER_CODE_VALUES),\n v.transform((value) => TransferCodeCodec.inputToProto[value]),\n ),\n ),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, timestampMin, timestampMax, ...input }) => ({\n ...input,\n tsMinUs: timestampMin,\n tsMaxUs: timestampMax,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListTransfersInput = v.InferInput<typeof ListTransfersInputSchema>;\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;AAED,MAAM,2BAA2B,EAAE,MAAM;CACrC,EAAE,OAAO;CACT,EAAE,OAAO;CACT,EAAE,KACE,EAAE,OAAO,GACT,EAAE,MAAM,OAAO,GACf,EAAE,WAAW,UAAU,OAAO,KAAK,CAAC,CACxC;AACJ,CAAC;AAED,MAAM,yBAAyB,EAAE,KAC7B,EAAE,KAAKA,gBAAsB,GAC7B,EAAE,WAAW,SACT,kBAAkB,sBAAsB,eAAe,MAAM,sBAAsB,MAAM,CAC7F,CACJ;AAEA,MAAa,2BAA2B,EAAE,OAAO;CAC7C,MAAM;CACN,WAAW;CACX,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"transfers.schemas.js","names":["Proto.TransferSideKind"],"sources":["../../../src/services/transfers/transfers.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport * as Proto from \"../../gen/ledger/read/v1/ledger_read_pb.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport {\n AccountCodeCodec,\n TRANSFER_CODE_VALUES,\n TransferCodeCodec,\n} from \"../../shared/ledger-codes.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { wireTimestampToMs } from \"../../utils/time.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsToUsInputSchema,\n} from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { E18_SCALE, scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { TransferSideKindCodec } from \"./transfers.codecs.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\nconst WireTimestampInputSchema = v.union([\n v.bigint(),\n v.number(),\n v.pipe(\n v.string(),\n v.regex(/^\\d+$/),\n v.transform((value) => BigInt(value)),\n ),\n]);\n\nconst TransferSideKindSchema = v.pipe(\n v.enum(Proto.TransferSideKind),\n v.transform((kind) =>\n requiredEnumLabel(TransferSideKindCodec.protoToOutput, kind, \"TransferSideSchema\", \"kind\"),\n ),\n);\n\nexport const LedgerTransferSideSchema = v.object({\n kind: TransferSideKindSchema,\n accountId: OptionalPublicIdSchema,\n address: v.optional(v.string(), \"\"),\n chainId: v.optional(v.number()),\n});\n\nexport type LedgerTransferSide = v.InferOutput<typeof LedgerTransferSideSchema>;\n\n/** Parses ledger transfer rows whose monetary fields use the protocol's fixed E18 scale. */\nexport const LedgerTransferSchema = v.pipe(\n v.object({\n assetId: v.number(),\n amountE18: v.optional(U128Schema),\n balanceAfterE18: v.optional(U128Schema),\n isDebit: v.boolean(),\n transferCode: v.number(),\n accountCode: v.number(),\n tsUs: WireTimestampInputSchema,\n linkId: v.optional(v.bigint()),\n flowId: v.optional(v.string()),\n source: v.optional(LedgerTransferSideSchema),\n destination: v.optional(LedgerTransferSideSchema),\n }),\n v.transform((tr) => {\n const amount = fromU128(tr.amountE18);\n const linkId = tr.linkId && tr.linkId > 0n ? tr.linkId.toString() : undefined;\n\n const output = {\n assetId: tr.assetId,\n amount: scaledToDecimalOutput(amount, E18_SCALE),\n balanceAfter:\n tr.balanceAfterE18 !== undefined\n ? scaledToDecimalOutput(fromU128(tr.balanceAfterE18), E18_SCALE)\n : undefined,\n type: requiredEnumLabel(\n TransferCodeCodec.protoToOutput,\n tr.transferCode,\n \"LedgerTransferSchema\",\n \"transfer code\",\n ),\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n tr.accountCode,\n \"LedgerTransferSchema\",\n \"account code\",\n ),\n timestamp: wireTimestampToMs(tr.tsUs),\n isDebit: tr.isDebit,\n linkId,\n flowId: tr.flowId?.trim() ?? \"\",\n };\n\n return {\n ...output,\n ...(tr.source ? { source: tr.source } : {}),\n ...(tr.destination ? { destination: tr.destination } : {}),\n };\n }),\n);\n\nexport type LedgerTransfer = v.InferOutput<typeof LedgerTransferSchema>;\n\nexport const ListTransfersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n ledger: v.optional(v.number(), 0),\n limit: v.optional(v.number()),\n reversed: v.optional(v.boolean(), false),\n timestampMin: OptionalTimestampMsToUsInputSchema,\n timestampMax: OptionalTimestampMsToUsInputSchema,\n transferCode: v.optional(\n v.pipe(\n v.picklist(TRANSFER_CODE_VALUES),\n v.transform((value) => TransferCodeCodec.inputToProto[value]),\n ),\n ),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, timestampMin, timestampMax, ...input }) => ({\n ...input,\n tsMinUs: timestampMin,\n tsMaxUs: timestampMax,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListTransfersInput = v.InferInput<typeof ListTransfersInputSchema>;\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;AAED,MAAM,2BAA2B,EAAE,MAAM;CACrC,EAAE,OAAO;CACT,EAAE,OAAO;CACT,EAAE,KACE,EAAE,OAAO,GACT,EAAE,MAAM,OAAO,GACf,EAAE,WAAW,UAAU,OAAO,KAAK,CAAC,CACxC;AACJ,CAAC;AAED,MAAM,yBAAyB,EAAE,KAC7B,EAAE,KAAKA,gBAAsB,GAC7B,EAAE,WAAW,SACT,kBAAkB,sBAAsB,eAAe,MAAM,sBAAsB,MAAM,CAC7F,CACJ;AAEA,MAAa,2BAA2B,EAAE,OAAO;CAC7C,MAAM;CACN,WAAW;CACX,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAClC,SAAS,EAAE,SAAS,EAAE,OAAO,CA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,KAAK;CACvC,cAAc;CACd,cAAc;CACd,cAAc,EAAE,SACZ,EAAE,KACE,EAAE,SAAS,oBAAoB,GAC/B,EAAE,WAAW,UAAU,kBAAkB,aAAa,MAAM,CAChE,CACJ;CACA,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,cAAc,cAAc,GAAG,aAAa;CAChE,GAAG;CACH,SAAS;CACT,SAAS;CACT,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN"}
|
|
@@ -809,7 +809,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
|
|
|
809
809
|
declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
810
810
|
readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
|
|
811
811
|
readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
812
|
-
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("
|
|
812
|
+
readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
|
|
813
813
|
readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
|
|
814
814
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
|
|
815
815
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
|
|
@@ -1030,7 +1030,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
|
|
|
1030
1030
|
readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
1031
1031
|
}, undefined>, v.TransformAction<{
|
|
1032
1032
|
limit?: number | undefined;
|
|
1033
|
-
eventType?: "
|
|
1033
|
+
eventType?: "failed" | "updated" | "fired" | "canceled" | undefined;
|
|
1034
1034
|
pageToken: string;
|
|
1035
1035
|
account?: "active" | "main" | {
|
|
1036
1036
|
subaccountId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-input.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"trigger-input.schemas.d.ts","names":[],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"mappings":";;;;;;iBA6VgB,+BAA+B,QAAQ,YAAS,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;KACxB,oBAAoB,EAAE,kBAAkB;cAEvC,0BAAwB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;KAUzB,qBAAqB,EAAE,kBAAkB;iBAErC,+BAA+B,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8DpD,qBAAqB,EAAE,WAAW,kBAAkB;cAEnD,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;KAiB7B,yBAAyB,EAAE,kBAAkB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../../gen/orders/v1/orders_pb.js";
|
|
2
2
|
import { idToBigInt } from "../../utils/base58-id.js";
|
|
3
3
|
import { parseOptionalPositiveBigIntLike, parseOptionalPositiveIntLike } from "../../utils/numbers.js";
|
|
4
|
+
import { PROTOBUF_INT64_MAX } from "../../shared/wire-bounds.js";
|
|
4
5
|
import { idInputSchema } from "../../shared/schemas.js";
|
|
5
|
-
import { PROTOBUF_INT32_MAX, PROTOBUF_INT64_MAX } from "../../shared/wire-bounds.js";
|
|
6
6
|
import { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from "../shared.js";
|
|
7
7
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
8
8
|
import { positiveDecimalInputToScaled } from "../../shared/decimal-surface.js";
|
|
9
9
|
import { OrderSideCodec } from "../orders/order-enums.codecs.js";
|
|
10
|
-
import { parseSlippageInput, parseTrailingDistanceInput } from "../trailing-oneof-inputs.js";
|
|
10
|
+
import { MAX_SLIPPAGE_BPS, parseSlippageInput, parseTrailingDistanceInput } from "../trailing-oneof-inputs.js";
|
|
11
11
|
import "../../gen/triggers/v1/triggers_pb.js";
|
|
12
12
|
import { TRIGGER_EVENT_TYPE_VALUES, TRIGGER_STATUS_FILTER_VALUES, TRIGGER_TYPE_VALUES, TriggerEventTypeCodec, TriggerStatusCodec, TriggerTypeCodec } from "./triggers.codecs.js";
|
|
13
13
|
import { BaseTriggerFieldsSchema, ConditionalExecutionInputSchema, DecimalInputStringSchema, LimitConditionalExecutionInputSchema, TriggerSideInputSchema, TwapExecutionInputSchema, buildConditionalExecution, buildTriggerIntentBase, buildTwapExecution } from "./trigger-child-order.schemas.js";
|
|
@@ -59,7 +59,7 @@ function parseMaxSlippage(scales, slippage) {
|
|
|
59
59
|
fieldName: "maxSlippage",
|
|
60
60
|
ticksCase: "maxSlippageTicks",
|
|
61
61
|
bpsCase: "maxSlippageBps",
|
|
62
|
-
maxBps:
|
|
62
|
+
maxBps: MAX_SLIPPAGE_BPS
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
function parseMaxSlippagePatch(scales, slippage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_INT32_MAX, PROTOBUF_INT64_MAX } from \"../../shared/wire-bounds.js\";\nimport {\n parseOptionalPositiveBigIntLike,\n parseOptionalPositiveIntLike,\n} from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\nimport { parseSlippageInput, parseTrailingDistanceInput } from \"../trailing-oneof-inputs.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\n/** Absolute price slippage, as a decimal price string (e.g. \"0.25\"). */\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst MaxSlippagePatchInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst ActivationPricePatchInputSchema = v.union([DecimalInputStringSchema, NoneInputSchema]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n return parseTrailingDistanceInput(scales, distance, \"trailingDistance\");\n}\n\nfunction parseTwapMilliseconds(\n value: string | number,\n fieldName: \"durationMs\" | \"sliceIntervalMs\",\n minimum: bigint,\n): bigint {\n const parsed = parseOptionalPositiveBigIntLike(value);\n if (parsed === undefined || parsed < minimum || parsed > PROTOBUF_INT64_MAX) {\n throw new Error(\n `${fieldName} must be between ${minimum} and ${PROTOBUF_INT64_MAX} milliseconds`,\n );\n }\n return parsed;\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n): MaxSlippageOneof {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: Number(PROTOBUF_INT32_MAX),\n });\n}\n\nfunction parseMaxSlippagePatch(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippagePatchInputSchema>,\n): MaxSlippageOneof {\n if (slippage.kind === \"none\") {\n return { case: \"maxSlippageTicks\", value: 0 };\n }\n return parseMaxSlippage(scales, slippage);\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"durationMs\", 1_000n)),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"sliceIntervalMs\", 100n)),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n v.check(\n (output) =>\n output.trigger.strategy.value.priceMinTicks <\n output.trigger.strategy.value.priceMaxTicks,\n \"priceMin must be less than priceMax\",\n ),\n );\n}\n\n/** Builds the create-trigger boundary schema using catalog scales keyed by symbol ID. */\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\n/** Public input for creating a standalone trigger. */\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\n/** Public filters for listing triggers in an account scope. */\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbolId: v.optional(SymbolIdInputSchema),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Public filters for listing triggers. */\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(ActivationPricePatchInputSchema),\n maxSlippage: v.optional(MaxSlippagePatchInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n symbolId: input.symbolId,\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : typeof input.activationPrice !== \"string\"\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippagePatch(scales, input.maxSlippage),\n })),\n );\n}\n\n/**\n * A trigger patch. Omitted fields remain unchanged; `{ kind: \"none\" }` clears\n * `activationPrice` or `maxSlippage`.\n */\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListTriggerEventsInput = v.InferInput<typeof ListTriggerEventsInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,oBAAoB,EAAE,SAAS,mBAAmB;AACxD,MAAM,4BAA4B,EAAE,SAAS,4BAA4B;AACzE,MAAM,yBAAyB,EAAE,SAAS,yBAAyB;AAGnE,MAAM,4BAA4B;CAC9B,WAHyB,cAAc,WAGT;CAC9B,GAAG;AACP;AAEA,MAAM,2BAA2B,EAAE,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
|
+
{"version":3,"file":"trigger-input.schemas.js","names":["TriggerSideCodec"],"sources":["../../../src/services/triggers/trigger-input.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { PROTOBUF_INT64_MAX } from \"../../shared/wire-bounds.js\";\nimport {\n parseOptionalPositiveBigIntLike,\n parseOptionalPositiveIntLike,\n} from \"../../utils/numbers.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport {\n TRIGGER_EVENT_TYPE_VALUES,\n TRIGGER_STATUS_FILTER_VALUES,\n TRIGGER_TYPE_VALUES,\n TriggerEventTypeCodec,\n TriggerSideCodec,\n TriggerTypeCodec,\n TriggerStatusCodec,\n} from \"./triggers.codecs.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n BaseTriggerFieldsSchema,\n ConditionalExecutionInputSchema,\n DecimalInputStringSchema,\n LimitConditionalExecutionInputSchema,\n TriggerSideInputSchema,\n TwapExecutionInputSchema,\n buildConditionalExecution,\n buildTriggerIntentBase,\n buildTwapExecution,\n type MaxSlippageOneof,\n type TrailingDistanceOneof,\n} from \"./trigger-child-order.schemas.js\";\nimport {\n MAX_SLIPPAGE_BPS,\n parseSlippageInput,\n parseTrailingDistanceInput,\n} from \"../trailing-oneof-inputs.js\";\n\nconst TriggerTypeSchema = v.picklist(TRIGGER_TYPE_VALUES);\nconst TriggerStatusFilterSchema = v.picklist(TRIGGER_STATUS_FILTER_VALUES);\nconst TriggerEventTypeSchema = v.picklist(TRIGGER_EVENT_TYPE_VALUES);\nconst TriggerIdInputSchema = idInputSchema(\"triggerId\");\n\nconst TriggerScopedInputEntries = {\n triggerId: TriggerIdInputSchema,\n ...AccountScopeInputEntries,\n};\n\nconst TriggerScopedInputSchema = v.pipe(\n v.strictObject(TriggerScopedInputEntries),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Absolute price distance, as a decimal price string (e.g. \"0.50\"). */\nconst PriceDistanceInputSchema = v.strictObject({\n kind: v.literal(\"distance\"),\n distance: DecimalInputStringSchema,\n});\n\n/** Absolute price slippage, as a decimal price string (e.g. \"0.25\"). */\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nconst TrailingDistanceInputSchema = v.union([\n PriceDistanceInputSchema,\n BpsStringOrNumberInputSchema,\n]);\n\nconst MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst MaxSlippagePatchInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\nconst ActivationPricePatchInputSchema = v.union([DecimalInputStringSchema, NoneInputSchema]);\n\nfunction parseTrailingDistance(\n scales: SdkScales,\n distance: v.InferOutput<typeof TrailingDistanceInputSchema>,\n): TrailingDistanceOneof {\n return parseTrailingDistanceInput(scales, distance, \"trailingDistance\");\n}\n\nfunction parseTwapMilliseconds(\n value: string | number,\n fieldName: \"durationMs\" | \"sliceIntervalMs\",\n minimum: bigint,\n): bigint {\n const parsed = parseOptionalPositiveBigIntLike(value);\n if (parsed === undefined || parsed < minimum || parsed > PROTOBUF_INT64_MAX) {\n throw new Error(\n `${fieldName} must be between ${minimum} and ${PROTOBUF_INT64_MAX} milliseconds`,\n );\n }\n return parsed;\n}\n\nfunction parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n): MaxSlippageOneof {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps: MAX_SLIPPAGE_BPS,\n });\n}\n\nfunction parseMaxSlippagePatch(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippagePatchInputSchema>,\n): MaxSlippageOneof {\n if (slippage.kind === \"none\") {\n return { case: \"maxSlippageTicks\", value: 0 };\n }\n return parseMaxSlippage(scales, slippage);\n}\n\nfunction createConditionalTriggerInputSchema<const TriggerType extends \"stop_loss\" | \"take_profit\">(\n scales: SdkScales,\n triggerType: TriggerType,\n) {\n const sharedEntries = {\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(triggerType),\n triggerPrice: DecimalInputStringSchema,\n };\n\n const sellInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"sell\"),\n execution: ConditionalExecutionInputSchema,\n });\n const buyInputSchema = v.strictObject({\n ...sharedEntries,\n side: v.literal(\"buy\"),\n execution: LimitConditionalExecutionInputSchema,\n });\n\n function transformInput(\n input: v.InferOutput<typeof sellInputSchema> | v.InferOutput<typeof buyInputSchema>,\n ) {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n const strategy = {\n triggerPriceTicks: positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n side: TriggerSideCodec.inputToProto[input.side],\n child: buildConditionalExecution(input.execution, scales),\n };\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy:\n triggerType === \"stop_loss\"\n ? ({ case: \"stopLoss\", value: strategy } as const)\n : ({ case: \"takeProfit\", value: strategy } as const),\n },\n };\n }\n\n return [\n v.pipe(\n sellInputSchema,\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input: v.InferOutput<typeof sellInputSchema>) => transformInput(input)),\n ),\n v.pipe(\n buyInputSchema,\n v.transform((input: v.InferOutput<typeof buyInputSchema>) => transformInput(input)),\n ),\n ] as const;\n}\n\nfunction createTrailingStopTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"trailing_stop\"),\n trailingDistance: TrailingDistanceInputSchema,\n activationPrice: v.optional(DecimalInputStringSchema),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.check(\n (input) => input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"Trailing-stop triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"trailingStop\",\n value: {\n trailingDistance: parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n side: ProtoOrders.Side.SELL,\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createTwapTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"twap\"),\n side: TriggerSideInputSchema,\n durationMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"durationMs\", 1_000n)),\n ),\n sliceIntervalMs: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.number()]),\n v.transform((value) => parseTwapMilliseconds(value, \"sliceIntervalMs\", 100n)),\n ),\n execution: TwapExecutionInputSchema,\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.check(\n (input) => input.sliceIntervalMs <= input.durationMs,\n \"sliceIntervalMs cannot exceed durationMs\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"twap\",\n value: {\n side: input.side,\n durationMs: input.durationMs,\n sliceIntervalMs: input.sliceIntervalMs,\n execution: buildTwapExecution(input.execution, scales),\n },\n } as const,\n },\n };\n }),\n );\n}\n\nfunction createLadderTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...BaseTriggerFieldsSchema.entries,\n triggerType: v.literal(\"ladder\"),\n side: TriggerSideInputSchema,\n priceMin: DecimalInputStringSchema,\n priceMax: DecimalInputStringSchema,\n levels: v.pipe(\n v.union([v.pipe(v.string(), v.trim()), v.pipe(v.number(), v.integer())]),\n v.transform((value) => {\n const levels = parseOptionalPositiveIntLike(value);\n if (!levels || levels < 2 || levels > 100) {\n throw new Error(\"levels must be between 2 and 100\");\n }\n return levels;\n }),\n ),\n postOnly: v.optional(v.boolean(), false),\n }),\n v.check(\n (input) =>\n input.side !== ProtoOrders.Side.SELL ||\n input.feeAsset === ProtoOrders.FeeAsset.QUOTE,\n \"SELL triggers must use the quote fee asset\",\n ),\n v.transform((input) => {\n const { subaccountId, intent } = buildTriggerIntentBase(input, scales);\n return {\n subaccountId,\n trigger: {\n ...intent,\n strategy: {\n case: \"ladder\",\n value: {\n side: input.side,\n priceMinTicks: positiveDecimalInputToScaled(\n \"priceMin\",\n input.priceMin,\n scales.price(),\n ),\n priceMaxTicks: positiveDecimalInputToScaled(\n \"priceMax\",\n input.priceMax,\n scales.price(),\n ),\n levels: input.levels,\n postOnly: input.postOnly,\n },\n } as const,\n },\n };\n }),\n v.check(\n (output) =>\n output.trigger.strategy.value.priceMinTicks <\n output.trigger.strategy.value.priceMaxTicks,\n \"priceMin must be less than priceMax\",\n ),\n );\n}\n\n/** Builds the create-trigger boundary schema using catalog scales keyed by symbol ID. */\nexport function createCreateTriggerInputSchema(scales: SdkScales) {\n return v.union([\n ...createConditionalTriggerInputSchema(scales, \"stop_loss\"),\n ...createConditionalTriggerInputSchema(scales, \"take_profit\"),\n createTrailingStopTriggerInputSchema(scales),\n createTwapTriggerInputSchema(scales),\n createLadderTriggerInputSchema(scales),\n ]);\n}\n\n/** Public input for creating a standalone trigger. */\nexport type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInputSchema>>;\n\n/** Public filters for listing triggers in an account scope. */\nexport const ListTriggersInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n parentOrderId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"parentOrderId\") : undefined)),\n ),\n symbolId: v.optional(SymbolIdInputSchema),\n status: v.pipe(\n v.optional(v.array(TriggerStatusFilterSchema)),\n v.transform(\n (values) => values?.map((value) => TriggerStatusCodec.inputToProto[value]) ?? [],\n ),\n ),\n triggerType: v.pipe(\n v.optional(TriggerTypeSchema),\n v.transform((value) =>\n value\n ? TriggerTypeCodec.inputToProto[value]\n : Proto.TriggerType.TRIGGER_TYPE_UNSPECIFIED,\n ),\n ),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Public filters for listing triggers. */\nexport type ListTriggersInput = v.InferInput<typeof ListTriggersInputSchema>;\n\nexport const CancelTriggerInputSchema = TriggerScopedInputSchema;\nexport type CancelTriggerInput = v.InferInput<typeof CancelTriggerInputSchema>;\n\nexport const GetTriggerInputSchema = CancelTriggerInputSchema;\nexport type GetTriggerInput = v.InferInput<typeof GetTriggerInputSchema>;\n\nexport const PauseTriggerInputSchema = TriggerScopedInputSchema;\nexport type PauseTriggerInput = v.InferInput<typeof PauseTriggerInputSchema>;\n\nexport const ResumeTriggerInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\nexport type ResumeTriggerInput = v.InferInput<typeof ResumeTriggerInputSchema>;\n\nexport function createModifyTriggerInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n symbolId: SymbolIdInputSchema,\n triggerPrice: v.optional(DecimalInputStringSchema),\n limitPrice: v.optional(DecimalInputStringSchema),\n trailingDistance: v.optional(TrailingDistanceInputSchema),\n activationPrice: v.optional(ActivationPricePatchInputSchema),\n maxSlippage: v.optional(MaxSlippagePatchInputSchema),\n }),\n v.check(\n (input) =>\n input.triggerPrice !== undefined ||\n input.limitPrice !== undefined ||\n input.trailingDistance !== undefined ||\n input.activationPrice !== undefined ||\n input.maxSlippage !== undefined,\n \"At least one patch field is required\",\n ),\n v.transform(({ account, ...input }) => ({\n triggerId: input.triggerId,\n subaccountId: accountScopeToSubaccountId(account),\n symbolId: input.symbolId,\n triggerPriceTicks:\n input.triggerPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\n \"triggerPrice\",\n input.triggerPrice,\n scales.price(),\n ),\n limitPriceTicks:\n input.limitPrice === undefined\n ? undefined\n : positiveDecimalInputToScaled(\"limitPrice\", input.limitPrice, scales.price()),\n trailingDistance:\n input.trailingDistance === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseTrailingDistance(scales, input.trailingDistance),\n activationPriceTicks:\n input.activationPrice === undefined\n ? undefined\n : typeof input.activationPrice !== \"string\"\n ? 0n\n : positiveDecimalInputToScaled(\n \"activationPrice\",\n input.activationPrice,\n scales.price(),\n ),\n maxSlippage:\n input.maxSlippage === undefined\n ? ({ case: undefined, value: undefined } as const)\n : parseMaxSlippagePatch(scales, input.maxSlippage),\n })),\n );\n}\n\n/**\n * A trigger patch. Omitted fields remain unchanged; `{ kind: \"none\" }` clears\n * `activationPrice` or `maxSlippage`.\n */\nexport type ModifyTriggerInput = v.InferInput<ReturnType<typeof createModifyTriggerInputSchema>>;\n\nexport const ListTriggerEventsInputSchema = v.pipe(\n v.strictObject({\n ...TriggerScopedInputEntries,\n limit: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(1000))),\n eventType: v.optional(TriggerEventTypeSchema),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n eventType:\n input.eventType === undefined\n ? undefined\n : TriggerEventTypeCodec.inputToProto[input.eventType],\n })),\n);\n\nexport type ListTriggerEventsInput = v.InferInput<typeof ListTriggerEventsInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,MAAM,oBAAoB,EAAE,SAAS,mBAAmB;AACxD,MAAM,4BAA4B,EAAE,SAAS,4BAA4B;AACzE,MAAM,yBAAyB,EAAE,SAAS,yBAAyB;AAGnE,MAAM,4BAA4B;CAC9B,WAHyB,cAAc,WAGT;CAC9B,GAAG;AACP;AAEA,MAAM,2BAA2B,EAAE,KAC/B,EAAE,aAAa,yBAAyB,GACxC,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;AAGA,MAAM,2BAA2B,EAAE,aAAa;CAC5C,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;;AAGD,MAAM,2BAA2B,EAAE,aAAa;CAC5C,MAAM,EAAE,QAAQ,UAAU;CAC1B,UAAU;AACd,CAAC;AAED,MAAM,8BAA8B,EAAE,MAAM,CACxC,0BACA,4BACJ,CAAC;AAED,MAAM,yBAAyB,EAAE,MAAM;CACnC;CACA;CACA;AACJ,CAAC;AAED,MAAM,8BAA8B,EAAE,MAAM;CACxC;CACA;CACA;AACJ,CAAC;AAED,MAAM,kCAAkC,EAAE,MAAM,CAAC,0BAA0B,eAAe,CAAC;AAE3F,SAAS,sBACL,QACA,UACqB;CACrB,OAAO,2BA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