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.
Files changed (122) hide show
  1. package/dist/general/api/inspectionsApiHelpers.d.ts +2 -2
  2. package/dist/general/api/inspectionsApiHelpers.d.ts.map +1 -1
  3. package/dist/general/api/inspectionsApiHelpers.js +7 -4
  4. package/dist/general/api/transactionsApiHelpers.d.ts.map +1 -1
  5. package/dist/general/api/transactionsApiHelpers.js +2 -1
  6. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  7. package/dist/general/types/castingTypes.d.ts +6 -0
  8. package/dist/general/types/castingTypes.d.ts.map +1 -1
  9. package/dist/general/types/configTypes.d.ts +24 -1
  10. package/dist/general/types/configTypes.d.ts.map +1 -1
  11. package/dist/general/utils/casting.d.ts +1 -0
  12. package/dist/general/utils/casting.d.ts.map +1 -1
  13. package/dist/general/utils/casting.js +1 -0
  14. package/dist/packages/capys/api/capysApiHelpers.d.ts.map +1 -1
  15. package/dist/packages/capys/api/capysApiHelpers.js +13 -13
  16. package/dist/packages/coin/api/coinApiHelpers.d.ts +7 -1
  17. package/dist/packages/coin/api/coinApiHelpers.d.ts.map +1 -1
  18. package/dist/packages/coin/api/coinApiHelpers.js +36 -23
  19. package/dist/packages/external/cetus/cetusApi.d.ts +33 -0
  20. package/dist/packages/external/cetus/cetusApi.d.ts.map +1 -0
  21. package/dist/packages/external/cetus/cetusApi.js +56 -0
  22. package/dist/packages/external/cetus/cetusApiHelpers.d.ts +197 -0
  23. package/dist/packages/external/cetus/cetusApiHelpers.d.ts.map +1 -0
  24. package/dist/packages/external/cetus/cetusApiHelpers.js +232 -0
  25. package/dist/packages/external/cetus/cetusTypes.d.ts +15 -0
  26. package/dist/packages/external/cetus/cetusTypes.d.ts.map +1 -0
  27. package/dist/packages/external/cetus/cetusTypes.js +7 -0
  28. package/dist/packages/external/deepBook/deepBookApi.d.ts +1 -1
  29. package/dist/packages/external/deepBook/deepBookApi.d.ts.map +1 -1
  30. package/dist/packages/external/deepBook/deepBookApiHelper.d.ts.map +1 -1
  31. package/dist/packages/external/deepBook/deepBookApiHelper.js +5 -6
  32. package/dist/packages/external/deepBook/deepBookTypes.d.ts.map +1 -1
  33. package/dist/packages/external/nojo/nojoAmmApi.d.ts +1 -1
  34. package/dist/packages/external/nojo/nojoAmmApi.d.ts.map +1 -1
  35. package/dist/packages/external/nojo/nojoAmmTypes.d.ts.map +1 -1
  36. package/dist/packages/external/turbos/turbosApi.d.ts +33 -0
  37. package/dist/packages/external/turbos/turbosApi.d.ts.map +1 -0
  38. package/dist/packages/external/turbos/turbosApi.js +56 -0
  39. package/dist/packages/external/turbos/turbosApiHelpers.d.ts +192 -0
  40. package/dist/packages/external/turbos/turbosApiHelpers.d.ts.map +1 -0
  41. package/dist/packages/external/turbos/turbosApiHelpers.js +266 -0
  42. package/dist/packages/external/turbos/turbosTypes.d.ts +18 -0
  43. package/dist/packages/external/turbos/turbosTypes.d.ts.map +1 -0
  44. package/dist/packages/external/turbos/turbosTypes.js +12 -0
  45. package/dist/packages/faucet/api/faucetApiHelpers.d.ts.map +1 -1
  46. package/dist/packages/faucet/api/faucetApiHelpers.js +4 -4
  47. package/dist/packages/nftAmm/api/nftAmmApiHelpers.js +4 -5
  48. package/dist/packages/pools/api/poolsApi.js +1 -1
  49. package/dist/packages/pools/api/poolsApiHelpers.d.ts +1 -1
  50. package/dist/packages/pools/api/poolsApiHelpers.d.ts.map +1 -1
  51. package/dist/packages/pools/api/poolsApiHelpers.js +11 -10
  52. package/dist/packages/referralVault/api/referralVaultApi.js +2 -2
  53. package/dist/packages/referralVault/api/referralVaultApiHelpers.d.ts.map +1 -1
  54. package/dist/packages/referralVault/api/referralVaultApiHelpers.js +6 -6
  55. package/dist/packages/router/api/routerApi.d.ts +18 -5
  56. package/dist/packages/router/api/routerApi.d.ts.map +1 -1
  57. package/dist/packages/router/api/routerApi.js +45 -11
  58. package/dist/packages/router/api/routerAsyncApiHelpers.d.ts +16 -0
  59. package/dist/packages/router/api/routerAsyncApiHelpers.d.ts.map +1 -0
  60. package/dist/packages/router/api/routerAsyncApiHelpers.js +94 -0
  61. package/dist/packages/router/api/{routerApiHelpers.d.ts → routerSynchronousApiHelpers.d.ts} +13 -7
  62. package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts.map +1 -0
  63. package/dist/packages/router/api/{routerApiHelpers.js → routerSynchronousApiHelpers.js} +74 -26
  64. package/dist/packages/router/index.d.ts +1 -1
  65. package/dist/packages/router/index.d.ts.map +1 -1
  66. package/dist/packages/router/index.js +1 -1
  67. package/dist/packages/router/router.d.ts +0 -1
  68. package/dist/packages/router/router.d.ts.map +1 -1
  69. package/dist/packages/router/router.js +9 -5
  70. package/dist/packages/router/routerTypes.d.ts +27 -10
  71. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  72. package/dist/packages/router/routerTypes.js +17 -0
  73. package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts +24 -0
  74. package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts.map +1 -0
  75. package/dist/packages/router/utils/async/routerAsyncGraph.d.ts +12 -0
  76. package/dist/packages/router/utils/async/routerAsyncGraph.d.ts.map +1 -0
  77. package/dist/packages/router/utils/async/routerAsyncGraph.js +115 -0
  78. package/dist/packages/router/utils/{routerApiInterface.d.ts → synchronous/interfaces/routerApiInterface.d.ts} +2 -2
  79. package/dist/packages/router/utils/synchronous/interfaces/routerApiInterface.d.ts.map +1 -0
  80. package/dist/packages/router/utils/synchronous/interfaces/routerApiInterface.js +2 -0
  81. package/dist/packages/router/utils/{routerPoolInterface.d.ts → synchronous/interfaces/routerPoolInterface.d.ts} +5 -3
  82. package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.d.ts.map +1 -0
  83. package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.js +32 -0
  84. package/dist/packages/router/utils/{routerGraph.d.ts → synchronous/routerGraph.d.ts} +30 -5
  85. package/dist/packages/router/utils/synchronous/routerGraph.d.ts.map +1 -0
  86. package/dist/packages/router/utils/{routerGraph.js → synchronous/routerGraph.js} +84 -15
  87. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/aftermathRouterPool.d.ts +7 -5
  88. package/dist/packages/router/utils/synchronous/routerPools/aftermathRouterPool.d.ts.map +1 -0
  89. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/aftermathRouterPool.js +3 -3
  90. package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts +85 -0
  91. package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts.map +1 -0
  92. package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.js +41 -0
  93. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/deepBookRouterPool.d.ts +7 -5
  94. package/dist/packages/router/utils/synchronous/routerPools/deepBookRouterPool.d.ts.map +1 -0
  95. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/deepBookRouterPool.js +2 -2
  96. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/nojoRouterPool.d.ts +7 -5
  97. package/dist/packages/router/utils/synchronous/routerPools/nojoRouterPool.d.ts.map +1 -0
  98. package/dist/packages/router/utils/{routerPools → synchronous/routerPools}/nojoRouterPool.js +3 -3
  99. package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts +85 -0
  100. package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts.map +1 -0
  101. package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.js +43 -0
  102. package/dist/packages/router/utils/synchronous/routerTest.d.ts.map +1 -0
  103. package/dist/packages/router/utils/synchronous/routerTest.js +124 -0
  104. package/dist/packages/staking/api/stakingApi.d.ts.map +1 -1
  105. package/dist/packages/staking/api/stakingApi.js +4 -2
  106. package/dist/packages/staking/api/stakingApiHelpers.js +4 -4
  107. package/dist/packages/staking/staking.d.ts +0 -4
  108. package/dist/packages/staking/staking.d.ts.map +1 -1
  109. package/dist/packages/staking/staking.js +1 -5
  110. package/package.json +1 -1
  111. package/dist/packages/router/api/routerApiHelpers.d.ts.map +0 -1
  112. package/dist/packages/router/utils/routerApiInterface.d.ts.map +0 -1
  113. package/dist/packages/router/utils/routerGraph.d.ts.map +0 -1
  114. package/dist/packages/router/utils/routerPoolInterface.d.ts.map +0 -1
  115. package/dist/packages/router/utils/routerPoolInterface.js +0 -24
  116. package/dist/packages/router/utils/routerPools/aftermathRouterPool.d.ts.map +0 -1
  117. package/dist/packages/router/utils/routerPools/deepBookRouterPool.d.ts.map +0 -1
  118. package/dist/packages/router/utils/routerPools/nojoRouterPool.d.ts.map +0 -1
  119. package/dist/packages/router/utils/routerTest.d.ts.map +0 -1
  120. package/dist/packages/router/utils/routerTest.js +0 -105
  121. /package/dist/packages/router/utils/{routerApiInterface.js → async/routerAsyncApiInterface.js} +0 -0
  122. /package/dist/packages/router/utils/{routerTest.d.ts → synchronous/routerTest.d.ts} +0 -0
@@ -0,0 +1,197 @@
1
+ import { ObjectId, SuiAddress, TransactionArgument, TransactionBlock } from "@mysten/sui.js";
2
+ import { AftermathApi } from "../../../general/providers/aftermathApi";
3
+ import { AnyObjectType, Balance, CetusAddresses, CoinType, PoolsAddresses, ReferralVaultAddresses } from "../../../types";
4
+ import { CetusCalcTradeResult, CetusPoolObject } from "./cetusTypes";
5
+ export declare class CetusApiHelpers {
6
+ readonly Provider: AftermathApi;
7
+ private static readonly constants;
8
+ readonly addresses: {
9
+ cetus: CetusAddresses;
10
+ pools: PoolsAddresses;
11
+ referralVault: ReferralVaultAddresses;
12
+ };
13
+ readonly objectTypes: {
14
+ pool: AnyObjectType;
15
+ };
16
+ constructor(Provider: AftermathApi);
17
+ fetchAllPools: () => Promise<CetusPoolObject[]>;
18
+ fetchPoolForCoinTypes: (inputs: {
19
+ coinType1: CoinType;
20
+ coinType2: CoinType;
21
+ }) => Promise<CetusPoolObject>;
22
+ tradeCoinAToCoinBTx: (inputs: {
23
+ tx: TransactionBlock;
24
+ poolObjectId: ObjectId;
25
+ coinInId: ObjectId | TransactionArgument;
26
+ coinInType: CoinType;
27
+ coinOutType: CoinType;
28
+ } & ({
29
+ coinInAmount: Balance;
30
+ } | {
31
+ coinOutAmount: Balance;
32
+ })) => ({
33
+ kind: "Input";
34
+ index: number;
35
+ type?: "object" | "pure" | undefined;
36
+ value?: any;
37
+ } | {
38
+ kind: "GasCoin";
39
+ } | {
40
+ kind: "Result";
41
+ index: number;
42
+ } | {
43
+ kind: "NestedResult";
44
+ index: number;
45
+ resultIndex: number;
46
+ }) & ({
47
+ kind: "Input";
48
+ index: number;
49
+ type?: "object" | "pure" | undefined;
50
+ value?: any;
51
+ } | {
52
+ kind: "GasCoin";
53
+ } | {
54
+ kind: "Result";
55
+ index: number;
56
+ } | {
57
+ kind: "NestedResult";
58
+ index: number;
59
+ resultIndex: number;
60
+ })[];
61
+ tradeCoinBToCoinATx: (inputs: {
62
+ tx: TransactionBlock;
63
+ poolObjectId: ObjectId;
64
+ coinInId: ObjectId | TransactionArgument;
65
+ coinInType: CoinType;
66
+ coinOutType: CoinType;
67
+ } & ({
68
+ coinInAmount: Balance;
69
+ } | {
70
+ coinOutAmount: Balance;
71
+ })) => ({
72
+ kind: "Input";
73
+ index: number;
74
+ type?: "object" | "pure" | undefined;
75
+ value?: any;
76
+ } | {
77
+ kind: "GasCoin";
78
+ } | {
79
+ kind: "Result";
80
+ index: number;
81
+ } | {
82
+ kind: "NestedResult";
83
+ index: number;
84
+ resultIndex: number;
85
+ }) & ({
86
+ kind: "Input";
87
+ index: number;
88
+ type?: "object" | "pure" | undefined;
89
+ value?: any;
90
+ } | {
91
+ kind: "GasCoin";
92
+ } | {
93
+ kind: "Result";
94
+ index: number;
95
+ } | {
96
+ kind: "NestedResult";
97
+ index: number;
98
+ resultIndex: number;
99
+ })[];
100
+ tradeTx: (inputs: {
101
+ tx: TransactionBlock;
102
+ pool: CetusPoolObject;
103
+ coinInId: ObjectId | TransactionArgument;
104
+ coinInType: CoinType;
105
+ coinOutType: CoinType;
106
+ } & ({
107
+ coinInAmount: Balance;
108
+ } | {
109
+ coinOutAmount: Balance;
110
+ })) => ({
111
+ kind: "Input";
112
+ index: number;
113
+ type?: "object" | "pure" | undefined;
114
+ value?: any;
115
+ } | {
116
+ kind: "GasCoin";
117
+ } | {
118
+ kind: "Result";
119
+ index: number;
120
+ } | {
121
+ kind: "NestedResult";
122
+ index: number;
123
+ resultIndex: number;
124
+ }) & ({
125
+ kind: "Input";
126
+ index: number;
127
+ type?: "object" | "pure" | undefined;
128
+ value?: any;
129
+ } | {
130
+ kind: "GasCoin";
131
+ } | {
132
+ kind: "Result";
133
+ index: number;
134
+ } | {
135
+ kind: "NestedResult";
136
+ index: number;
137
+ resultIndex: number;
138
+ })[];
139
+ calcTradeResultTx: (inputs: {
140
+ tx: TransactionBlock;
141
+ poolObjectId: ObjectId;
142
+ coinInType: CoinType;
143
+ coinOutType: CoinType;
144
+ coinTypeA: CoinType;
145
+ coinTypeB: CoinType;
146
+ } & ({
147
+ coinInAmount: Balance;
148
+ } | {
149
+ coinOutAmount: Balance;
150
+ })) => ({
151
+ kind: "Input";
152
+ index: number;
153
+ type?: "object" | "pure" | undefined;
154
+ value?: any;
155
+ } | {
156
+ kind: "GasCoin";
157
+ } | {
158
+ kind: "Result";
159
+ index: number;
160
+ } | {
161
+ kind: "NestedResult";
162
+ index: number;
163
+ resultIndex: number;
164
+ }) & ({
165
+ kind: "Input";
166
+ index: number;
167
+ type?: "object" | "pure" | undefined;
168
+ value?: any;
169
+ } | {
170
+ kind: "GasCoin";
171
+ } | {
172
+ kind: "Result";
173
+ index: number;
174
+ } | {
175
+ kind: "NestedResult";
176
+ index: number;
177
+ resultIndex: number;
178
+ })[];
179
+ fetchBuildTradeTx: (inputs: {
180
+ walletAddress: SuiAddress;
181
+ pool: CetusPoolObject;
182
+ coinInType: CoinType;
183
+ coinOutType: CoinType;
184
+ coinInAmount: Balance;
185
+ }) => Promise<TransactionBlock>;
186
+ fetchCalcTradeResult: (inputs: {
187
+ walletAddress: SuiAddress;
188
+ pool: CetusPoolObject;
189
+ coinInType: CoinType;
190
+ coinOutType: CoinType;
191
+ coinInAmount: Balance;
192
+ }) => Promise<CetusCalcTradeResult>;
193
+ private static poolFromSuiObjectResponse;
194
+ private static isPoolForCoinTypes;
195
+ private static isCoinA;
196
+ }
197
+ //# sourceMappingURL=cetusApiHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cetusApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/cetus/cetusApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EAEV,mBAAmB,EACnB,gBAAgB,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,aAAa,EACb,OAAO,EACP,cAAc,EACd,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMrE,qBAAa,eAAe;aA8BC,QAAQ,EAAE,YAAY;IAzBlD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAK/B;IAMF,SAAgB,SAAS,EAAE;QAC1B,KAAK,EAAE,cAAc,CAAC;QACtB,KAAK,EAAE,cAAc,CAAC;QACtB,aAAa,EAAE,sBAAsB,CAAC;KACtC,CAAC;IAEF,SAAgB,WAAW,EAAE;QAC5B,IAAI,EAAE,aAAa,CAAC;KACpB,CAAC;gBAM0B,QAAQ,EAAE,YAAY;IA8B3C,aAAa,mCAalB;IAEK,qBAAqB,WAAkB;QAC7C,SAAS,EAAE,QAAQ,CAAC;QACpB,SAAS,EAAE,QAAQ,CAAC;KACpB,8BAeC;IAMK,mBAAmB,WACjB;QACP,EAAE,EAAE,gBAAgB,CAAC;QACrB,YAAY,EAAE,QAAQ,CAAC;QACvB,QAAQ,E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BAAiB,WAAkB;QACzC,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,eAAe,CAAC;QACtB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;KACtB,KAAG,QAAQ,gBAAgB,CAAC,CAqB3B;IAMK,oBAAoB,WAAkB;QAC5C,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,eAAe,CAAC;QACtB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;KACtB,KAAG,QAAQ,oBAAoB,CAAC,CA6C/B;IAUF,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAkBtC;IAMF,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAa/B;IAEF,OAAO,CAAC,MAAM,CAAC,OAAO,CACmC;CACzD"}
@@ -0,0 +1,232 @@
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.CetusApiHelpers = 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 CetusApiHelpers {
18
+ /////////////////////////////////////////////////////////////////////
19
+ //// Constructor
20
+ /////////////////////////////////////////////////////////////////////
21
+ constructor(Provider) {
22
+ var _a;
23
+ this.Provider = Provider;
24
+ /////////////////////////////////////////////////////////////////////
25
+ //// Public Methods
26
+ /////////////////////////////////////////////////////////////////////
27
+ /////////////////////////////////////////////////////////////////////
28
+ //// Objects
29
+ /////////////////////////////////////////////////////////////////////
30
+ this.fetchAllPools = () => __awaiter(this, void 0, void 0, function* () {
31
+ const poolsSimpleInfo = yield this.Provider.DynamicFields().fetchCastAllDynamicFieldsOfType(this.addresses.cetus.objects.poolsTable, (objectIds) => this.Provider.Objects().fetchCastObjectBatch(objectIds, CetusApiHelpers.poolFromSuiObjectResponse), () => true);
32
+ return poolsSimpleInfo;
33
+ });
34
+ this.fetchPoolForCoinTypes = (inputs) => __awaiter(this, void 0, void 0, function* () {
35
+ const allPools = yield this.fetchAllPools();
36
+ // NOTE: will there ever be more than 1 valid pool (is this unsafe ?)
37
+ const foundPool = allPools.find((pool) => CetusApiHelpers.isPoolForCoinTypes(Object.assign({ pool }, inputs)));
38
+ if (!foundPool)
39
+ throw new Error("no cetus pools found for given coin types");
40
+ return foundPool;
41
+ });
42
+ /////////////////////////////////////////////////////////////////////
43
+ //// Transaction Commands
44
+ /////////////////////////////////////////////////////////////////////
45
+ this.tradeCoinAToCoinBTx = (inputs) => {
46
+ const { tx, coinInId } = inputs;
47
+ return tx.moveCall({
48
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.cetus.packages.scripts, CetusApiHelpers.constants.moduleNames.poolScript, "swap_a2b"),
49
+ typeArguments: [inputs.coinInType, inputs.coinOutType],
50
+ arguments: [
51
+ tx.object(this.addresses.cetus.objects.globalConfig),
52
+ tx.object(inputs.poolObjectId),
53
+ tx.makeMoveVec({
54
+ objects: [
55
+ typeof coinInId === "string"
56
+ ? tx.object(coinInId)
57
+ : coinInId,
58
+ ],
59
+ }),
60
+ tx.pure("coinInAmount" in inputs, "bool"),
61
+ tx.pure("coinInAmount" in inputs
62
+ ? inputs.coinInAmount
63
+ : inputs.coinOutAmount, "u64"),
64
+ tx.pure(
65
+ // "coinInAmount" in inputs
66
+ // ? inputs.coinInAmount
67
+ // : inputs.coinOutAmount,
68
+ "0", "u64"),
69
+ tx.pure(BigInt("4295048016"), "u128"),
70
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
71
+ ],
72
+ });
73
+ };
74
+ this.tradeCoinBToCoinATx = (inputs) => {
75
+ const { tx, coinInId } = inputs;
76
+ return tx.moveCall({
77
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.cetus.packages.scripts, CetusApiHelpers.constants.moduleNames.poolScript, "swap_b2a"),
78
+ typeArguments: [inputs.coinOutType, inputs.coinInType],
79
+ arguments: [
80
+ tx.object(this.addresses.cetus.objects.globalConfig),
81
+ tx.object(inputs.poolObjectId),
82
+ tx.makeMoveVec({
83
+ objects: [
84
+ typeof coinInId === "string"
85
+ ? tx.object(coinInId)
86
+ : coinInId,
87
+ ],
88
+ }),
89
+ tx.pure("coinInAmount" in inputs, "bool"),
90
+ tx.pure("coinInAmount" in inputs
91
+ ? inputs.coinInAmount
92
+ : inputs.coinOutAmount, "u64"),
93
+ tx.pure(
94
+ // "coinInAmount" in inputs
95
+ // ? inputs.coinInAmount
96
+ // : inputs.coinOutAmount,
97
+ "0", "u64"),
98
+ tx.pure(BigInt("79226673515401279992447579055"), "u128"),
99
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
100
+ ],
101
+ });
102
+ };
103
+ this.tradeTx = (inputs) => {
104
+ const { coinInType, pool } = inputs;
105
+ const commandInputs = Object.assign(Object.assign({}, inputs), { poolObjectId: pool.id });
106
+ if (CetusApiHelpers.isCoinA(coinInType, pool))
107
+ return this.tradeCoinAToCoinBTx(commandInputs);
108
+ return this.tradeCoinBToCoinATx(commandInputs);
109
+ };
110
+ /////////////////////////////////////////////////////////////////////
111
+ //// Transaction Inspection Commands
112
+ /////////////////////////////////////////////////////////////////////
113
+ this.calcTradeResultTx = (inputs) => {
114
+ const { tx } = inputs;
115
+ return tx.moveCall({
116
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.cetus.packages.clmm, CetusApiHelpers.constants.moduleNames.pool, "calculate_swap_result"),
117
+ typeArguments: [inputs.coinTypeA, inputs.coinTypeB],
118
+ arguments: [
119
+ tx.object(inputs.poolObjectId),
120
+ tx.pure(inputs.coinInType === inputs.coinTypeA, "bool"),
121
+ tx.pure("coinInAmount" in inputs, "bool"),
122
+ tx.pure("coinInAmount" in inputs
123
+ ? inputs.coinInAmount
124
+ : inputs.coinOutAmount, "u64"), // amount
125
+ ],
126
+ });
127
+ };
128
+ /////////////////////////////////////////////////////////////////////
129
+ //// Transaction Builders
130
+ /////////////////////////////////////////////////////////////////////
131
+ this.fetchBuildTradeTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
132
+ const { walletAddress, coinInType, coinInAmount } = inputs;
133
+ const tx = new sui_js_1.TransactionBlock();
134
+ tx.setSender(walletAddress);
135
+ const coinInId = yield this.Provider.Coin().Helpers.fetchCoinWithAmountTx({
136
+ tx,
137
+ walletAddress,
138
+ coinType: coinInType,
139
+ coinAmount: coinInAmount,
140
+ });
141
+ this.tradeTx(Object.assign(Object.assign({ tx }, inputs), { coinInId }));
142
+ return tx;
143
+ });
144
+ /////////////////////////////////////////////////////////////////////
145
+ //// Inspections
146
+ /////////////////////////////////////////////////////////////////////
147
+ this.fetchCalcTradeResult = (inputs) => __awaiter(this, void 0, void 0, function* () {
148
+ const tx = new sui_js_1.TransactionBlock();
149
+ tx.setSender(inputs.walletAddress);
150
+ this.calcTradeResultTx(Object.assign(Object.assign({ tx, poolObjectId: inputs.pool.id }, inputs.pool), inputs));
151
+ const resultBytes = yield this.Provider.Inspections().fetchFirstBytesFromTxOutput(tx);
152
+ sui_js_1.bcs.registerStructType("SwapStepResult", {
153
+ current_sqrt_price: bcs_1.BCS.U128,
154
+ target_sqrt_price: bcs_1.BCS.U128,
155
+ current_liquidity: bcs_1.BCS.U128,
156
+ amount_in: bcs_1.BCS.U64,
157
+ amount_out: bcs_1.BCS.U64,
158
+ fee_amount: bcs_1.BCS.U64,
159
+ remainer_amount: bcs_1.BCS.U64,
160
+ });
161
+ sui_js_1.bcs.registerStructType("CalculatedSwapResult", {
162
+ amount_in: bcs_1.BCS.U64,
163
+ amount_out: bcs_1.BCS.U64,
164
+ fee_amount: bcs_1.BCS.U64,
165
+ fee_rate: bcs_1.BCS.U64,
166
+ after_sqrt_price: bcs_1.BCS.U128,
167
+ is_exceed: bcs_1.BCS.BOOL,
168
+ step_results: "vector<SwapStepResult>",
169
+ });
170
+ const data = sui_js_1.bcs.de("CalculatedSwapResult", new Uint8Array(resultBytes));
171
+ return {
172
+ amountIn: BigInt(data.amount_in),
173
+ amountOut: BigInt(data.amount_out),
174
+ feeAmount: BigInt(data.fee_amount),
175
+ feeRate: BigInt(data.fee_rate),
176
+ };
177
+ });
178
+ const cetus = (_a = this.Provider.addresses.externalRouter) === null || _a === void 0 ? void 0 : _a.cetus;
179
+ const pools = this.Provider.addresses.pools;
180
+ const referralVault = this.Provider.addresses.referralVault;
181
+ if (!cetus || !pools || !referralVault)
182
+ throw new Error("not all required addresses have been set in provider");
183
+ this.Provider = Provider;
184
+ this.addresses = {
185
+ cetus,
186
+ pools,
187
+ referralVault,
188
+ };
189
+ this.objectTypes = {
190
+ pool: `${cetus.packages.clmm}::pool::Pool`,
191
+ };
192
+ }
193
+ }
194
+ exports.CetusApiHelpers = CetusApiHelpers;
195
+ /////////////////////////////////////////////////////////////////////
196
+ //// Constants
197
+ /////////////////////////////////////////////////////////////////////
198
+ CetusApiHelpers.constants = {
199
+ moduleNames: {
200
+ poolScript: "pool_script",
201
+ pool: "pool",
202
+ },
203
+ };
204
+ /////////////////////////////////////////////////////////////////////
205
+ //// Private Static Methods
206
+ /////////////////////////////////////////////////////////////////////
207
+ /////////////////////////////////////////////////////////////////////
208
+ //// Casting
209
+ /////////////////////////////////////////////////////////////////////
210
+ CetusApiHelpers.poolFromSuiObjectResponse = (data) => {
211
+ var _a;
212
+ const content = (_a = data.data) === null || _a === void 0 ? void 0 : _a.content;
213
+ if ((content === null || content === void 0 ? void 0 : content.dataType) !== "moveObject")
214
+ throw new Error("sui object response is not an object");
215
+ const fields = content.fields.value.fields.value.fields;
216
+ return {
217
+ coinTypeA: "0x" + fields.coin_type_a.fields.name,
218
+ coinTypeB: "0x" + fields.coin_type_b.fields.name,
219
+ id: fields.pool_id,
220
+ };
221
+ };
222
+ /////////////////////////////////////////////////////////////////////
223
+ //// Helpers
224
+ /////////////////////////////////////////////////////////////////////
225
+ CetusApiHelpers.isPoolForCoinTypes = (inputs) => {
226
+ const { pool, coinType1, coinType2 } = inputs;
227
+ return ((pool.coinTypeA === utils_1.Helpers.addLeadingZeroesToType(coinType1) &&
228
+ pool.coinTypeB === utils_1.Helpers.addLeadingZeroesToType(coinType2)) ||
229
+ (pool.coinTypeA === utils_1.Helpers.addLeadingZeroesToType(coinType2) &&
230
+ pool.coinTypeB === utils_1.Helpers.addLeadingZeroesToType(coinType1)));
231
+ };
232
+ CetusApiHelpers.isCoinA = (coin, pool) => utils_1.Helpers.addLeadingZeroesToType(coin) === pool.coinTypeA;
@@ -0,0 +1,15 @@
1
+ import { ObjectId } from "@mysten/sui.js";
2
+ import { Balance, CoinType, RouterSerializablePool } from "../../../types";
3
+ export interface CetusPoolObject {
4
+ id: ObjectId;
5
+ coinTypeA: CoinType;
6
+ coinTypeB: CoinType;
7
+ }
8
+ export interface CetusCalcTradeResult {
9
+ amountIn: Balance;
10
+ amountOut: Balance;
11
+ feeAmount: Balance;
12
+ feeRate: bigint;
13
+ }
14
+ export declare const isCetusRouterPoolObject: (pool: RouterSerializablePool) => pool is CetusPoolObject;
15
+ //# sourceMappingURL=cetusTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cetusTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/cetus/cetusTypes.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,eAAe;IAC/B,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,uBAAuB,SAC7B,sBAAsB,4BAG5B,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCetusRouterPoolObject = void 0;
4
+ const isCetusRouterPoolObject = (pool) => {
5
+ return "id" in pool && "coinTypeA" in pool && "coinTypeB" in pool;
6
+ };
7
+ exports.isCetusRouterPoolObject = isCetusRouterPoolObject;
@@ -2,7 +2,7 @@ import { AftermathApi } from "../../../general/providers";
2
2
  import { CoinType } from "../../coin/coinTypes";
3
3
  import { DeepBookApiHelpers } from "./deepBookApiHelper";
4
4
  import { DeepBookPoolObject, PartialDeepBookPoolObject } from "./deepBookTypes";
5
- import { RouterApiInterface } from "../../router/utils/routerApiInterface";
5
+ import { RouterApiInterface } from "../../router/utils/synchronous/interfaces/routerApiInterface";
6
6
  import { ObjectId, TransactionArgument, TransactionBlock } from "@mysten/sui.js";
7
7
  export declare class DeepBookApi implements RouterApiInterface<DeepBookPoolObject> {
8
8
  private readonly Provider;
@@ -1 +1 @@
1
- {"version":3,"file":"deepBookApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/deepBook/deepBookApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;SAmBC;IAEK,8BAA8B,WAAY;QAChD,EAAE,EAAE,gBAAgB,CAAC;QACrB,YAAY,EAAE,QAAQ,CAAC;QACvB,YAAY,EAAE,QAAQ,CAAC;QACvB,aAAa,EAAE,QAAQ,CAAC;KACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBC;IAEK,8BAA8B,WAAY;QAChD,EAAE,EAAE,gBAAgB,CAAC;QACrB,YAAY,EAAE,QAAQ,CAAC;QACvB,YAAY,EAAE,QAAQ,CAAC;QACvB,aAAa,EAAE,QAAQ,CAAC;KACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBC;IAEK,4CAA4C,WAAY;QAC9D,EAAE,EAAE,gBAAgB,CAAC;QACrB,IAAI,EAAE,yBAAyB,CAAC;QAChC,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBC;IAMK,cAAc,WAAkB;QACtC,IAAI,EAAE,yBAAyB,CAAC;QAChC,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB,KAAG,QAAQ,kBAAkB,EAAE,CAAC,CAkD/B;IAMK,wCAAwC,WAAkB;QAChE,IAAI,EAAE,yBAAyB,CAAC;KAChC,KAAG,QAAQ,kBAAkB,CAAC,CAqB7B;CACF"}
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DeepBookApiHelpers = void 0;
13
13
  const sui_js_1 = require("@mysten/sui.js");
14
- const aftermathApi_1 = require("../../../general/providers/aftermathApi");
15
14
  const sui_1 = require("../../sui");
16
15
  const eventsApiHelpers_1 = require("../../../general/api/eventsApiHelpers");
17
16
  const coin_1 = require("../../coin");
@@ -47,7 +46,7 @@ class DeepBookApiHelpers {
47
46
  this.addTradeBaseToQuoteCommandToTransaction = (inputs) => {
48
47
  const { tx, coinInId } = inputs;
49
48
  return tx.moveCall({
50
- target: aftermathApi_1.AftermathApi.helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.wrapper, DeepBookApiHelpers.constants.moduleNames.wrapper, "swap_exact_base_for_quote_ktc"),
49
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.wrapper, DeepBookApiHelpers.constants.moduleNames.wrapper, "swap_exact_base_for_quote_ktc"),
51
50
  typeArguments: [inputs.coinInType, inputs.coinOutType],
52
51
  arguments: [
53
52
  tx.object(inputs.poolObjectId),
@@ -63,7 +62,7 @@ class DeepBookApiHelpers {
63
62
  this.addTradeQuoteToBaseCommandToTransaction = (inputs) => {
64
63
  const { tx, coinInId } = inputs;
65
64
  return tx.moveCall({
66
- target: aftermathApi_1.AftermathApi.helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.wrapper, DeepBookApiHelpers.constants.moduleNames.wrapper, "swap_exact_quote_for_base"),
65
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.wrapper, DeepBookApiHelpers.constants.moduleNames.wrapper, "swap_exact_quote_for_base"),
67
66
  typeArguments: [inputs.coinOutType, inputs.coinInType],
68
67
  arguments: [
69
68
  tx.object(inputs.poolObjectId),
@@ -79,7 +78,7 @@ class DeepBookApiHelpers {
79
78
  this.addGetAsksCommandToTransaction = (inputs) => {
80
79
  const { tx } = inputs;
81
80
  return tx.moveCall({
82
- target: aftermathApi_1.AftermathApi.helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.clob, DeepBookApiHelpers.constants.moduleNames.clob, "get_level2_book_status_ask_side"),
81
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.clob, DeepBookApiHelpers.constants.moduleNames.clob, "get_level2_book_status_ask_side"),
83
82
  typeArguments: [inputs.baseCoinType, inputs.quoteCoinType],
84
83
  arguments: [
85
84
  tx.object(inputs.poolObjectId),
@@ -92,7 +91,7 @@ class DeepBookApiHelpers {
92
91
  this.addGetBidsCommandToTransaction = (inputs) => {
93
92
  const { tx } = inputs;
94
93
  return tx.moveCall({
95
- target: aftermathApi_1.AftermathApi.helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.clob, DeepBookApiHelpers.constants.moduleNames.clob, "get_level2_book_status_bid_side"),
94
+ target: utils_1.Helpers.transactions.createTransactionTarget(this.addresses.deepBook.packages.clob, DeepBookApiHelpers.constants.moduleNames.clob, "get_level2_book_status_bid_side"),
96
95
  typeArguments: [inputs.baseCoinType, inputs.quoteCoinType],
97
96
  arguments: [
98
97
  tx.object(inputs.poolObjectId),
@@ -120,7 +119,7 @@ class DeepBookApiHelpers {
120
119
  let depths;
121
120
  try {
122
121
  [prices, depths] =
123
- yield this.Provider.Inspections().fetchOutputsBytesFromTransaction({
122
+ yield this.Provider.Inspections().fetchAllBytesFromTxOutput({
124
123
  tx,
125
124
  });
126
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deepBookTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/deepBook/deepBookTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAMjE,MAAM,WAAW,yBAAyB;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG;IAC5D,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,oBAAoB,SAC1B,sBAAsB,+BAQ5B,CAAC"}
1
+ {"version":3,"file":"deepBookTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/deepBook/deepBookTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACN,OAAO,EACP,sBAAsB,EAEtB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,yBAAyB;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG;IAC5D,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,oBAAoB,SAC1B,sBAAsB,+BAQ5B,CAAC"}
@@ -4,7 +4,7 @@ import { ObjectId, TransactionArgument, TransactionBlock } from "@mysten/sui.js"
4
4
  import { NojoAmmApiHelpers } from "./nojoAmmApiHelpers";
5
5
  import { CoinType } from "../../coin/coinTypes";
6
6
  import { Balance } from "../../../types";
7
- import { RouterApiInterface } from "../../router/utils/routerApiInterface";
7
+ import { RouterApiInterface } from "../../router/utils/synchronous/interfaces/routerApiInterface";
8
8
  import { NojoPoolObject } from "./nojoAmmTypes";
9
9
  export declare class NojoAmmApi implements RouterApiInterface<NojoPoolObject> {
10
10
  private readonly Provider;
@@ -1 +1 @@
1
- {"version":3,"file":"nojoAmmApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/nojo/nojoAmmApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,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Root":"","sources":["../../../../src/packages/external/nojo/nojoAmmTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACN,sBAAsB,EAEtB,MAAM,0BAA0B,CAAC;AAMlC,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,SACtB,sBAAsB,2BAG5B,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { AftermathApi } from "../../../general/providers";
2
+ import { CoinType } from "../../coin/coinTypes";
3
+ import { TurbosApiHelpers } from "./turbosApiHelpers";
4
+ import { SuiAddress } from "@mysten/sui.js";
5
+ import { Balance, SerializedTransaction } from "../../../types";
6
+ import { RouterApiInterface } from "../../router/utils/synchronous/interfaces/routerApiInterface";
7
+ import { TurbosPoolObject } from "./turbosTypes";
8
+ export declare class TurbosApi implements RouterApiInterface<TurbosPoolObject> {
9
+ private readonly Provider;
10
+ readonly Helpers: TurbosApiHelpers;
11
+ constructor(Provider: AftermathApi);
12
+ fetchPoolForCoinTypes: (inputs: {
13
+ coinType1: CoinType;
14
+ coinType2: CoinType;
15
+ }) => Promise<TurbosPoolObject>;
16
+ fetchAllPools: () => Promise<TurbosPoolObject[]>;
17
+ fetchSupportedCoins: () => Promise<string[]>;
18
+ fetchTradeAmountOut: (inputs: {
19
+ walletAddress: SuiAddress;
20
+ pool: TurbosPoolObject;
21
+ coinInType: CoinType;
22
+ coinOutType: CoinType;
23
+ coinInAmount: Balance;
24
+ }) => Promise<Balance>;
25
+ fetchTradeTx: (inputs: {
26
+ walletAddress: SuiAddress;
27
+ pool: TurbosPoolObject;
28
+ coinInType: CoinType;
29
+ coinOutType: CoinType;
30
+ coinInAmount: Balance;
31
+ }) => Promise<SerializedTransaction>;
32
+ }
33
+ //# sourceMappingURL=turbosApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turbosApi.d.ts","sourceRoot":"","sources":["../../../../src/packages/external/turbos/turbosApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAElG,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,qBAAa,SAAU,YAAW,kBAAkB,CAAC,gBAAgB,CAAC;IAWzD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IANrC,SAAgB,OAAO,mBAAC;gBAMK,QAAQ,EAAE,YAAY;IAa5C,qBAAqB,WAAkB;QAC7C,SAAS,EAAE,QAAQ,CAAC;QACpB,SAAS,EAAE,QAAQ,CAAC;KACpB,KAAG,QAAQ,gBAAgB,CAAC,CAE3B;IAEK,aAAa,oCAGlB;IAEK,mBAAmB,0BAQxB;IAMK,mBAAmB,WAAkB;QAC3C,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,gBAAgB,CAAC;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;KACtB,KAAG,QAAQ,OAAO,CAAC,CAGlB;IAMK,YAAY,WAAY;QAC9B,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,gBAAgB,CAAC;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,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