@7kprotocol/sdk-ts 1.2.7 → 1.3.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/README.md CHANGED
@@ -34,6 +34,29 @@ const quoteResponse = await getQuote({
34
34
  });
35
35
  ```
36
36
 
37
+ or
38
+
39
+ ```typescript
40
+ import { getQuote } from "@7kprotocol/sdk-ts";
41
+
42
+ const quoteResponse = await getQuote({
43
+ tokenIn: "0x2::sui::SUI",
44
+ tokenOut:
45
+ "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
46
+ amountIn: "1000000000",
47
+ sources: [
48
+ "suiswap",
49
+ "turbos",
50
+ "cetus",
51
+ "bluemove",
52
+ "kriya_v3",
53
+ "aftermath",
54
+ "deepbook",
55
+ "flowx",
56
+ ], // Optional: if empty, the latest sources supported by the current SDK version will be used.
57
+ });
58
+ ```
59
+
37
60
  ### 3. Build Transaction
38
61
 
39
62
  ```typescript
@@ -11,9 +11,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getQuote = getQuote;
13
13
  const token_1 = require("./utils/token");
14
+ const DEFAULT_SOURCES = [
15
+ "suiswap",
16
+ "turbos",
17
+ "cetus",
18
+ "bluemove",
19
+ "kriya_v3",
20
+ "aftermath",
21
+ "deepbook",
22
+ "flowx",
23
+ ];
14
24
  function getQuote(_a) {
15
- return __awaiter(this, arguments, void 0, function* ({ tokenIn, tokenOut, amountIn, }) {
16
- const response = yield fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${(0, token_1.normalizeTokenType)(tokenIn)}&to=${(0, token_1.normalizeTokenType)(tokenOut)}`);
25
+ return __awaiter(this, arguments, void 0, function* ({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
26
+ const response = yield fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${(0, token_1.normalizeTokenType)(tokenIn)}&to=${(0, token_1.normalizeTokenType)(tokenOut)}&sources=${sources.join(",")}`);
17
27
  if (!response.ok) {
18
28
  throw new Error("Failed to fetch aggregator quote");
19
29
  }
@@ -9,6 +9,7 @@ const kriya_1 = require("./kriya");
9
9
  const turbos_1 = require("./turbos");
10
10
  const suiswap_1 = require("./suiswap");
11
11
  const bluemove_1 = require("./bluemove");
12
+ const kriyaV3_1 = require("./kriyaV3");
12
13
  exports.ProtocolContract = {
13
14
  cetus: cetus_1.CetusContract,
14
15
  turbos: turbos_1.TurbosContract,
@@ -18,4 +19,5 @@ exports.ProtocolContract = {
18
19
  aftermath: aftermath_1.AfterMathContract,
19
20
  deepbook: deepbook_1.DeepBookContract,
20
21
  flowx: flowx_1.FlowXContract,
22
+ kriya_v3: kriyaV3_1.KriyaV3Contract,
21
23
  };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.KriyaV3Contract = void 0;
13
+ const base_1 = require("../base");
14
+ const utils_1 = require("@mysten/sui.js/utils");
15
+ const token_1 = require("../../../utils/token");
16
+ const PACKAGE_ID = "0xbd8d4489782042c6fafad4de4bc6a5e0b84a43c6c00647ffd7062d1e2bb7549e";
17
+ const VERSION_ID = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
18
+ class KriyaV3Contract extends base_1.BaseContract {
19
+ swap(tx) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const swapXtoY = this.swapInfo.swapXtoY;
22
+ const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
23
+ const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
24
+ const poolId = this.swapInfo.poolId;
25
+ const LowLimitPrice = 4295048017;
26
+ const limitPrice = BigInt("79226673515401279992447579050");
27
+ const [receive_a, receive_b, flash_receipt] = tx.moveCall({
28
+ target: `${PACKAGE_ID}::trade::flash_swap`,
29
+ typeArguments: this.getTypeParams(),
30
+ arguments: [
31
+ tx.object(poolId),
32
+ tx.pure(swapXtoY),
33
+ tx.pure(true),
34
+ this.getInputCoinValue(tx),
35
+ tx.pure(swapXtoY ? LowLimitPrice : limitPrice),
36
+ tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
37
+ tx.object(VERSION_ID),
38
+ ],
39
+ });
40
+ tx.moveCall({
41
+ target: `0x2::balance::destroy_zero`,
42
+ arguments: [swapXtoY ? receive_a : receive_b],
43
+ typeArguments: [coinInType],
44
+ });
45
+ const [zeroOutCoin] = tx.moveCall({
46
+ target: `0x2::balance::zero`,
47
+ arguments: [],
48
+ typeArguments: [coinOutType],
49
+ });
50
+ const inputCoinBalance = tx.moveCall({
51
+ target: `0x2::coin::into_balance`,
52
+ typeArguments: [coinInType],
53
+ arguments: [this.inputCoinObject],
54
+ });
55
+ const pay_coin_a = swapXtoY ? inputCoinBalance : zeroOutCoin;
56
+ const pay_coin_b = swapXtoY ? zeroOutCoin : inputCoinBalance;
57
+ tx.moveCall({
58
+ target: `${PACKAGE_ID}::trade::repay_flash_swap`,
59
+ typeArguments: this.getTypeParams(),
60
+ arguments: [
61
+ tx.object(poolId),
62
+ flash_receipt,
63
+ pay_coin_a,
64
+ pay_coin_b,
65
+ tx.object(VERSION_ID),
66
+ ],
67
+ });
68
+ const [tokenOut] = tx.moveCall({
69
+ target: `0x2::coin::from_balance`,
70
+ typeArguments: [coinOutType],
71
+ arguments: [swapXtoY ? receive_b : receive_a],
72
+ });
73
+ return tokenOut;
74
+ });
75
+ }
76
+ }
77
+ exports.KriyaV3Contract = KriyaV3Contract;
@@ -1,9 +1,10 @@
1
- import { QuoteResponse } from "./types/aggregator";
1
+ import { QuoteResponse, SourceDex } from "./types/aggregator";
2
2
  interface Params {
3
3
  tokenIn: string;
4
4
  tokenOut: string;
5
5
  amountIn: string;
6
+ sources?: SourceDex[];
6
7
  }
7
- export declare function getQuote({ tokenIn, tokenOut, amountIn, }: Params): Promise<QuoteResponse>;
8
+ export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, }: Params): Promise<QuoteResponse>;
8
9
  export {};
9
10
  //# sourceMappingURL=getQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQjC"}
1
+ {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAaD,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQjC"}
@@ -6,6 +6,7 @@ import { KriyaContract } from "./kriya";
6
6
  import { TurbosContract } from "./turbos";
7
7
  import { SuiswapContract } from "./suiswap";
8
8
  import { BluemoveContract } from "./bluemove";
9
+ import { KriyaV3Contract } from "./kriyaV3";
9
10
  export declare const ProtocolContract: {
10
11
  cetus: typeof CetusContract;
11
12
  turbos: typeof TurbosContract;
@@ -15,5 +16,6 @@ export declare const ProtocolContract: {
15
16
  aftermath: typeof AfterMathContract;
16
17
  deepbook: typeof DeepBookContract;
17
18
  flowx: typeof FlowXContract;
19
+ kriya_v3: typeof KriyaV3Contract;
18
20
  };
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,gBAAgB;;;;;;;;;CAS5B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,gBAAgB;;;;;;;;;;CAU5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class KriyaV3Contract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/kriyaV3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CA+DhC"}
@@ -1,4 +1,4 @@
1
- export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "aftermath" | "deepbook" | "flowx";
1
+ export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "flowx";
2
2
  export type SorSwap = {
3
3
  poolId: string;
4
4
  assetInIndex: number;
@@ -1 +1 @@
1
- {"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAA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ACjB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -1,6 +1,16 @@
1
1
  import { normalizeTokenType } from "./utils/token";
2
- export async function getQuote({ tokenIn, tokenOut, amountIn, }) {
3
- const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}`);
2
+ const DEFAULT_SOURCES = [
3
+ "suiswap",
4
+ "turbos",
5
+ "cetus",
6
+ "bluemove",
7
+ "kriya_v3",
8
+ "aftermath",
9
+ "deepbook",
10
+ "flowx",
11
+ ];
12
+ export async function getQuote({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
13
+ const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}&sources=${sources.join(",")}`);
4
14
  if (!response.ok) {
5
15
  throw new Error("Failed to fetch aggregator quote");
6
16
  }
@@ -6,6 +6,7 @@ import { KriyaContract } from "./kriya";
6
6
  import { TurbosContract } from "./turbos";
7
7
  import { SuiswapContract } from "./suiswap";
8
8
  import { BluemoveContract } from "./bluemove";
9
+ import { KriyaV3Contract } from "./kriyaV3";
9
10
  export const ProtocolContract = {
10
11
  cetus: CetusContract,
11
12
  turbos: TurbosContract,
@@ -15,4 +16,5 @@ export const ProtocolContract = {
15
16
  aftermath: AfterMathContract,
16
17
  deepbook: DeepBookContract,
17
18
  flowx: FlowXContract,
19
+ kriya_v3: KriyaV3Contract,
18
20
  };
@@ -0,0 +1,62 @@
1
+ import { BaseContract } from "../base";
2
+ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui.js/utils";
3
+ import { normalizeTokenType } from "../../../utils/token";
4
+ const PACKAGE_ID = "0xbd8d4489782042c6fafad4de4bc6a5e0b84a43c6c00647ffd7062d1e2bb7549e";
5
+ const VERSION_ID = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
6
+ export class KriyaV3Contract extends BaseContract {
7
+ async swap(tx) {
8
+ const swapXtoY = this.swapInfo.swapXtoY;
9
+ const coinInType = normalizeTokenType(this.swapInfo.assetIn);
10
+ const coinOutType = normalizeTokenType(this.swapInfo.assetOut);
11
+ const poolId = this.swapInfo.poolId;
12
+ const LowLimitPrice = 4295048017;
13
+ const limitPrice = BigInt("79226673515401279992447579050");
14
+ const [receive_a, receive_b, flash_receipt] = tx.moveCall({
15
+ target: `${PACKAGE_ID}::trade::flash_swap`,
16
+ typeArguments: this.getTypeParams(),
17
+ arguments: [
18
+ tx.object(poolId),
19
+ tx.pure(swapXtoY),
20
+ tx.pure(true),
21
+ this.getInputCoinValue(tx),
22
+ tx.pure(swapXtoY ? LowLimitPrice : limitPrice),
23
+ tx.object(SUI_CLOCK_OBJECT_ID),
24
+ tx.object(VERSION_ID),
25
+ ],
26
+ });
27
+ tx.moveCall({
28
+ target: `0x2::balance::destroy_zero`,
29
+ arguments: [swapXtoY ? receive_a : receive_b],
30
+ typeArguments: [coinInType],
31
+ });
32
+ const [zeroOutCoin] = tx.moveCall({
33
+ target: `0x2::balance::zero`,
34
+ arguments: [],
35
+ typeArguments: [coinOutType],
36
+ });
37
+ const inputCoinBalance = tx.moveCall({
38
+ target: `0x2::coin::into_balance`,
39
+ typeArguments: [coinInType],
40
+ arguments: [this.inputCoinObject],
41
+ });
42
+ const pay_coin_a = swapXtoY ? inputCoinBalance : zeroOutCoin;
43
+ const pay_coin_b = swapXtoY ? zeroOutCoin : inputCoinBalance;
44
+ tx.moveCall({
45
+ target: `${PACKAGE_ID}::trade::repay_flash_swap`,
46
+ typeArguments: this.getTypeParams(),
47
+ arguments: [
48
+ tx.object(poolId),
49
+ flash_receipt,
50
+ pay_coin_a,
51
+ pay_coin_b,
52
+ tx.object(VERSION_ID),
53
+ ],
54
+ });
55
+ const [tokenOut] = tx.moveCall({
56
+ target: `0x2::coin::from_balance`,
57
+ typeArguments: [coinOutType],
58
+ arguments: [swapXtoY ? receive_b : receive_a],
59
+ });
60
+ return tokenOut;
61
+ }
62
+ }
@@ -1,9 +1,10 @@
1
- import { QuoteResponse } from "./types/aggregator";
1
+ import { QuoteResponse, SourceDex } from "./types/aggregator";
2
2
  interface Params {
3
3
  tokenIn: string;
4
4
  tokenOut: string;
5
5
  amountIn: string;
6
+ sources?: SourceDex[];
6
7
  }
7
- export declare function getQuote({ tokenIn, tokenOut, amountIn, }: Params): Promise<QuoteResponse>;
8
+ export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, }: Params): Promise<QuoteResponse>;
8
9
  export {};
9
10
  //# sourceMappingURL=getQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQjC"}
1
+ {"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../src/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAaD,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQjC"}
@@ -6,6 +6,7 @@ import { KriyaContract } from "./kriya";
6
6
  import { TurbosContract } from "./turbos";
7
7
  import { SuiswapContract } from "./suiswap";
8
8
  import { BluemoveContract } from "./bluemove";
9
+ import { KriyaV3Contract } from "./kriyaV3";
9
10
  export declare const ProtocolContract: {
10
11
  cetus: typeof CetusContract;
11
12
  turbos: typeof TurbosContract;
@@ -15,5 +16,6 @@ export declare const ProtocolContract: {
15
16
  aftermath: typeof AfterMathContract;
16
17
  deepbook: typeof DeepBookContract;
17
18
  flowx: typeof FlowXContract;
19
+ kriya_v3: typeof KriyaV3Contract;
18
20
  };
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,gBAAgB;;;;;;;;;CAS5B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,gBAAgB;;;;;;;;;;CAU5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class KriyaV3Contract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/kriyaV3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CA+DhC"}
@@ -1,4 +1,4 @@
1
- export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "aftermath" | "deepbook" | "flowx";
1
+ export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "flowx";
2
2
  export type SorSwap = {
3
3
  poolId: string;
4
4
  assetInIndex: number;
@@ -1 +1 @@
1
- {"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KA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