@waiaas/actions 2.13.0 → 2.14.0-rc.4

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.
Files changed (34) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +14 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/providers/polymarket/market-schemas.d.ts +2 -2
  6. package/dist/providers/xrpl-dex/__tests__/offer-builder.test.d.ts +2 -0
  7. package/dist/providers/xrpl-dex/__tests__/offer-builder.test.d.ts.map +1 -0
  8. package/dist/providers/xrpl-dex/__tests__/offer-builder.test.js +225 -0
  9. package/dist/providers/xrpl-dex/__tests__/offer-builder.test.js.map +1 -0
  10. package/dist/providers/xrpl-dex/__tests__/orderbook-client.test.d.ts +2 -0
  11. package/dist/providers/xrpl-dex/__tests__/orderbook-client.test.d.ts.map +1 -0
  12. package/dist/providers/xrpl-dex/__tests__/orderbook-client.test.js +321 -0
  13. package/dist/providers/xrpl-dex/__tests__/orderbook-client.test.js.map +1 -0
  14. package/dist/providers/xrpl-dex/__tests__/xrpl-dex-provider.test.d.ts +2 -0
  15. package/dist/providers/xrpl-dex/__tests__/xrpl-dex-provider.test.d.ts.map +1 -0
  16. package/dist/providers/xrpl-dex/__tests__/xrpl-dex-provider.test.js +255 -0
  17. package/dist/providers/xrpl-dex/__tests__/xrpl-dex-provider.test.js.map +1 -0
  18. package/dist/providers/xrpl-dex/index.d.ts +39 -0
  19. package/dist/providers/xrpl-dex/index.d.ts.map +1 -0
  20. package/dist/providers/xrpl-dex/index.js +262 -0
  21. package/dist/providers/xrpl-dex/index.js.map +1 -0
  22. package/dist/providers/xrpl-dex/offer-builder.d.ts +67 -0
  23. package/dist/providers/xrpl-dex/offer-builder.d.ts.map +1 -0
  24. package/dist/providers/xrpl-dex/offer-builder.js +166 -0
  25. package/dist/providers/xrpl-dex/offer-builder.js.map +1 -0
  26. package/dist/providers/xrpl-dex/orderbook-client.d.ts +94 -0
  27. package/dist/providers/xrpl-dex/orderbook-client.d.ts.map +1 -0
  28. package/dist/providers/xrpl-dex/orderbook-client.js +220 -0
  29. package/dist/providers/xrpl-dex/orderbook-client.js.map +1 -0
  30. package/dist/providers/xrpl-dex/schemas.d.ts +95 -0
  31. package/dist/providers/xrpl-dex/schemas.d.ts.map +1 -0
  32. package/dist/providers/xrpl-dex/schemas.js +73 -0
  33. package/dist/providers/xrpl-dex/schemas.js.map +1 -0
  34. package/package.json +4 -3
@@ -0,0 +1,220 @@
1
+ /**
2
+ * XrplOrderbookClient -- XRPL RPC wrapper for orderbook and account queries.
3
+ *
4
+ * Provides:
5
+ * - getOrderbook: book_offers for asks + bids with normalized prices
6
+ * - getAccountOffers: account_offers for active orders
7
+ * - checkTrustLine: account_lines for trust line existence
8
+ * - getAccountReserve: account_info for reserve calculation
9
+ *
10
+ * Uses lazy connection (ensureConnected) and explicit disconnect.
11
+ *
12
+ * @see Phase 02-01 Task 3
13
+ */
14
+ import { Client } from 'xrpl';
15
+ // ---------------------------------------------------------------------------
16
+ // Client
17
+ // ---------------------------------------------------------------------------
18
+ export class XrplOrderbookClient {
19
+ rpcUrl;
20
+ client = null;
21
+ connectingPromise = null;
22
+ constructor(rpcUrl) {
23
+ this.rpcUrl = rpcUrl;
24
+ }
25
+ /**
26
+ * Ensure WebSocket connection is established (lazy connect).
27
+ */
28
+ async ensureConnected() {
29
+ if (this.client?.isConnected())
30
+ return;
31
+ // Prevent concurrent connect attempts
32
+ if (this.connectingPromise) {
33
+ await this.connectingPromise;
34
+ return;
35
+ }
36
+ this.connectingPromise = (async () => {
37
+ try {
38
+ this.client = new Client(this.rpcUrl, { connectionTimeout: 10000 });
39
+ await this.client.connect();
40
+ }
41
+ finally {
42
+ this.connectingPromise = null;
43
+ }
44
+ })();
45
+ await this.connectingPromise;
46
+ }
47
+ /**
48
+ * Close WebSocket connection.
49
+ */
50
+ async disconnect() {
51
+ if (this.client) {
52
+ try {
53
+ await this.client.disconnect();
54
+ }
55
+ catch {
56
+ // ignore disconnect errors
57
+ }
58
+ this.client = null;
59
+ }
60
+ }
61
+ /**
62
+ * Get the underlying xrpl.Client (for testing/direct access).
63
+ */
64
+ getClient() {
65
+ if (!this.client) {
66
+ throw new Error('XrplOrderbookClient: not connected. Call ensureConnected() first.');
67
+ }
68
+ return this.client;
69
+ }
70
+ // -------------------------------------------------------------------------
71
+ // Orderbook queries
72
+ // -------------------------------------------------------------------------
73
+ /**
74
+ * Query orderbook for a trading pair (both ask and bid sides).
75
+ */
76
+ async getOrderbook(base, counter, limit) {
77
+ await this.ensureConnected();
78
+ const client = this.getClient();
79
+ // Asks: offers selling base for counter (taker perspective: taker_gets=base, taker_pays=counter)
80
+ const asksResponse = await client.request({
81
+ command: 'book_offers',
82
+ taker_gets: base,
83
+ taker_pays: counter,
84
+ limit,
85
+ });
86
+ // Bids: offers buying base with counter (taker perspective: taker_gets=counter, taker_pays=base)
87
+ const bidsResponse = await client.request({
88
+ command: 'book_offers',
89
+ taker_gets: counter,
90
+ taker_pays: base,
91
+ limit,
92
+ });
93
+ const asks = (asksResponse.result.offers || []).map((offer) => {
94
+ const getsValue = parseAmountValue(offer.TakerGets);
95
+ const paysValue = parseAmountValue(offer.TakerPays);
96
+ const price = paysValue / getsValue; // counter per base
97
+ return {
98
+ price,
99
+ amount: getsValue,
100
+ total: paysValue,
101
+ ownerFunds: String(offer.owner_funds ?? '0'),
102
+ sequence: offer.Sequence ?? 0,
103
+ };
104
+ });
105
+ const bids = (bidsResponse.result.offers || []).map((offer) => {
106
+ const getsValue = parseAmountValue(offer.TakerGets); // counter
107
+ const paysValue = parseAmountValue(offer.TakerPays); // base
108
+ const price = getsValue / paysValue; // counter per base
109
+ return {
110
+ price,
111
+ amount: paysValue,
112
+ total: getsValue,
113
+ ownerFunds: String(offer.owner_funds ?? '0'),
114
+ sequence: offer.Sequence ?? 0,
115
+ };
116
+ });
117
+ // Calculate spread
118
+ const bestAsk = asks.length > 0 ? asks[0].price : NaN;
119
+ const bestBid = bids.length > 0 ? bids[0].price : NaN;
120
+ const spread = !isNaN(bestAsk) && !isNaN(bestBid) ? bestAsk - bestBid : NaN;
121
+ return { asks, bids, spread };
122
+ }
123
+ /**
124
+ * Query account's active offers.
125
+ */
126
+ async getAccountOffers(account, limit) {
127
+ await this.ensureConnected();
128
+ const client = this.getClient();
129
+ const response = await client.request({
130
+ command: 'account_offers',
131
+ account,
132
+ limit,
133
+ });
134
+ return (response.result.offers || []).map((offer) => ({
135
+ seq: offer.seq,
136
+ takerGets: formatAmountDisplay(offer.taker_gets),
137
+ takerPays: formatAmountDisplay(offer.taker_pays),
138
+ flags: offer.flags ?? 0,
139
+ expiration: offer.expiration,
140
+ }));
141
+ }
142
+ // -------------------------------------------------------------------------
143
+ // Trust line and reserve queries
144
+ // -------------------------------------------------------------------------
145
+ /**
146
+ * Check if a trust line exists for a specific currency/issuer pair.
147
+ */
148
+ async checkTrustLine(account, currency, issuer) {
149
+ await this.ensureConnected();
150
+ const client = this.getClient();
151
+ try {
152
+ const response = await client.request({
153
+ command: 'account_lines',
154
+ account,
155
+ peer: issuer,
156
+ });
157
+ const lines = response.result.lines || [];
158
+ return lines.some((line) => line.currency?.toUpperCase() === currency.toUpperCase());
159
+ }
160
+ catch {
161
+ // If account doesn't exist yet, no trust lines
162
+ return false;
163
+ }
164
+ }
165
+ /**
166
+ * Get account reserve information.
167
+ */
168
+ async getAccountReserve(account) {
169
+ await this.ensureConnected();
170
+ const client = this.getClient();
171
+ const accountInfo = await client.request({
172
+ command: 'account_info',
173
+ account,
174
+ ledger_index: 'validated',
175
+ });
176
+ const accountData = accountInfo.result.account_data;
177
+ const balance = accountData.Balance;
178
+ const ownerCount = (accountData.OwnerCount ?? 0);
179
+ // Default reserves (per amendment status as of 2024)
180
+ const baseReserve = 1_000_000; // 1 XRP (previously 10, reduced by amendment)
181
+ const ownerReserve = 200_000; // 0.2 XRP
182
+ const totalReserve = BigInt(baseReserve) + BigInt(ownerCount) * BigInt(ownerReserve);
183
+ const available = BigInt(balance) - totalReserve;
184
+ const availableBalance = available > 0n ? available.toString() : '0';
185
+ return {
186
+ balance,
187
+ ownerCount,
188
+ baseReserve,
189
+ ownerReserve,
190
+ availableBalance,
191
+ };
192
+ }
193
+ }
194
+ // ---------------------------------------------------------------------------
195
+ // Helpers
196
+ // ---------------------------------------------------------------------------
197
+ /**
198
+ * Parse XRPL Amount to numeric value.
199
+ * XRP: drops string -> drops / 1000000
200
+ * IOU: { value: "100.5" } -> 100.5
201
+ */
202
+ function parseAmountValue(amount) {
203
+ if (typeof amount === 'string') {
204
+ // XRP drops
205
+ return Number(amount) / 1_000_000;
206
+ }
207
+ return parseFloat(amount.value);
208
+ }
209
+ /**
210
+ * Format XRPL Amount for display.
211
+ * XRP: drops string -> "1000000 drops"
212
+ * IOU: { currency, issuer, value } -> "100.5 USD"
213
+ */
214
+ function formatAmountDisplay(amount) {
215
+ if (typeof amount === 'string') {
216
+ return `${amount} drops`;
217
+ }
218
+ return `${amount.value} ${amount.currency}`;
219
+ }
220
+ //# sourceMappingURL=orderbook-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderbook-client.js","sourceRoot":"","sources":["../../../src/providers/xrpl-dex/orderbook-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAwD9B,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,OAAO,mBAAmB;IAID;IAHrB,MAAM,GAAkB,IAAI,CAAC;IAC7B,iBAAiB,GAAyB,IAAI,CAAC;IAEvD,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,IAAI,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE;YAAE,OAAO;QAEvC,sCAAsC;QACtC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3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CAAW,CAAC;QAE3D,qDAAqD;QACrD,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,8CAA8C;QAC7E,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,UAAU;QAExC,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QACrF,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC;QACjD,MAAM,gBAAgB,GAAG,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAErE,OAAO;YACL,OAAO;YACP,UAAU;YACV,WAAW;YACX,YAAY;YACZ,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACtC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,YAAY;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,QAAQ,CAAC;IAC3B,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Zod input schemas for XRPL DEX Provider actions.
3
+ *
4
+ * Token format: "XRP" for native, "{CURRENCY}.{ISSUER}" for IOU
5
+ * (matches parseTrustLineToken convention from @waiaas/adapter-ripple).
6
+ *
7
+ * @see Phase 02-01 Task 1
8
+ */
9
+ import { z } from 'zod';
10
+ export declare const SwapInputSchema: z.ZodObject<{
11
+ /** Token the agent offers (gives away). "XRP" or "CURRENCY.ISSUER". */
12
+ takerGets: z.ZodString;
13
+ /** Amount of takerGets in display units. XRP in drops, IOU in decimal string. */
14
+ takerGetsAmount: z.ZodString;
15
+ /** Token the agent wants to receive. "XRP" or "CURRENCY.ISSUER". */
16
+ takerPays: z.ZodString;
17
+ /** Amount of takerPays in display units. */
18
+ takerPaysAmount: z.ZodString;
19
+ /** Slippage tolerance in basis points (default 50 = 0.5%). */
20
+ slippageBps: z.ZodDefault<z.ZodNumber>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ slippageBps: number;
23
+ takerGets: string;
24
+ takerGetsAmount: string;
25
+ takerPays: string;
26
+ takerPaysAmount: string;
27
+ }, {
28
+ takerGets: string;
29
+ takerGetsAmount: string;
30
+ takerPays: string;
31
+ takerPaysAmount: string;
32
+ slippageBps?: number | undefined;
33
+ }>;
34
+ export type SwapInput = z.infer<typeof SwapInputSchema>;
35
+ export declare const LimitOrderInputSchema: z.ZodObject<{
36
+ /** Token the agent offers (gives away). */
37
+ takerGets: z.ZodString;
38
+ /** Amount of takerGets in display units. */
39
+ takerGetsAmount: z.ZodString;
40
+ /** Token the agent wants to receive. */
41
+ takerPays: z.ZodString;
42
+ /** Amount of takerPays in display units. */
43
+ takerPaysAmount: z.ZodString;
44
+ /** Order expiration in seconds from now (default 86400 = 24h). */
45
+ expirationSeconds: z.ZodDefault<z.ZodNumber>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ takerGets: string;
48
+ takerGetsAmount: string;
49
+ takerPays: string;
50
+ takerPaysAmount: string;
51
+ expirationSeconds: number;
52
+ }, {
53
+ takerGets: string;
54
+ takerGetsAmount: string;
55
+ takerPays: string;
56
+ takerPaysAmount: string;
57
+ expirationSeconds?: number | undefined;
58
+ }>;
59
+ export type LimitOrderInput = z.infer<typeof LimitOrderInputSchema>;
60
+ export declare const CancelOrderInputSchema: z.ZodObject<{
61
+ /** The Sequence number of the offer to cancel (from get_offers result). */
62
+ offerSequence: z.ZodNumber;
63
+ }, "strip", z.ZodTypeAny, {
64
+ offerSequence: number;
65
+ }, {
66
+ offerSequence: number;
67
+ }>;
68
+ export type CancelOrderInput = z.infer<typeof CancelOrderInputSchema>;
69
+ export declare const GetOrderbookInputSchema: z.ZodObject<{
70
+ /** Base token (e.g., "XRP"). */
71
+ base: z.ZodString;
72
+ /** Counter token (e.g., "USD.rIssuer..."). */
73
+ counter: z.ZodString;
74
+ /** Max offers per side (default 20). */
75
+ limit: z.ZodDefault<z.ZodNumber>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ base: string;
78
+ counter: string;
79
+ limit: number;
80
+ }, {
81
+ base: string;
82
+ counter: string;
83
+ limit?: number | undefined;
84
+ }>;
85
+ export type GetOrderbookInput = z.infer<typeof GetOrderbookInputSchema>;
86
+ export declare const GetOffersInputSchema: z.ZodObject<{
87
+ /** Max offers to return (default 50). */
88
+ limit: z.ZodDefault<z.ZodNumber>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ limit: number;
91
+ }, {
92
+ limit?: number | undefined;
93
+ }>;
94
+ export type GetOffersInput = z.infer<typeof GetOffersInputSchema>;
95
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/providers/xrpl-dex/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,eAAO,MAAM,eAAe;IAC1B,uEAAuE;;IAEvE,iFAAiF;;IAEjF,oEAAoE;;IAEpE,4CAA4C;;IAE5C,8DAA8D;;;;;;;;;;;;;;EAE9D,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAMxD,eAAO,MAAM,qBAAqB;IAChC,2CAA2C;;IAE3C,4CAA4C;;IAE5C,wCAAwC;;IAExC,4CAA4C;;IAE5C,kEAAkE;;;;;;;;;;;;;;EAElE,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE,eAAO,MAAM,sBAAsB;IACjC,2EAA2E;;;;;;EAE3E,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMtE,eAAO,MAAM,uBAAuB;IAClC,gCAAgC;;IAEhC,8CAA8C;;IAE9C,wCAAwC;;;;;;;;;;EAExC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAMxE,eAAO,MAAM,oBAAoB;IAC/B,yCAAyC;;;;;;EAEzC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Zod input schemas for XRPL DEX Provider actions.
3
+ *
4
+ * Token format: "XRP" for native, "{CURRENCY}.{ISSUER}" for IOU
5
+ * (matches parseTrustLineToken convention from @waiaas/adapter-ripple).
6
+ *
7
+ * @see Phase 02-01 Task 1
8
+ */
9
+ import { z } from 'zod';
10
+ // ---------------------------------------------------------------------------
11
+ // Shared token string pattern
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * Token identifier: "XRP" for native, or "CURRENCY.rISSUER" (dot-separated) for IOU.
15
+ * Examples: "XRP", "USD.rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
16
+ */
17
+ const tokenString = z.string().min(1, 'Token identifier is required');
18
+ // ---------------------------------------------------------------------------
19
+ // SwapInputSchema -- Immediate or Cancel swap
20
+ // ---------------------------------------------------------------------------
21
+ export const SwapInputSchema = z.object({
22
+ /** Token the agent offers (gives away). "XRP" or "CURRENCY.ISSUER". */
23
+ takerGets: tokenString.describe('Token to sell (e.g., "XRP" or "USD.rIssuer...")'),
24
+ /** Amount of takerGets in display units. XRP in drops, IOU in decimal string. */
25
+ takerGetsAmount: z.string().min(1, 'takerGetsAmount is required'),
26
+ /** Token the agent wants to receive. "XRP" or "CURRENCY.ISSUER". */
27
+ takerPays: tokenString.describe('Token to buy (e.g., "USD.rIssuer..." or "XRP")'),
28
+ /** Amount of takerPays in display units. */
29
+ takerPaysAmount: z.string().min(1, 'takerPaysAmount is required'),
30
+ /** Slippage tolerance in basis points (default 50 = 0.5%). */
31
+ slippageBps: z.number().int().min(1).max(500).default(50),
32
+ });
33
+ // ---------------------------------------------------------------------------
34
+ // LimitOrderInputSchema -- Passive order on the orderbook
35
+ // ---------------------------------------------------------------------------
36
+ export const LimitOrderInputSchema = z.object({
37
+ /** Token the agent offers (gives away). */
38
+ takerGets: tokenString.describe('Token to sell'),
39
+ /** Amount of takerGets in display units. */
40
+ takerGetsAmount: z.string().min(1, 'takerGetsAmount is required'),
41
+ /** Token the agent wants to receive. */
42
+ takerPays: tokenString.describe('Token to buy'),
43
+ /** Amount of takerPays in display units. */
44
+ takerPaysAmount: z.string().min(1, 'takerPaysAmount is required'),
45
+ /** Order expiration in seconds from now (default 86400 = 24h). */
46
+ expirationSeconds: z.number().int().min(60).max(2592000).default(86400),
47
+ });
48
+ // ---------------------------------------------------------------------------
49
+ // CancelOrderInputSchema -- Cancel an existing offer
50
+ // ---------------------------------------------------------------------------
51
+ export const CancelOrderInputSchema = z.object({
52
+ /** The Sequence number of the offer to cancel (from get_offers result). */
53
+ offerSequence: z.number().int().positive(),
54
+ });
55
+ // ---------------------------------------------------------------------------
56
+ // GetOrderbookInputSchema -- Query orderbook depth
57
+ // ---------------------------------------------------------------------------
58
+ export const GetOrderbookInputSchema = z.object({
59
+ /** Base token (e.g., "XRP"). */
60
+ base: tokenString.describe('Base token for the trading pair'),
61
+ /** Counter token (e.g., "USD.rIssuer..."). */
62
+ counter: tokenString.describe('Counter/quote token for the trading pair'),
63
+ /** Max offers per side (default 20). */
64
+ limit: z.number().int().min(1).max(400).default(20),
65
+ });
66
+ // ---------------------------------------------------------------------------
67
+ // GetOffersInputSchema -- Query account's active offers
68
+ // ---------------------------------------------------------------------------
69
+ export const GetOffersInputSchema = z.object({
70
+ /** Max offers to return (default 50). */
71
+ limit: z.number().int().min(1).max(400).default(50),
72
+ });
73
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/providers/xrpl-dex/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC,CAAC;AAEtE,8EAA8E;AAC9E,8CAA8C;AAC9C,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,uEAAuE;IACvE,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAClF,iFAAiF;IACjF,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACjE,oEAAoE;IACpE,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,gDAAgD,CAAC;IACjF,4CAA4C;IAC5C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACjE,8DAA8D;IAC9D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC1D,C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CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACpD,CAAC,CAAC;AAIH,8EAA8E;AAC9E,wDAAwD;AACxD,8EAA8E;AAE9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,yCAAyC;IACzC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACpD,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waiaas/actions",
3
- "version": "2.13.0",
3
+ "version": "2.14.0-rc.4",
4
4
  "description": "WAIaaS built-in DeFi Action Provider implementations",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,12 +31,13 @@
31
31
  "@msgpack/msgpack": "^3.1.3",
32
32
  "viem": "^2.21.0",
33
33
  "zod": "^3.24.0",
34
- "@waiaas/core": "2.13.0"
34
+ "@waiaas/core": "2.14.0-rc.4"
35
35
  },
36
36
  "optionalDependencies": {
37
37
  "@kamino-finance/klend-sdk": "^3.2.26",
38
38
  "@drift-labs/sdk": "^2.106.0",
39
- "@solana/web3.js": "^1.98.0"
39
+ "@solana/web3.js": "^1.98.0",
40
+ "xrpl": "^4.6.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@types/node": "^25.2.3",