@7kprotocol/sdk-ts 2.1.5 → 2.1.7
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/lib/cjs/getQuote.js +5 -2
- package/lib/cjs/libs/protocols/bluefin/index.js +1 -1
- package/lib/cjs/libs/protocols/index.js +4 -0
- package/lib/cjs/libs/protocols/obric/index.js +42 -0
- package/lib/cjs/libs/protocols/springsui/index.js +35 -0
- package/lib/cjs/types/getQuote.d.ts +1 -0
- package/lib/cjs/types/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/index.d.ts +4 -0
- package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/obric/index.d.ts +9 -0
- package/lib/cjs/types/libs/protocols/obric/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/springsui/index.d.ts +9 -0
- package/lib/cjs/types/libs/protocols/springsui/index.d.ts.map +1 -0
- package/lib/cjs/types/types/aggregator.d.ts +1 -1
- package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
- package/lib/esm/getQuote.js +3 -1
- package/lib/esm/libs/protocols/bluefin/index.js +1 -1
- package/lib/esm/libs/protocols/index.js +4 -0
- package/lib/esm/libs/protocols/obric/index.js +27 -0
- package/lib/esm/libs/protocols/springsui/index.js +20 -0
- package/lib/esm/types/getQuote.d.ts +1 -0
- package/lib/esm/types/getQuote.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/index.d.ts +4 -0
- package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/obric/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/obric/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/springsui/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/springsui/index.d.ts.map +1 -0
- package/lib/esm/types/types/aggregator.d.ts +1 -1
- package/lib/esm/types/types/aggregator.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/getQuote.js
CHANGED
|
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DEFAULT_SOURCES = void 0;
|
|
12
13
|
exports.getQuote = getQuote;
|
|
13
14
|
const token_1 = require("./utils/token");
|
|
14
|
-
|
|
15
|
+
exports.DEFAULT_SOURCES = [
|
|
15
16
|
"suiswap",
|
|
16
17
|
"turbos",
|
|
17
18
|
"cetus",
|
|
@@ -23,9 +24,11 @@ const DEFAULT_SOURCES = [
|
|
|
23
24
|
"deepbook_v3",
|
|
24
25
|
"flowx",
|
|
25
26
|
"bluefin",
|
|
27
|
+
"springsui",
|
|
28
|
+
"obric",
|
|
26
29
|
];
|
|
27
30
|
function getQuote(_a) {
|
|
28
|
-
return __awaiter(this, arguments, void 0, function* ({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
|
|
31
|
+
return __awaiter(this, arguments, void 0, function* ({ tokenIn, tokenOut, amountIn, sources = exports.DEFAULT_SOURCES, }) {
|
|
29
32
|
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}`);
|
|
30
33
|
if (!response.ok) {
|
|
31
34
|
throw new Error("Failed to fetch aggregator quote");
|
|
@@ -18,7 +18,7 @@ const utils_1 = require("@mysten/sui/utils");
|
|
|
18
18
|
const utils_2 = require("../utils");
|
|
19
19
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
20
20
|
const sui_1 = require("../../../utils/sui");
|
|
21
|
-
const PACKAGE_ID = "
|
|
21
|
+
const PACKAGE_ID = "0xa31282fc0a0ad50cf5f20908cfbb1539a143f5a38912eb8823a8dd6cbf98bc44";
|
|
22
22
|
const CONFIG_ID = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
23
23
|
class BluefinContract extends base_1.BaseContract {
|
|
24
24
|
swap(tx) {
|
|
@@ -12,6 +12,8 @@ const bluemove_1 = require("./bluemove");
|
|
|
12
12
|
const kriyaV3_1 = require("./kriyaV3");
|
|
13
13
|
const sponsored_1 = require("./deepbookV3/sponsored");
|
|
14
14
|
const bluefin_1 = require("./bluefin");
|
|
15
|
+
const springsui_1 = require("./springsui");
|
|
16
|
+
const obric_1 = require("./obric");
|
|
15
17
|
exports.ProtocolContract = {
|
|
16
18
|
cetus: cetus_1.CetusContract,
|
|
17
19
|
turbos: turbos_1.TurbosContract,
|
|
@@ -24,4 +26,6 @@ exports.ProtocolContract = {
|
|
|
24
26
|
flowx: flowx_1.FlowXContract,
|
|
25
27
|
kriya_v3: kriyaV3_1.KriyaV3Contract,
|
|
26
28
|
bluefin: bluefin_1.BluefinContract,
|
|
29
|
+
springsui: springsui_1.SpringSuiContract,
|
|
30
|
+
obric: obric_1.ObricContract,
|
|
27
31
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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.ObricContract = void 0;
|
|
13
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
14
|
+
const base_1 = require("../base");
|
|
15
|
+
const PACKAGE_ID = "0xb84e63d22ea4822a0a333c250e790f69bf5c2ef0c63f4e120e05a6415991368f";
|
|
16
|
+
const PYTH_STATE = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
17
|
+
class ObricContract extends base_1.BaseContract {
|
|
18
|
+
swap(tx) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const [coinX, coinY] = this.swapInfo.pool.allTokens;
|
|
21
|
+
const xToY = this.swapInfo.swapXtoY;
|
|
22
|
+
const { x_price_id, y_price_id } = this.swapInfo.extra || {};
|
|
23
|
+
if (!x_price_id || !y_price_id) {
|
|
24
|
+
throw new Error("x_price_id and y_price_id are required");
|
|
25
|
+
}
|
|
26
|
+
const [coinOut] = tx.moveCall({
|
|
27
|
+
target: `${PACKAGE_ID}::v2::${xToY ? "swap_x_to_y" : "swap_y_to_x"}`,
|
|
28
|
+
typeArguments: [coinX.address, coinY.address],
|
|
29
|
+
arguments: [
|
|
30
|
+
tx.object(this.swapInfo.poolId),
|
|
31
|
+
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
32
|
+
tx.object(PYTH_STATE),
|
|
33
|
+
tx.object(x_price_id), // pyth pricefeed for x
|
|
34
|
+
tx.object(y_price_id), // pyth pricefeed for y
|
|
35
|
+
this.inputCoinObject,
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
return coinOut;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ObricContract = ObricContract;
|
|
@@ -0,0 +1,35 @@
|
|
|
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.SpringSuiContract = void 0;
|
|
13
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
14
|
+
const base_1 = require("../base");
|
|
15
|
+
const PACKAGE_ID = "0x82e6f4f75441eae97d2d5850f41a09d28c7b64a05b067d37748d471f43aaf3f7";
|
|
16
|
+
class SpringSuiContract extends base_1.BaseContract {
|
|
17
|
+
swap(tx) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// coinX is always SUI
|
|
20
|
+
const coinY = this.swapInfo.pool.allTokens[1];
|
|
21
|
+
const isStake = this.swapInfo.swapXtoY;
|
|
22
|
+
const [coinOut] = tx.moveCall({
|
|
23
|
+
target: `${PACKAGE_ID}::liquid_staking::${isStake ? "mint" : "redeem"}`,
|
|
24
|
+
typeArguments: [coinY.address],
|
|
25
|
+
arguments: [
|
|
26
|
+
tx.object(this.swapInfo.poolId),
|
|
27
|
+
isStake ? tx.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID) : this.inputCoinObject,
|
|
28
|
+
isStake ? this.inputCoinObject : tx.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
return coinOut;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.SpringSuiContract = SpringSuiContract;
|
|
@@ -5,6 +5,7 @@ interface Params {
|
|
|
5
5
|
amountIn: string;
|
|
6
6
|
sources?: SourceDex[];
|
|
7
7
|
}
|
|
8
|
+
export declare const DEFAULT_SOURCES: SourceDex[];
|
|
8
9
|
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, }: Params): Promise<QuoteResponse>;
|
|
9
10
|
export {};
|
|
10
11
|
//# 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,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;
|
|
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;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EActC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAUjC"}
|
|
@@ -9,6 +9,8 @@ import { BluemoveContract } from "./bluemove";
|
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
11
|
import { BluefinContract } from "./bluefin";
|
|
12
|
+
import { SpringSuiContract } from "./springsui";
|
|
13
|
+
import { ObricContract } from "./obric";
|
|
12
14
|
export declare const ProtocolContract: {
|
|
13
15
|
cetus: typeof CetusContract;
|
|
14
16
|
turbos: typeof TurbosContract;
|
|
@@ -21,5 +23,7 @@ export declare const ProtocolContract: {
|
|
|
21
23
|
flowx: typeof FlowXContract;
|
|
22
24
|
kriya_v3: typeof KriyaV3Contract;
|
|
23
25
|
bluefin: typeof BluefinContract;
|
|
26
|
+
springsui: typeof SpringSuiContract;
|
|
27
|
+
obric: typeof ObricContract;
|
|
24
28
|
};
|
|
25
29
|
//# 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;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,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;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;CAc5B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class ObricContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/obric/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAuB3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class SpringSuiContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/springsui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC,qBAAa,iBAAkB,SAAQ,YAAY;IAC3C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAgB3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin";
|
|
1
|
+
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin" | "springsui" | "obric";
|
|
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,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,CAAC;
|
|
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,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,GACT,WAAW,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rB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,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"}
|
package/lib/esm/getQuote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeTokenType } from "./utils/token";
|
|
2
|
-
const DEFAULT_SOURCES = [
|
|
2
|
+
export const DEFAULT_SOURCES = [
|
|
3
3
|
"suiswap",
|
|
4
4
|
"turbos",
|
|
5
5
|
"cetus",
|
|
@@ -11,6 +11,8 @@ const DEFAULT_SOURCES = [
|
|
|
11
11
|
"deepbook_v3",
|
|
12
12
|
"flowx",
|
|
13
13
|
"bluefin",
|
|
14
|
+
"springsui",
|
|
15
|
+
"obric",
|
|
14
16
|
];
|
|
15
17
|
export async function getQuote({ tokenIn, tokenOut, amountIn, sources = DEFAULT_SOURCES, }) {
|
|
16
18
|
const response = await fetch(`https://api.7k.ag/quote?amount=${amountIn}&from=${normalizeTokenType(tokenIn)}&to=${normalizeTokenType(tokenOut)}&sources=${sources}`);
|
|
@@ -3,7 +3,7 @@ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
|
3
3
|
import { getDefaultSqrtPriceLimit } from "../utils";
|
|
4
4
|
import BN from "bn.js";
|
|
5
5
|
import { SuiUtils } from "../../../utils/sui";
|
|
6
|
-
const PACKAGE_ID = "
|
|
6
|
+
const PACKAGE_ID = "0xa31282fc0a0ad50cf5f20908cfbb1539a143f5a38912eb8823a8dd6cbf98bc44";
|
|
7
7
|
const CONFIG_ID = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
|
|
8
8
|
export class BluefinContract extends BaseContract {
|
|
9
9
|
async swap(tx) {
|
|
@@ -9,6 +9,8 @@ import { BluemoveContract } from "./bluemove";
|
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
11
|
import { BluefinContract } from "./bluefin";
|
|
12
|
+
import { SpringSuiContract } from "./springsui";
|
|
13
|
+
import { ObricContract } from "./obric";
|
|
12
14
|
export const ProtocolContract = {
|
|
13
15
|
cetus: CetusContract,
|
|
14
16
|
turbos: TurbosContract,
|
|
@@ -21,4 +23,6 @@ export const ProtocolContract = {
|
|
|
21
23
|
flowx: FlowXContract,
|
|
22
24
|
kriya_v3: KriyaV3Contract,
|
|
23
25
|
bluefin: BluefinContract,
|
|
26
|
+
springsui: SpringSuiContract,
|
|
27
|
+
obric: ObricContract,
|
|
24
28
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
const PACKAGE_ID = "0xb84e63d22ea4822a0a333c250e790f69bf5c2ef0c63f4e120e05a6415991368f";
|
|
4
|
+
const PYTH_STATE = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
5
|
+
export class ObricContract extends BaseContract {
|
|
6
|
+
async swap(tx) {
|
|
7
|
+
const [coinX, coinY] = this.swapInfo.pool.allTokens;
|
|
8
|
+
const xToY = this.swapInfo.swapXtoY;
|
|
9
|
+
const { x_price_id, y_price_id } = this.swapInfo.extra || {};
|
|
10
|
+
if (!x_price_id || !y_price_id) {
|
|
11
|
+
throw new Error("x_price_id and y_price_id are required");
|
|
12
|
+
}
|
|
13
|
+
const [coinOut] = tx.moveCall({
|
|
14
|
+
target: `${PACKAGE_ID}::v2::${xToY ? "swap_x_to_y" : "swap_y_to_x"}`,
|
|
15
|
+
typeArguments: [coinX.address, coinY.address],
|
|
16
|
+
arguments: [
|
|
17
|
+
tx.object(this.swapInfo.poolId),
|
|
18
|
+
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
19
|
+
tx.object(PYTH_STATE),
|
|
20
|
+
tx.object(x_price_id), // pyth pricefeed for x
|
|
21
|
+
tx.object(y_price_id), // pyth pricefeed for y
|
|
22
|
+
this.inputCoinObject,
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
return coinOut;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui/utils";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
const PACKAGE_ID = "0x82e6f4f75441eae97d2d5850f41a09d28c7b64a05b067d37748d471f43aaf3f7";
|
|
4
|
+
export class SpringSuiContract extends BaseContract {
|
|
5
|
+
async swap(tx) {
|
|
6
|
+
// coinX is always SUI
|
|
7
|
+
const coinY = this.swapInfo.pool.allTokens[1];
|
|
8
|
+
const isStake = this.swapInfo.swapXtoY;
|
|
9
|
+
const [coinOut] = tx.moveCall({
|
|
10
|
+
target: `${PACKAGE_ID}::liquid_staking::${isStake ? "mint" : "redeem"}`,
|
|
11
|
+
typeArguments: [coinY.address],
|
|
12
|
+
arguments: [
|
|
13
|
+
tx.object(this.swapInfo.poolId),
|
|
14
|
+
isStake ? tx.object(SUI_SYSTEM_STATE_OBJECT_ID) : this.inputCoinObject,
|
|
15
|
+
isStake ? this.inputCoinObject : tx.object(SUI_SYSTEM_STATE_OBJECT_ID),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
return coinOut;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -5,6 +5,7 @@ interface Params {
|
|
|
5
5
|
amountIn: string;
|
|
6
6
|
sources?: SourceDex[];
|
|
7
7
|
}
|
|
8
|
+
export declare const DEFAULT_SOURCES: SourceDex[];
|
|
8
9
|
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources, }: Params): Promise<QuoteResponse>;
|
|
9
10
|
export {};
|
|
10
11
|
//# 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,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;
|
|
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;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EActC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAyB,GAC1B,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAUjC"}
|
|
@@ -9,6 +9,8 @@ import { BluemoveContract } from "./bluemove";
|
|
|
9
9
|
import { KriyaV3Contract } from "./kriyaV3";
|
|
10
10
|
import { SponsoredDeepBookV3Contract } from "./deepbookV3/sponsored";
|
|
11
11
|
import { BluefinContract } from "./bluefin";
|
|
12
|
+
import { SpringSuiContract } from "./springsui";
|
|
13
|
+
import { ObricContract } from "./obric";
|
|
12
14
|
export declare const ProtocolContract: {
|
|
13
15
|
cetus: typeof CetusContract;
|
|
14
16
|
turbos: typeof TurbosContract;
|
|
@@ -21,5 +23,7 @@ export declare const ProtocolContract: {
|
|
|
21
23
|
flowx: typeof FlowXContract;
|
|
22
24
|
kriya_v3: typeof KriyaV3Contract;
|
|
23
25
|
bluefin: typeof BluefinContract;
|
|
26
|
+
springsui: typeof SpringSuiContract;
|
|
27
|
+
obric: typeof ObricContract;
|
|
24
28
|
};
|
|
25
29
|
//# 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;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,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;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;CAc5B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class ObricContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/obric/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAuB3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { BaseContract } from "../base";
|
|
3
|
+
export declare class SpringSuiContract extends BaseContract {
|
|
4
|
+
swap(tx: Transaction): Promise<{
|
|
5
|
+
$kind: "NestedResult";
|
|
6
|
+
NestedResult: [number, number];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/springsui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC,qBAAa,iBAAkB,SAAQ,YAAY;IAC3C,IAAI,CAAC,EAAE,EAAE,WAAW;;;;CAgB3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin";
|
|
1
|
+
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook" | "deepbook_v3" | "flowx" | "bluefin" | "springsui" | "obric";
|
|
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,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,CAAC;
|
|
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,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,GACT,WAAW,GACX,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,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