@7kprotocol/sdk-ts 3.5.0 → 3.5.2-beta.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 +45 -171
- package/lib/cjs/config/index.js +9 -0
- package/lib/cjs/constants/_7k.js +2 -1
- package/lib/cjs/features/metaAg/common.js +117 -0
- package/lib/cjs/features/metaAg/index.js +88 -93
- package/lib/cjs/features/metaAg/providers/astro.js +42 -0
- package/lib/cjs/features/metaAg/providers/bluefin.js +8 -8
- package/lib/cjs/features/metaAg/providers/bluefinx.js +87 -0
- package/lib/cjs/features/metaAg/providers/cetus.js +7 -4
- package/lib/cjs/features/metaAg/providers/flowx.js +6 -4
- package/lib/cjs/features/metaAg/providers/okx.js +181 -0
- package/lib/cjs/features/swap/buildTx.js +3 -0
- package/lib/cjs/features/swap/buildTxV2.js +10 -6
- package/lib/cjs/features/swap/config.js +2 -1
- package/lib/cjs/features/swap/getQuote.js +3 -2
- package/lib/cjs/libs/protocols/bluefinx/client.js +1 -1
- package/lib/cjs/types/config/index.d.ts +4 -0
- package/lib/cjs/types/config/index.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +1 -0
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/common.d.ts +33 -0
- package/lib/cjs/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/index.d.ts +11 -2
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/astro.d.ts +9 -0
- package/lib/cjs/types/features/metaAg/providers/astro.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/bluefinx.d.ts +10 -0
- package/lib/cjs/types/features/metaAg/providers/bluefinx.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +1 -0
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts +1 -3
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +3 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/metaAg.js +11 -4
- package/lib/cjs/types/okx.js +6 -0
- package/lib/cjs/types/types/metaAg.d.ts +60 -8
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/cjs/types/types/okx.d.ts +193 -0
- package/lib/cjs/types/types/okx.d.ts.map +1 -0
- package/lib/cjs/types/utils/condition.d.ts +1 -1
- package/lib/cjs/types/utils/condition.d.ts.map +1 -1
- package/lib/esm/config/index.js +9 -0
- package/lib/esm/constants/_7k.js +1 -0
- package/lib/esm/features/metaAg/common.js +109 -0
- package/lib/esm/features/metaAg/index.js +89 -94
- package/lib/esm/features/metaAg/providers/astro.js +39 -0
- package/lib/esm/features/metaAg/providers/bluefin.js +8 -8
- package/lib/esm/features/metaAg/providers/bluefinx.js +84 -0
- package/lib/esm/features/metaAg/providers/cetus.js +7 -4
- package/lib/esm/features/metaAg/providers/flowx.js +7 -5
- package/lib/esm/features/metaAg/providers/okx.js +146 -0
- package/lib/esm/features/swap/buildTx.js +3 -0
- package/lib/esm/features/swap/buildTxV2.js +6 -2
- package/lib/esm/features/swap/config.js +2 -1
- package/lib/esm/features/swap/getQuote.js +3 -2
- package/lib/esm/libs/protocols/bluefinx/client.js +1 -1
- package/lib/esm/types/config/index.d.ts +4 -0
- package/lib/esm/types/config/index.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +1 -0
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/common.d.ts +33 -0
- package/lib/esm/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/index.d.ts +11 -2
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/astro.d.ts +9 -0
- package/lib/esm/types/features/metaAg/providers/astro.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/bluefinx.d.ts +10 -0
- package/lib/esm/types/features/metaAg/providers/bluefinx.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +1 -0
- package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/esm/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/esm/types/features/swap/config.d.ts.map +1 -1
- package/lib/esm/types/features/swap/getQuote.d.ts +1 -3
- package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +3 -1
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/metaAg.js +8 -2
- package/lib/esm/types/okx.js +5 -0
- package/lib/esm/types/types/metaAg.d.ts +60 -8
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/types/types/okx.d.ts +193 -0
- package/lib/esm/types/types/okx.d.ts.map +1 -0
- package/lib/esm/types/utils/condition.d.ts +1 -1
- package/lib/esm/types/utils/condition.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
import { Config } from "../../../config";
|
|
4
|
-
import {
|
|
5
|
-
import { SUI_ADDRESS_ZERO } from "../../../constants/sui";
|
|
4
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
6
5
|
import { EProvider, } from "../../../types/metaAg";
|
|
7
6
|
import { assert } from "../../../utils/condition";
|
|
8
7
|
import { buildTxV2 } from "../../swap/buildTxV2";
|
|
@@ -20,6 +19,8 @@ export class BluefinProvider {
|
|
|
20
19
|
const pythConnection = new SuiPriceServiceConnection(this.metaOptions.hermesApi);
|
|
21
20
|
if (options.apiKey)
|
|
22
21
|
Config.setApiKey(options.apiKey);
|
|
22
|
+
if (options.api)
|
|
23
|
+
Config.setApi(options.api);
|
|
23
24
|
Config.setSuiClient(client);
|
|
24
25
|
Config.setPythClient(pythClient);
|
|
25
26
|
Config.setPythConnection(pythConnection);
|
|
@@ -27,9 +28,8 @@ export class BluefinProvider {
|
|
|
27
28
|
async quote(options) {
|
|
28
29
|
const quote = await getQuote({
|
|
29
30
|
amountIn: options.amountIn,
|
|
30
|
-
tokenIn: options.
|
|
31
|
-
tokenOut: options.
|
|
32
|
-
api: this.options.api || API_ENDPOINTS.MAIN,
|
|
31
|
+
tokenIn: options.coinTypeIn,
|
|
32
|
+
tokenOut: options.coinTypeOut,
|
|
33
33
|
sources: this.options.sources,
|
|
34
34
|
maxPaths: this.options.maxPaths,
|
|
35
35
|
excludedPools: this.options.excludedPools,
|
|
@@ -42,8 +42,8 @@ export class BluefinProvider {
|
|
|
42
42
|
amountIn: quote.swapAmountWithDecimal,
|
|
43
43
|
rawAmountOut: quote.returnAmountWithDecimal,
|
|
44
44
|
amountOut: quote.returnAmountWithDecimal,
|
|
45
|
-
coinTypeIn: options.
|
|
46
|
-
coinTypeOut: options.
|
|
45
|
+
coinTypeIn: options.coinTypeIn,
|
|
46
|
+
coinTypeOut: options.coinTypeOut,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async swap({ quote, signer, tx, coinIn }) {
|
|
@@ -53,7 +53,7 @@ export class BluefinProvider {
|
|
|
53
53
|
accountAddress: signer,
|
|
54
54
|
commission: {
|
|
55
55
|
commissionBps: 0,
|
|
56
|
-
partner:
|
|
56
|
+
partner: _7K_PARTNER_ADDRESS,
|
|
57
57
|
},
|
|
58
58
|
slippage: 1,
|
|
59
59
|
extendTx: {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { isValidSuiAddress } from "@mysten/sui/utils";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
import { Config } from "../../../config";
|
|
5
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
6
|
+
import { executeBluefinTx } from "../../../libs/protocols/bluefinx/client";
|
|
7
|
+
import { BluefinXTx } from "../../../types/aggregator";
|
|
8
|
+
import { EProvider, } from "../../../types/metaAg";
|
|
9
|
+
import { assert } from "../../../utils/condition";
|
|
10
|
+
import { buildTxV2Int } from "../../swap/buildTxV2";
|
|
11
|
+
import { getQuote } from "../../swap/getQuote";
|
|
12
|
+
import { metaSettle } from "../common";
|
|
13
|
+
const SUPPORT_COINS = [
|
|
14
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
15
|
+
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
16
|
+
];
|
|
17
|
+
export class BluefinXProvider {
|
|
18
|
+
options;
|
|
19
|
+
kind = EProvider.BLUEFINX;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
if (options.apiKey)
|
|
23
|
+
Config.setApiKey(options.apiKey);
|
|
24
|
+
if (options.api)
|
|
25
|
+
Config.setApi(options.api);
|
|
26
|
+
}
|
|
27
|
+
async quote(options) {
|
|
28
|
+
if (!this.canQuote(options))
|
|
29
|
+
return null;
|
|
30
|
+
const quote = await getQuote({
|
|
31
|
+
amountIn: options.amountIn,
|
|
32
|
+
tokenIn: options.coinTypeIn,
|
|
33
|
+
tokenOut: options.coinTypeOut,
|
|
34
|
+
sources: ["bluefinx"],
|
|
35
|
+
taker: options.signer,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
id: v4(),
|
|
39
|
+
provider: this.kind,
|
|
40
|
+
quote,
|
|
41
|
+
amountIn: quote.swapAmountWithDecimal,
|
|
42
|
+
rawAmountOut: quote.returnAmountWithDecimal,
|
|
43
|
+
amountOut: quote.returnAmountWithDecimal,
|
|
44
|
+
coinTypeIn: options.coinTypeIn,
|
|
45
|
+
coinTypeOut: options.coinTypeOut,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
canQuote(options) {
|
|
49
|
+
return (!!options.signer &&
|
|
50
|
+
isValidSuiAddress(options.signer) &&
|
|
51
|
+
SUPPORT_COINS.includes(options.coinTypeIn) &&
|
|
52
|
+
SUPPORT_COINS.includes(options.coinTypeOut));
|
|
53
|
+
}
|
|
54
|
+
async fastSwap(options) {
|
|
55
|
+
assert(options.quote.provider === this.kind, "Invalid BluefinX quote");
|
|
56
|
+
const quote = options.quote.quote;
|
|
57
|
+
const tx = new Transaction();
|
|
58
|
+
const { tx: bluefinTx } = await buildTxV2Int({
|
|
59
|
+
quoteResponse: quote,
|
|
60
|
+
accountAddress: options.signer,
|
|
61
|
+
commission: { commissionBps: 0, partner: _7K_PARTNER_ADDRESS },
|
|
62
|
+
slippage: 0,
|
|
63
|
+
extendTx: {
|
|
64
|
+
tx,
|
|
65
|
+
coinIn: coinWithBalance({
|
|
66
|
+
type: options.quote.coinTypeIn,
|
|
67
|
+
balance: BigInt(options.quote.amountIn),
|
|
68
|
+
useGasCoin: false,
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
}, (tx, coinOut) => {
|
|
72
|
+
if (coinOut) {
|
|
73
|
+
tx.add(metaSettle(options.quote, coinOut, 0, 0));
|
|
74
|
+
tx.transferObjects([coinOut], options.signer);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
assert(bluefinTx instanceof BluefinXTx, "BluefinX transaction not found");
|
|
78
|
+
const { signature } = await options.signTransaction(bluefinTx.txBytes);
|
|
79
|
+
const res = await executeBluefinTx(bluefinTx, signature);
|
|
80
|
+
assert(res.approved, "BluefinX transaction not approved");
|
|
81
|
+
assert(res.txDigest, "BluefinX transaction digest not found");
|
|
82
|
+
return res.txDigest;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AggregatorClient, Env } from "@cetusprotocol/aggregator-sdk";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
3
4
|
import { EProvider, } from "../../../types/metaAg";
|
|
4
5
|
import { assert } from "../../../utils/condition";
|
|
5
6
|
export class CetusProvider {
|
|
@@ -14,14 +15,16 @@ export class CetusProvider {
|
|
|
14
15
|
endpoint: options.api,
|
|
15
16
|
env: Env.Mainnet,
|
|
16
17
|
pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],
|
|
18
|
+
overlayFeeRate: 0,
|
|
19
|
+
overlayFeeReceiver: _7K_PARTNER_ADDRESS,
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
async quote(quoteOptions) {
|
|
20
23
|
const quote = await this.cetusClient.findRouters({
|
|
21
24
|
amount: quoteOptions.amountIn,
|
|
22
25
|
byAmountIn: true,
|
|
23
|
-
from: quoteOptions.
|
|
24
|
-
target: quoteOptions.
|
|
26
|
+
from: quoteOptions.coinTypeIn,
|
|
27
|
+
target: quoteOptions.coinTypeOut,
|
|
25
28
|
providers: this.options.sources,
|
|
26
29
|
splitCount: this.options.splitCount,
|
|
27
30
|
splitAlgorithm: this.options.splitAlgorithm,
|
|
@@ -37,8 +40,8 @@ export class CetusProvider {
|
|
|
37
40
|
amountIn: quote.amountIn.toString() || "0",
|
|
38
41
|
rawAmountOut: quote.amountOut.toString() || "0",
|
|
39
42
|
amountOut: quote.amountOut.toString() || "0",
|
|
40
|
-
coinTypeIn: quoteOptions.
|
|
41
|
-
coinTypeOut: quoteOptions.
|
|
43
|
+
coinTypeIn: quoteOptions.coinTypeIn,
|
|
44
|
+
coinTypeOut: quoteOptions.coinTypeOut,
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
async swap(options) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AggregatorQuoter, TradeBuilder } from "@flowx-finance/sdk";
|
|
1
|
+
import { AggregatorQuoter, Commission, CommissionType, TradeBuilder, } from "@flowx-finance/sdk";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
3
4
|
import { EProvider, } from "../../../types/metaAg";
|
|
4
5
|
import { assert } from "../../../utils/condition";
|
|
5
6
|
export class FlowxProvider {
|
|
@@ -15,8 +16,8 @@ export class FlowxProvider {
|
|
|
15
16
|
async quote(quoteOptions) {
|
|
16
17
|
const quote = await this.quoter.getRoutes({
|
|
17
18
|
amountIn: quoteOptions.amountIn,
|
|
18
|
-
tokenIn: quoteOptions.
|
|
19
|
-
tokenOut: quoteOptions.
|
|
19
|
+
tokenIn: quoteOptions.coinTypeIn,
|
|
20
|
+
tokenOut: quoteOptions.coinTypeOut,
|
|
20
21
|
includeSources: this.options.sources,
|
|
21
22
|
excludePools: this.options.excludePools,
|
|
22
23
|
excludeSources: this.options.excludeSources,
|
|
@@ -30,8 +31,8 @@ export class FlowxProvider {
|
|
|
30
31
|
amountIn: quote.amountIn?.toString() ?? "0",
|
|
31
32
|
rawAmountOut: quote.amountOut?.toString() ?? "0",
|
|
32
33
|
amountOut: quote.amountOut?.toString() ?? "0",
|
|
33
|
-
coinTypeIn: quoteOptions.
|
|
34
|
-
coinTypeOut: quoteOptions.
|
|
34
|
+
coinTypeIn: quoteOptions.coinTypeIn,
|
|
35
|
+
coinTypeOut: quoteOptions.coinTypeOut,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
async swap(options) {
|
|
@@ -39,6 +40,7 @@ export class FlowxProvider {
|
|
|
39
40
|
const builder = new TradeBuilder("mainnet", options.quote.quote.routes);
|
|
40
41
|
builder.sender(options.signer);
|
|
41
42
|
builder.slippage(10000 * 100);
|
|
43
|
+
builder.commission(new Commission(_7K_PARTNER_ADDRESS, options.quote.quote.coinOut, CommissionType.PERCENTAGE, 0, true));
|
|
42
44
|
const res = await builder.build().swap({
|
|
43
45
|
tx: options.tx,
|
|
44
46
|
client: this.client,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Commands, Transaction, TransactionDataBuilder, } from "@mysten/sui/transactions";
|
|
2
|
+
import { normalizeStructTag, normalizeSuiAddress, toBase64, } from "@mysten/sui/utils";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
import { SUI_TYPE } from "../../../constants/tokens";
|
|
5
|
+
import { EProvider, } from "../../../types/metaAg";
|
|
6
|
+
import { assert } from "../../../utils/condition";
|
|
7
|
+
import { metaSettle, simulateSwapTx } from "../common";
|
|
8
|
+
const API = "https://web3.okx.com";
|
|
9
|
+
const SWAP_PATH = "/api/v5/dex/aggregator/swap";
|
|
10
|
+
const CHAIN_ID = "784";
|
|
11
|
+
const NORMALIZED_SUI_TYPE = normalizeStructTag(SUI_TYPE);
|
|
12
|
+
export class OkxProvider {
|
|
13
|
+
options;
|
|
14
|
+
metaOptions;
|
|
15
|
+
client;
|
|
16
|
+
kind = EProvider.OKX;
|
|
17
|
+
constructor(options, metaOptions, client) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.metaOptions = metaOptions;
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
async quote({ amountIn, coinTypeIn, coinTypeOut, signer, }) {
|
|
23
|
+
if (!signer)
|
|
24
|
+
return null;
|
|
25
|
+
const request = {
|
|
26
|
+
chainId: CHAIN_ID,
|
|
27
|
+
amount: amountIn,
|
|
28
|
+
fromTokenAddress: coinTypeIn === NORMALIZED_SUI_TYPE ? SUI_TYPE : coinTypeIn,
|
|
29
|
+
toTokenAddress: coinTypeOut === NORMALIZED_SUI_TYPE ? SUI_TYPE : coinTypeOut,
|
|
30
|
+
slippage: (this.metaOptions.slippageBps / 10000).toString(),
|
|
31
|
+
userWalletAddress: signer,
|
|
32
|
+
};
|
|
33
|
+
const queryString = "?" + new URLSearchParams(request).toString();
|
|
34
|
+
const url = `${this.options.api ?? API}${SWAP_PATH}${queryString}`;
|
|
35
|
+
const response = await fetch(url, {
|
|
36
|
+
headers: await getHeaders(this.options, "GET", SWAP_PATH, queryString),
|
|
37
|
+
});
|
|
38
|
+
const quote = (await response.json());
|
|
39
|
+
assert(quote.code === "0" && quote.data.length > 0, "No quote found");
|
|
40
|
+
return {
|
|
41
|
+
id: v4(),
|
|
42
|
+
provider: this.kind,
|
|
43
|
+
coinTypeIn,
|
|
44
|
+
coinTypeOut,
|
|
45
|
+
amountIn,
|
|
46
|
+
amountOut: quote.data[0].routerResult.toTokenAmount,
|
|
47
|
+
rawAmountOut: quote.data[0].routerResult.toTokenAmount,
|
|
48
|
+
quote: quote.data[0],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async fastSwap(options) {
|
|
52
|
+
const { quote, signer, signTransaction } = options;
|
|
53
|
+
assert(quote.provider === EProvider.OKX, "Invalid quote");
|
|
54
|
+
const { tx, coin } = buildTx({ quote, signer });
|
|
55
|
+
tx.add(metaSettle(quote, coin, this.metaOptions.slippageBps, this.metaOptions.tipBps, this.metaOptions.partner, this.metaOptions.partnerCommissionBps));
|
|
56
|
+
tx.transferObjects([coin], signer);
|
|
57
|
+
const txBytes = await tx.build({ client: this.client });
|
|
58
|
+
const { bytes, signature } = await signTransaction(toBase64(txBytes));
|
|
59
|
+
const res = await this.client.executeTransactionBlock({
|
|
60
|
+
signature,
|
|
61
|
+
transactionBlock: bytes,
|
|
62
|
+
});
|
|
63
|
+
return res.digest;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function generateHmacSha256(message, secretKey) {
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
const encodeBase64 = (bytes) => {
|
|
69
|
+
if (typeof Buffer !== "undefined") {
|
|
70
|
+
return Buffer.from(bytes).toString("base64");
|
|
71
|
+
}
|
|
72
|
+
let binary = "";
|
|
73
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
74
|
+
binary += String.fromCharCode(bytes[i]);
|
|
75
|
+
}
|
|
76
|
+
if (typeof btoa !== "undefined") {
|
|
77
|
+
return btoa(binary);
|
|
78
|
+
}
|
|
79
|
+
throw new Error("Base64 encoder not available in this environment");
|
|
80
|
+
};
|
|
81
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto?.subtle) {
|
|
82
|
+
const key = await globalThis.crypto.subtle.importKey("raw", encoder.encode(secretKey), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
83
|
+
const signature = await globalThis.crypto.subtle.sign("HMAC", key, encoder.encode(message));
|
|
84
|
+
return encodeBase64(new Uint8Array(signature));
|
|
85
|
+
}
|
|
86
|
+
const { createHmac } = await import("node:crypto");
|
|
87
|
+
return createHmac("sha256", secretKey).update(message).digest("base64");
|
|
88
|
+
}
|
|
89
|
+
async function getHeaders(options, method, requestPath, queryString = "") {
|
|
90
|
+
const { apiKey, secretKey, apiPassphrase, projectId } = options;
|
|
91
|
+
if (!apiKey || !secretKey || !apiPassphrase || !projectId) {
|
|
92
|
+
throw new Error("Missing required environment variables");
|
|
93
|
+
}
|
|
94
|
+
const timestamp = new Date().toISOString();
|
|
95
|
+
const stringToSign = timestamp + method + requestPath + queryString;
|
|
96
|
+
return {
|
|
97
|
+
"Content-Type": "application/json",
|
|
98
|
+
"OK-ACCESS-KEY": apiKey,
|
|
99
|
+
"OK-ACCESS-SIGN": await generateHmacSha256(stringToSign, secretKey),
|
|
100
|
+
"OK-ACCESS-TIMESTAMP": timestamp,
|
|
101
|
+
"OK-ACCESS-PASSPHRASE": apiPassphrase,
|
|
102
|
+
"OK-ACCESS-PROJECT": projectId,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const replaceFinalizeCommand = (tx, packageId) => {
|
|
106
|
+
const builder = TransactionDataBuilder.restore(tx.getData());
|
|
107
|
+
const i = builder.commands.findIndex((cmd) => cmd.$kind === "MoveCall" &&
|
|
108
|
+
normalizeSuiAddress(cmd.MoveCall.package) ===
|
|
109
|
+
normalizeSuiAddress(packageId) &&
|
|
110
|
+
cmd.MoveCall.module === "router" &&
|
|
111
|
+
cmd.MoveCall.function === "finalize");
|
|
112
|
+
const cmd = builder.commands[i];
|
|
113
|
+
assert(cmd.MoveCall, "OKX: Finalize command not found");
|
|
114
|
+
builder.replaceCommand(i, Commands.MoveCall({
|
|
115
|
+
package: packageId,
|
|
116
|
+
module: "router",
|
|
117
|
+
function: "finalize_without_transfer",
|
|
118
|
+
typeArguments: cmd.MoveCall.typeArguments,
|
|
119
|
+
arguments: [
|
|
120
|
+
cmd.MoveCall.arguments[0],
|
|
121
|
+
cmd.MoveCall.arguments[5],
|
|
122
|
+
cmd.MoveCall.arguments[6],
|
|
123
|
+
],
|
|
124
|
+
}));
|
|
125
|
+
const tx2 = Transaction.from(builder.build());
|
|
126
|
+
return { tx: tx2, coin: { NestedResult: [i, 0] } };
|
|
127
|
+
};
|
|
128
|
+
const buildTx = (options) => {
|
|
129
|
+
const { quote, signer } = options;
|
|
130
|
+
assert(quote.provider === EProvider.OKX, "Invalid quote");
|
|
131
|
+
const tx = Transaction.from(quote.quote.tx.data);
|
|
132
|
+
tx.setSenderIfNotSet(signer);
|
|
133
|
+
const { tx: tx2, coin } = replaceFinalizeCommand(tx, quote.quote.tx.to);
|
|
134
|
+
return { tx: tx2, coin };
|
|
135
|
+
};
|
|
136
|
+
export const simulateOKXSwap = async (quote, inspector, simulation, metaOptions) => {
|
|
137
|
+
const { tx, coin } = buildTx({ quote, signer: quote.quote.tx.from });
|
|
138
|
+
tx.add(metaSettle(quote, coin, 10000, metaOptions.tipBps, metaOptions.partner, metaOptions.partnerCommissionBps));
|
|
139
|
+
tx.transferObjects([coin], quote.quote.tx.from);
|
|
140
|
+
const res = await simulateSwapTx(tx, inspector, simulation);
|
|
141
|
+
return {
|
|
142
|
+
id: quote.id,
|
|
143
|
+
provider: quote.provider,
|
|
144
|
+
...res,
|
|
145
|
+
};
|
|
146
|
+
};
|
|
@@ -168,6 +168,9 @@ export const buildBluefinXTx = async (tx, accountAddress, quoteResponse) => {
|
|
|
168
168
|
if (extra.quoteExpiresAtUtcMillis < Date.now()) {
|
|
169
169
|
throw new Error("Quote expired");
|
|
170
170
|
}
|
|
171
|
+
if (extra.taker !== accountAddress) {
|
|
172
|
+
throw new Error("Sender mismatch with quote");
|
|
173
|
+
}
|
|
171
174
|
tx.setSenderIfNotSet(accountAddress);
|
|
172
175
|
const bytes = await tx.build({
|
|
173
176
|
client: Config.getSuiClient(),
|
|
@@ -12,7 +12,10 @@ import { getConfig } from "./config";
|
|
|
12
12
|
* 2. Merging redundant swaps to the same pool within each wave
|
|
13
13
|
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
14
14
|
*/
|
|
15
|
-
export const buildTxV2 = async (
|
|
15
|
+
export const buildTxV2 = async (params) => {
|
|
16
|
+
return buildTxV2Int(params);
|
|
17
|
+
};
|
|
18
|
+
export const buildTxV2Int = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }, beforeBuildBluefinXTx) => {
|
|
16
19
|
const isBluefinX = isBluefinXRouting(quoteResponse);
|
|
17
20
|
const _commission = {
|
|
18
21
|
...__commission,
|
|
@@ -58,6 +61,7 @@ export const buildTxV2 = async ({ quoteResponse, accountAddress, slippage, commi
|
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
if (isBluefinX) {
|
|
64
|
+
beforeBuildBluefinXTx?.(tx, coinOut);
|
|
61
65
|
return {
|
|
62
66
|
tx: await buildBluefinXTx(tx, accountAddress, quoteResponse),
|
|
63
67
|
coinOut,
|
|
@@ -66,7 +70,7 @@ export const buildTxV2 = async ({ quoteResponse, accountAddress, slippage, commi
|
|
|
66
70
|
tx.setSenderIfNotSet(accountAddress);
|
|
67
71
|
return { tx, coinOut };
|
|
68
72
|
};
|
|
69
|
-
|
|
73
|
+
const optimize = async (pythMap, config, routes, coinData, tx, accountAddress) => {
|
|
70
74
|
// Initialize route states with split coins
|
|
71
75
|
const routeStates = routes.map((route, index) => ({
|
|
72
76
|
routeIndex: index,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Config as _Config } from "../../config";
|
|
1
2
|
import { fetchClient } from "../../config/fetchClient";
|
|
2
3
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
3
4
|
export const DEFAULT_CONFIG = {
|
|
@@ -137,7 +138,7 @@ export async function getConfig() {
|
|
|
137
138
|
return config;
|
|
138
139
|
}
|
|
139
140
|
try {
|
|
140
|
-
const response = await fetchClient(`${API_ENDPOINTS.MAIN}/config`);
|
|
141
|
+
const response = await fetchClient(`${_Config.getApi() || API_ENDPOINTS.MAIN}/config`);
|
|
141
142
|
const quoteResponse = (await response.json());
|
|
142
143
|
config = { ...config, ...quoteResponse };
|
|
143
144
|
configTs = Date.now();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
2
|
+
import { Config } from "../../config";
|
|
2
3
|
import { fetchClient } from "../../config/fetchClient";
|
|
3
4
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
4
5
|
import { isBluefinXRouting, } from "../../types/aggregator";
|
|
@@ -36,7 +37,7 @@ export const ORACLE_BASED_SOURCES = new Set([
|
|
|
36
37
|
"steamm_oracle_quoter",
|
|
37
38
|
"steamm_oracle_quoter_v2",
|
|
38
39
|
]);
|
|
39
|
-
export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored,
|
|
40
|
+
export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
|
|
40
41
|
let sources = _sources;
|
|
41
42
|
if (isSponsored) {
|
|
42
43
|
sources = _sources.filter((s) => !ORACLE_BASED_SOURCES.has(s));
|
|
@@ -59,7 +60,7 @@ export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources
|
|
|
59
60
|
if (maxPaths) {
|
|
60
61
|
params.append("max_paths", maxPaths.toString());
|
|
61
62
|
}
|
|
62
|
-
const response = await fetchClient(`${
|
|
63
|
+
const response = await fetchClient(`${Config.getApi() || API_ENDPOINTS.MAIN}/quote?${params}`);
|
|
63
64
|
if (!response.ok) {
|
|
64
65
|
let responseText;
|
|
65
66
|
try {
|
|
@@ -8,7 +8,7 @@ const request = async (path, body) => {
|
|
|
8
8
|
if (bluefinXApiKey) {
|
|
9
9
|
headers.set("Bluefin-X-API-Key", bluefinXApiKey);
|
|
10
10
|
}
|
|
11
|
-
const res = await fetch(`${API_ENDPOINTS.MAIN}/${path}`, {
|
|
11
|
+
const res = await fetch(`${Config.getApi() || API_ENDPOINTS.MAIN}/${path}`, {
|
|
12
12
|
method: "POST",
|
|
13
13
|
body: JSON.stringify(body),
|
|
14
14
|
headers,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
3
|
+
declare function setApi(url: string): void;
|
|
4
|
+
declare function getApi(): string;
|
|
3
5
|
declare function setApiKey(key: string): void;
|
|
4
6
|
declare function getApiKey(): string;
|
|
5
7
|
declare function setBluefinXApiKey(key: string): void;
|
|
@@ -11,6 +13,8 @@ declare function getPythClient(): SuiPythClient;
|
|
|
11
13
|
declare function setPythConnection(connection: SuiPriceServiceConnection): void;
|
|
12
14
|
declare function getPythConnection(): SuiPriceServiceConnection;
|
|
13
15
|
declare const Config: {
|
|
16
|
+
setApi: typeof setApi;
|
|
17
|
+
getApi: typeof getApi;
|
|
14
18
|
setApiKey: typeof setApiKey;
|
|
15
19
|
getApiKey: typeof getApiKey;
|
|
16
20
|
setBluefinXApiKey: typeof setBluefinXApiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAuBlC,iBAAS,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEjC;AAED,iBAAS,MAAM,IAAI,MAAM,CAExB;AAED,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEpC;AAED,iBAAS,SAAS,IAAI,MAAM,CAE3B;AAED,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,iBAAS,iBAAiB,IAAI,MAAM,CAEnC;AAED,iBAAS,YAAY,IAAI,SAAS,CAEjC;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE7C;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAElD;AAED,iBAAS,aAAa,IAAI,aAAa,CAEtC;AAED,iBAAS,iBAAiB,CAAC,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAEtE;AAED,iBAAS,iBAAiB,IAAI,yBAAyB,CAEtD;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;CAaX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -5,4 +5,5 @@ export declare const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049
|
|
|
5
5
|
export declare const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
6
6
|
export declare const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
7
7
|
export declare const _7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
|
|
8
|
+
export declare const _7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
|
|
8
9
|
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GasCostSummary } from "@mysten/sui/client";
|
|
2
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
+
import { AggregatorProvider, EProvider, MetaAgOptions, MetaQuote, MetaSimulationOptions } from "../../types/metaAg";
|
|
4
|
+
import { SuiClientUtils } from "../../utils/SuiClientUtils";
|
|
5
|
+
export declare const simulateBluefinX: <T extends MetaQuote & {
|
|
6
|
+
provider: EProvider.BLUEFINX;
|
|
7
|
+
}>(quote: T) => {
|
|
8
|
+
id: string;
|
|
9
|
+
simulatedAmountOut: string;
|
|
10
|
+
gasUsed: GasCostSummary;
|
|
11
|
+
provider: EProvider.BLUEFINX;
|
|
12
|
+
};
|
|
13
|
+
export declare const simulateSwapTx: (tx: Transaction, inspector: SuiClientUtils, simulation: MetaSimulationOptions) => Promise<{
|
|
14
|
+
simulatedAmountOut: string;
|
|
15
|
+
gasUsed: GasCostSummary;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const simulateAggregator: (provider: AggregatorProvider, quote: MetaQuote, simulation: MetaSimulationOptions, inspector: SuiClientUtils, options: Required<MetaAgOptions>) => Promise<{
|
|
18
|
+
simulatedAmountOut: string;
|
|
19
|
+
gasUsed: GasCostSummary;
|
|
20
|
+
id: string;
|
|
21
|
+
provider: EProvider.BLUEFIN7K | EProvider.CETUS | EProvider.FLOWX | EProvider.ASTRO;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
|
|
25
|
+
* @param quote Meta Aggregator Quote
|
|
26
|
+
* @param coinOut Coin Out Object
|
|
27
|
+
* @param slippageBps Slippage Bps
|
|
28
|
+
* @param tipBps Tip Bps default = 0
|
|
29
|
+
* @param partner address of partner for analytic default is zero address
|
|
30
|
+
*/
|
|
31
|
+
export declare const metaSettle: (quote: MetaQuote, coinOut: TransactionObjectArgument, slippageBps?: number, tipBps?: number, partner?: string, commissionBps?: number) => (tx: Transaction) => void;
|
|
32
|
+
export declare const timeout: <T = any>(fn: () => Promise<T>, timeout: number, msg?: string) => Promise<T>;
|
|
33
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAEL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,SAAS,EACT,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAS5D,eAAO,MAAM,gBAAgB,GAC3B,CAAC,SAAS,SAAS,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAA;CAAE,EAEtD,OAAO,CAAC;;;;;CAQT,CAAC;AACF,eAAO,MAAM,cAAc,GACzB,IAAI,WAAW,EACf,WAAW,cAAc,EACzB,YAAY,qBAAqB;wBAeE,MAAM;;EAG1C,CAAC;AACF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,kBAAkB,EAC5B,OAAO,SAAS,EAChB,YAAY,qBAAqB,EACjC,WAAW,cAAc,EACzB,SAAS,QAAQ,CAAC,aAAa,CAAC;wBATG,MAAM;;;;EAuC1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,SAAS,EAChB,SAAS,yBAAyB,EAClC,oBAAiB,EACjB,eAAU,EACV,UAAU,MAAM,EAChB,sBAAiB,MAET,IAAI,WAAW,SAqCxB,CAAC;AASF,eAAO,MAAM,OAAO,GAAU,CAAC,GAAG,GAAG,EACnC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,MAAM,EACf,MAAM,MAAM,eAab,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SuiClient } from "@mysten/sui/client";
|
|
1
|
+
import { GetTransactionBlockParams, SuiClient, SuiTransactionBlockResponse } from "@mysten/sui/client";
|
|
2
2
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import { MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSimulationOptions, MetaSwapOptions } from "../../types/metaAg";
|
|
3
|
+
import { MetaAgOptions, MetaFastSwapOptions, MetaQuote, MetaQuoteOptions, MetaSimulationOptions, MetaSwapOptions } from "../../types/metaAg";
|
|
4
4
|
export declare class MetaAg {
|
|
5
5
|
client: SuiClient;
|
|
6
6
|
private providers;
|
|
@@ -10,6 +10,7 @@ export declare class MetaAg {
|
|
|
10
10
|
private _getProvider;
|
|
11
11
|
private _simulate;
|
|
12
12
|
private _quote;
|
|
13
|
+
private _fastSwap;
|
|
13
14
|
/**
|
|
14
15
|
* Get quotes from all providers
|
|
15
16
|
* @param options - quote options
|
|
@@ -19,11 +20,19 @@ export declare class MetaAg {
|
|
|
19
20
|
quote(options: MetaQuoteOptions, simulation?: MetaSimulationOptions): Promise<MetaQuote[]>;
|
|
20
21
|
/**
|
|
21
22
|
* Build transaction from quote
|
|
23
|
+
* @info Use this function to build composable transaction (ie: add more commands after the swap, consume the coin out object)
|
|
24
|
+
* @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie: BluefinX, Okx, ...) are not supported, please use `fastSwap` instead
|
|
22
25
|
* @param options - build tx options
|
|
23
26
|
* @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
|
|
24
27
|
* @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
|
|
25
28
|
*/
|
|
26
29
|
swap(options: MetaSwapOptions, slippageBps?: number): Promise<TransactionObjectArgument>;
|
|
30
|
+
/**
|
|
31
|
+
* Build, Sign, and Execute transaction in one step
|
|
32
|
+
* @param options - fast swap options
|
|
33
|
+
* @returns - txDigest of the transaction
|
|
34
|
+
*/
|
|
35
|
+
fastSwap(options: MetaFastSwapOptions, getTransactionBlockParams?: Omit<GetTransactionBlockParams, "digest">): Promise<SuiTransactionBlockResponse>;
|
|
27
36
|
/**
|
|
28
37
|
* Update meta aggregator options
|
|
29
38
|
* @param options - update options payload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,SAAS,EACT,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EASL,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAwB5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAAiD;IAClE,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YA2DZ,SAAS;YAkCT,MAAM;YAyCN,SAAS;IA2BvB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAuBvB;;;;;;;OAOG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAsBrC;;;;OAIG;IACG,QAAQ,CACZ,OAAO,EAAE,mBAAmB,EAC5B,yBAAyB,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,GACpE,OAAO,CAAC,2BAA2B,CAAC;IAcvC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AggregatorProvider, AstroProviderOptions, EProvider, MetaQuote, MetaQuoteOptions, MetaSwapOptions, QuoteProvider } from "../../../types/metaAg";
|
|
2
|
+
export declare class AstroProvider implements QuoteProvider, AggregatorProvider {
|
|
3
|
+
private readonly options;
|
|
4
|
+
readonly kind = EProvider.ASTRO;
|
|
5
|
+
constructor(options: AstroProviderOptions);
|
|
6
|
+
quote({ amountIn, coinTypeIn, coinTypeOut, }: MetaQuoteOptions): Promise<MetaQuote | null>;
|
|
7
|
+
swap({ signer, quote, coinIn, tx }: MetaSwapOptions): Promise<import("@mysten/sui/dist/cjs/transactions").TransactionResult>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/astro.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,aAAa,EAAE,kBAAkB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,QAAQ,CAAC,IAAI,mBAAmB;gBACH,OAAO,EAAE,oBAAoB;IAEpD,KAAK,CAAC,EACV,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA6BzC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,eAAe;CAW1D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
|
-
import {
|
|
3
|
-
export declare class BluefinProvider implements
|
|
2
|
+
import { AggregatorProvider, BluefinProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions, QuoteProvider } from "../../../types/metaAg";
|
|
3
|
+
export declare class BluefinProvider implements QuoteProvider, AggregatorProvider {
|
|
4
4
|
private readonly options;
|
|
5
5
|
private readonly metaOptions;
|
|
6
|
-
kind
|
|
6
|
+
readonly kind = EProvider.BLUEFIN7K;
|
|
7
7
|
constructor(options: BluefinProviderOptions, metaOptions: Required<MetaAgOptions>, client: SuiClient);
|
|
8
8
|
quote(options: MetaQuoteOptions): Promise<MetaQuote>;
|
|
9
9
|
swap({ quote, signer, tx, coinIn }: MetaSwapOptions): Promise<import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAQ/B,qBAAa,eAAgB,YAAW,aAAa,EAAE,kBAAkB;IAGrE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAH9B,QAAQ,CAAC,IAAI,uBAAuB;gBAEjB,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,EACrD,MAAM,EAAE,SAAS;IAgBb,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAqBpD,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,eAAe;CAiB1D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BluefinXProviderOptions, EProvider, MetaFastSwapOptions, MetaQuote, MetaQuoteOptions, QuoteProvider, SwapAPIProvider } from "../../../types/metaAg";
|
|
2
|
+
export declare class BluefinXProvider implements QuoteProvider, SwapAPIProvider {
|
|
3
|
+
private readonly options;
|
|
4
|
+
readonly kind = EProvider.BLUEFINX;
|
|
5
|
+
constructor(options: BluefinXProviderOptions);
|
|
6
|
+
quote(options: MetaQuoteOptions): Promise<MetaQuote | null>;
|
|
7
|
+
canQuote(options: MetaQuoteOptions): boolean;
|
|
8
|
+
fastSwap(options: MetaFastSwapOptions): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=bluefinx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bluefinx.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefinx.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAU/B,qBAAa,gBAAiB,YAAW,aAAa,EAAE,eAAe;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,QAAQ,CAAC,IAAI,sBAAsB;gBACN,OAAO,EAAE,uBAAuB;IAKvD,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAqBjE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAStC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiC9D"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare class CetusProvider implements AgProvider {
|
|
2
|
+
import { AggregatorProvider, CetusProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions, QuoteProvider } from "../../../types/metaAg";
|
|
3
|
+
export declare class CetusProvider implements QuoteProvider, AggregatorProvider {
|
|
5
4
|
private readonly options;
|
|
6
|
-
kind
|
|
5
|
+
readonly kind = EProvider.CETUS;
|
|
7
6
|
private readonly cetusClient;
|
|
8
7
|
constructor(options: CetusProviderOptions, metaOptions: MetaAgOptions, client: SuiClient);
|
|
9
8
|
quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
10
|
-
swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
9
|
+
swap(options: MetaSwapOptions): Promise<import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument>;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=cetus.d.ts.map
|