@tcswap/helpers 4.5.15
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/api/index.cjs +4 -0
- package/dist/api/index.cjs.map +16 -0
- package/dist/api/index.js +4 -0
- package/dist/api/index.js.map +16 -0
- package/dist/chunk-pfmeq01a.js +5 -0
- package/dist/chunk-pfmeq01a.js.map +9 -0
- package/dist/chunk-vb4wtm2w.js +4 -0
- package/dist/chunk-vb4wtm2w.js.map +9 -0
- package/dist/contracts.cjs +4 -0
- package/dist/contracts.cjs.map +10 -0
- package/dist/contracts.js +4 -0
- package/dist/contracts.js.map +10 -0
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +30 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +30 -0
- package/dist/tokens.cjs +4 -0
- package/dist/tokens.cjs.map +10 -0
- package/dist/tokens.js +4 -0
- package/dist/tokens.js.map +10 -0
- package/dist/types/api/index.d.ts +502 -0
- package/dist/types/api/index.d.ts.map +1 -0
- package/dist/types/api/memoless/endpoints.d.ts +56 -0
- package/dist/types/api/memoless/endpoints.d.ts.map +1 -0
- package/dist/types/api/memoless/types.d.ts +85 -0
- package/dist/types/api/memoless/types.d.ts.map +1 -0
- package/dist/types/api/midgard/endpoints.d.ts +80 -0
- package/dist/types/api/midgard/endpoints.d.ts.map +1 -0
- package/dist/types/api/midgard/types.d.ts +543 -0
- package/dist/types/api/midgard/types.d.ts.map +1 -0
- package/dist/types/api/thornode/endpoints.d.ts +34 -0
- package/dist/types/api/thornode/endpoints.d.ts.map +1 -0
- package/dist/types/api/thornode/types.d.ts +264 -0
- package/dist/types/api/thornode/types.d.ts.map +1 -0
- package/dist/types/api/uswap/endpoints.d.ts +372 -0
- package/dist/types/api/uswap/endpoints.d.ts.map +1 -0
- package/dist/types/api/uswap/types.d.ts +1487 -0
- package/dist/types/api/uswap/types.d.ts.map +1 -0
- package/dist/types/contracts.d.ts +2 -0
- package/dist/types/contracts.d.ts.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/modules/assetValue.d.ts +82 -0
- package/dist/types/modules/assetValue.d.ts.map +1 -0
- package/dist/types/modules/bigIntArithmetics.d.ts +60 -0
- package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -0
- package/dist/types/modules/feeMultiplier.d.ts +48 -0
- package/dist/types/modules/feeMultiplier.d.ts.map +1 -0
- package/dist/types/modules/requestClient.d.ts +33 -0
- package/dist/types/modules/requestClient.d.ts.map +1 -0
- package/dist/types/modules/uSwapConfig.d.ts +249 -0
- package/dist/types/modules/uSwapConfig.d.ts.map +1 -0
- package/dist/types/modules/uSwapError.d.ts +879 -0
- package/dist/types/modules/uSwapError.d.ts.map +1 -0
- package/dist/types/modules/uSwapNumber.d.ts +10 -0
- package/dist/types/modules/uSwapNumber.d.ts.map +1 -0
- package/dist/types/tokens.d.ts +2 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/types/types/commonTypes.d.ts +16 -0
- package/dist/types/types/commonTypes.d.ts.map +1 -0
- package/dist/types/types/derivationPath.d.ts +4 -0
- package/dist/types/types/derivationPath.d.ts.map +1 -0
- package/dist/types/types/errors/apiV1.d.ts +2 -0
- package/dist/types/types/errors/apiV1.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/quotes.d.ts +180 -0
- package/dist/types/types/quotes.d.ts.map +1 -0
- package/dist/types/types/sdk.d.ts +35 -0
- package/dist/types/types/sdk.d.ts.map +1 -0
- package/dist/types/types/wallet.d.ts +130 -0
- package/dist/types/types/wallet.d.ts.map +1 -0
- package/dist/types/utils/asset.d.ts +37 -0
- package/dist/types/utils/asset.d.ts.map +1 -0
- package/dist/types/utils/chains.d.ts +13 -0
- package/dist/types/utils/chains.d.ts.map +1 -0
- package/dist/types/utils/derivationPath.d.ts +21 -0
- package/dist/types/utils/derivationPath.d.ts.map +1 -0
- package/dist/types/utils/explorerUrls.d.ts +10 -0
- package/dist/types/utils/explorerUrls.d.ts.map +1 -0
- package/dist/types/utils/liquidity.d.ts +62 -0
- package/dist/types/utils/liquidity.d.ts.map +1 -0
- package/dist/types/utils/memo.d.ts +65 -0
- package/dist/types/utils/memo.d.ts.map +1 -0
- package/dist/types/utils/others.d.ts +15 -0
- package/dist/types/utils/others.d.ts.map +1 -0
- package/dist/types/utils/validators.d.ts +6 -0
- package/dist/types/utils/validators.d.ts.map +1 -0
- package/dist/types/utils/wallets.d.ts +36 -0
- package/dist/types/utils/wallets.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/api/index.ts +15 -0
- package/src/api/memoless/endpoints.ts +62 -0
- package/src/api/memoless/types.ts +83 -0
- package/src/api/midgard/endpoints.ts +352 -0
- package/src/api/midgard/types.ts +515 -0
- package/src/api/thornode/endpoints.ts +109 -0
- package/src/api/thornode/types.ts +247 -0
- package/src/api/uswap/endpoints.ts +252 -0
- package/src/api/uswap/types.ts +626 -0
- package/src/contracts.ts +1 -0
- package/src/index.ts +32 -0
- package/src/modules/__tests__/assetValue.test.ts +2452 -0
- package/src/modules/__tests__/bigIntArithmetics.test.ts +410 -0
- package/src/modules/__tests__/feeMultiplier.test.ts +131 -0
- package/src/modules/__tests__/uSwapConfig.test.ts +429 -0
- package/src/modules/__tests__/uSwapNumber.test.ts +439 -0
- package/src/modules/assetValue.ts +536 -0
- package/src/modules/bigIntArithmetics.ts +366 -0
- package/src/modules/feeMultiplier.ts +84 -0
- package/src/modules/requestClient.ts +116 -0
- package/src/modules/uSwapConfig.ts +189 -0
- package/src/modules/uSwapError.ts +474 -0
- package/src/modules/uSwapNumber.ts +17 -0
- package/src/tokens.ts +1 -0
- package/src/types/commonTypes.ts +10 -0
- package/src/types/derivationPath.ts +11 -0
- package/src/types/errors/apiV1.ts +0 -0
- package/src/types/index.ts +5 -0
- package/src/types/quotes.ts +182 -0
- package/src/types/sdk.ts +38 -0
- package/src/types/wallet.ts +124 -0
- package/src/utils/__tests__/asset.test.ts +186 -0
- package/src/utils/__tests__/derivationPath.test.ts +142 -0
- package/src/utils/__tests__/explorerUrls.test.ts +59 -0
- package/src/utils/__tests__/liquidity.test.ts +302 -0
- package/src/utils/__tests__/memo.test.ts +99 -0
- package/src/utils/__tests__/others.test.ts +169 -0
- package/src/utils/__tests__/validators.test.ts +84 -0
- package/src/utils/__tests__/wallets.test.ts +625 -0
- package/src/utils/asset.ts +399 -0
- package/src/utils/chains.ts +104 -0
- package/src/utils/derivationPath.ts +101 -0
- package/src/utils/explorerUrls.ts +32 -0
- package/src/utils/liquidity.ts +154 -0
- package/src/utils/memo.ts +102 -0
- package/src/utils/others.ts +64 -0
- package/src/utils/validators.ts +36 -0
- package/src/utils/wallets.ts +238 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
// Pool types
|
|
2
|
+
export type Pool = {
|
|
3
|
+
asset: string;
|
|
4
|
+
assetDepth: string;
|
|
5
|
+
assetPrice: string;
|
|
6
|
+
assetPriceUSD: string;
|
|
7
|
+
liquidityUnits: string;
|
|
8
|
+
poolAPY: string;
|
|
9
|
+
runeDepth: string;
|
|
10
|
+
saversAPR: string;
|
|
11
|
+
saversDepth: string;
|
|
12
|
+
saversUnits: string;
|
|
13
|
+
status: string;
|
|
14
|
+
synthSupply: string;
|
|
15
|
+
synthUnits: string;
|
|
16
|
+
units: string;
|
|
17
|
+
volume24h: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type PoolStats = {
|
|
21
|
+
addAssetLiquidityVolume: string;
|
|
22
|
+
addLiquidityCount: string;
|
|
23
|
+
addLiquidityVolume: string;
|
|
24
|
+
addRuneLiquidityVolume: string;
|
|
25
|
+
annualPercentageRate: string;
|
|
26
|
+
asset: string;
|
|
27
|
+
assetDepth: string;
|
|
28
|
+
assetPrice: string;
|
|
29
|
+
assetPriceUSD: string;
|
|
30
|
+
averageSlip: string;
|
|
31
|
+
earnings: string;
|
|
32
|
+
earningsAnnualAsPercentOfDepth: string;
|
|
33
|
+
impermanentLossProtectionPaid: string;
|
|
34
|
+
liquidityUnits: string;
|
|
35
|
+
period: string;
|
|
36
|
+
poolAPY: string;
|
|
37
|
+
runeDepth: string;
|
|
38
|
+
status: string;
|
|
39
|
+
swapCount: string;
|
|
40
|
+
swapVolume: string;
|
|
41
|
+
synthSupply: string;
|
|
42
|
+
synthUnits: string;
|
|
43
|
+
toAssetAverageSlip: string;
|
|
44
|
+
toAssetCount: string;
|
|
45
|
+
toAssetFees: string;
|
|
46
|
+
toAssetVolume: string;
|
|
47
|
+
toRuneAverageSlip: string;
|
|
48
|
+
toRuneCount: string;
|
|
49
|
+
toRuneFees: string;
|
|
50
|
+
toRuneVolume: string;
|
|
51
|
+
totalFees: string;
|
|
52
|
+
uniqueMemberCount: string;
|
|
53
|
+
uniqueSwapperCount: string;
|
|
54
|
+
units: string;
|
|
55
|
+
withdrawAssetVolume: string;
|
|
56
|
+
withdrawCount: string;
|
|
57
|
+
withdrawRuneVolume: string;
|
|
58
|
+
withdrawVolume: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Network types
|
|
62
|
+
export type NetworkInfo = {
|
|
63
|
+
blockRewards: { blockReward: string; bondReward: string; poolReward: string };
|
|
64
|
+
bondMetrics: {
|
|
65
|
+
averageActiveBond: string;
|
|
66
|
+
averageStandbyBond: string;
|
|
67
|
+
maximumActiveBond: string;
|
|
68
|
+
maximumStandbyBond: string;
|
|
69
|
+
medianActiveBond: string;
|
|
70
|
+
medianStandbyBond: string;
|
|
71
|
+
minimumActiveBond: string;
|
|
72
|
+
minimumStandbyBond: string;
|
|
73
|
+
totalActiveBond: string;
|
|
74
|
+
totalStandbyBond: string;
|
|
75
|
+
};
|
|
76
|
+
bondingAPY: string;
|
|
77
|
+
liquidityAPY: string;
|
|
78
|
+
nextChurnHeight: string;
|
|
79
|
+
poolActivationCountdown: number;
|
|
80
|
+
poolShareFactor: string;
|
|
81
|
+
runePriceUSD: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type HealthInfo = { database: boolean; inSync: boolean; scannerHeight: string; thornodeHeight: string };
|
|
85
|
+
|
|
86
|
+
export type Node = {
|
|
87
|
+
bond: string;
|
|
88
|
+
award: string;
|
|
89
|
+
slash: string;
|
|
90
|
+
leaveHeight: string;
|
|
91
|
+
ipAddress: string;
|
|
92
|
+
status: string;
|
|
93
|
+
version: string;
|
|
94
|
+
forcedToLeave: boolean;
|
|
95
|
+
requestedToLeave: boolean;
|
|
96
|
+
bondAddress: string;
|
|
97
|
+
preflight: { status: string; reason: string; code: number };
|
|
98
|
+
nodeOperatorAddress: string;
|
|
99
|
+
nodeAddress: string;
|
|
100
|
+
observerAddress: string;
|
|
101
|
+
pubKeySet: { secp256k1: string; ed25519: string };
|
|
102
|
+
bondProviders: { nodeOperatorFee: string; providers: Array<{ bondAddress: string; bond: string }> };
|
|
103
|
+
signMembership: string[];
|
|
104
|
+
jail: { releaseHeight: string; reason: string };
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Stats types
|
|
108
|
+
export type Stats = {
|
|
109
|
+
addLiquidityCount: string;
|
|
110
|
+
addLiquidityVolume: string;
|
|
111
|
+
annualPercentageRate: string;
|
|
112
|
+
bondingAPY: string;
|
|
113
|
+
dailyActiveUsers: string;
|
|
114
|
+
dailyTx: string;
|
|
115
|
+
impermanentLossProtectionPaid: string;
|
|
116
|
+
liquidityAPY: string;
|
|
117
|
+
monthlyActiveUsers: string;
|
|
118
|
+
poolCount: string;
|
|
119
|
+
runeDepth: string;
|
|
120
|
+
runePriceUSD: string;
|
|
121
|
+
swapCount: string;
|
|
122
|
+
swapCount24h: string;
|
|
123
|
+
swapCount30d: string;
|
|
124
|
+
swapVolume: string;
|
|
125
|
+
swapVolume24h: string;
|
|
126
|
+
swapVolume30d: string;
|
|
127
|
+
synthBurnCount: string;
|
|
128
|
+
synthMintCount: string;
|
|
129
|
+
toAssetCount: string;
|
|
130
|
+
toRuneCount: string;
|
|
131
|
+
totalEarned: string;
|
|
132
|
+
totalVolume24h: string;
|
|
133
|
+
totalVolumeUSD: string;
|
|
134
|
+
uniqueSwapperCount: string;
|
|
135
|
+
withdrawCount: string;
|
|
136
|
+
withdrawVolume: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Action types
|
|
140
|
+
export type Action = {
|
|
141
|
+
date: string;
|
|
142
|
+
height: string;
|
|
143
|
+
in: Transaction[];
|
|
144
|
+
metadata: {
|
|
145
|
+
swap?: SwapMetadata;
|
|
146
|
+
addLiquidity?: AddLiquidityMetadata;
|
|
147
|
+
withdraw?: WithdrawMetadata;
|
|
148
|
+
refund?: RefundMetadata;
|
|
149
|
+
bond?: BondMetadata;
|
|
150
|
+
switch?: SwitchMetadata;
|
|
151
|
+
};
|
|
152
|
+
out: Transaction[];
|
|
153
|
+
pools: string[];
|
|
154
|
+
status: string;
|
|
155
|
+
type: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type Transaction = { address: string; coins: Coin[]; txID: string };
|
|
159
|
+
|
|
160
|
+
export type Coin = { amount: string; asset: string };
|
|
161
|
+
|
|
162
|
+
export type SwapMetadata = {
|
|
163
|
+
affiliateAddress: string;
|
|
164
|
+
affiliateFee: string;
|
|
165
|
+
isStreamingSwap: boolean;
|
|
166
|
+
liquidityFee: string;
|
|
167
|
+
memo: string;
|
|
168
|
+
networkFees: Coin[];
|
|
169
|
+
swapSlip: string;
|
|
170
|
+
swapTarget: string;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export type AddLiquidityMetadata = { liquidityUnits: string };
|
|
174
|
+
|
|
175
|
+
export type WithdrawMetadata = { asymmetry: string; basisPoints: string; liquidityUnits: string; networkFees: Coin[] };
|
|
176
|
+
|
|
177
|
+
export type RefundMetadata = { networkFees: Coin[]; reason: string };
|
|
178
|
+
|
|
179
|
+
export type BondMetadata = { bondType: string };
|
|
180
|
+
|
|
181
|
+
export type SwitchMetadata = { burn: Coin; mint: Coin };
|
|
182
|
+
|
|
183
|
+
// THORName/MAYAName types
|
|
184
|
+
export type THORNameDetails = {
|
|
185
|
+
/** @description List details of all chains and their addresses for a given THORName */
|
|
186
|
+
entries: THORNameEntry[];
|
|
187
|
+
/** @description Int64, THORChain block height in which THORName expires */
|
|
188
|
+
expire: string;
|
|
189
|
+
/**
|
|
190
|
+
* @description owner's THOR address
|
|
191
|
+
* @example thor102y0m3uptg0vvudeyh00r2fnz70wq7d8y7mu2g
|
|
192
|
+
*/
|
|
193
|
+
owner: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type THORNameEntry = {
|
|
197
|
+
/** @description address on blockchain */
|
|
198
|
+
address: string;
|
|
199
|
+
/** @description blockchain */
|
|
200
|
+
chain: string;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Member types
|
|
204
|
+
export type MemberDetailsMayachain = {
|
|
205
|
+
/** @MemberPool List details of all the liquidity providers identified with the given address */
|
|
206
|
+
pools: MemberPoolMayachain[];
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type MemberPoolMayachain = {
|
|
210
|
+
/** @description Int64(e8), total asset added to the pool by member */
|
|
211
|
+
assetAdded: string;
|
|
212
|
+
/** @description asset address used by the member */
|
|
213
|
+
assetAddress: string;
|
|
214
|
+
/** @description Int64(e8), total asset that is currently deposited to the pool by member.
|
|
215
|
+
* This field is same as the `asset_deposit_value` field in thornode. Mainly can be used
|
|
216
|
+
* for tracking, mainly Growth Percentage
|
|
217
|
+
* */
|
|
218
|
+
assetDeposit: string;
|
|
219
|
+
/** @description Int64(e8), asset sent but not added yet, it will be added when the rune pair arrives
|
|
220
|
+
* */
|
|
221
|
+
assetPending: string;
|
|
222
|
+
/** @description Int64(e8), total asset withdrawn from the pool by member */
|
|
223
|
+
assetWithdrawn: string;
|
|
224
|
+
/** @description Int64(e8), total Cacao that is currently deposited to the pool by member.
|
|
225
|
+
* This field is same as the `rune_deposit_value` field in thornode. Mainly can be used
|
|
226
|
+
* for tracking, mainly Growth Percentage
|
|
227
|
+
* */
|
|
228
|
+
cacaoDeposit: string;
|
|
229
|
+
/** @description Int64, Unix timestamp for the first time member deposited into the pool */
|
|
230
|
+
dateFirstAdded: string;
|
|
231
|
+
/** @description Int64, Unix timestamp for the last time member deposited into the pool */
|
|
232
|
+
dateLastAdded: string;
|
|
233
|
+
/** @description Int64, pool liquidity units that belong the the member */
|
|
234
|
+
liquidityUnits: string;
|
|
235
|
+
/** @description Pool rest of the data refers to */
|
|
236
|
+
pool: string;
|
|
237
|
+
/** @description Int64(e8), total Rune added to the pool by member */
|
|
238
|
+
runeAdded: string;
|
|
239
|
+
/** @description Rune address used by the member */
|
|
240
|
+
runeAddress: string;
|
|
241
|
+
/** @description Int64(e8), Rune sent but not added yet, it will be added when the asset pair arrives
|
|
242
|
+
* */
|
|
243
|
+
runePending: string;
|
|
244
|
+
/** @description Int64(e8), total Rune withdrawn from the pool by member */
|
|
245
|
+
runeWithdrawn: string;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type MemberDetailsThorchain = {
|
|
249
|
+
/** @MemberPool List details of all the liquidity providers identified with the given address */
|
|
250
|
+
pools: MemberPoolThorchain[];
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type MemberPoolThorchain = {
|
|
254
|
+
/** @description Int64(e8), total asset added to the pool by member */
|
|
255
|
+
assetAdded: string;
|
|
256
|
+
/** @description asset address used by the member */
|
|
257
|
+
assetAddress: string;
|
|
258
|
+
/** @description Int64(e8), total asset that is currently deposited to the pool by member.
|
|
259
|
+
* This field is same as the `asset_deposit_value` field in thornode. Mainly can be used
|
|
260
|
+
* for tracking, mainly Growth Percentage
|
|
261
|
+
* */
|
|
262
|
+
assetDeposit: string;
|
|
263
|
+
/** @description Int64(e8), asset sent but not added yet, it will be added when the rune pair arrives
|
|
264
|
+
* */
|
|
265
|
+
assetPending: string;
|
|
266
|
+
/** @description Int64(e8), total asset withdrawn from the pool by member */
|
|
267
|
+
assetWithdrawn: string;
|
|
268
|
+
/** @description Int64(e8), total Rune that is currently deposited to the pool by member.
|
|
269
|
+
* This field is same as the `rune_deposit_value` field in thornode. Mainly can be used
|
|
270
|
+
* for tracking, mainly Growth Percentage
|
|
271
|
+
* */
|
|
272
|
+
runeDeposit: string;
|
|
273
|
+
/** @description Int64, Unix timestamp for the first time member deposited into the pool */
|
|
274
|
+
dateFirstAdded: string;
|
|
275
|
+
/** @description Int64, Unix timestamp for the last time member deposited into the pool */
|
|
276
|
+
dateLastAdded: string;
|
|
277
|
+
/** @description Int64, pool liquidity units that belong the the member */
|
|
278
|
+
liquidityUnits: string;
|
|
279
|
+
/** @description Pool rest of the data refers to */
|
|
280
|
+
pool: string;
|
|
281
|
+
/** @description Int64(e8), total Rune added to the pool by member */
|
|
282
|
+
runeAdded: string;
|
|
283
|
+
/** @description Rune address used by the member */
|
|
284
|
+
runeAddress: string;
|
|
285
|
+
/** @description Int64(e8), Rune sent but not added yet, it will be added when the asset pair arrives
|
|
286
|
+
* */
|
|
287
|
+
runePending: string;
|
|
288
|
+
/** @description Int64(e8), total Rune withdrawn from the pool by member */
|
|
289
|
+
runeWithdrawn: string;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// Saver types
|
|
293
|
+
export type SaverDetails = {
|
|
294
|
+
asset: string;
|
|
295
|
+
assetAddress: string;
|
|
296
|
+
lastAddHeight: string;
|
|
297
|
+
lastWithdrawHeight: string;
|
|
298
|
+
units: string;
|
|
299
|
+
assetDepositValue: string;
|
|
300
|
+
assetRedeemValue: string;
|
|
301
|
+
growthPct: string;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export type SaversHistory = {
|
|
305
|
+
intervals: Array<{
|
|
306
|
+
startTime: string;
|
|
307
|
+
endTime: string;
|
|
308
|
+
saversCount: string;
|
|
309
|
+
saversUnits: string;
|
|
310
|
+
saversDepth: string;
|
|
311
|
+
}>;
|
|
312
|
+
meta: {
|
|
313
|
+
startTime: string;
|
|
314
|
+
endTime: string;
|
|
315
|
+
priceShiftLoss: string;
|
|
316
|
+
luviIncrease: string;
|
|
317
|
+
earned: string;
|
|
318
|
+
runePriceUSD: string;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// Earnings types
|
|
323
|
+
export type EarningsHistory = {
|
|
324
|
+
intervals: Array<{
|
|
325
|
+
startTime: string;
|
|
326
|
+
endTime: string;
|
|
327
|
+
liquidityFees: string;
|
|
328
|
+
blockRewards: string;
|
|
329
|
+
earnings: string;
|
|
330
|
+
bondingEarnings: string;
|
|
331
|
+
liquidityEarnings: string;
|
|
332
|
+
avgNodeCount: string;
|
|
333
|
+
runePriceUSD: string;
|
|
334
|
+
pools: Array<{
|
|
335
|
+
pool: string;
|
|
336
|
+
assetLiquidityFees: string;
|
|
337
|
+
runeLiquidityFees: string;
|
|
338
|
+
totalLiquidityFeesRune: string;
|
|
339
|
+
saverEarning: string;
|
|
340
|
+
rewards: string;
|
|
341
|
+
earnings: string;
|
|
342
|
+
}>;
|
|
343
|
+
}>;
|
|
344
|
+
meta: { bonding: string; liquidity: string; earnings: string; runePriceUSD: string };
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// TVL types
|
|
348
|
+
export type TVLHistory = {
|
|
349
|
+
intervals: Array<{
|
|
350
|
+
startTime: string;
|
|
351
|
+
endTime: string;
|
|
352
|
+
totalValuePooled: string;
|
|
353
|
+
totalValueBonded: string;
|
|
354
|
+
totalValueLocked: string;
|
|
355
|
+
bondTVL: string;
|
|
356
|
+
poolTVL: string;
|
|
357
|
+
runePriceUSD: string;
|
|
358
|
+
totalActiveBond: string;
|
|
359
|
+
totalPooledRune: string;
|
|
360
|
+
}>;
|
|
361
|
+
meta: {
|
|
362
|
+
startTime: string;
|
|
363
|
+
endTime: string;
|
|
364
|
+
startTotalPooledRune: string;
|
|
365
|
+
endTotalPooledRune: string;
|
|
366
|
+
startTVLPooled: string;
|
|
367
|
+
endTVLPooled: string;
|
|
368
|
+
startRunePriceUSD: string;
|
|
369
|
+
endRunePriceUSD: string;
|
|
370
|
+
priceShiftLoss: string;
|
|
371
|
+
luviIncrease: string;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// Swap history types
|
|
376
|
+
export type SwapHistory = {
|
|
377
|
+
intervals: Array<{
|
|
378
|
+
startTime: string;
|
|
379
|
+
endTime: string;
|
|
380
|
+
toAssetCount: string;
|
|
381
|
+
toRuneCount: string;
|
|
382
|
+
toTradeCount: string;
|
|
383
|
+
fromTradeCount: string;
|
|
384
|
+
synthMintCount: string;
|
|
385
|
+
synthRedeemCount: string;
|
|
386
|
+
totalCount: string;
|
|
387
|
+
toAssetVolume: string;
|
|
388
|
+
toRuneVolume: string;
|
|
389
|
+
toTradeVolume: string;
|
|
390
|
+
fromTradeVolume: string;
|
|
391
|
+
synthMintVolume: string;
|
|
392
|
+
synthRedeemVolume: string;
|
|
393
|
+
totalVolume: string;
|
|
394
|
+
toAssetVolumeUSD: string;
|
|
395
|
+
toRuneVolumeUSD: string;
|
|
396
|
+
toTradeVolumeUSD: string;
|
|
397
|
+
fromTradeVolumeUSD: string;
|
|
398
|
+
synthMintVolumeUSD: string;
|
|
399
|
+
synthRedeemVolumeUSD: string;
|
|
400
|
+
totalVolumeUSD: string;
|
|
401
|
+
toAssetFees: string;
|
|
402
|
+
toRuneFees: string;
|
|
403
|
+
toTradeFees: string;
|
|
404
|
+
fromTradeFees: string;
|
|
405
|
+
synthMintFees: string;
|
|
406
|
+
synthRedeemFees: string;
|
|
407
|
+
totalFees: string;
|
|
408
|
+
toAssetAverageSlip: string;
|
|
409
|
+
toRuneAverageSlip: string;
|
|
410
|
+
toTradeAverageSlip: string;
|
|
411
|
+
fromTradeAverageSlip: string;
|
|
412
|
+
synthMintAverageSlip: string;
|
|
413
|
+
synthRedeemAverageSlip: string;
|
|
414
|
+
averageSlip: string;
|
|
415
|
+
runePriceUSD: string;
|
|
416
|
+
}>;
|
|
417
|
+
meta: {
|
|
418
|
+
startTime: string;
|
|
419
|
+
endTime: string;
|
|
420
|
+
toAssetCount: string;
|
|
421
|
+
toRuneCount: string;
|
|
422
|
+
toTradeCount: string;
|
|
423
|
+
fromTradeCount: string;
|
|
424
|
+
synthMintCount: string;
|
|
425
|
+
synthRedeemCount: string;
|
|
426
|
+
totalCount: string;
|
|
427
|
+
toAssetVolume: string;
|
|
428
|
+
toRuneVolume: string;
|
|
429
|
+
toTradeVolume: string;
|
|
430
|
+
fromTradeVolume: string;
|
|
431
|
+
synthMintVolume: string;
|
|
432
|
+
synthRedeemVolume: string;
|
|
433
|
+
totalVolume: string;
|
|
434
|
+
toAssetVolumeUSD: string;
|
|
435
|
+
toRuneVolumeUSD: string;
|
|
436
|
+
toTradeVolumeUSD: string;
|
|
437
|
+
fromTradeVolumeUSD: string;
|
|
438
|
+
synthMintVolumeUSD: string;
|
|
439
|
+
synthRedeemVolumeUSD: string;
|
|
440
|
+
totalVolumeUSD: string;
|
|
441
|
+
toAssetFees: string;
|
|
442
|
+
toRuneFees: string;
|
|
443
|
+
toTradeFees: string;
|
|
444
|
+
fromTradeFees: string;
|
|
445
|
+
synthMintFees: string;
|
|
446
|
+
synthRedeemFees: string;
|
|
447
|
+
totalFees: string;
|
|
448
|
+
toAssetAverageSlip: string;
|
|
449
|
+
toRuneAverageSlip: string;
|
|
450
|
+
toTradeAverageSlip: string;
|
|
451
|
+
fromTradeAverageSlip: string;
|
|
452
|
+
synthMintAverageSlip: string;
|
|
453
|
+
synthRedeemAverageSlip: string;
|
|
454
|
+
averageSlip: string;
|
|
455
|
+
runePriceUSD: string;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// Balance types
|
|
460
|
+
export type Balance = { asset: string; amount: string; dateLastAdded?: string };
|
|
461
|
+
|
|
462
|
+
// Depth history types
|
|
463
|
+
export type DepthHistory = {
|
|
464
|
+
intervals: Array<{
|
|
465
|
+
startTime: string;
|
|
466
|
+
endTime: string;
|
|
467
|
+
assetDepth: string;
|
|
468
|
+
assetPrice: string;
|
|
469
|
+
assetPriceUSD: string;
|
|
470
|
+
liquidityUnits: string;
|
|
471
|
+
membersCount: string;
|
|
472
|
+
runeDepth: string;
|
|
473
|
+
synthSupply: string;
|
|
474
|
+
synthUnits: string;
|
|
475
|
+
units: string;
|
|
476
|
+
}>;
|
|
477
|
+
meta: {
|
|
478
|
+
startTime: string;
|
|
479
|
+
endTime: string;
|
|
480
|
+
priceShiftLoss: string;
|
|
481
|
+
luviIncrease: string;
|
|
482
|
+
startAssetDepth: string;
|
|
483
|
+
startRuneDepth: string;
|
|
484
|
+
startLPUnits: string;
|
|
485
|
+
startSynthUnits: string;
|
|
486
|
+
endAssetDepth: string;
|
|
487
|
+
endRuneDepth: string;
|
|
488
|
+
endLPUnits: string;
|
|
489
|
+
endSynthUnits: string;
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// Constants types
|
|
494
|
+
export type Constants = {
|
|
495
|
+
int64_values: Record<string, string>;
|
|
496
|
+
bool_values: Record<string, boolean>;
|
|
497
|
+
string_values: Record<string, string>;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// Generic response wrapper types
|
|
501
|
+
export type PagedResponse<T> = { data: T[]; meta?: { total?: number; nextPageToken?: string; prevPageToken?: string } };
|
|
502
|
+
|
|
503
|
+
export type HistoryQuery = { interval?: string; count?: number; from?: number; to?: number };
|
|
504
|
+
|
|
505
|
+
export type ActionQuery = {
|
|
506
|
+
address?: string;
|
|
507
|
+
txid?: string;
|
|
508
|
+
asset?: string;
|
|
509
|
+
type?: string;
|
|
510
|
+
affiliate?: string;
|
|
511
|
+
limit?: number;
|
|
512
|
+
offset?: number;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
export type MimirVote = { key: string; value: string; signer: string; blockHeight: string };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AssetValue, RequestClient, USwapConfig } from "@tcswap/helpers";
|
|
6
|
+
import { MAYAConfig, StagenetMAYAConfig, StagenetTHORConfig, THORConfig } from "@tcswap/types";
|
|
7
|
+
import type {
|
|
8
|
+
InboundAddressesItem,
|
|
9
|
+
LastBlockItem,
|
|
10
|
+
MimirData,
|
|
11
|
+
NodeItem,
|
|
12
|
+
RunePoolInfo,
|
|
13
|
+
RunePoolProviderInfo,
|
|
14
|
+
TCYClaimerResponse,
|
|
15
|
+
TCYClaimersResponse,
|
|
16
|
+
TCYStakerResponse,
|
|
17
|
+
TCYStakersResponse,
|
|
18
|
+
THORNodeTNSDetails,
|
|
19
|
+
THORNodeType,
|
|
20
|
+
} from "./types";
|
|
21
|
+
|
|
22
|
+
function baseUrl(type?: THORNodeType) {
|
|
23
|
+
const { isStagenet } = USwapConfig.get("envs");
|
|
24
|
+
|
|
25
|
+
switch (type) {
|
|
26
|
+
case "mayachain": {
|
|
27
|
+
const nodeUrl = isStagenet ? StagenetMAYAConfig.nodeUrl : MAYAConfig.nodeUrl;
|
|
28
|
+
return `${nodeUrl}/mayachain`;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
const nodeUrl = isStagenet ? StagenetTHORConfig.nodeUrl : THORConfig.nodeUrl;
|
|
32
|
+
|
|
33
|
+
return `${nodeUrl}/thorchain`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getNameServiceBaseUrl(type?: THORNodeType) {
|
|
39
|
+
const nsType = type === "mayachain" ? "mayaname" : "thorname";
|
|
40
|
+
|
|
41
|
+
return `${baseUrl(type)}/${nsType}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getLastBlock<T extends THORNodeType = "thorchain">(type: T = "thorchain" as T) {
|
|
45
|
+
return RequestClient.get<LastBlockItem<T>[]>(`${baseUrl(type)}/lastblock`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getThorchainQueue(type?: THORNodeType) {
|
|
49
|
+
return RequestClient.get(`${baseUrl(type)}/queue`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getNodes(type?: THORNodeType) {
|
|
53
|
+
return RequestClient.get<NodeItem[]>(`${baseUrl(type)}/nodes`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getMimirInfo(type?: THORNodeType) {
|
|
57
|
+
return RequestClient.get<MimirData>(`${baseUrl(type)}/mimir`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getInboundAddresses(type?: THORNodeType) {
|
|
61
|
+
return RequestClient.get<InboundAddressesItem[]>(`${baseUrl(type)}/inbound_addresses`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function getTHORNodeTNSDetails({
|
|
65
|
+
type,
|
|
66
|
+
name,
|
|
67
|
+
}: {
|
|
68
|
+
type?: THORNodeType;
|
|
69
|
+
name: string;
|
|
70
|
+
}): Promise<THORNodeTNSDetails> {
|
|
71
|
+
try {
|
|
72
|
+
const result = await RequestClient.get<THORNodeTNSDetails>(`${getNameServiceBaseUrl(type)}/${name}`);
|
|
73
|
+
return result;
|
|
74
|
+
} catch {
|
|
75
|
+
return { affiliate_collector_rune: "", aliases: [], expire_block_height: 0, name, owner: "", preferred_asset: "" };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function getTNSPreferredAsset({ type, tns }: { type?: THORNodeType; tns: string }) {
|
|
80
|
+
const tnsDetails = await getTHORNodeTNSDetails({ name: tns, type });
|
|
81
|
+
|
|
82
|
+
if (!tnsDetails.preferred_asset || tnsDetails.preferred_asset === ".") return undefined;
|
|
83
|
+
|
|
84
|
+
return AssetValue.from({ asset: tnsDetails.preferred_asset, asyncTokenLookup: true });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getRunePoolInfo(type?: THORNodeType) {
|
|
88
|
+
return RequestClient.get<RunePoolInfo>(`${baseUrl(type)}/runepool`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function getRunePoolProviderInfo({ type, thorAddress }: { type?: THORNodeType; thorAddress: string }) {
|
|
92
|
+
return RequestClient.get<RunePoolProviderInfo>(`${baseUrl(type)}/rune_provider/${thorAddress}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getTcyStaker({ type, address }: { type?: THORNodeType; address: string }) {
|
|
96
|
+
return RequestClient.get<TCYStakerResponse>(`${baseUrl(type)}/tcy_staker/${address}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getTcyStakers(type?: THORNodeType) {
|
|
100
|
+
return RequestClient.get<TCYStakersResponse>(`${baseUrl(type)}/tcy_stakers`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function getTcyClaimer({ type, address }: { type?: THORNodeType; address: string }) {
|
|
104
|
+
return RequestClient.get<TCYClaimerResponse>(`${baseUrl(type)}/tcy_claimer/${address}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getTcyClaimers(type?: THORNodeType) {
|
|
108
|
+
return RequestClient.get<TCYClaimersResponse>(`${baseUrl(type)}/tcy_claimers`);
|
|
109
|
+
}
|