@tokemak/queries 0.3.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.mjs
CHANGED
|
@@ -883,9 +883,6 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
883
883
|
}
|
|
884
884
|
extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
|
|
885
885
|
if (baseApr === void 0) baseApr = 0;
|
|
886
|
-
if (autopool.symbol === "autoETH") {
|
|
887
|
-
baseApr = 0.024;
|
|
888
|
-
}
|
|
889
886
|
const combinedApr = baseApr + extraApr;
|
|
890
887
|
let denominatedToken = ETH_TOKEN;
|
|
891
888
|
let useDenominatedValues = false;
|
|
@@ -1150,7 +1147,8 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = TOKEMAK_L
|
|
|
1150
1147
|
timestamp: startTimestamp
|
|
1151
1148
|
});
|
|
1152
1149
|
const formattedDayDatas = autopoolDayDatas.map((autoPoolDayData) => {
|
|
1153
|
-
const
|
|
1150
|
+
const baseDecimals = Number(autoPoolDayData.baseAsset.decimals) || 18;
|
|
1151
|
+
const navPerShare = Number(autoPoolDayData.nav) / Number(autoPoolDayData.totalSupply) * Math.pow(10, 18 - baseDecimals);
|
|
1154
1152
|
let baseApy = autoPoolDayData.autopoolApy;
|
|
1155
1153
|
let rewarderApy = 0;
|
|
1156
1154
|
const formattedRewarder7DayMAApy = formatEtherNum3(
|
|
@@ -3034,135 +3032,8 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = mainnet7.id) => {
|
|
|
3034
3032
|
}
|
|
3035
3033
|
};
|
|
3036
3034
|
|
|
3037
|
-
// functions/getTokenPrices.ts
|
|
3038
|
-
import {
|
|
3039
|
-
ETH_TOKEN as ETH_TOKEN4,
|
|
3040
|
-
PXETH_TOKEN,
|
|
3041
|
-
TOKE_TOKEN as TOKE_TOKEN2,
|
|
3042
|
-
USDC_TOKEN,
|
|
3043
|
-
S_TOKEN as S_TOKEN2,
|
|
3044
|
-
DOLA_TOKEN,
|
|
3045
|
-
WETH_TOKEN as WETH_TOKEN2,
|
|
3046
|
-
WS_TOKEN as WS_TOKEN2,
|
|
3047
|
-
EURC_TOKEN,
|
|
3048
|
-
SILO_TOKEN,
|
|
3049
|
-
WXPL_TOKEN as WXPL_TOKEN2,
|
|
3050
|
-
USDT_TOKEN,
|
|
3051
|
-
XPL_TOKEN as XPL_TOKEN2,
|
|
3052
|
-
USDT0_TOKEN,
|
|
3053
|
-
AUTO_TOKEN as AUTO_TOKEN3,
|
|
3054
|
-
MON_TOKEN,
|
|
3055
|
-
WMON_TOKEN
|
|
3056
|
-
} from "@tokemak/tokenlist";
|
|
3057
|
-
import { TOKEMAK_PRICES_STAGING_URL } from "@tokemak/constants";
|
|
3058
|
-
|
|
3059
|
-
// functions/getBackupTokenPrices.ts
|
|
3060
|
-
var getBackupTokenPrices = async () => {
|
|
3061
|
-
try {
|
|
3062
|
-
const backupData = await getBlobData(`getTokenPrices-latest-success.json`);
|
|
3063
|
-
if (backupData) {
|
|
3064
|
-
return backupData;
|
|
3065
|
-
}
|
|
3066
|
-
} catch (e) {
|
|
3067
|
-
console.error(e);
|
|
3068
|
-
return void 0;
|
|
3069
|
-
}
|
|
3070
|
-
return void 0;
|
|
3071
|
-
};
|
|
3072
|
-
|
|
3073
|
-
// functions/getTokenPrices.ts
|
|
3074
|
-
var BASE_ASSETS = [
|
|
3075
|
-
{ ...ETH_TOKEN4, symbol: "ETH", coinGeckoId: "ethereum" },
|
|
3076
|
-
{ ...PXETH_TOKEN, symbol: "PXETH", coinGeckoId: "dinero-staked-eth" },
|
|
3077
|
-
{ ...USDC_TOKEN, symbol: "USDC", coinGeckoId: "usd-coin" },
|
|
3078
|
-
{ ...DOLA_TOKEN, symbol: "DOLA", coinGeckoId: "dola-usd" },
|
|
3079
|
-
{ ...S_TOKEN2, symbol: "S" },
|
|
3080
|
-
{ ...EURC_TOKEN, symbol: "EURC", coinGeckoId: "euro-coin" },
|
|
3081
|
-
{ ...USDT_TOKEN, symbol: "USDT", coinGeckoId: "tether" },
|
|
3082
|
-
{ ...USDT0_TOKEN, symbol: "USDT0", coinGeckoId: "tether" }
|
|
3083
|
-
];
|
|
3084
|
-
var PRICED_TOKENS = [
|
|
3085
|
-
...BASE_ASSETS,
|
|
3086
|
-
{ ...TOKE_TOKEN2, symbol: "TOKE" },
|
|
3087
|
-
{ ...AUTO_TOKEN3, symbol: "AUTO" },
|
|
3088
|
-
{ ...SILO_TOKEN, symbol: "SILO" },
|
|
3089
|
-
{ ...XPL_TOKEN2, address: WXPL_TOKEN2.address, symbol: "XPL" },
|
|
3090
|
-
{ ...MON_TOKEN, address: WMON_TOKEN.address, symbol: "MON" },
|
|
3091
|
-
{ ...USDT0_TOKEN, symbol: "USDT0" }
|
|
3092
|
-
];
|
|
3093
|
-
var WRAPPED_TOKENS = [
|
|
3094
|
-
{ ...WETH_TOKEN2, symbol: "WETH" },
|
|
3095
|
-
{ ...WS_TOKEN2, symbol: "WS" },
|
|
3096
|
-
{ ...WXPL_TOKEN2, symbol: "WXPL" },
|
|
3097
|
-
{ ...WMON_TOKEN, symbol: "WMON" }
|
|
3098
|
-
];
|
|
3099
|
-
var isStale = (timestamp) => {
|
|
3100
|
-
return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
|
|
3101
|
-
};
|
|
3102
|
-
var getTokenPrices = async (isCronJob = false) => {
|
|
3103
|
-
try {
|
|
3104
|
-
const body = {
|
|
3105
|
-
tokens: PRICED_TOKENS.map((asset) => ({
|
|
3106
|
-
token: asset.address,
|
|
3107
|
-
chainId: asset.chainId,
|
|
3108
|
-
systemName: "gen3",
|
|
3109
|
-
timeoutMS: 5 * 1e3
|
|
3110
|
-
}))
|
|
3111
|
-
};
|
|
3112
|
-
const response = await fetch(`${TOKEMAK_PRICES_STAGING_URL}`, {
|
|
3113
|
-
method: "POST",
|
|
3114
|
-
headers: {
|
|
3115
|
-
"Content-Type": "application/json"
|
|
3116
|
-
},
|
|
3117
|
-
body: JSON.stringify(body)
|
|
3118
|
-
});
|
|
3119
|
-
const data = await response.json();
|
|
3120
|
-
const prices = PRICED_TOKENS.reduce((acc, asset) => {
|
|
3121
|
-
const priceData = data.find(
|
|
3122
|
-
(item) => item.token.toLowerCase() === asset.address.toLowerCase() && item.chainId === asset.chainId
|
|
3123
|
-
);
|
|
3124
|
-
acc[asset.symbol] = priceData?.price ?? 0;
|
|
3125
|
-
return acc;
|
|
3126
|
-
}, {});
|
|
3127
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
3128
|
-
return {
|
|
3129
|
-
timestamp,
|
|
3130
|
-
isStale: false,
|
|
3131
|
-
prices: {
|
|
3132
|
-
...prices,
|
|
3133
|
-
AUTO: prices.TOKE,
|
|
3134
|
-
WETH: prices.ETH,
|
|
3135
|
-
WS: prices.S,
|
|
3136
|
-
WXPL: prices.XPL
|
|
3137
|
-
}
|
|
3138
|
-
};
|
|
3139
|
-
} catch (e) {
|
|
3140
|
-
if (isCronJob) {
|
|
3141
|
-
return {
|
|
3142
|
-
prices: void 0,
|
|
3143
|
-
timestamp: void 0,
|
|
3144
|
-
isStale: false
|
|
3145
|
-
};
|
|
3146
|
-
} else {
|
|
3147
|
-
const backupPrices = await getBackupTokenPrices();
|
|
3148
|
-
if (backupPrices) {
|
|
3149
|
-
return {
|
|
3150
|
-
prices: backupPrices.prices,
|
|
3151
|
-
timestamp: backupPrices.timestamp,
|
|
3152
|
-
isStale: isStale(backupPrices.timestamp)
|
|
3153
|
-
};
|
|
3154
|
-
}
|
|
3155
|
-
return {
|
|
3156
|
-
prices: void 0,
|
|
3157
|
-
timestamp: void 0,
|
|
3158
|
-
isStale: false
|
|
3159
|
-
};
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
};
|
|
3163
|
-
|
|
3164
3035
|
// functions/getHistoricalTokenPrices.ts
|
|
3165
|
-
import { ETH_TOKEN as
|
|
3036
|
+
import { BASE_ASSETS, ETH_TOKEN as ETH_TOKEN4 } from "@tokemak/tokenlist";
|
|
3166
3037
|
var hasCoinGeckoId = (asset) => typeof asset?.coinGeckoId === "string" && asset.coinGeckoId.length > 0;
|
|
3167
3038
|
var getBlobHistoricalTokenPrices = async (tokenSymbol) => {
|
|
3168
3039
|
const blobName = `historical_v2/${tokenSymbol}-latest-success.json`;
|
|
@@ -3179,7 +3050,7 @@ var getHistoricalTokenPrices = async () => {
|
|
|
3179
3050
|
const historicalBaseAssetPrices = await Promise.all(
|
|
3180
3051
|
BASE_ASSETS.map(async (baseAsset) => {
|
|
3181
3052
|
if (!hasCoinGeckoId(baseAsset)) {
|
|
3182
|
-
const address = baseAsset.address ===
|
|
3053
|
+
const address = baseAsset.address === ETH_TOKEN4.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
|
|
3183
3054
|
const prices2 = await getTokenValueDayDatas(
|
|
3184
3055
|
address,
|
|
3185
3056
|
baseAsset.chainId
|
|
@@ -3673,7 +3544,7 @@ import {
|
|
|
3673
3544
|
formatEtherNum as formatEtherNum8,
|
|
3674
3545
|
formatUnitsNum as formatUnitsNum6
|
|
3675
3546
|
} from "@tokemak/utils";
|
|
3676
|
-
import { ETH_TOKEN as
|
|
3547
|
+
import { ETH_TOKEN as ETH_TOKEN5, PRICED_TOKENS } from "@tokemak/tokenlist";
|
|
3677
3548
|
|
|
3678
3549
|
// functions/getUserAutopool.tsx
|
|
3679
3550
|
import { erc20Abi as erc20Abi4 } from "viem";
|
|
@@ -4034,7 +3905,7 @@ var getUserAutopools = async ({
|
|
|
4034
3905
|
};
|
|
4035
3906
|
}
|
|
4036
3907
|
});
|
|
4037
|
-
let denominatedToken =
|
|
3908
|
+
let denominatedToken = ETH_TOKEN5;
|
|
4038
3909
|
const useDenomination = userAutopoolsWithData.filter((autopool) => autopool?.useDenomination).length === 1 && userAutopoolsWithData.length === 1;
|
|
4039
3910
|
if (useDenomination) {
|
|
4040
3911
|
const autopoolWithDenomination = userAutopoolsWithData.find(
|
|
@@ -4351,7 +4222,7 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4351
4222
|
|
|
4352
4223
|
// functions/getUserAutopoolsRewards.ts
|
|
4353
4224
|
import { formatUnitsNum as formatUnitsNum7, getToken as getToken2 } from "@tokemak/utils";
|
|
4354
|
-
import { SILO_TOKEN
|
|
4225
|
+
import { SILO_TOKEN, TOKE_TOKEN as TOKE_TOKEN2 } from "@tokemak/tokenlist";
|
|
4355
4226
|
import { plasma } from "viem/chains";
|
|
4356
4227
|
var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
4357
4228
|
address,
|
|
@@ -4388,7 +4259,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4388
4259
|
const claimableAmount = rewards ? rewards[getAddress4(extraRewards2.rewardToken?.id)] : 0n;
|
|
4389
4260
|
let price = tokenPrices[rewarderToken.symbol] || 0;
|
|
4390
4261
|
if (rewarderToken.symbol === "XSILO") {
|
|
4391
|
-
price = tokenPrices[
|
|
4262
|
+
price = tokenPrices[SILO_TOKEN.symbol] || 0;
|
|
4392
4263
|
}
|
|
4393
4264
|
const formattedAmount = formatUnitsNum7(
|
|
4394
4265
|
claimableAmount,
|
|
@@ -4426,7 +4297,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4426
4297
|
([tokenSymbol, { amount, decimals }]) => {
|
|
4427
4298
|
let price = tokenPrices[tokenSymbol] || 0;
|
|
4428
4299
|
if (tokenSymbol === "XSILO") {
|
|
4429
|
-
price = tokenPrices[
|
|
4300
|
+
price = tokenPrices[SILO_TOKEN.symbol] || 0;
|
|
4430
4301
|
}
|
|
4431
4302
|
const formattedAmount = formatUnitsNum7(amount, decimals || 18);
|
|
4432
4303
|
tokenRewards[tokenSymbol] = {
|
|
@@ -4443,7 +4314,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
4443
4314
|
tokenRewards["TOKE"] = {
|
|
4444
4315
|
...undefinedToken,
|
|
4445
4316
|
USD: undefinedToken.formattedAmount * price,
|
|
4446
|
-
logoURI:
|
|
4317
|
+
logoURI: TOKE_TOKEN2.logoURI
|
|
4447
4318
|
};
|
|
4448
4319
|
delete tokenRewards["undefined"];
|
|
4449
4320
|
}
|
|
@@ -4532,20 +4403,20 @@ var getAutopilotRouter = async (wagmiConfig, { chainId }) => await getAddressFro
|
|
|
4532
4403
|
|
|
4533
4404
|
// functions/getSwapQuote.ts
|
|
4534
4405
|
import { getCoreConfig as getCoreConfig4 } from "@tokemak/config";
|
|
4535
|
-
import { ETH_TOKEN as
|
|
4406
|
+
import { ETH_TOKEN as ETH_TOKEN6, WS_TOKEN as WS_TOKEN2, WXPL_TOKEN as WXPL_TOKEN2 } from "@tokemak/tokenlist";
|
|
4536
4407
|
import { plasma as plasma2, sonic as sonic2 } from "viem/chains";
|
|
4537
4408
|
var getSwapQuote = async (config, { chainId, ...params }) => {
|
|
4538
4409
|
try {
|
|
4539
4410
|
if (!params.sellToken || !params.buyToken) {
|
|
4540
4411
|
throw new Error("Sell token and buy token are required");
|
|
4541
4412
|
}
|
|
4542
|
-
if (params.sellToken ===
|
|
4413
|
+
if (params.sellToken === ETH_TOKEN6.address) {
|
|
4543
4414
|
params.sellToken = getCoreConfig4(chainId).weth;
|
|
4544
4415
|
if (chainId === sonic2.id) {
|
|
4545
|
-
params.sellToken =
|
|
4416
|
+
params.sellToken = WS_TOKEN2.address;
|
|
4546
4417
|
}
|
|
4547
4418
|
if (chainId === plasma2.id) {
|
|
4548
|
-
params.sellToken =
|
|
4419
|
+
params.sellToken = WXPL_TOKEN2.address;
|
|
4549
4420
|
}
|
|
4550
4421
|
}
|
|
4551
4422
|
const sellAmount = params.sellAmount.toString();
|
|
@@ -4692,7 +4563,7 @@ var getDynamicSwap = async ({
|
|
|
4692
4563
|
};
|
|
4693
4564
|
|
|
4694
4565
|
// functions/getAmountWithdrawn.ts
|
|
4695
|
-
import { ETH_TOKEN as
|
|
4566
|
+
import { ETH_TOKEN as ETH_TOKEN7 } from "@tokemak/tokenlist";
|
|
4696
4567
|
import { getCoreConfig as getCoreConfig6 } from "@tokemak/config";
|
|
4697
4568
|
import { readContract as readContract11 } from "@wagmi/core";
|
|
4698
4569
|
import { autopoolEthAbi as autopoolEthAbi4 } from "@tokemak/abis";
|
|
@@ -4730,7 +4601,7 @@ var getAmountWithdrawn = async ({
|
|
|
4730
4601
|
);
|
|
4731
4602
|
let minAmount = formatUnits7(minAmountWithSlippage, decimals);
|
|
4732
4603
|
if (isSwap) {
|
|
4733
|
-
if (buyToken ===
|
|
4604
|
+
if (buyToken === ETH_TOKEN7.address) {
|
|
4734
4605
|
const weth = getCoreConfig6(chainId).weth;
|
|
4735
4606
|
buyToken = weth;
|
|
4736
4607
|
}
|
|
@@ -5455,6 +5326,92 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
|
5455
5326
|
};
|
|
5456
5327
|
};
|
|
5457
5328
|
|
|
5329
|
+
// functions/getTokenPrices.ts
|
|
5330
|
+
import {
|
|
5331
|
+
PRICED_TOKENS as PRICED_TOKENS2
|
|
5332
|
+
} from "@tokemak/tokenlist";
|
|
5333
|
+
import { TOKEMAK_PRICES_STAGING_URL } from "@tokemak/constants";
|
|
5334
|
+
|
|
5335
|
+
// functions/getBackupTokenPrices.ts
|
|
5336
|
+
var getBackupTokenPrices = async () => {
|
|
5337
|
+
try {
|
|
5338
|
+
const backupData = await getBlobData(`getTokenPrices-latest-success.json`);
|
|
5339
|
+
if (backupData) {
|
|
5340
|
+
return backupData;
|
|
5341
|
+
}
|
|
5342
|
+
} catch (e) {
|
|
5343
|
+
console.error(e);
|
|
5344
|
+
return void 0;
|
|
5345
|
+
}
|
|
5346
|
+
return void 0;
|
|
5347
|
+
};
|
|
5348
|
+
|
|
5349
|
+
// functions/getTokenPrices.ts
|
|
5350
|
+
var isStale = (timestamp) => {
|
|
5351
|
+
return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
|
|
5352
|
+
};
|
|
5353
|
+
var getTokenPrices = async (isCronJob = false) => {
|
|
5354
|
+
try {
|
|
5355
|
+
const body = {
|
|
5356
|
+
tokens: PRICED_TOKENS2.map((asset) => ({
|
|
5357
|
+
token: asset.address,
|
|
5358
|
+
chainId: asset.chainId,
|
|
5359
|
+
systemName: "gen3",
|
|
5360
|
+
timeoutMS: 5 * 1e3
|
|
5361
|
+
}))
|
|
5362
|
+
};
|
|
5363
|
+
const response = await fetch(`${TOKEMAK_PRICES_STAGING_URL}`, {
|
|
5364
|
+
method: "POST",
|
|
5365
|
+
headers: {
|
|
5366
|
+
"Content-Type": "application/json"
|
|
5367
|
+
},
|
|
5368
|
+
body: JSON.stringify(body)
|
|
5369
|
+
});
|
|
5370
|
+
const data = await response.json();
|
|
5371
|
+
const prices = PRICED_TOKENS2.reduce((acc, asset) => {
|
|
5372
|
+
const priceData = data.find(
|
|
5373
|
+
(item) => item.token.toLowerCase() === asset.address.toLowerCase() && item.chainId === asset.chainId
|
|
5374
|
+
);
|
|
5375
|
+
acc[asset.symbol] = priceData?.price ?? 0;
|
|
5376
|
+
return acc;
|
|
5377
|
+
}, {});
|
|
5378
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5379
|
+
return {
|
|
5380
|
+
timestamp,
|
|
5381
|
+
isStale: false,
|
|
5382
|
+
prices: {
|
|
5383
|
+
...prices,
|
|
5384
|
+
WETH: prices.ETH,
|
|
5385
|
+
WS: prices.S,
|
|
5386
|
+
WXPL: prices.XPL,
|
|
5387
|
+
WMON: prices.MON
|
|
5388
|
+
}
|
|
5389
|
+
};
|
|
5390
|
+
} catch (e) {
|
|
5391
|
+
if (isCronJob) {
|
|
5392
|
+
return {
|
|
5393
|
+
prices: void 0,
|
|
5394
|
+
timestamp: void 0,
|
|
5395
|
+
isStale: false
|
|
5396
|
+
};
|
|
5397
|
+
} else {
|
|
5398
|
+
const backupPrices = await getBackupTokenPrices();
|
|
5399
|
+
if (backupPrices) {
|
|
5400
|
+
return {
|
|
5401
|
+
prices: backupPrices.prices,
|
|
5402
|
+
timestamp: backupPrices.timestamp,
|
|
5403
|
+
isStale: isStale(backupPrices.timestamp)
|
|
5404
|
+
};
|
|
5405
|
+
}
|
|
5406
|
+
return {
|
|
5407
|
+
prices: void 0,
|
|
5408
|
+
timestamp: void 0,
|
|
5409
|
+
isStale: false
|
|
5410
|
+
};
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
};
|
|
5414
|
+
|
|
5458
5415
|
// functions/getChainSubgraphStatus.ts
|
|
5459
5416
|
import { getSdkByChainId as getSdkByChainId16 } from "@tokemak/graph-cli";
|
|
5460
5417
|
var getChainSubgraphStatus = async (chain) => {
|
|
@@ -5658,12 +5615,12 @@ import { getSdkByChainId as getSdkByChainId17 } from "@tokemak/graph-cli";
|
|
|
5658
5615
|
import { getCoreConfig as getCoreConfig10 } from "@tokemak/config";
|
|
5659
5616
|
import { readContract as readContract17 } from "@wagmi/core";
|
|
5660
5617
|
import { rootPriceOracleAbi } from "@tokemak/abis";
|
|
5661
|
-
import { USDC_TOKEN
|
|
5618
|
+
import { USDC_TOKEN } from "@tokemak/tokenlist";
|
|
5662
5619
|
var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
|
|
5663
5620
|
const config = getCoreConfig10(chainId);
|
|
5664
5621
|
const rootPriceOracle = config.rootPriceOracle;
|
|
5665
5622
|
const weth = config.weth;
|
|
5666
|
-
const usdc =
|
|
5623
|
+
const usdc = USDC_TOKEN.extensions?.bridgeInfo?.[chainId]?.tokenAddress || USDC_TOKEN.address;
|
|
5667
5624
|
const priceAtBlock = await readContract17(wagmiConfig, {
|
|
5668
5625
|
address: rootPriceOracle,
|
|
5669
5626
|
abi: rootPriceOracleAbi,
|
|
@@ -5677,7 +5634,7 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
|
|
|
5677
5634
|
|
|
5678
5635
|
// functions/getRebalanceStats.ts
|
|
5679
5636
|
import { formatEtherNum as formatEtherNum15, formatUnitsNum as formatUnitsNum8 } from "@tokemak/utils";
|
|
5680
|
-
import { USDC_TOKEN as
|
|
5637
|
+
import { USDC_TOKEN as USDC_TOKEN2 } from "@tokemak/tokenlist";
|
|
5681
5638
|
import { sonic as sonic3 } from "viem/chains";
|
|
5682
5639
|
var BATCH_SIZE = 500;
|
|
5683
5640
|
var fetchChainRebalances = async (chainId) => {
|
|
@@ -5698,7 +5655,7 @@ function inferBaseAssetDecimals(rebalance, chainId) {
|
|
|
5698
5655
|
if (chainId === sonic3.id) {
|
|
5699
5656
|
return rebalance.tokenOut.decimals;
|
|
5700
5657
|
}
|
|
5701
|
-
return
|
|
5658
|
+
return USDC_TOKEN2.decimals;
|
|
5702
5659
|
}
|
|
5703
5660
|
var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
5704
5661
|
const ethWei = BigInt(rebalance.tokenOutValueInEth || "0");
|
|
@@ -5709,7 +5666,7 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
|
5709
5666
|
BigInt(rebalance.blockNumber),
|
|
5710
5667
|
chainId
|
|
5711
5668
|
);
|
|
5712
|
-
const ethUsd = Number(formatUnitsNum8(price,
|
|
5669
|
+
const ethUsd = Number(formatUnitsNum8(price, USDC_TOKEN2.decimals));
|
|
5713
5670
|
const ethAmt = Number(formatEtherNum15(ethWei));
|
|
5714
5671
|
const usd = ethAmt * ethUsd;
|
|
5715
5672
|
return usd;
|
|
@@ -6174,12 +6131,12 @@ var getUserMerklRewards = async (address) => {
|
|
|
6174
6131
|
import { getAddress as getAddress5 } from "viem";
|
|
6175
6132
|
import { formatAmount as formatAmount2, formatUnitsNum as formatUnitsNum9 } from "@tokemak/utils";
|
|
6176
6133
|
import {
|
|
6177
|
-
TOKE_TOKEN as
|
|
6134
|
+
TOKE_TOKEN as TOKE_TOKEN3
|
|
6178
6135
|
} from "@tokemak/tokenlist";
|
|
6179
6136
|
var getUserEthAutoLPRewards = async (address) => {
|
|
6180
6137
|
const rewards = await getUserMerklRewards(address);
|
|
6181
6138
|
const autoTokenRewards = rewards?.rewards?.filter(
|
|
6182
|
-
(reward) => getAddress5(reward.token.address) === getAddress5(
|
|
6139
|
+
(reward) => getAddress5(reward.token.address) === getAddress5(TOKE_TOKEN3.address)
|
|
6183
6140
|
);
|
|
6184
6141
|
const autoRewards = autoTokenRewards?.[0];
|
|
6185
6142
|
const amount = autoRewards?.amount;
|
|
@@ -6330,12 +6287,10 @@ var getCombinedRewards = async () => {
|
|
|
6330
6287
|
};
|
|
6331
6288
|
export {
|
|
6332
6289
|
AutopoolCategory,
|
|
6333
|
-
BASE_ASSETS,
|
|
6334
6290
|
BATCH_SIZE,
|
|
6335
6291
|
ETH_BASE_ASSETS,
|
|
6336
6292
|
EUR_BASE_ASSETS,
|
|
6337
6293
|
MessageStatus,
|
|
6338
|
-
PRICED_TOKENS,
|
|
6339
6294
|
USD_BASE_ASSETS,
|
|
6340
6295
|
aggregateSTokeRewardsDayData,
|
|
6341
6296
|
arraysToObject,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokemak/queries",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup && tsc --emitDeclarationOnly",
|
|
29
|
+
"lint": "eslint \"**/*.ts\" --ignore-pattern dist",
|
|
30
|
+
"clean": "rimraf .turbo node_modules dist",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest"
|
|
33
|
+
},
|
|
27
34
|
"devDependencies": {
|
|
28
|
-
"vitest": "
|
|
35
|
+
"vitest": "4.1.5"
|
|
29
36
|
},
|
|
30
37
|
"dependencies": {
|
|
31
38
|
"@layerzerolabs/lz-v2-utilities": "3.0.4",
|
|
32
39
|
"@merkl/api": "1.17.4",
|
|
33
|
-
"
|
|
34
|
-
"@tokemak/config": "
|
|
35
|
-
"@tokemak/
|
|
36
|
-
"@tokemak/
|
|
37
|
-
"@tokemak/
|
|
38
|
-
"@tokemak/utils": "
|
|
39
|
-
"
|
|
40
|
+
"@tokemak/abis": "workspace:*",
|
|
41
|
+
"@tokemak/config": "workspace:*",
|
|
42
|
+
"@tokemak/constants": "workspace:*",
|
|
43
|
+
"@tokemak/graph-cli": "workspace:*",
|
|
44
|
+
"@tokemak/tokenlist": "workspace:*",
|
|
45
|
+
"@tokemak/utils": "workspace:*",
|
|
46
|
+
"graphql-request": "6.1.0"
|
|
40
47
|
},
|
|
41
48
|
"peerDependencies": {
|
|
42
49
|
"@wagmi/core": ">=2.9.0",
|
|
43
50
|
"viem": "2.x",
|
|
44
51
|
"wagmi": ">=2.9.0"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "tsup && tsc --emitDeclarationOnly",
|
|
48
|
-
"lint": "eslint \"**/*.ts\" --ignore-pattern dist",
|
|
49
|
-
"clean": "rimraf .turbo node_modules dist",
|
|
50
|
-
"test": "vitest run",
|
|
51
|
-
"test:watch": "vitest"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|