@7kprotocol/sdk-ts 3.4.2-beta.7 → 3.4.2-beta.9

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.
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.MetaAg = void 0;
37
37
  const client_1 = require("@mysten/sui/client");
38
38
  const transactions_1 = require("@mysten/sui/transactions");
39
+ const utils_1 = require("@mysten/sui/utils");
39
40
  const _7k_1 = require("../../constants/_7k");
40
41
  const sui_1 = require("../../constants/sui");
41
42
  const metaAg_1 = require("../../types/metaAg");
@@ -99,6 +100,7 @@ class MetaAg {
99
100
  coinIn: (0, transactions_1.coinWithBalance)({
100
101
  balance: BigInt(quote.amountIn),
101
102
  type: quote.coinTypeIn,
103
+ useGasCoin: false,
102
104
  }),
103
105
  signer: simulation.sender,
104
106
  tx,
@@ -109,6 +111,9 @@ class MetaAg {
109
111
  sender: simulation.sender,
110
112
  transactionBlock: tx,
111
113
  }), simulation.timeout ?? 2000, `simulation for ${provider.kind} provider with id ${id}`);
114
+ if (res.effects.status.status === "failure") {
115
+ throw new Error(res.error ?? "Simulation failed");
116
+ }
112
117
  const amountOut = extractAmountOutWrapper(res.events);
113
118
  return {
114
119
  id,
@@ -146,9 +151,14 @@ class MetaAg {
146
151
  * @returns quotes from all providers
147
152
  */
148
153
  async quote(options, simulation) {
154
+ const opts = {
155
+ ...options,
156
+ coinInType: (0, utils_1.normalizeStructTag)(options.coinInType),
157
+ coinOutType: (0, utils_1.normalizeStructTag)(options.coinOutType),
158
+ };
149
159
  const quotes = await Promise.allSettled(Object.keys(this.options.providers).map(async (provider) => {
150
160
  const p = await this._getProvider(provider);
151
- return this._quote(p, options, simulation);
161
+ return this._quote(p, opts, simulation);
152
162
  }));
153
163
  return quotes
154
164
  .map((quote) => quote.status === "fulfilled"
@@ -45,8 +45,8 @@ class BluefinProvider {
45
45
  amountIn: quote.swapAmountWithDecimal,
46
46
  rawAmountOut: quote.returnAmountWithDecimal,
47
47
  amountOut: expectedAmount,
48
- coinTypeIn: quote.tokenIn,
49
- coinTypeOut: quote.tokenOut,
48
+ coinTypeIn: options.coinInType,
49
+ coinTypeOut: options.coinOutType,
50
50
  };
51
51
  }
52
52
  async swap({ quote, signer, tx, coinIn }) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAyCZ,SAAS;YAiDT,MAAM;IA0BpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAgBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAyCZ,SAAS;YAqDT,MAAM;IA0BpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAqBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
@@ -1,5 +1,6 @@
1
1
  import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
2
2
  import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
3
+ import { normalizeStructTag } from "@mysten/sui/utils";
3
4
  import { _7K_META_CONFIG, _7K_META_PACKAGE_ID, _7K_META_PUBLISHED_AT, _7K_META_VAULT, } from "../../constants/_7k";
4
5
  import { SUI_ADDRESS_ZERO } from "../../constants/sui";
5
6
  import { EProvider, } from "../../types/metaAg";
@@ -66,6 +67,7 @@ export class MetaAg {
66
67
  coinIn: coinWithBalance({
67
68
  balance: BigInt(quote.amountIn),
68
69
  type: quote.coinTypeIn,
70
+ useGasCoin: false,
69
71
  }),
70
72
  signer: simulation.sender,
71
73
  tx,
@@ -76,6 +78,9 @@ export class MetaAg {
76
78
  sender: simulation.sender,
77
79
  transactionBlock: tx,
78
80
  }), simulation.timeout ?? 2000, `simulation for ${provider.kind} provider with id ${id}`);
81
+ if (res.effects.status.status === "failure") {
82
+ throw new Error(res.error ?? "Simulation failed");
83
+ }
79
84
  const amountOut = extractAmountOutWrapper(res.events);
80
85
  return {
81
86
  id,
@@ -113,9 +118,14 @@ export class MetaAg {
113
118
  * @returns quotes from all providers
114
119
  */
115
120
  async quote(options, simulation) {
121
+ const opts = {
122
+ ...options,
123
+ coinInType: normalizeStructTag(options.coinInType),
124
+ coinOutType: normalizeStructTag(options.coinOutType),
125
+ };
116
126
  const quotes = await Promise.allSettled(Object.keys(this.options.providers).map(async (provider) => {
117
127
  const p = await this._getProvider(provider);
118
- return this._quote(p, options, simulation);
128
+ return this._quote(p, opts, simulation);
119
129
  }));
120
130
  return quotes
121
131
  .map((quote) => quote.status === "fulfilled"
@@ -44,8 +44,8 @@ export class BluefinProvider {
44
44
  amountIn: quote.swapAmountWithDecimal,
45
45
  rawAmountOut: quote.returnAmountWithDecimal,
46
46
  amountOut: expectedAmount,
47
- coinTypeIn: quote.tokenIn,
48
- coinTypeOut: quote.tokenOut,
47
+ coinTypeIn: options.coinInType,
48
+ coinTypeOut: options.coinOutType,
49
49
  };
50
50
  }
51
51
  async swap({ quote, signer, tx, coinIn }) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAyCZ,SAAS;YAiDT,MAAM;IA0BpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAgBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAyCZ,SAAS;YAqDT,MAAM;IA0BpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAqBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7kprotocol/sdk-ts",
3
- "version": "3.4.2-beta.7",
3
+ "version": "3.4.2-beta.9",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {