@cetusprotocol/aggregator-sdk 0.3.31 → 0.4.0

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/dist/index.mjs CHANGED
@@ -5631,6 +5631,8 @@ function getAggregatorServerErrorMessage(code) {
5631
5631
  return "Insufficient Liquidity";
5632
5632
  case 10004 /* HoneyPot */:
5633
5633
  return "Target token is detected as a HoneyPot scam";
5634
+ case 10005 /* RateLimitExceeded */:
5635
+ return "Too many requests. Please try again later";
5634
5636
  default:
5635
5637
  return "Unknown error";
5636
5638
  }
@@ -6418,6 +6420,67 @@ var Metastable = class {
6418
6420
  }
6419
6421
  };
6420
6422
 
6423
+ // src/transaction/obric.ts
6424
+ var Obric = class {
6425
+ constructor(env, pythPriceIDs) {
6426
+ if (env === 1 /* Testnet */) {
6427
+ throw new Error("Obric is not supported on testnet");
6428
+ }
6429
+ this.pythPriceIDs = pythPriceIDs;
6430
+ this.pythStateObjectId = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
6431
+ }
6432
+ swap(client, txb, path, inputCoin, packages) {
6433
+ return __async(this, null, function* () {
6434
+ const { direction, from, target } = path;
6435
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6436
+ let coinAPriceSeed;
6437
+ let coinBPriceSeed;
6438
+ let coinAPriceInfoObjectId;
6439
+ let coinBPriceInfoObjectId;
6440
+ if (path.extendedDetails == null) {
6441
+ throw new Error("Extended details not supported in obric");
6442
+ } else {
6443
+ if (path.extendedDetails.obricCoinAPriceSeed && path.extendedDetails.obricCoinBPriceSeed) {
6444
+ coinAPriceSeed = path.extendedDetails.obricCoinAPriceSeed;
6445
+ coinAPriceInfoObjectId = this.pythPriceIDs.get(coinAPriceSeed);
6446
+ coinBPriceSeed = path.extendedDetails.obricCoinBPriceSeed;
6447
+ coinBPriceInfoObjectId = this.pythPriceIDs.get(coinBPriceSeed);
6448
+ } else {
6449
+ if (!path.extendedDetails.obricCoinAPriceId || !path.extendedDetails.obricCoinBPriceId) {
6450
+ throw new Error("Base price id or quote price id not supported");
6451
+ } else {
6452
+ coinAPriceInfoObjectId = path.extendedDetails.obricCoinAPriceId;
6453
+ coinBPriceInfoObjectId = path.extendedDetails.obricCoinBPriceId;
6454
+ }
6455
+ }
6456
+ }
6457
+ if (!coinAPriceInfoObjectId || !coinBPriceInfoObjectId) {
6458
+ throw new Error(
6459
+ "Base price info object id or quote price info object id not found"
6460
+ );
6461
+ }
6462
+ const args = [
6463
+ txb.object(path.id),
6464
+ inputCoin,
6465
+ txb.object(this.pythStateObjectId),
6466
+ txb.object(coinAPriceInfoObjectId),
6467
+ txb.object(coinBPriceInfoObjectId),
6468
+ txb.object(CLOCK_ADDRESS)
6469
+ ];
6470
+ const publishedAt = getAggregatorV2ExtendPublishedAt(
6471
+ client.publishedAtV2Extend(),
6472
+ packages
6473
+ );
6474
+ const res = txb.moveCall({
6475
+ target: `${publishedAt}::obric::${func}`,
6476
+ typeArguments: [coinAType, coinBType],
6477
+ arguments: args
6478
+ });
6479
+ return res;
6480
+ });
6481
+ }
6482
+ };
6483
+
6421
6484
  // src/client.ts
6422
6485
  var CETUS = "CETUS";
6423
6486
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6440,6 +6503,7 @@ var ALPHAFI = "ALPHAFI";
6440
6503
  var SPRINGSUI = "SPRINGSUI";
6441
6504
  var STEAMM = "STEAMM";
6442
6505
  var METASTABLE = "METASTABLE";
6506
+ var OBRIC = "OBRIC";
6443
6507
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6444
6508
  function isBuilderRouterSwapParams(params) {
6445
6509
  return Array.isArray(params.routers);
@@ -6509,6 +6573,62 @@ var _AggregatorClient = class _AggregatorClient {
6509
6573
  return getRouterResult(this.endpoint, params);
6510
6574
  });
6511
6575
  }
6576
+ executeFlexibleInputSwap(txb, inputCoin, routers, amountOutLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
6577
+ return __async(this, null, function* () {
6578
+ if (routers.length === 0) {
6579
+ throw new Error("No router found");
6580
+ }
6581
+ const outputCoinType = routers[0].path[routers[0].path.length - 1].target;
6582
+ const outputCoins = [];
6583
+ for (let i = 0; i < routers.length - 1; i++) {
6584
+ if (routers[i].path.length === 0) {
6585
+ throw new Error("Empty path");
6586
+ }
6587
+ const splitCoin = txb.splitCoins(inputCoin, [routers[i].amountIn.toString()]);
6588
+ let nextCoin = splitCoin[0];
6589
+ for (const path of routers[i].path) {
6590
+ const dex = this.newDex(path.provider, pythPriceIDs, partner);
6591
+ nextCoin = yield dex.swap(
6592
+ this,
6593
+ txb,
6594
+ path,
6595
+ nextCoin,
6596
+ packages,
6597
+ deepbookv3DeepFee
6598
+ );
6599
+ }
6600
+ outputCoins.push(nextCoin);
6601
+ }
6602
+ if (routers[routers.length - 1].path.length === 0) {
6603
+ throw new Error("Empty path");
6604
+ }
6605
+ let lastCoin = inputCoin;
6606
+ for (const path of routers[routers.length - 1].path) {
6607
+ const dex = this.newDex(path.provider, pythPriceIDs, partner);
6608
+ lastCoin = yield dex.swap(
6609
+ this,
6610
+ txb,
6611
+ path,
6612
+ lastCoin,
6613
+ packages,
6614
+ deepbookv3DeepFee
6615
+ );
6616
+ }
6617
+ outputCoins.push(lastCoin);
6618
+ const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
6619
+ this.publishedAtV2(),
6620
+ packages
6621
+ );
6622
+ const mergedTargetCoin = this.checkCoinThresholdAndMergeCoin(
6623
+ txb,
6624
+ outputCoins,
6625
+ outputCoinType,
6626
+ amountOutLimit,
6627
+ aggregatorV2PublishedAt
6628
+ );
6629
+ return mergedTargetCoin;
6630
+ });
6631
+ }
6512
6632
  expectInputSwap(txb, inputCoin, routers, amountOutLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
6513
6633
  return __async(this, null, function* () {
6514
6634
  if (routers.length === 0) {
@@ -6687,6 +6807,53 @@ var _AggregatorClient = class _AggregatorClient {
6687
6807
  return targetCoin;
6688
6808
  });
6689
6809
  }
6810
+ fixableRouterSwap(params) {
6811
+ return __async(this, null, function* () {
6812
+ const { routers, inputCoin, slippage, txb, partner, deepbookv3DeepFee } = params;
6813
+ const routerData = Array.isArray(routers) ? routers : routers.routes;
6814
+ const byAmountIn = params.routers.byAmountIn;
6815
+ const amountIn = routerData.reduce(
6816
+ (acc, router) => acc.add(router.amountIn),
6817
+ new import_bn5.default(0)
6818
+ );
6819
+ const amountOut = routerData.reduce(
6820
+ (acc, router) => acc.add(router.amountOut),
6821
+ new import_bn5.default(0)
6822
+ );
6823
+ const amountLimit = CalculateAmountLimitBN(
6824
+ byAmountIn ? amountOut : amountIn,
6825
+ byAmountIn,
6826
+ slippage
6827
+ );
6828
+ const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
6829
+ getAggregatorV2PublishedAt(
6830
+ this.publishedAtV2(),
6831
+ packages
6832
+ );
6833
+ const priceIDs = findPythPriceIDs(routerData);
6834
+ const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
6835
+ if (byAmountIn) {
6836
+ const targetCoin2 = yield this.executeFlexibleInputSwap(
6837
+ txb,
6838
+ inputCoin,
6839
+ routerData,
6840
+ amountLimit,
6841
+ priceInfoObjectIds,
6842
+ partner,
6843
+ deepbookv3DeepFee,
6844
+ packages
6845
+ );
6846
+ return targetCoin2;
6847
+ }
6848
+ const targetCoin = yield this.expectOutputSwap(
6849
+ txb,
6850
+ inputCoin,
6851
+ routerData,
6852
+ partner
6853
+ );
6854
+ return targetCoin;
6855
+ });
6856
+ }
6690
6857
  // auto build input coin
6691
6858
  // auto merge, transfer or destory target coin.
6692
6859
  fastRouterSwap(params) {
@@ -6790,7 +6957,7 @@ var _AggregatorClient = class _AggregatorClient {
6790
6957
  // Include deepbookv3, scallop, bluefin
6791
6958
  publishedAtV2Extend() {
6792
6959
  if (this.env === 0 /* Mainnet */) {
6793
- return "0x34ef25b60b51f9d07cd9b7dc5b08dfdf26c7b0ff00c57bb17454c161fa6b6b83";
6960
+ return "0x200e762fa2c49f3dc150813038fbf22fd4f894ac6f23ebe1085c62f2ef97f1ca";
6794
6961
  } else {
6795
6962
  return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
6796
6963
  }
@@ -6871,6 +7038,8 @@ var _AggregatorClient = class _AggregatorClient {
6871
7038
  return new Steamm(this.env);
6872
7039
  case METASTABLE:
6873
7040
  return new Metastable(this.env, pythPriceIDs);
7041
+ case OBRIC:
7042
+ return new Obric(this.env, pythPriceIDs);
6874
7043
  default:
6875
7044
  throw new Error(`Unsupported dex ${provider}`);
6876
7045
  }
@@ -6978,7 +7147,7 @@ _AggregatorClient.CONFIG = {
6978
7147
  pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
6979
7148
  }
6980
7149
  };
6981
- var AggregatorClient21 = _AggregatorClient;
7150
+ var AggregatorClient22 = _AggregatorClient;
6982
7151
  function findPythPriceIDs(routes) {
6983
7152
  const priceIDs = /* @__PURE__ */ new Set();
6984
7153
  for (const route of routes) {
@@ -6997,6 +7166,14 @@ function findPythPriceIDs(routes) {
6997
7166
  priceIDs.add(path.extendedDetails.metastableETHPriceSeed);
6998
7167
  }
6999
7168
  }
7169
+ if (path.provider === OBRIC) {
7170
+ if (path.extendedDetails && path.extendedDetails.obricCoinAPriceSeed) {
7171
+ priceIDs.add(path.extendedDetails.obricCoinAPriceSeed);
7172
+ }
7173
+ if (path.extendedDetails && path.extendedDetails.obricCoinBPriceSeed) {
7174
+ priceIDs.add(path.extendedDetails.obricCoinBPriceSeed);
7175
+ }
7176
+ }
7000
7177
  }
7001
7178
  }
7002
7179
  return Array.from(priceIDs);
@@ -7025,13 +7202,13 @@ function parseRouterResponse(data, byAmountIn) {
7025
7202
  routes: data.routes.map((route) => {
7026
7203
  return {
7027
7204
  path: route.path.map((path) => {
7028
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
7205
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
7029
7206
  let version;
7030
7207
  if (path.provider === AFTERMATH) {
7031
7208
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
7032
7209
  }
7033
7210
  let extendedDetails;
7034
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM || path.provider === METASTABLE) {
7211
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM || path.provider === METASTABLE || path.provider === OBRIC) {
7035
7212
  extendedDetails = {
7036
7213
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
7037
7214
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
@@ -7053,7 +7230,11 @@ function parseRouterResponse(data, byAmountIn) {
7053
7230
  metastableCreateCapPkgId: (_r = path.extended_details) == null ? void 0 : _r.metastable_create_cap_pkg_id,
7054
7231
  metastableCreateCapModule: (_s = path.extended_details) == null ? void 0 : _s.metastable_create_cap_module,
7055
7232
  metastableCreateCapAllTypeParams: (_t = path.extended_details) == null ? void 0 : _t.metastable_create_cap_all_type_params,
7056
- metastableRegistryId: (_u = path.extended_details) == null ? void 0 : _u.metastable_registry_id
7233
+ metastableRegistryId: (_u = path.extended_details) == null ? void 0 : _u.metastable_registry_id,
7234
+ obricCoinAPriceSeed: (_v = path.extended_details) == null ? void 0 : _v.obric_coin_a_price_seed,
7235
+ obricCoinBPriceSeed: (_w = path.extended_details) == null ? void 0 : _w.obric_coin_b_price_seed,
7236
+ obricCoinAPriceId: (_x = path.extended_details) == null ? void 0 : _x.obric_coin_a_price_id,
7237
+ obricCoinBPriceId: (_y = path.extended_details) == null ? void 0 : _y.obric_coin_b_price_id
7057
7238
  };
7058
7239
  }
7059
7240
  return {
@@ -7100,23 +7281,34 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
7100
7281
  // src/utils/msafe.ts
7101
7282
  var import_bn6 = __toESM(require_bn());
7102
7283
  var dealWithFastRouterSwapParamsForMsafe = (data) => {
7103
- const result = data == null ? void 0 : data.map((item) => {
7104
- var _a, _b, _c;
7105
- return __spreadProps(__spreadValues({}, item), {
7106
- amountIn: (_a = item == null ? void 0 : item.amountIn) == null ? void 0 : _a.toString(),
7107
- amountOut: (_b = item == null ? void 0 : item.amountOut) == null ? void 0 : _b.toString(),
7108
- initialPrice: (_c = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c.toString()
7109
- });
7284
+ var _a, _b, _c;
7285
+ const result = __spreadProps(__spreadValues({}, data), {
7286
+ amountIn: (_a = data == null ? void 0 : data.amountIn) == null ? void 0 : _a.toString(),
7287
+ amountOut: (_b = data == null ? void 0 : data.amountIn) == null ? void 0 : _b.toString(),
7288
+ routes: (_c = data == null ? void 0 : data.routes) == null ? void 0 : _c.map((item) => {
7289
+ var _a2, _b2, _c2;
7290
+ return __spreadProps(__spreadValues({}, item), {
7291
+ amountIn: (_a2 = item == null ? void 0 : item.amountIn) == null ? void 0 : _a2.toString(),
7292
+ amountOut: (_b2 = item == null ? void 0 : item.amountOut) == null ? void 0 : _b2.toString(),
7293
+ initialPrice: (_c2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _c2.toString()
7294
+ });
7295
+ })
7110
7296
  });
7111
7297
  return result;
7112
7298
  };
7113
7299
  var restituteMsafeFastRouterSwapParams = (data) => {
7114
- const result = data == null ? void 0 : data.map((item) => {
7115
- return __spreadProps(__spreadValues({}, item), {
7116
- amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
7117
- amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
7118
- initialPrice: new decimal_default(item == null ? void 0 : item.initialPrice)
7119
- });
7300
+ var _a;
7301
+ const result = __spreadProps(__spreadValues({}, data), {
7302
+ amountIn: new import_bn6.default(data == null ? void 0 : data.amountIn),
7303
+ amountOut: new import_bn6.default(data == null ? void 0 : data.amountIn),
7304
+ routes: (_a = data == null ? void 0 : data.routes) == null ? void 0 : _a.map((item) => {
7305
+ var _a2;
7306
+ return __spreadProps(__spreadValues({}, item), {
7307
+ amountIn: new import_bn6.default(item == null ? void 0 : item.amountIn),
7308
+ amountOut: new import_bn6.default(item == null ? void 0 : item.amountOut),
7309
+ initialPrice: new decimal_default((_a2 = item == null ? void 0 : item.initialPrice) == null ? void 0 : _a2.toString())
7310
+ });
7311
+ })
7120
7312
  });
7121
7313
  return result;
7122
7314
  };
@@ -7130,7 +7322,7 @@ function processEndpoint(endpoint) {
7130
7322
  }
7131
7323
 
7132
7324
  // src/api.ts
7133
- var SDK_VERSION = 1000331;
7325
+ var SDK_VERSION = 1000400;
7134
7326
  function getRouterResult(endpoint, params) {
7135
7327
  return __async(this, null, function* () {
7136
7328
  let response;
@@ -7143,6 +7335,10 @@ function getRouterResult(endpoint, params) {
7143
7335
  return null;
7144
7336
  }
7145
7337
  if (!response.ok) {
7338
+ let errorCode = 10001 /* NumberTooLarge */;
7339
+ if (response.status === 429) {
7340
+ errorCode = 10005 /* RateLimitExceeded */;
7341
+ }
7146
7342
  return {
7147
7343
  amountIn: ZERO,
7148
7344
  amountOut: ZERO,
@@ -7150,10 +7346,8 @@ function getRouterResult(endpoint, params) {
7150
7346
  byAmountIn: params.byAmountIn,
7151
7347
  insufficientLiquidity: false,
7152
7348
  error: {
7153
- code: 10001 /* NumberTooLarge */,
7154
- msg: getAggregatorServerErrorMessage(
7155
- 10001 /* NumberTooLarge */
7156
- )
7349
+ code: errorCode,
7350
+ msg: getAggregatorServerErrorMessage(errorCode)
7157
7351
  }
7158
7352
  };
7159
7353
  }
@@ -7318,4 +7512,4 @@ decimal.js/decimal.mjs:
7318
7512
  *)
7319
7513
  */
7320
7514
 
7321
- export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient21 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, METASTABLE, ONE, SCALLOP, SPRINGSUI, STEAMM, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
7515
+ export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient22 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, METASTABLE, OBRIC, ONE, SCALLOP, SPRINGSUI, STEAMM, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/src/api.d.ts CHANGED
@@ -41,6 +41,10 @@ export type ExtendedDetails = {
41
41
  metastableCreateCapModule?: string;
42
42
  metastableCreateCapAllTypeParams?: boolean;
43
43
  metastableRegistryId?: string;
44
+ obricCoinAPriceSeed?: string;
45
+ obricCoinBPriceSeed?: string;
46
+ obricCoinAPriceId?: string;
47
+ obricCoinBPriceId?: string;
44
48
  };
45
49
  export type Path = {
46
50
  id: string;
@@ -25,6 +25,7 @@ export declare const ALPHAFI = "ALPHAFI";
25
25
  export declare const SPRINGSUI = "SPRINGSUI";
26
26
  export declare const STEAMM = "STEAMM";
27
27
  export declare const METASTABLE = "METASTABLE";
28
+ export declare const OBRIC = "OBRIC";
28
29
  export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
29
30
  export type BuildRouterSwapParams = {
30
31
  routers: Router[];
@@ -83,10 +84,12 @@ export declare class AggregatorClient {
83
84
  constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
84
85
  getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
85
86
  findRouters(params: FindRouterParams): Promise<RouterData | null>;
87
+ executeFlexibleInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
86
88
  expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
87
89
  expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
88
90
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
89
91
  routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
92
+ fixableRouterSwap(params: BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
90
93
  fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
91
94
  publishedAtV2(): string;
92
95
  publishedAtV2Extend(): string;
@@ -34,6 +34,7 @@ export declare enum AggregatorServerErrorCode {
34
34
  NumberTooLarge = 10001,
35
35
  NoRouter = 10002,
36
36
  InsufficientLiquidity = 10003,
37
- HoneyPot = 10004
37
+ HoneyPot = 10004,
38
+ RateLimitExceeded = 10005
38
39
  }
39
40
  export declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Obric implements Dex {
4
+ private pythPriceIDs;
5
+ private pythStateObjectId;
6
+ constructor(env: Env, pythPriceIDs: Map<string, string>);
7
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
2
+ export declare function buildTestAccount(): Ed25519Keypair;
@@ -0,0 +1,2 @@
1
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
2
+ export declare function buildTestAccount(): Ed25519Keypair;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.31",
3
+ "version": "0.4.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from "./errors"
9
9
  import { parseRouterResponse } from "./client"
10
10
 
11
- const SDK_VERSION = 1000331
11
+ const SDK_VERSION = 1000400
12
12
 
13
13
  export interface FindRouterParams {
14
14
  from: string
@@ -60,6 +60,10 @@ export type ExtendedDetails = {
60
60
  metastableCreateCapModule?: string
61
61
  metastableCreateCapAllTypeParams?: boolean
62
62
  metastableRegistryId?: string
63
+ obricCoinAPriceSeed?: string
64
+ obricCoinBPriceSeed?: string
65
+ obricCoinAPriceId?: string
66
+ obricCoinBPriceId?: string
63
67
  }
64
68
 
65
69
  export type Path = {
@@ -120,6 +124,11 @@ export async function getRouterResult(
120
124
  }
121
125
 
122
126
  if (!response.ok) {
127
+ let errorCode = AggregatorServerErrorCode.NumberTooLarge
128
+ if (response.status === 429) {
129
+ errorCode = AggregatorServerErrorCode.RateLimitExceeded
130
+ }
131
+
123
132
  return {
124
133
  amountIn: ZERO,
125
134
  amountOut: ZERO,
@@ -127,10 +136,8 @@ export async function getRouterResult(
127
136
  byAmountIn: params.byAmountIn,
128
137
  insufficientLiquidity: false,
129
138
  error: {
130
- code: AggregatorServerErrorCode.NumberTooLarge,
131
- msg: getAggregatorServerErrorMessage(
132
- AggregatorServerErrorCode.NumberTooLarge
133
- ),
139
+ code: errorCode,
140
+ msg: getAggregatorServerErrorMessage(errorCode),
134
141
  },
135
142
  }
136
143
  }