aftermath-ts-sdk 0.0.126 → 0.0.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/general/api/inspectionsApiHelpers.d.ts +2 -2
- package/dist/general/api/inspectionsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/inspectionsApiHelpers.js +7 -4
- package/dist/general/api/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/transactionsApiHelpers.js +2 -1
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/types/castingTypes.d.ts +6 -0
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/configTypes.d.ts +24 -1
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/utils/casting.d.ts +1 -0
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +1 -0
- package/dist/packages/capys/api/capysApiHelpers.d.ts.map +1 -1
- package/dist/packages/capys/api/capysApiHelpers.js +13 -13
- package/dist/packages/coin/api/coinApiHelpers.d.ts +7 -1
- package/dist/packages/coin/api/coinApiHelpers.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApiHelpers.js +36 -23
- package/dist/packages/external/cetus/cetusApi.d.ts +33 -0
- package/dist/packages/external/cetus/cetusApi.d.ts.map +1 -0
- package/dist/packages/external/cetus/cetusApi.js +56 -0
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts +197 -0
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts.map +1 -0
- package/dist/packages/external/cetus/cetusApiHelpers.js +232 -0
- package/dist/packages/external/cetus/cetusTypes.d.ts +15 -0
- package/dist/packages/external/cetus/cetusTypes.d.ts.map +1 -0
- package/dist/packages/external/cetus/cetusTypes.js +7 -0
- package/dist/packages/external/deepBook/deepBookApi.d.ts +1 -1
- package/dist/packages/external/deepBook/deepBookApi.d.ts.map +1 -1
- package/dist/packages/external/deepBook/deepBookApiHelper.d.ts.map +1 -1
- package/dist/packages/external/deepBook/deepBookApiHelper.js +5 -6
- package/dist/packages/external/deepBook/deepBookTypes.d.ts.map +1 -1
- package/dist/packages/external/nojo/nojoAmmApi.d.ts +1 -1
- package/dist/packages/external/nojo/nojoAmmApi.d.ts.map +1 -1
- package/dist/packages/external/nojo/nojoAmmTypes.d.ts.map +1 -1
- package/dist/packages/external/turbos/turbosApi.d.ts +33 -0
- package/dist/packages/external/turbos/turbosApi.d.ts.map +1 -0
- package/dist/packages/external/turbos/turbosApi.js +56 -0
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts +192 -0
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts.map +1 -0
- package/dist/packages/external/turbos/turbosApiHelpers.js +266 -0
- package/dist/packages/external/turbos/turbosTypes.d.ts +18 -0
- package/dist/packages/external/turbos/turbosTypes.d.ts.map +1 -0
- package/dist/packages/external/turbos/turbosTypes.js +12 -0
- package/dist/packages/faucet/api/faucetApiHelpers.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApiHelpers.js +4 -4
- package/dist/packages/nftAmm/api/nftAmmApiHelpers.js +4 -5
- package/dist/packages/pools/api/poolsApi.js +1 -1
- package/dist/packages/pools/api/poolsApiHelpers.d.ts +1 -1
- package/dist/packages/pools/api/poolsApiHelpers.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApiHelpers.js +11 -10
- package/dist/packages/referralVault/api/referralVaultApi.js +2 -2
- package/dist/packages/referralVault/api/referralVaultApiHelpers.d.ts.map +1 -1
- package/dist/packages/referralVault/api/referralVaultApiHelpers.js +6 -6
- package/dist/packages/router/api/routerApi.d.ts +18 -5
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +45 -11
- package/dist/packages/router/api/routerAsyncApiHelpers.d.ts +16 -0
- package/dist/packages/router/api/routerAsyncApiHelpers.d.ts.map +1 -0
- package/dist/packages/router/api/routerAsyncApiHelpers.js +94 -0
- package/dist/packages/router/api/{routerApiHelpers.d.ts → routerSynchronousApiHelpers.d.ts} +13 -7
- package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts.map +1 -0
- package/dist/packages/router/api/{routerApiHelpers.js → routerSynchronousApiHelpers.js} +74 -26
- package/dist/packages/router/index.d.ts +1 -1
- package/dist/packages/router/index.d.ts.map +1 -1
- package/dist/packages/router/index.js +1 -1
- package/dist/packages/router/router.d.ts +0 -1
- package/dist/packages/router/router.d.ts.map +1 -1
- package/dist/packages/router/router.js +9 -5
- package/dist/packages/router/routerTypes.d.ts +27 -10
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/router/routerTypes.js +17 -0
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts +24 -0
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts.map +1 -0
- package/dist/packages/router/utils/async/routerAsyncGraph.d.ts +12 -0
- package/dist/packages/router/utils/async/routerAsyncGraph.d.ts.map +1 -0
- package/dist/packages/router/utils/async/routerAsyncGraph.js +115 -0
- package/dist/packages/router/utils/{routerApiInterface.d.ts → synchronous/interfaces/routerApiInterface.d.ts} +2 -2
- package/dist/packages/router/utils/synchronous/interfaces/routerApiInterface.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/interfaces/routerApiInterface.js +2 -0
- package/dist/packages/router/utils/{routerPoolInterface.d.ts → synchronous/interfaces/routerPoolInterface.d.ts} +5 -3
- package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.js +32 -0
- package/dist/packages/router/utils/{routerGraph.d.ts → synchronous/routerGraph.d.ts} +30 -5
- package/dist/packages/router/utils/synchronous/routerGraph.d.ts.map +1 -0
- package/dist/packages/router/utils/{routerGraph.js → synchronous/routerGraph.js} +84 -15
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/aftermathRouterPool.d.ts +7 -5
- package/dist/packages/router/utils/synchronous/routerPools/aftermathRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/aftermathRouterPool.js +3 -3
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts +85 -0
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.js +41 -0
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/deepBookRouterPool.d.ts +7 -5
- package/dist/packages/router/utils/synchronous/routerPools/deepBookRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/deepBookRouterPool.js +2 -2
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/nojoRouterPool.d.ts +7 -5
- package/dist/packages/router/utils/synchronous/routerPools/nojoRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/nojoRouterPool.js +3 -3
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts +85 -0
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.js +43 -0
- package/dist/packages/router/utils/synchronous/routerTest.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerTest.js +124 -0
- package/dist/packages/staking/api/stakingApi.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApi.js +4 -2
- package/dist/packages/staking/api/stakingApiHelpers.js +4 -4
- package/dist/packages/staking/staking.d.ts +0 -4
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/staking/staking.js +1 -5
- package/package.json +1 -1
- package/dist/packages/router/api/routerApiHelpers.d.ts.map +0 -1
- package/dist/packages/router/utils/routerApiInterface.d.ts.map +0 -1
- package/dist/packages/router/utils/routerGraph.d.ts.map +0 -1
- package/dist/packages/router/utils/routerPoolInterface.d.ts.map +0 -1
- package/dist/packages/router/utils/routerPoolInterface.js +0 -24
- package/dist/packages/router/utils/routerPools/aftermathRouterPool.d.ts.map +0 -1
- package/dist/packages/router/utils/routerPools/deepBookRouterPool.d.ts.map +0 -1
- package/dist/packages/router/utils/routerPools/nojoRouterPool.d.ts.map +0 -1
- package/dist/packages/router/utils/routerTest.d.ts.map +0 -1
- package/dist/packages/router/utils/routerTest.js +0 -105
- /package/dist/packages/router/utils/{routerApiInterface.js → async/routerAsyncApiInterface.js} +0 -0
- /package/dist/packages/router/utils/{routerTest.d.ts → synchronous/routerTest.d.ts} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
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.TurbosApi = void 0;
|
|
13
|
+
const turbosApiHelpers_1 = require("./turbosApiHelpers");
|
|
14
|
+
const utils_1 = require("../../../general/utils");
|
|
15
|
+
class TurbosApi {
|
|
16
|
+
/////////////////////////////////////////////////////////////////////
|
|
17
|
+
//// Constructor
|
|
18
|
+
/////////////////////////////////////////////////////////////////////
|
|
19
|
+
constructor(Provider) {
|
|
20
|
+
this.Provider = Provider;
|
|
21
|
+
/////////////////////////////////////////////////////////////////////
|
|
22
|
+
//// Public Methods
|
|
23
|
+
/////////////////////////////////////////////////////////////////////
|
|
24
|
+
/////////////////////////////////////////////////////////////////////
|
|
25
|
+
//// Objects
|
|
26
|
+
/////////////////////////////////////////////////////////////////////
|
|
27
|
+
this.fetchPoolForCoinTypes = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return this.Helpers.fetchPoolForCoinTypes(inputs);
|
|
29
|
+
});
|
|
30
|
+
this.fetchAllPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const pools = yield this.Helpers.fetchAllPools();
|
|
32
|
+
return pools;
|
|
33
|
+
});
|
|
34
|
+
this.fetchSupportedCoins = () => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const pools = yield this.Helpers.fetchAllPools();
|
|
36
|
+
const allCoins = pools.reduce((acc, pool) => [...acc, pool.coinTypeA, pool.coinTypeB], []);
|
|
37
|
+
return utils_1.Helpers.uniqueArray(allCoins);
|
|
38
|
+
});
|
|
39
|
+
/////////////////////////////////////////////////////////////////////
|
|
40
|
+
//// Inspections
|
|
41
|
+
/////////////////////////////////////////////////////////////////////
|
|
42
|
+
this.fetchTradeAmountOut = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const tradeResult = yield this.Helpers.fetchCalcTradeResult(inputs);
|
|
44
|
+
return tradeResult.amountOut;
|
|
45
|
+
});
|
|
46
|
+
/////////////////////////////////////////////////////////////////////
|
|
47
|
+
//// Transactions
|
|
48
|
+
/////////////////////////////////////////////////////////////////////
|
|
49
|
+
this.fetchTradeTx = (inputs) => {
|
|
50
|
+
return this.Provider.Transactions().fetchSetGasBudgetAndSerializeTransaction(this.Helpers.fetchBuildTradeTx(inputs));
|
|
51
|
+
};
|
|
52
|
+
this.Provider = Provider;
|
|
53
|
+
this.Helpers = new turbosApiHelpers_1.TurbosApiHelpers(Provider);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TurbosApi = TurbosApi;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ObjectId, SuiAddress, TransactionArgument, TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
import { AftermathApi } from "../../../general/providers/aftermathApi";
|
|
3
|
+
import { Balance, TurbosAddresses, CoinType, PoolsAddresses, ReferralVaultAddresses } from "../../../types";
|
|
4
|
+
import { TurbosCalcTradeResult, TurbosPoolObject } from "./turbosTypes";
|
|
5
|
+
export declare class TurbosApiHelpers {
|
|
6
|
+
readonly Provider: AftermathApi;
|
|
7
|
+
private static readonly constants;
|
|
8
|
+
readonly addresses: {
|
|
9
|
+
turbos: TurbosAddresses;
|
|
10
|
+
pools: PoolsAddresses;
|
|
11
|
+
referralVault: ReferralVaultAddresses;
|
|
12
|
+
};
|
|
13
|
+
constructor(Provider: AftermathApi);
|
|
14
|
+
fetchAllPools: () => Promise<TurbosPoolObject[]>;
|
|
15
|
+
fetchPoolForCoinTypes: (inputs: {
|
|
16
|
+
coinType1: CoinType;
|
|
17
|
+
coinType2: CoinType;
|
|
18
|
+
}) => Promise<TurbosPoolObject>;
|
|
19
|
+
tradeCoinAToCoinBTx: (inputs: {
|
|
20
|
+
tx: TransactionBlock;
|
|
21
|
+
poolObjectId: ObjectId;
|
|
22
|
+
coinInId: ObjectId | TransactionArgument;
|
|
23
|
+
coinInType: CoinType;
|
|
24
|
+
coinOutType: CoinType;
|
|
25
|
+
coinInAmount: Balance;
|
|
26
|
+
feeCoinType: CoinType;
|
|
27
|
+
walletAddress: SuiAddress;
|
|
28
|
+
sqrtPrice: bigint;
|
|
29
|
+
}) => ({
|
|
30
|
+
kind: "Input";
|
|
31
|
+
index: number;
|
|
32
|
+
type?: "object" | "pure" | undefined;
|
|
33
|
+
value?: any;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "GasCoin";
|
|
36
|
+
} | {
|
|
37
|
+
kind: "Result";
|
|
38
|
+
index: number;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "NestedResult";
|
|
41
|
+
index: number;
|
|
42
|
+
resultIndex: number;
|
|
43
|
+
}) & ({
|
|
44
|
+
kind: "Input";
|
|
45
|
+
index: number;
|
|
46
|
+
type?: "object" | "pure" | undefined;
|
|
47
|
+
value?: any;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "GasCoin";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "Result";
|
|
52
|
+
index: number;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "NestedResult";
|
|
55
|
+
index: number;
|
|
56
|
+
resultIndex: number;
|
|
57
|
+
})[];
|
|
58
|
+
tradeCoinBToCoinATx: (inputs: {
|
|
59
|
+
tx: TransactionBlock;
|
|
60
|
+
poolObjectId: ObjectId;
|
|
61
|
+
coinInId: ObjectId | TransactionArgument;
|
|
62
|
+
coinInType: CoinType;
|
|
63
|
+
coinOutType: CoinType;
|
|
64
|
+
coinInAmount: Balance;
|
|
65
|
+
feeCoinType: CoinType;
|
|
66
|
+
walletAddress: SuiAddress;
|
|
67
|
+
sqrtPrice: bigint;
|
|
68
|
+
}) => ({
|
|
69
|
+
kind: "Input";
|
|
70
|
+
index: number;
|
|
71
|
+
type?: "object" | "pure" | undefined;
|
|
72
|
+
value?: any;
|
|
73
|
+
} | {
|
|
74
|
+
kind: "GasCoin";
|
|
75
|
+
} | {
|
|
76
|
+
kind: "Result";
|
|
77
|
+
index: number;
|
|
78
|
+
} | {
|
|
79
|
+
kind: "NestedResult";
|
|
80
|
+
index: number;
|
|
81
|
+
resultIndex: number;
|
|
82
|
+
}) & ({
|
|
83
|
+
kind: "Input";
|
|
84
|
+
index: number;
|
|
85
|
+
type?: "object" | "pure" | undefined;
|
|
86
|
+
value?: any;
|
|
87
|
+
} | {
|
|
88
|
+
kind: "GasCoin";
|
|
89
|
+
} | {
|
|
90
|
+
kind: "Result";
|
|
91
|
+
index: number;
|
|
92
|
+
} | {
|
|
93
|
+
kind: "NestedResult";
|
|
94
|
+
index: number;
|
|
95
|
+
resultIndex: number;
|
|
96
|
+
})[];
|
|
97
|
+
tradeTx: (inputs: {
|
|
98
|
+
tx: TransactionBlock;
|
|
99
|
+
pool: TurbosPoolObject;
|
|
100
|
+
coinInId: ObjectId | TransactionArgument;
|
|
101
|
+
coinInType: CoinType;
|
|
102
|
+
coinOutType: CoinType;
|
|
103
|
+
coinInAmount: Balance;
|
|
104
|
+
walletAddress: SuiAddress;
|
|
105
|
+
}) => ({
|
|
106
|
+
kind: "Input";
|
|
107
|
+
index: number;
|
|
108
|
+
type?: "object" | "pure" | undefined;
|
|
109
|
+
value?: any;
|
|
110
|
+
} | {
|
|
111
|
+
kind: "GasCoin";
|
|
112
|
+
} | {
|
|
113
|
+
kind: "Result";
|
|
114
|
+
index: number;
|
|
115
|
+
} | {
|
|
116
|
+
kind: "NestedResult";
|
|
117
|
+
index: number;
|
|
118
|
+
resultIndex: number;
|
|
119
|
+
}) & ({
|
|
120
|
+
kind: "Input";
|
|
121
|
+
index: number;
|
|
122
|
+
type?: "object" | "pure" | undefined;
|
|
123
|
+
value?: any;
|
|
124
|
+
} | {
|
|
125
|
+
kind: "GasCoin";
|
|
126
|
+
} | {
|
|
127
|
+
kind: "Result";
|
|
128
|
+
index: number;
|
|
129
|
+
} | {
|
|
130
|
+
kind: "NestedResult";
|
|
131
|
+
index: number;
|
|
132
|
+
resultIndex: number;
|
|
133
|
+
})[];
|
|
134
|
+
calcTradeResultTx: (inputs: {
|
|
135
|
+
tx: TransactionBlock;
|
|
136
|
+
poolObjectId: ObjectId;
|
|
137
|
+
coinInType: CoinType;
|
|
138
|
+
coinOutType: CoinType;
|
|
139
|
+
feeCoinType: CoinType;
|
|
140
|
+
coinTypeA: CoinType;
|
|
141
|
+
coinTypeB: CoinType;
|
|
142
|
+
coinInAmount: Balance;
|
|
143
|
+
sqrtPrice: bigint;
|
|
144
|
+
}) => ({
|
|
145
|
+
kind: "Input";
|
|
146
|
+
index: number;
|
|
147
|
+
type?: "object" | "pure" | undefined;
|
|
148
|
+
value?: any;
|
|
149
|
+
} | {
|
|
150
|
+
kind: "GasCoin";
|
|
151
|
+
} | {
|
|
152
|
+
kind: "Result";
|
|
153
|
+
index: number;
|
|
154
|
+
} | {
|
|
155
|
+
kind: "NestedResult";
|
|
156
|
+
index: number;
|
|
157
|
+
resultIndex: number;
|
|
158
|
+
}) & ({
|
|
159
|
+
kind: "Input";
|
|
160
|
+
index: number;
|
|
161
|
+
type?: "object" | "pure" | undefined;
|
|
162
|
+
value?: any;
|
|
163
|
+
} | {
|
|
164
|
+
kind: "GasCoin";
|
|
165
|
+
} | {
|
|
166
|
+
kind: "Result";
|
|
167
|
+
index: number;
|
|
168
|
+
} | {
|
|
169
|
+
kind: "NestedResult";
|
|
170
|
+
index: number;
|
|
171
|
+
resultIndex: number;
|
|
172
|
+
})[];
|
|
173
|
+
fetchBuildTradeTx: (inputs: {
|
|
174
|
+
walletAddress: SuiAddress;
|
|
175
|
+
pool: TurbosPoolObject;
|
|
176
|
+
coinInType: CoinType;
|
|
177
|
+
coinOutType: CoinType;
|
|
178
|
+
coinInAmount: Balance;
|
|
179
|
+
}) => Promise<TransactionBlock>;
|
|
180
|
+
fetchCalcTradeResult: (inputs: {
|
|
181
|
+
walletAddress: SuiAddress;
|
|
182
|
+
pool: TurbosPoolObject;
|
|
183
|
+
coinInType: CoinType;
|
|
184
|
+
coinOutType: CoinType;
|
|
185
|
+
coinInAmount: Balance;
|
|
186
|
+
}) => Promise<TurbosCalcTradeResult>;
|
|
187
|
+
private static partialPoolFromSuiObjectResponse;
|
|
188
|
+
private static isPoolForCoinTypes;
|
|
189
|
+
private static isCoinA;
|
|
190
|
+
private static calcSqrtPriceLimit;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=turbosApiHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbosApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/turbos/turbosApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EAEV,mBAAmB,EACnB,gBAAgB,EAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,OAAO,EACP,eAAe,EACf,QAAQ,EACR,cAAc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OAAO,CACmC;IAEzD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAY/B;CACF"}
|
|
@@ -0,0 +1,266 @@
|
|
|
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.TurbosApiHelpers = void 0;
|
|
13
|
+
const sui_js_1 = require("@mysten/sui.js");
|
|
14
|
+
const sui_1 = require("../../sui");
|
|
15
|
+
const utils_1 = require("../../../general/utils");
|
|
16
|
+
const bcs_1 = require("@mysten/bcs");
|
|
17
|
+
class TurbosApiHelpers {
|
|
18
|
+
// public readonly objectTypes: {
|
|
19
|
+
// pool: AnyObjectType;
|
|
20
|
+
// };
|
|
21
|
+
/////////////////////////////////////////////////////////////////////
|
|
22
|
+
//// Constructor
|
|
23
|
+
/////////////////////////////////////////////////////////////////////
|
|
24
|
+
constructor(Provider) {
|
|
25
|
+
var _a;
|
|
26
|
+
this.Provider = Provider;
|
|
27
|
+
/////////////////////////////////////////////////////////////////////
|
|
28
|
+
//// Public Methods
|
|
29
|
+
/////////////////////////////////////////////////////////////////////
|
|
30
|
+
/////////////////////////////////////////////////////////////////////
|
|
31
|
+
//// Objects
|
|
32
|
+
/////////////////////////////////////////////////////////////////////
|
|
33
|
+
this.fetchAllPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const poolsSimpleInfo = yield this.Provider.DynamicFields().fetchCastAllDynamicFieldsOfType(this.addresses.turbos.objects.poolsTable, (objectIds) => this.Provider.Objects().fetchCastObjectBatch(objectIds, TurbosApiHelpers.partialPoolFromSuiObjectResponse), () => true);
|
|
35
|
+
const sqrtPrices = yield this.Provider.Objects().fetchCastObjectBatch(poolsSimpleInfo.map((poolInfo) => poolInfo.id), (data) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const sqrtPrice = (_a = (0, sui_js_1.getObjectFields)(data)) === null || _a === void 0 ? void 0 : _a.sqrt_price;
|
|
38
|
+
return BigInt(sqrtPrice);
|
|
39
|
+
});
|
|
40
|
+
const pools = poolsSimpleInfo.map((info, index) => {
|
|
41
|
+
return Object.assign(Object.assign({}, info), { sqrtPrice: sqrtPrices[index] });
|
|
42
|
+
});
|
|
43
|
+
return pools;
|
|
44
|
+
});
|
|
45
|
+
this.fetchPoolForCoinTypes = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const allPools = yield this.fetchAllPools();
|
|
47
|
+
// NOTE: will there ever be more than 1 valid pool (is this unsafe ?)
|
|
48
|
+
const foundPool = allPools.find((pool) => TurbosApiHelpers.isPoolForCoinTypes(Object.assign({ pool }, inputs)));
|
|
49
|
+
if (!foundPool)
|
|
50
|
+
throw new Error("no turbos pools found for given coin types");
|
|
51
|
+
return foundPool;
|
|
52
|
+
});
|
|
53
|
+
/////////////////////////////////////////////////////////////////////
|
|
54
|
+
//// Transaction Commands
|
|
55
|
+
/////////////////////////////////////////////////////////////////////
|
|
56
|
+
this.tradeCoinAToCoinBTx = (inputs) => {
|
|
57
|
+
const { tx, coinInId } = inputs;
|
|
58
|
+
return tx.moveCall({
|
|
59
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.turbos.packages.clmm, TurbosApiHelpers.constants.moduleNames.swapRouter, "swap_a_b"),
|
|
60
|
+
typeArguments: [
|
|
61
|
+
inputs.coinInType,
|
|
62
|
+
inputs.coinOutType,
|
|
63
|
+
inputs.feeCoinType,
|
|
64
|
+
],
|
|
65
|
+
arguments: [
|
|
66
|
+
tx.object(inputs.poolObjectId),
|
|
67
|
+
tx.makeMoveVec({
|
|
68
|
+
objects: [
|
|
69
|
+
typeof coinInId === "string"
|
|
70
|
+
? tx.object(coinInId)
|
|
71
|
+
: coinInId,
|
|
72
|
+
],
|
|
73
|
+
}),
|
|
74
|
+
tx.pure(inputs.coinInAmount, "u64"),
|
|
75
|
+
tx.pure(utils_1.Casting.zeroBigInt.toString(), "u64"),
|
|
76
|
+
tx.pure(TurbosApiHelpers.calcSqrtPriceLimit(Object.assign(Object.assign({}, inputs), { isCoinAToCoinB: true })).toString(), "u128"),
|
|
77
|
+
tx.pure(true, "bool"),
|
|
78
|
+
tx.pure(inputs.walletAddress, "address"),
|
|
79
|
+
tx.pure(utils_1.Casting.u64MaxBigInt.toString(), "u64"),
|
|
80
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
81
|
+
tx.object(this.addresses.turbos.objects.versioned),
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
this.tradeCoinBToCoinATx = (inputs) => {
|
|
86
|
+
const { tx, coinInId } = inputs;
|
|
87
|
+
return tx.moveCall({
|
|
88
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.turbos.packages.clmm, TurbosApiHelpers.constants.moduleNames.swapRouter, "swap_b_a"),
|
|
89
|
+
typeArguments: [
|
|
90
|
+
inputs.coinOutType,
|
|
91
|
+
inputs.coinInType,
|
|
92
|
+
inputs.feeCoinType,
|
|
93
|
+
],
|
|
94
|
+
arguments: [
|
|
95
|
+
tx.object(inputs.poolObjectId),
|
|
96
|
+
tx.makeMoveVec({
|
|
97
|
+
objects: [
|
|
98
|
+
typeof coinInId === "string"
|
|
99
|
+
? tx.object(coinInId)
|
|
100
|
+
: coinInId,
|
|
101
|
+
],
|
|
102
|
+
}),
|
|
103
|
+
tx.pure(inputs.coinInAmount, "u64"),
|
|
104
|
+
tx.pure(utils_1.Casting.zeroBigInt.toString(), "u64"),
|
|
105
|
+
tx.pure(TurbosApiHelpers.calcSqrtPriceLimit(Object.assign(Object.assign({}, inputs), { isCoinAToCoinB: false })).toString(), "u128"),
|
|
106
|
+
tx.pure(true, "bool"),
|
|
107
|
+
tx.pure(inputs.walletAddress, "address"),
|
|
108
|
+
tx.pure(utils_1.Casting.u64MaxBigInt.toString(), "u64"),
|
|
109
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
110
|
+
tx.object(this.addresses.turbos.objects.versioned),
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
this.tradeTx = (inputs) => {
|
|
115
|
+
const { coinInType, pool } = inputs;
|
|
116
|
+
const commandInputs = Object.assign(Object.assign(Object.assign({}, inputs), pool), { poolObjectId: pool.id });
|
|
117
|
+
if (TurbosApiHelpers.isCoinA(coinInType, pool))
|
|
118
|
+
return this.tradeCoinAToCoinBTx(commandInputs);
|
|
119
|
+
return this.tradeCoinBToCoinATx(commandInputs);
|
|
120
|
+
};
|
|
121
|
+
/////////////////////////////////////////////////////////////////////
|
|
122
|
+
//// Transaction Inspection Commands
|
|
123
|
+
/////////////////////////////////////////////////////////////////////
|
|
124
|
+
this.calcTradeResultTx = (inputs) => {
|
|
125
|
+
const { tx } = inputs;
|
|
126
|
+
const isCoinAToCoinB = utils_1.Helpers.addLeadingZeroesToType(inputs.coinInType) ===
|
|
127
|
+
utils_1.Helpers.addLeadingZeroesToType(inputs.coinTypeA);
|
|
128
|
+
return tx.moveCall({
|
|
129
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.turbos.packages.clmm, TurbosApiHelpers.constants.moduleNames.poolFetcher, "compute_swap_result"),
|
|
130
|
+
typeArguments: [
|
|
131
|
+
inputs.coinTypeA,
|
|
132
|
+
inputs.coinTypeB,
|
|
133
|
+
inputs.feeCoinType,
|
|
134
|
+
],
|
|
135
|
+
arguments: [
|
|
136
|
+
tx.object(inputs.poolObjectId),
|
|
137
|
+
tx.pure(isCoinAToCoinB, "bool"),
|
|
138
|
+
tx.pure(inputs.coinInAmount, "u128"),
|
|
139
|
+
tx.pure(true, "bool"),
|
|
140
|
+
tx.pure(TurbosApiHelpers.calcSqrtPriceLimit(Object.assign(Object.assign({}, inputs), { isCoinAToCoinB })).toString(), "u128"),
|
|
141
|
+
tx.object(sui_1.Sui.constants.addresses.suiClockId),
|
|
142
|
+
tx.object(this.addresses.turbos.objects.versioned),
|
|
143
|
+
],
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/////////////////////////////////////////////////////////////////////
|
|
147
|
+
//// Transaction Builders
|
|
148
|
+
/////////////////////////////////////////////////////////////////////
|
|
149
|
+
this.fetchBuildTradeTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
const { walletAddress, coinInType, coinInAmount } = inputs;
|
|
151
|
+
const tx = new sui_js_1.TransactionBlock();
|
|
152
|
+
tx.setSender(walletAddress);
|
|
153
|
+
const coinInId = yield this.Provider.Coin().Helpers.fetchCoinWithAmountTx({
|
|
154
|
+
tx,
|
|
155
|
+
walletAddress,
|
|
156
|
+
coinType: coinInType,
|
|
157
|
+
coinAmount: coinInAmount,
|
|
158
|
+
});
|
|
159
|
+
this.tradeTx(Object.assign(Object.assign({ tx }, inputs), { coinInId }));
|
|
160
|
+
return tx;
|
|
161
|
+
});
|
|
162
|
+
/////////////////////////////////////////////////////////////////////
|
|
163
|
+
//// Inspections
|
|
164
|
+
/////////////////////////////////////////////////////////////////////
|
|
165
|
+
this.fetchCalcTradeResult = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
const tx = new sui_js_1.TransactionBlock();
|
|
167
|
+
tx.setSender(inputs.walletAddress);
|
|
168
|
+
this.calcTradeResultTx(Object.assign(Object.assign({ tx, poolObjectId: inputs.pool.id }, inputs.pool), inputs));
|
|
169
|
+
try {
|
|
170
|
+
const resultBytes = yield this.Provider.Inspections().fetchFirstBytesFromTxOutput(tx);
|
|
171
|
+
sui_js_1.bcs.registerStructType("I32", {
|
|
172
|
+
bits: bcs_1.BCS.U32,
|
|
173
|
+
});
|
|
174
|
+
sui_js_1.bcs.registerStructType("ComputeSwapState", {
|
|
175
|
+
amount_a: bcs_1.BCS.U128,
|
|
176
|
+
amount_b: bcs_1.BCS.U128,
|
|
177
|
+
amount_specified_remaining: bcs_1.BCS.U128,
|
|
178
|
+
amount_calculated: bcs_1.BCS.U128,
|
|
179
|
+
sqrt_price: bcs_1.BCS.U128,
|
|
180
|
+
tick_current_index: "I32",
|
|
181
|
+
fee_growth_global: bcs_1.BCS.U128,
|
|
182
|
+
protocol_fee: bcs_1.BCS.U128,
|
|
183
|
+
liquidity: bcs_1.BCS.U128,
|
|
184
|
+
fee_amount: bcs_1.BCS.U128,
|
|
185
|
+
});
|
|
186
|
+
const data = sui_js_1.bcs.de("ComputeSwapState", new Uint8Array(resultBytes));
|
|
187
|
+
const amountIn = BigInt(data.amount_a) <= BigInt(0)
|
|
188
|
+
? BigInt(data.amount_b)
|
|
189
|
+
: BigInt(data.amount_a);
|
|
190
|
+
return {
|
|
191
|
+
amountIn,
|
|
192
|
+
amountOut: BigInt(data.amount_calculated),
|
|
193
|
+
feeAmount: BigInt(data.fee_amount),
|
|
194
|
+
protocolFee: BigInt(data.protocol_fee),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
console.error(e);
|
|
199
|
+
throw new Error("e");
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
const turbos = (_a = this.Provider.addresses.externalRouter) === null || _a === void 0 ? void 0 : _a.turbos;
|
|
203
|
+
const pools = this.Provider.addresses.pools;
|
|
204
|
+
const referralVault = this.Provider.addresses.referralVault;
|
|
205
|
+
if (!turbos || !pools || !referralVault)
|
|
206
|
+
throw new Error("not all required addresses have been set in provider");
|
|
207
|
+
this.Provider = Provider;
|
|
208
|
+
this.addresses = {
|
|
209
|
+
turbos,
|
|
210
|
+
pools,
|
|
211
|
+
referralVault,
|
|
212
|
+
};
|
|
213
|
+
// this.objectTypes = {
|
|
214
|
+
// pool: `${turbos.packages.clmm}::pool::Pool`,
|
|
215
|
+
// };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.TurbosApiHelpers = TurbosApiHelpers;
|
|
219
|
+
/////////////////////////////////////////////////////////////////////
|
|
220
|
+
//// Constants
|
|
221
|
+
/////////////////////////////////////////////////////////////////////
|
|
222
|
+
TurbosApiHelpers.constants = {
|
|
223
|
+
moduleNames: {
|
|
224
|
+
poolFetcher: "pool_fetcher",
|
|
225
|
+
swapRouter: "swap_router",
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
/////////////////////////////////////////////////////////////////////
|
|
229
|
+
//// Private Static Methods
|
|
230
|
+
/////////////////////////////////////////////////////////////////////
|
|
231
|
+
/////////////////////////////////////////////////////////////////////
|
|
232
|
+
//// Casting
|
|
233
|
+
/////////////////////////////////////////////////////////////////////
|
|
234
|
+
TurbosApiHelpers.partialPoolFromSuiObjectResponse = (data) => {
|
|
235
|
+
var _a;
|
|
236
|
+
const content = (_a = data.data) === null || _a === void 0 ? void 0 : _a.content;
|
|
237
|
+
if ((content === null || content === void 0 ? void 0 : content.dataType) !== "moveObject")
|
|
238
|
+
throw new Error("sui object response is not an object");
|
|
239
|
+
const fields = content.fields.value.fields;
|
|
240
|
+
return {
|
|
241
|
+
id: fields.pool_id,
|
|
242
|
+
coinTypeA: utils_1.Helpers.addLeadingZeroesToType("0x" + fields.coin_type_a.fields.name),
|
|
243
|
+
coinTypeB: utils_1.Helpers.addLeadingZeroesToType("0x" + fields.coin_type_b.fields.name),
|
|
244
|
+
feeCoinType: utils_1.Helpers.addLeadingZeroesToType("0x" + fields.fee_type.fields.name),
|
|
245
|
+
fee: BigInt(fields.fee),
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/////////////////////////////////////////////////////////////////////
|
|
249
|
+
//// Helpers
|
|
250
|
+
/////////////////////////////////////////////////////////////////////
|
|
251
|
+
TurbosApiHelpers.isPoolForCoinTypes = (inputs) => {
|
|
252
|
+
const { pool, coinType1, coinType2 } = inputs;
|
|
253
|
+
return ((pool.coinTypeA === utils_1.Helpers.addLeadingZeroesToType(coinType1) &&
|
|
254
|
+
pool.coinTypeB === utils_1.Helpers.addLeadingZeroesToType(coinType2)) ||
|
|
255
|
+
(pool.coinTypeA === utils_1.Helpers.addLeadingZeroesToType(coinType2) &&
|
|
256
|
+
pool.coinTypeB === utils_1.Helpers.addLeadingZeroesToType(coinType1)));
|
|
257
|
+
};
|
|
258
|
+
TurbosApiHelpers.isCoinA = (coin, pool) => utils_1.Helpers.addLeadingZeroesToType(coin) === pool.coinTypeA;
|
|
259
|
+
TurbosApiHelpers.calcSqrtPriceLimit = (inputs) => {
|
|
260
|
+
const { sqrtPrice, isCoinAToCoinB } = inputs;
|
|
261
|
+
const change = sqrtPrice / BigInt(100);
|
|
262
|
+
const sqrtPriceLimit = isCoinAToCoinB
|
|
263
|
+
? sqrtPrice - change
|
|
264
|
+
: sqrtPrice + change;
|
|
265
|
+
return sqrtPriceLimit;
|
|
266
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ObjectId } from "@mysten/sui.js";
|
|
2
|
+
import { Balance, CoinType, RouterSerializablePool } from "../../../types";
|
|
3
|
+
export interface TurbosPoolObject {
|
|
4
|
+
id: ObjectId;
|
|
5
|
+
coinTypeA: CoinType;
|
|
6
|
+
coinTypeB: CoinType;
|
|
7
|
+
fee: bigint;
|
|
8
|
+
feeCoinType: CoinType;
|
|
9
|
+
sqrtPrice: bigint;
|
|
10
|
+
}
|
|
11
|
+
export interface TurbosCalcTradeResult {
|
|
12
|
+
amountIn: Balance;
|
|
13
|
+
amountOut: Balance;
|
|
14
|
+
feeAmount: Balance;
|
|
15
|
+
protocolFee: bigint;
|
|
16
|
+
}
|
|
17
|
+
export declare const isTurbosPoolObject: (pool: RouterSerializablePool) => pool is TurbosPoolObject;
|
|
18
|
+
//# sourceMappingURL=turbosTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbosTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/turbos/turbosTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAM3E,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,QAAQ,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,kBAAkB,SACxB,sBAAsB,6BAU5B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTurbosPoolObject = void 0;
|
|
4
|
+
const isTurbosPoolObject = (pool) => {
|
|
5
|
+
return ("id" in pool &&
|
|
6
|
+
"coinTypeA" in pool &&
|
|
7
|
+
"coinTypeB" in pool &&
|
|
8
|
+
"fee" in pool &&
|
|
9
|
+
"feeCoinType" in pool &&
|
|
10
|
+
"sqrtPrice" in pool);
|
|
11
|
+
};
|
|
12
|
+
exports.isTurbosPoolObject = isTurbosPoolObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faucetApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/faucet/api/faucetApiH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AAS,CAAC,gBAAgB,eAMxB;CACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FaucetApiHelpers = void 0;
|
|
4
|
-
const aftermathApi_1 = require("../../../general/providers/aftermathApi");
|
|
5
4
|
const eventsApiHelpers_1 = require("../../../general/api/eventsApiHelpers");
|
|
6
5
|
const sui_js_1 = require("@mysten/sui.js");
|
|
6
|
+
const utils_1 = require("../../../general/utils");
|
|
7
7
|
class FaucetApiHelpers {
|
|
8
8
|
/////////////////////////////////////////////////////////////////////
|
|
9
9
|
//// Constructor
|
|
@@ -16,7 +16,7 @@ class FaucetApiHelpers {
|
|
|
16
16
|
this.faucetAddCoinTransaction = (treasuryCapId, treasuryCapType) => {
|
|
17
17
|
const tx = new sui_js_1.TransactionBlock();
|
|
18
18
|
tx.moveCall({
|
|
19
|
-
target:
|
|
19
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.packages.faucet, FaucetApiHelpers.constants.faucetModuleName, FaucetApiHelpers.constants.functions.add.name),
|
|
20
20
|
typeArguments: [treasuryCapType],
|
|
21
21
|
arguments: [
|
|
22
22
|
tx.object(this.addresses.objects.faucet),
|
|
@@ -29,7 +29,7 @@ class FaucetApiHelpers {
|
|
|
29
29
|
const tx = new sui_js_1.TransactionBlock();
|
|
30
30
|
tx.setSender(walletAddress);
|
|
31
31
|
tx.moveCall({
|
|
32
|
-
target:
|
|
32
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.packages.faucet, FaucetApiHelpers.constants.faucetModuleName, FaucetApiHelpers.constants.functions.requestAmount.name),
|
|
33
33
|
typeArguments: [coinType],
|
|
34
34
|
arguments: [
|
|
35
35
|
tx.object(this.addresses.objects.faucet),
|
|
@@ -41,7 +41,7 @@ class FaucetApiHelpers {
|
|
|
41
41
|
this.faucetRequestCoinTransaction = (coinType) => {
|
|
42
42
|
const tx = new sui_js_1.TransactionBlock();
|
|
43
43
|
tx.moveCall({
|
|
44
|
-
target:
|
|
44
|
+
target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.packages.faucet, FaucetApiHelpers.constants.faucetModuleName, FaucetApiHelpers.constants.functions.request.name),
|
|
45
45
|
typeArguments: [coinType],
|
|
46
46
|
arguments: [tx.object(this.addresses.objects.faucet)],
|
|
47
47
|
});
|