@tokemak/queries 0.4.0 → 0.5.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/dist/functions/getAutopoolDayData.d.ts.map +1 -1
- package/dist/functions/getAutopoolHistory.d.ts.map +1 -1
- package/dist/functions/getAutopools.d.ts.map +1 -1
- package/dist/functions/getAutopoolsRebalances.d.ts.map +1 -1
- package/dist/functions/getChainAutopools.d.ts.map +1 -1
- package/dist/functions/getHistoricalTokenPrices.d.ts +1 -1
- package/dist/functions/getHistoricalTokenPrices.d.ts.map +1 -1
- package/dist/functions/getMultipleAutopoolRebalances.d.ts.map +1 -1
- package/dist/functions/getTokenPrices.d.ts +1 -486
- package/dist/functions/getTokenPrices.d.ts.map +1 -1
- package/dist/functions/getUserAutopoolBalanceChanges.d.ts.map +1 -1
- package/dist/functions/getUserAutopools.d.ts.map +1 -1
- package/dist/index.js +113 -144
- package/dist/index.mjs +109 -154
- package/package.json +17 -17
package/dist/index.js
CHANGED
|
@@ -21,12 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AutopoolCategory: () => AutopoolCategory,
|
|
24
|
-
BASE_ASSETS: () => BASE_ASSETS,
|
|
25
24
|
BATCH_SIZE: () => BATCH_SIZE,
|
|
26
25
|
ETH_BASE_ASSETS: () => ETH_BASE_ASSETS,
|
|
27
26
|
EUR_BASE_ASSETS: () => EUR_BASE_ASSETS,
|
|
28
27
|
MessageStatus: () => MessageStatus,
|
|
29
|
-
PRICED_TOKENS: () => PRICED_TOKENS,
|
|
30
28
|
USD_BASE_ASSETS: () => USD_BASE_ASSETS,
|
|
31
29
|
aggregateSTokeRewardsDayData: () => aggregateSTokeRewardsDayData,
|
|
32
30
|
arraysToObject: () => arraysToObject,
|
|
@@ -1001,9 +999,6 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
1001
999
|
}
|
|
1002
1000
|
extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
|
|
1003
1001
|
if (baseApr === void 0) baseApr = 0;
|
|
1004
|
-
if (autopool.symbol === "autoETH") {
|
|
1005
|
-
baseApr = 0.024;
|
|
1006
|
-
}
|
|
1007
1002
|
const combinedApr = baseApr + extraApr;
|
|
1008
1003
|
let denominatedToken = import_tokenlist3.ETH_TOKEN;
|
|
1009
1004
|
let useDenominatedValues = false;
|
|
@@ -1268,7 +1263,8 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
|
|
|
1268
1263
|
timestamp: startTimestamp
|
|
1269
1264
|
});
|
|
1270
1265
|
const formattedDayDatas = autopoolDayDatas.map((autoPoolDayData) => {
|
|
1271
|
-
const
|
|
1266
|
+
const baseDecimals = Number(autoPoolDayData.baseAsset.decimals) || 18;
|
|
1267
|
+
const navPerShare = Number(autoPoolDayData.nav) / Number(autoPoolDayData.totalSupply) * Math.pow(10, 18 - baseDecimals);
|
|
1272
1268
|
let baseApy = autoPoolDayData.autopoolApy;
|
|
1273
1269
|
let rewarderApy = 0;
|
|
1274
1270
|
const formattedRewarder7DayMAApy = (0, import_utils10.formatEtherNum)(
|
|
@@ -3133,117 +3129,8 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains10.mainn
|
|
|
3133
3129
|
}
|
|
3134
3130
|
};
|
|
3135
3131
|
|
|
3136
|
-
// functions/getTokenPrices.ts
|
|
3137
|
-
var import_tokenlist6 = require("@tokemak/tokenlist");
|
|
3138
|
-
var import_constants16 = require("@tokemak/constants");
|
|
3139
|
-
|
|
3140
|
-
// functions/getBackupTokenPrices.ts
|
|
3141
|
-
var getBackupTokenPrices = async () => {
|
|
3142
|
-
try {
|
|
3143
|
-
const backupData = await getBlobData(`getTokenPrices-latest-success.json`);
|
|
3144
|
-
if (backupData) {
|
|
3145
|
-
return backupData;
|
|
3146
|
-
}
|
|
3147
|
-
} catch (e) {
|
|
3148
|
-
console.error(e);
|
|
3149
|
-
return void 0;
|
|
3150
|
-
}
|
|
3151
|
-
return void 0;
|
|
3152
|
-
};
|
|
3153
|
-
|
|
3154
|
-
// functions/getTokenPrices.ts
|
|
3155
|
-
var BASE_ASSETS = [
|
|
3156
|
-
{ ...import_tokenlist6.ETH_TOKEN, symbol: "ETH", coinGeckoId: "ethereum" },
|
|
3157
|
-
{ ...import_tokenlist6.PXETH_TOKEN, symbol: "PXETH", coinGeckoId: "dinero-staked-eth" },
|
|
3158
|
-
{ ...import_tokenlist6.USDC_TOKEN, symbol: "USDC", coinGeckoId: "usd-coin" },
|
|
3159
|
-
{ ...import_tokenlist6.DOLA_TOKEN, symbol: "DOLA", coinGeckoId: "dola-usd" },
|
|
3160
|
-
{ ...import_tokenlist6.S_TOKEN, symbol: "S" },
|
|
3161
|
-
{ ...import_tokenlist6.EURC_TOKEN, symbol: "EURC", coinGeckoId: "euro-coin" },
|
|
3162
|
-
{ ...import_tokenlist6.USDT_TOKEN, symbol: "USDT", coinGeckoId: "tether" },
|
|
3163
|
-
{ ...import_tokenlist6.USDT0_TOKEN, symbol: "USDT0", coinGeckoId: "tether" }
|
|
3164
|
-
];
|
|
3165
|
-
var PRICED_TOKENS = [
|
|
3166
|
-
...BASE_ASSETS,
|
|
3167
|
-
{ ...import_tokenlist6.TOKE_TOKEN, symbol: "TOKE" },
|
|
3168
|
-
{ ...import_tokenlist6.AUTO_TOKEN, symbol: "AUTO" },
|
|
3169
|
-
{ ...import_tokenlist6.SILO_TOKEN, symbol: "SILO" },
|
|
3170
|
-
{ ...import_tokenlist6.XPL_TOKEN, address: import_tokenlist6.WXPL_TOKEN.address, symbol: "XPL" },
|
|
3171
|
-
{ ...import_tokenlist6.MON_TOKEN, address: import_tokenlist6.WMON_TOKEN.address, symbol: "MON" },
|
|
3172
|
-
{ ...import_tokenlist6.USDT0_TOKEN, symbol: "USDT0" }
|
|
3173
|
-
];
|
|
3174
|
-
var WRAPPED_TOKENS = [
|
|
3175
|
-
{ ...import_tokenlist6.WETH_TOKEN, symbol: "WETH" },
|
|
3176
|
-
{ ...import_tokenlist6.WS_TOKEN, symbol: "WS" },
|
|
3177
|
-
{ ...import_tokenlist6.WXPL_TOKEN, symbol: "WXPL" },
|
|
3178
|
-
{ ...import_tokenlist6.WMON_TOKEN, symbol: "WMON" }
|
|
3179
|
-
];
|
|
3180
|
-
var isStale = (timestamp) => {
|
|
3181
|
-
return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
|
|
3182
|
-
};
|
|
3183
|
-
var getTokenPrices = async (isCronJob = false) => {
|
|
3184
|
-
try {
|
|
3185
|
-
const body = {
|
|
3186
|
-
tokens: PRICED_TOKENS.map((asset) => ({
|
|
3187
|
-
token: asset.address,
|
|
3188
|
-
chainId: asset.chainId,
|
|
3189
|
-
systemName: "gen3",
|
|
3190
|
-
timeoutMS: 5 * 1e3
|
|
3191
|
-
}))
|
|
3192
|
-
};
|
|
3193
|
-
const response = await fetch(`${import_constants16.TOKEMAK_PRICES_STAGING_URL}`, {
|
|
3194
|
-
method: "POST",
|
|
3195
|
-
headers: {
|
|
3196
|
-
"Content-Type": "application/json"
|
|
3197
|
-
},
|
|
3198
|
-
body: JSON.stringify(body)
|
|
3199
|
-
});
|
|
3200
|
-
const data = await response.json();
|
|
3201
|
-
const prices = PRICED_TOKENS.reduce((acc, asset) => {
|
|
3202
|
-
const priceData = data.find(
|
|
3203
|
-
(item) => item.token.toLowerCase() === asset.address.toLowerCase() && item.chainId === asset.chainId
|
|
3204
|
-
);
|
|
3205
|
-
acc[asset.symbol] = priceData?.price ?? 0;
|
|
3206
|
-
return acc;
|
|
3207
|
-
}, {});
|
|
3208
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
3209
|
-
return {
|
|
3210
|
-
timestamp,
|
|
3211
|
-
isStale: false,
|
|
3212
|
-
prices: {
|
|
3213
|
-
...prices,
|
|
3214
|
-
AUTO: prices.TOKE,
|
|
3215
|
-
WETH: prices.ETH,
|
|
3216
|
-
WS: prices.S,
|
|
3217
|
-
WXPL: prices.XPL
|
|
3218
|
-
}
|
|
3219
|
-
};
|
|
3220
|
-
} catch (e) {
|
|
3221
|
-
if (isCronJob) {
|
|
3222
|
-
return {
|
|
3223
|
-
prices: void 0,
|
|
3224
|
-
timestamp: void 0,
|
|
3225
|
-
isStale: false
|
|
3226
|
-
};
|
|
3227
|
-
} else {
|
|
3228
|
-
const backupPrices = await getBackupTokenPrices();
|
|
3229
|
-
if (backupPrices) {
|
|
3230
|
-
return {
|
|
3231
|
-
prices: backupPrices.prices,
|
|
3232
|
-
timestamp: backupPrices.timestamp,
|
|
3233
|
-
isStale: isStale(backupPrices.timestamp)
|
|
3234
|
-
};
|
|
3235
|
-
}
|
|
3236
|
-
return {
|
|
3237
|
-
prices: void 0,
|
|
3238
|
-
timestamp: void 0,
|
|
3239
|
-
isStale: false
|
|
3240
|
-
};
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
};
|
|
3244
|
-
|
|
3245
3132
|
// functions/getHistoricalTokenPrices.ts
|
|
3246
|
-
var
|
|
3133
|
+
var import_tokenlist6 = require("@tokemak/tokenlist");
|
|
3247
3134
|
var hasCoinGeckoId = (asset) => typeof asset?.coinGeckoId === "string" && asset.coinGeckoId.length > 0;
|
|
3248
3135
|
var getBlobHistoricalTokenPrices = async (tokenSymbol) => {
|
|
3249
3136
|
const blobName = `historical_v2/${tokenSymbol}-latest-success.json`;
|
|
@@ -3258,9 +3145,9 @@ var getBlobHistoricalTokenPrices = async (tokenSymbol) => {
|
|
|
3258
3145
|
var getHistoricalTokenPrices = async () => {
|
|
3259
3146
|
const ETH_ADDRESS_IN_SUBGRAPH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
3260
3147
|
const historicalBaseAssetPrices = await Promise.all(
|
|
3261
|
-
BASE_ASSETS.map(async (baseAsset) => {
|
|
3148
|
+
import_tokenlist6.BASE_ASSETS.map(async (baseAsset) => {
|
|
3262
3149
|
if (!hasCoinGeckoId(baseAsset)) {
|
|
3263
|
-
const address = baseAsset.address ===
|
|
3150
|
+
const address = baseAsset.address === import_tokenlist6.ETH_TOKEN.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
|
|
3264
3151
|
const prices2 = await getTokenValueDayDatas(
|
|
3265
3152
|
address,
|
|
3266
3153
|
baseAsset.chainId
|
|
@@ -3284,7 +3171,7 @@ var getHistoricalTokenPrices = async () => {
|
|
|
3284
3171
|
(timestamp) => {
|
|
3285
3172
|
const prices = {};
|
|
3286
3173
|
const baseAssetsWithUsd = [
|
|
3287
|
-
...BASE_ASSETS.map((asset) => asset.symbol),
|
|
3174
|
+
...import_tokenlist6.BASE_ASSETS.map((asset) => asset.symbol),
|
|
3288
3175
|
"USD"
|
|
3289
3176
|
];
|
|
3290
3177
|
const usdPrices = /* @__PURE__ */ new Map();
|
|
@@ -3750,7 +3637,7 @@ var getChainUserAutopools = async ({
|
|
|
3750
3637
|
|
|
3751
3638
|
// functions/getUserAutopools.ts
|
|
3752
3639
|
var import_utils25 = require("@tokemak/utils");
|
|
3753
|
-
var
|
|
3640
|
+
var import_tokenlist7 = require("@tokemak/tokenlist");
|
|
3754
3641
|
|
|
3755
3642
|
// functions/getUserAutopool.tsx
|
|
3756
3643
|
var import_viem11 = require("viem");
|
|
@@ -3893,7 +3780,7 @@ function accumulateMap(dest, delta, multiplier = 1) {
|
|
|
3893
3780
|
}
|
|
3894
3781
|
var createInitialCurrencyValues = () => {
|
|
3895
3782
|
const currencies = Object.fromEntries([
|
|
3896
|
-
...PRICED_TOKENS.map((token) => [token.symbol, 0]),
|
|
3783
|
+
...import_tokenlist7.PRICED_TOKENS.map((token) => [token.symbol, 0]),
|
|
3897
3784
|
["USD", 0]
|
|
3898
3785
|
]);
|
|
3899
3786
|
return currencies;
|
|
@@ -4111,7 +3998,7 @@ var getUserAutopools = async ({
|
|
|
4111
3998
|
};
|
|
4112
3999
|
}
|
|
4113
4000
|
});
|
|
4114
|
-
let denominatedToken =
|
|
4001
|
+
let denominatedToken = import_tokenlist7.ETH_TOKEN;
|
|
4115
4002
|
const useDenomination = userAutopoolsWithData.filter((autopool) => autopool?.useDenomination).length === 1 && userAutopoolsWithData.length === 1;
|
|
4116
4003
|
if (useDenomination) {
|
|
4117
4004
|
const autopoolWithDenomination = userAutopoolsWithData.find(
|
|
@@ -4303,10 +4190,10 @@ var getUserTokenBalances = async ({
|
|
|
4303
4190
|
};
|
|
4304
4191
|
|
|
4305
4192
|
// functions/getTokenList.ts
|
|
4306
|
-
var
|
|
4193
|
+
var import_tokenlist8 = require("@tokemak/tokenlist");
|
|
4307
4194
|
var getTokenList = async () => {
|
|
4308
4195
|
try {
|
|
4309
|
-
let url = `${
|
|
4196
|
+
let url = `${import_tokenlist8.TOKEMAK_LISTS_URL}/swap_enabled.json`;
|
|
4310
4197
|
const listResponse = await fetch(url);
|
|
4311
4198
|
const { tokens: tokenList } = await listResponse.json();
|
|
4312
4199
|
return tokenList;
|
|
@@ -4428,7 +4315,7 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4428
4315
|
|
|
4429
4316
|
// functions/getUserAutopoolsRewards.ts
|
|
4430
4317
|
var import_utils29 = require("@tokemak/utils");
|
|
4431
|
-
var
|
|
4318
|
+
var import_tokenlist9 = require("@tokemak/tokenlist");
|
|
4432
4319
|
var import_chains11 = require("viem/chains");
|
|
4433
4320
|
var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
4434
4321
|
address,
|
|
@@ -4465,7 +4352,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4465
4352
|
const claimableAmount = rewards ? rewards[(0, import_viem14.getAddress)(extraRewards2.rewardToken?.id)] : 0n;
|
|
4466
4353
|
let price = tokenPrices[rewarderToken.symbol] || 0;
|
|
4467
4354
|
if (rewarderToken.symbol === "XSILO") {
|
|
4468
|
-
price = tokenPrices[
|
|
4355
|
+
price = tokenPrices[import_tokenlist9.SILO_TOKEN.symbol] || 0;
|
|
4469
4356
|
}
|
|
4470
4357
|
const formattedAmount = (0, import_utils29.formatUnitsNum)(
|
|
4471
4358
|
claimableAmount,
|
|
@@ -4503,7 +4390,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4503
4390
|
([tokenSymbol, { amount, decimals }]) => {
|
|
4504
4391
|
let price = tokenPrices[tokenSymbol] || 0;
|
|
4505
4392
|
if (tokenSymbol === "XSILO") {
|
|
4506
|
-
price = tokenPrices[
|
|
4393
|
+
price = tokenPrices[import_tokenlist9.SILO_TOKEN.symbol] || 0;
|
|
4507
4394
|
}
|
|
4508
4395
|
const formattedAmount = (0, import_utils29.formatUnitsNum)(amount, decimals || 18);
|
|
4509
4396
|
tokenRewards[tokenSymbol] = {
|
|
@@ -4520,7 +4407,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4520
4407
|
tokenRewards["TOKE"] = {
|
|
4521
4408
|
...undefinedToken,
|
|
4522
4409
|
USD: undefinedToken.formattedAmount * price,
|
|
4523
|
-
logoURI:
|
|
4410
|
+
logoURI: import_tokenlist9.TOKE_TOKEN.logoURI
|
|
4524
4411
|
};
|
|
4525
4412
|
delete tokenRewards["undefined"];
|
|
4526
4413
|
}
|
|
@@ -4579,7 +4466,7 @@ var import_viem16 = require("viem");
|
|
|
4579
4466
|
var import_utils31 = require("@tokemak/utils");
|
|
4580
4467
|
|
|
4581
4468
|
// functions/getSwapQuote.ts
|
|
4582
|
-
var
|
|
4469
|
+
var import_constants16 = require("@tokemak/constants");
|
|
4583
4470
|
|
|
4584
4471
|
// functions/getAddressFromSystemRegistry.ts
|
|
4585
4472
|
var import_core15 = require("@wagmi/core");
|
|
@@ -4606,25 +4493,25 @@ var getAutopilotRouter = async (wagmiConfig, { chainId }) => await getAddressFro
|
|
|
4606
4493
|
|
|
4607
4494
|
// functions/getSwapQuote.ts
|
|
4608
4495
|
var import_config10 = require("@tokemak/config");
|
|
4609
|
-
var
|
|
4496
|
+
var import_tokenlist10 = require("@tokemak/tokenlist");
|
|
4610
4497
|
var import_chains12 = require("viem/chains");
|
|
4611
4498
|
var getSwapQuote = async (config, { chainId, ...params }) => {
|
|
4612
4499
|
try {
|
|
4613
4500
|
if (!params.sellToken || !params.buyToken) {
|
|
4614
4501
|
throw new Error("Sell token and buy token are required");
|
|
4615
4502
|
}
|
|
4616
|
-
if (params.sellToken ===
|
|
4503
|
+
if (params.sellToken === import_tokenlist10.ETH_TOKEN.address) {
|
|
4617
4504
|
params.sellToken = (0, import_config10.getCoreConfig)(chainId).weth;
|
|
4618
4505
|
if (chainId === import_chains12.sonic.id) {
|
|
4619
|
-
params.sellToken =
|
|
4506
|
+
params.sellToken = import_tokenlist10.WS_TOKEN.address;
|
|
4620
4507
|
}
|
|
4621
4508
|
if (chainId === import_chains12.plasma.id) {
|
|
4622
|
-
params.sellToken =
|
|
4509
|
+
params.sellToken = import_tokenlist10.WXPL_TOKEN.address;
|
|
4623
4510
|
}
|
|
4624
4511
|
}
|
|
4625
4512
|
const sellAmount = params.sellAmount.toString();
|
|
4626
4513
|
const taker = await getAutopilotRouter(config, { chainId });
|
|
4627
|
-
const response = await fetch(
|
|
4514
|
+
const response = await fetch(import_constants16.TOKEMAK_SWAP_QUOTE_URL, {
|
|
4628
4515
|
method: "POST",
|
|
4629
4516
|
headers: {
|
|
4630
4517
|
"Content-Type": "application/json"
|
|
@@ -4655,7 +4542,7 @@ var import_abis13 = require("@tokemak/abis");
|
|
|
4655
4542
|
var import_config11 = require("@tokemak/config");
|
|
4656
4543
|
var import_autopilot_swap_route_calc = require("@tokemak/autopilot-swap-route-calc");
|
|
4657
4544
|
var import_viem15 = require("viem");
|
|
4658
|
-
var
|
|
4545
|
+
var import_constants17 = require("@tokemak/constants");
|
|
4659
4546
|
var getDynamicSwap = async ({
|
|
4660
4547
|
address,
|
|
4661
4548
|
amount,
|
|
@@ -4679,7 +4566,7 @@ var getDynamicSwap = async ({
|
|
|
4679
4566
|
client.transport.transports[0].value.url,
|
|
4680
4567
|
address,
|
|
4681
4568
|
amount,
|
|
4682
|
-
|
|
4569
|
+
import_constants17.LIQUIDATION_PROBE_AMOUNT
|
|
4683
4570
|
);
|
|
4684
4571
|
if (liquidations?.liquidations?.length > 0) {
|
|
4685
4572
|
tokensToLiquidate = liquidations.liquidations;
|
|
@@ -4700,12 +4587,12 @@ var getDynamicSwap = async ({
|
|
|
4700
4587
|
chainId,
|
|
4701
4588
|
systemName: "gen3",
|
|
4702
4589
|
// slippageBps: Math.floor(slippage * 10000),
|
|
4703
|
-
slippageBps:
|
|
4590
|
+
slippageBps: import_constants17.DYNAMIC_SWAP_DEFAULT_SLIPPAGE_BPS,
|
|
4704
4591
|
tokensToLiquidate,
|
|
4705
4592
|
sellAllOnlyCompatible: true
|
|
4706
4593
|
})
|
|
4707
4594
|
};
|
|
4708
|
-
dynamicSwaps = await (await fetch(
|
|
4595
|
+
dynamicSwaps = await (await fetch(import_constants17.TOKEMAK_DYNAMIC_SWAP_ROUTES_URL, requestInit)).json();
|
|
4709
4596
|
if (dynamicSwaps?.success) {
|
|
4710
4597
|
const autopoolRouter = await getAutopilotRouter(config, { chainId });
|
|
4711
4598
|
if (!autopoolRouter) {
|
|
@@ -4726,7 +4613,7 @@ var getDynamicSwap = async ({
|
|
|
4726
4613
|
data: x.data
|
|
4727
4614
|
}))
|
|
4728
4615
|
],
|
|
4729
|
-
account: user ||
|
|
4616
|
+
account: user || import_constants17.SIMULATION_PLACEHOLDER_ADDRESS
|
|
4730
4617
|
});
|
|
4731
4618
|
} catch (e) {
|
|
4732
4619
|
if (e instanceof import_viem15.ContractFunctionExecutionError && e.cause instanceof import_viem15.ContractFunctionRevertedError && e.cause.data?.errorName === "PreviewRedeemWithRoutesResult") {
|
|
@@ -4744,7 +4631,7 @@ var getDynamicSwap = async ({
|
|
|
4744
4631
|
functionName: "previewRedeem",
|
|
4745
4632
|
args: [amount],
|
|
4746
4633
|
chainId,
|
|
4747
|
-
account: user ||
|
|
4634
|
+
account: user || import_constants17.SIMULATION_PLACEHOLDER_ADDRESS
|
|
4748
4635
|
});
|
|
4749
4636
|
if (previewRedeemOnChain >= previewRedeem) {
|
|
4750
4637
|
standardPreviewRedeem = true;
|
|
@@ -4758,7 +4645,7 @@ var getDynamicSwap = async ({
|
|
|
4758
4645
|
};
|
|
4759
4646
|
|
|
4760
4647
|
// functions/getAmountWithdrawn.ts
|
|
4761
|
-
var
|
|
4648
|
+
var import_tokenlist11 = require("@tokemak/tokenlist");
|
|
4762
4649
|
var import_config12 = require("@tokemak/config");
|
|
4763
4650
|
var import_core17 = require("@wagmi/core");
|
|
4764
4651
|
var import_abis14 = require("@tokemak/abis");
|
|
@@ -4796,7 +4683,7 @@ var getAmountWithdrawn = async ({
|
|
|
4796
4683
|
);
|
|
4797
4684
|
let minAmount = (0, import_viem16.formatUnits)(minAmountWithSlippage, decimals);
|
|
4798
4685
|
if (isSwap) {
|
|
4799
|
-
if (buyToken ===
|
|
4686
|
+
if (buyToken === import_tokenlist11.ETH_TOKEN.address) {
|
|
4800
4687
|
const weth = (0, import_config12.getCoreConfig)(chainId).weth;
|
|
4801
4688
|
buyToken = weth;
|
|
4802
4689
|
}
|
|
@@ -5504,6 +5391,90 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
|
5504
5391
|
};
|
|
5505
5392
|
};
|
|
5506
5393
|
|
|
5394
|
+
// functions/getTokenPrices.ts
|
|
5395
|
+
var import_tokenlist12 = require("@tokemak/tokenlist");
|
|
5396
|
+
var import_constants18 = require("@tokemak/constants");
|
|
5397
|
+
|
|
5398
|
+
// functions/getBackupTokenPrices.ts
|
|
5399
|
+
var getBackupTokenPrices = async () => {
|
|
5400
|
+
try {
|
|
5401
|
+
const backupData = await getBlobData(`getTokenPrices-latest-success.json`);
|
|
5402
|
+
if (backupData) {
|
|
5403
|
+
return backupData;
|
|
5404
|
+
}
|
|
5405
|
+
} catch (e) {
|
|
5406
|
+
console.error(e);
|
|
5407
|
+
return void 0;
|
|
5408
|
+
}
|
|
5409
|
+
return void 0;
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5412
|
+
// functions/getTokenPrices.ts
|
|
5413
|
+
var isStale = (timestamp) => {
|
|
5414
|
+
return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
|
|
5415
|
+
};
|
|
5416
|
+
var getTokenPrices = async (isCronJob = false) => {
|
|
5417
|
+
try {
|
|
5418
|
+
const body = {
|
|
5419
|
+
tokens: import_tokenlist12.PRICED_TOKENS.map((asset) => ({
|
|
5420
|
+
token: asset.address,
|
|
5421
|
+
chainId: asset.chainId,
|
|
5422
|
+
systemName: "gen3",
|
|
5423
|
+
timeoutMS: 5 * 1e3
|
|
5424
|
+
}))
|
|
5425
|
+
};
|
|
5426
|
+
const response = await fetch(`${import_constants18.TOKEMAK_PRICES_STAGING_URL}`, {
|
|
5427
|
+
method: "POST",
|
|
5428
|
+
headers: {
|
|
5429
|
+
"Content-Type": "application/json"
|
|
5430
|
+
},
|
|
5431
|
+
body: JSON.stringify(body)
|
|
5432
|
+
});
|
|
5433
|
+
const data = await response.json();
|
|
5434
|
+
const prices = import_tokenlist12.PRICED_TOKENS.reduce((acc, asset) => {
|
|
5435
|
+
const priceData = data.find(
|
|
5436
|
+
(item) => item.token.toLowerCase() === asset.address.toLowerCase() && item.chainId === asset.chainId
|
|
5437
|
+
);
|
|
5438
|
+
acc[asset.symbol] = priceData?.price ?? 0;
|
|
5439
|
+
return acc;
|
|
5440
|
+
}, {});
|
|
5441
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5442
|
+
return {
|
|
5443
|
+
timestamp,
|
|
5444
|
+
isStale: false,
|
|
5445
|
+
prices: {
|
|
5446
|
+
...prices,
|
|
5447
|
+
WETH: prices.ETH,
|
|
5448
|
+
WS: prices.S,
|
|
5449
|
+
WXPL: prices.XPL,
|
|
5450
|
+
WMON: prices.MON
|
|
5451
|
+
}
|
|
5452
|
+
};
|
|
5453
|
+
} catch (e) {
|
|
5454
|
+
if (isCronJob) {
|
|
5455
|
+
return {
|
|
5456
|
+
prices: void 0,
|
|
5457
|
+
timestamp: void 0,
|
|
5458
|
+
isStale: false
|
|
5459
|
+
};
|
|
5460
|
+
} else {
|
|
5461
|
+
const backupPrices = await getBackupTokenPrices();
|
|
5462
|
+
if (backupPrices) {
|
|
5463
|
+
return {
|
|
5464
|
+
prices: backupPrices.prices,
|
|
5465
|
+
timestamp: backupPrices.timestamp,
|
|
5466
|
+
isStale: isStale(backupPrices.timestamp)
|
|
5467
|
+
};
|
|
5468
|
+
}
|
|
5469
|
+
return {
|
|
5470
|
+
prices: void 0,
|
|
5471
|
+
timestamp: void 0,
|
|
5472
|
+
isStale: false
|
|
5473
|
+
};
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
};
|
|
5477
|
+
|
|
5507
5478
|
// functions/getChainSubgraphStatus.ts
|
|
5508
5479
|
var import_graph_cli16 = require("@tokemak/graph-cli");
|
|
5509
5480
|
var getChainSubgraphStatus = async (chain) => {
|
|
@@ -6360,12 +6331,10 @@ var getCombinedRewards = async () => {
|
|
|
6360
6331
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6361
6332
|
0 && (module.exports = {
|
|
6362
6333
|
AutopoolCategory,
|
|
6363
|
-
BASE_ASSETS,
|
|
6364
6334
|
BATCH_SIZE,
|
|
6365
6335
|
ETH_BASE_ASSETS,
|
|
6366
6336
|
EUR_BASE_ASSETS,
|
|
6367
6337
|
MessageStatus,
|
|
6368
|
-
PRICED_TOKENS,
|
|
6369
6338
|
USD_BASE_ASSETS,
|
|
6370
6339
|
aggregateSTokeRewardsDayData,
|
|
6371
6340
|
arraysToObject,
|