@xoxno/sdk-js 1.0.228 → 1.0.229

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.
@@ -10,7 +10,7 @@ import { xdr } from '@stellar/stellar-sdk';
10
10
  * On-chain swap venues, validated at runtime for a caller-supplied venue.
11
11
  * Mirrors the Soroban-only aggregator router's opcode table.
12
12
  */
13
- export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "Sushi", "CometDex"];
13
+ export declare const STELLAR_SWAP_VENUES: readonly ["Soroswap", "Aquarius", "Phoenix", "Sushi", "CometDex", "Curve"];
14
14
  export type StellarSwapVenue = (typeof STELLAR_SWAP_VENUES)[number];
15
15
  /**
16
16
  * Instruction opcode per venue. Part of the on-chain ABI — see
@@ -24,7 +24,7 @@ function _define_property(obj, key, value) {
24
24
  */ import { Address, Asset, scValToBigInt, StrKey, xdr } from "@stellar/stellar-sdk";
25
25
  import { STELLAR_NETWORK_PASSPHRASE } from "./contracts.js";
26
26
  import { xdrBytes, xdrField, xdrType } from "./xdr-compat.js";
27
- import { asStellarStrategySwapBytes, MAX_AMOUNTS, MAX_ASSETS, MAX_OPS, MAX_WEIGHTS, MODE_ALL, MODE_FIXED_BASE, MODE_PPM_BASE, MODE_PREV, OP_BURN, OP_MINT, PPM_DENOMINATOR, STELLAR_PROGRAM_VERSION, STELLAR_SWAP_VENUES } from "./scval-encode.js";
27
+ import { asStellarStrategySwapBytes, MAX_AMOUNTS, MAX_ASSETS, MAX_OPS, MAX_WEIGHTS, MODE_ALL, MODE_FIXED_BASE, MODE_PPM_BASE, MODE_PREV, OP_BURN, OP_MINT, PPM_DENOMINATOR, STELLAR_PROGRAM_VERSION, STELLAR_SWAP_VENUES, STELLAR_SWAP_VENUE_OPCODE } from "./scval-encode.js";
28
28
  const HEADER_LEN = 10;
29
29
  const OP_LEN = 5;
30
30
  const WEIGHT_LEN = 3;
@@ -164,7 +164,10 @@ const readPayloadFields = (buf)=>{
164
164
  const idxA = byte(at + 2);
165
165
  const idxB = byte(at + 3);
166
166
  const idxC = byte(at + 4);
167
- if (opcode > OP_MINT) fail('UNKNOWN_OPCODE', `instruction ${i} has opcode ${opcode}`);
167
+ const venue = STELLAR_SWAP_VENUES.find((value)=>STELLAR_SWAP_VENUE_OPCODE[value] === opcode);
168
+ if (!venue && opcode !== OP_BURN && opcode !== OP_MINT) {
169
+ fail('UNKNOWN_OPCODE', `instruction ${i} has opcode ${opcode}`);
170
+ }
168
171
  let mode;
169
172
  if (modeByte === MODE_ALL) {
170
173
  mode = {
@@ -208,7 +211,7 @@ const readPayloadFields = (buf)=>{
208
211
  if (idxB === idxC) fail('INVALID_STRUCTURE', `instruction ${i} swaps a token for itself`);
209
212
  decoded.push({
210
213
  kind: 'swap',
211
- venue: STELLAR_SWAP_VENUES[opcode],
214
+ venue: venue,
212
215
  mode,
213
216
  pool,
214
217
  tokenIn: asset(idxB),
@@ -27,7 +27,8 @@ import { Buffer } from "buffer";
27
27
  'Aquarius',
28
28
  'Phoenix',
29
29
  'Sushi',
30
- 'CometDex'
30
+ 'CometDex',
31
+ 'Curve'
31
32
  ];
32
33
  /**
33
34
  * Instruction opcode per venue. Part of the on-chain ABI — see
@@ -37,7 +38,8 @@ import { Buffer } from "buffer";
37
38
  Aquarius: 1,
38
39
  Phoenix: 2,
39
40
  Sushi: 3,
40
- CometDex: 4
41
+ CometDex: 4,
42
+ Curve: 7
41
43
  };
42
44
  /** Wire version of the packed program. Must match the contract's `VERSION`. */ export const STELLAR_PROGRAM_VERSION = 1;
43
45
  /** Split weights are parts per million. */ export const PPM_DENOMINATOR = 1000000;