@tomo-inc/transaction-builder-sdk 0.0.1-alpha.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/CHANGELOG.md +3 -0
- package/README.md +162 -0
- package/__tests__/business.test.ts +316 -0
- package/package.json +35 -0
- package/src/api/index.ts +115 -0
- package/src/api/types.ts +196 -0
- package/src/chains/const.ts +776 -0
- package/src/chains/getBridgeSupportChains.ts +5 -0
- package/src/chains/getChains.ts +6 -0
- package/src/chains/getSwapSupportChains.ts +5 -0
- package/src/constant/abi.ts +191 -0
- package/src/constant/abis/permit2.json +901 -0
- package/src/constant/address.ts +3 -0
- package/src/constant/index.ts +3 -0
- package/src/constant/stage.json +10 -0
- package/src/index.ts +368 -0
- package/src/swap/bridgeBuilder.ts +46 -0
- package/src/swap/getApproveBuilder.ts +25 -0
- package/src/swap/getBridgeQuotes.ts +12 -0
- package/src/swap/getSwapQuotes.ts +11 -0
- package/src/swap/methods/builder.ts +19 -0
- package/src/swap/methods/chains/const.ts +13 -0
- package/src/swap/methods/chains/evm.ts +124 -0
- package/src/swap/methods/chains/sol.ts +19 -0
- package/src/swap/methods/chains/tron.ts +123 -0
- package/src/swap/methods/permit.ts +1 -0
- package/src/swap/methods/quote.ts +60 -0
- package/src/swap/methods/unsign.ts +26 -0
- package/src/swap/methods/utils.ts +70 -0
- package/src/swap/permitSign.ts +0 -0
- package/src/swap/swapBuilder.ts +46 -0
- package/src/types/chain.ts +86 -0
- package/src/types/index.ts +15 -0
- package/src/types/swap.ts +140 -0
package/src/api/types.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { reinitializeApiMethods } from ".";
|
|
2
|
+
|
|
3
|
+
export enum SwapV2DexName {
|
|
4
|
+
OKX_SWAP = "OKXSwap",
|
|
5
|
+
OKX0 = "OKXCross0",
|
|
6
|
+
OKX1 = "OKXCross1",
|
|
7
|
+
OKX2 = "OKXCross2",
|
|
8
|
+
RANGO_BASIC = "RangoBasic",
|
|
9
|
+
RANGO_MAIN = "RangoMain",
|
|
10
|
+
JUPITER = "Jupiter",
|
|
11
|
+
ARRAKIS_BRIDGE = "ArrakisBridge",
|
|
12
|
+
SUN = "Sun",
|
|
13
|
+
TOMO = "Tomo",
|
|
14
|
+
KODIAK = "Kodiak",
|
|
15
|
+
STON = "Ston",
|
|
16
|
+
ONE_INCH = "1Inch",
|
|
17
|
+
NAVI = "Navi",
|
|
18
|
+
DOGE_OS = "DogeOS",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SwapApiRoutesRequestV2 {
|
|
22
|
+
amount: string;
|
|
23
|
+
dexs: SwapV2DexName[]; //OKXSwap
|
|
24
|
+
dexsExclude: boolean;
|
|
25
|
+
fromToken: {
|
|
26
|
+
address: string;
|
|
27
|
+
chainID: string;
|
|
28
|
+
decimals: number;
|
|
29
|
+
symbol: string;
|
|
30
|
+
};
|
|
31
|
+
recipient: string;
|
|
32
|
+
sender: string;
|
|
33
|
+
slippage: number;
|
|
34
|
+
toToken: {
|
|
35
|
+
address: string;
|
|
36
|
+
chainID: string;
|
|
37
|
+
decimals: number;
|
|
38
|
+
symbol: string;
|
|
39
|
+
};
|
|
40
|
+
trade_id?: string;
|
|
41
|
+
quote_track_id?: string;
|
|
42
|
+
user_id?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type SwapApiRouterTxRequestV2 = {
|
|
46
|
+
extendedData:
|
|
47
|
+
| {
|
|
48
|
+
permit2: {
|
|
49
|
+
permit2InputEncode: string;
|
|
50
|
+
permitSingle: {
|
|
51
|
+
details: {
|
|
52
|
+
amount: string;
|
|
53
|
+
expiration: number;
|
|
54
|
+
nonce: number;
|
|
55
|
+
token: string;
|
|
56
|
+
};
|
|
57
|
+
sigDeadline: number;
|
|
58
|
+
spender: string;
|
|
59
|
+
};
|
|
60
|
+
signature: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
| undefined
|
|
64
|
+
| null;
|
|
65
|
+
quoteID: string;
|
|
66
|
+
trade_id?: string;
|
|
67
|
+
user_id?: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export enum SwapRouterTxEVMType {
|
|
71
|
+
APPROVE = "approve",
|
|
72
|
+
SWAP = "swap",
|
|
73
|
+
EIP712 = "EIP712",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// export type CreateTxMethodParamsV2 = {
|
|
77
|
+
// fromToken: IToken;
|
|
78
|
+
// toToken: IToken;
|
|
79
|
+
// fromAmount: string;
|
|
80
|
+
// fromAddress: string;
|
|
81
|
+
// toAddress: string;
|
|
82
|
+
// slippage?: number;
|
|
83
|
+
// routeInfo: DexRouteInfoV2;
|
|
84
|
+
// feeMode: FeeMode;
|
|
85
|
+
// referrerInfo: {
|
|
86
|
+
// referrerFee: number;
|
|
87
|
+
// referrerAddress: string;
|
|
88
|
+
// }[];
|
|
89
|
+
// gasLimit?: string;
|
|
90
|
+
// gasPrice?: string;
|
|
91
|
+
// evmPermit: TypeEVMPermit | undefined;
|
|
92
|
+
// trackInfo?: TrackInfo;
|
|
93
|
+
// userInfo?: UserInfo;
|
|
94
|
+
// };
|
|
95
|
+
|
|
96
|
+
export type SwapRouterTxEVMResult = {
|
|
97
|
+
type: SwapRouterTxEVMType;
|
|
98
|
+
chainId: number;
|
|
99
|
+
data: string;
|
|
100
|
+
value: string;
|
|
101
|
+
from: string;
|
|
102
|
+
to: string;
|
|
103
|
+
nonce: number;
|
|
104
|
+
gasInfo: {
|
|
105
|
+
gasLimit: string;
|
|
106
|
+
baseFee: string;
|
|
107
|
+
priorityFee: {
|
|
108
|
+
low: string;
|
|
109
|
+
medium: string;
|
|
110
|
+
high: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
extended: {
|
|
114
|
+
requestID: string;
|
|
115
|
+
};
|
|
116
|
+
// params?: CreateTxMethodParamsV2;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type SwapRouterTxSOLResult = {
|
|
120
|
+
type: SwapRouterTxEVMType.SWAP;
|
|
121
|
+
chainId: number;
|
|
122
|
+
data: string;
|
|
123
|
+
serializedData: string;
|
|
124
|
+
blockHash: string;
|
|
125
|
+
gasInfo: {
|
|
126
|
+
gasLimit: string;
|
|
127
|
+
baseFee: string;
|
|
128
|
+
priorityFee: {
|
|
129
|
+
low: string;
|
|
130
|
+
medium: string;
|
|
131
|
+
high: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
// params?: CreateTxMethodParamsV2;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type SwapRouterTxTronResult = {
|
|
138
|
+
type: SwapRouterTxEVMType;
|
|
139
|
+
chainId: number;
|
|
140
|
+
data: string;
|
|
141
|
+
value: string;
|
|
142
|
+
from: string;
|
|
143
|
+
to: string;
|
|
144
|
+
rawData: {
|
|
145
|
+
visible: boolean;
|
|
146
|
+
txID: string;
|
|
147
|
+
raw_data: any;
|
|
148
|
+
raw_data_hex: string;
|
|
149
|
+
};
|
|
150
|
+
gasInfo: {
|
|
151
|
+
gasLimit: string;
|
|
152
|
+
baseFee: string;
|
|
153
|
+
};
|
|
154
|
+
// params?: CreateTxMethodParamsV2;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type SwapApiRouterTxResponseV2 = {
|
|
158
|
+
transactions: (SwapRouterTxEVMResult | SwapRouterTxSOLResult | SwapRouterTxTronResult)[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export interface IRawApiToken {
|
|
162
|
+
createdTime: string;
|
|
163
|
+
updatedTime: string;
|
|
164
|
+
id: number;
|
|
165
|
+
name: string;
|
|
166
|
+
displayName: string;
|
|
167
|
+
symbol: string;
|
|
168
|
+
imageUrl?: string;
|
|
169
|
+
decimals: number;
|
|
170
|
+
chain: string;
|
|
171
|
+
isNative: boolean;
|
|
172
|
+
priceUsd: string;
|
|
173
|
+
realPrice?: string;
|
|
174
|
+
address: string;
|
|
175
|
+
marketCapUsd?: string;
|
|
176
|
+
risk: string;
|
|
177
|
+
riskLevel?: number;
|
|
178
|
+
|
|
179
|
+
isTomoji: boolean;
|
|
180
|
+
priceChangeH24: number;
|
|
181
|
+
change24h?: number;
|
|
182
|
+
volumeH24: string;
|
|
183
|
+
fdvUsd: string;
|
|
184
|
+
totalSupply: string;
|
|
185
|
+
websiteUrl?: string;
|
|
186
|
+
twitterUrl?: string;
|
|
187
|
+
isPoolBaseToken: boolean;
|
|
188
|
+
supportRango: boolean;
|
|
189
|
+
groupId: string;
|
|
190
|
+
liquidityUsd?: string;
|
|
191
|
+
poolAddress?: string;
|
|
192
|
+
coingeckoCoinId?: string;
|
|
193
|
+
forceSafe?: boolean;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type ApiMethods = ReturnType<typeof reinitializeApiMethods>;
|