@tokemak/queries 0.2.1 → 0.3.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/getAutopoolUser.d.ts +14 -0
- package/dist/functions/getAutopoolUser.d.ts.map +1 -1
- package/dist/functions/getAutopools.d.ts +25 -15
- package/dist/functions/getAutopools.d.ts.map +1 -1
- package/dist/functions/getChainAutopools.d.ts +26 -16
- package/dist/functions/getChainAutopools.d.ts.map +1 -1
- package/dist/functions/getMerklCreatorApr.d.ts +1 -1
- package/dist/functions/getMerklCreatorApr.d.ts.map +1 -1
- package/dist/functions/getTokenPrices.d.ts +107 -71
- package/dist/functions/getTokenPrices.d.ts.map +1 -1
- package/dist/functions/getUserAutopool.d.ts +3 -3
- package/dist/functions/getUserAutopools.d.ts +27 -9
- package/dist/functions/getUserAutopools.d.ts.map +1 -1
- package/dist/functions/getUserMerklRewards.d.ts.map +1 -1
- package/dist/functions/getUserTokenBalances.d.ts +1 -2
- package/dist/functions/getUserTokenBalances.d.ts.map +1 -1
- package/dist/index.js +52 -52
- package/dist/index.mjs +49 -47
- package/dist/utils/convertBaseAssetToTokenPricesAndDenom.d.ts +2 -0
- package/dist/utils/convertBaseAssetToTokenPricesAndDenom.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -776,9 +776,15 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
776
776
|
exchange: getProtocol(destination.exchangeName)
|
|
777
777
|
};
|
|
778
778
|
});
|
|
779
|
+
const HIDDEN_DESTINATION_SYMBOLS = ["USR", "WSTUSR"];
|
|
780
|
+
const filteredDestinations = destinations.filter(
|
|
781
|
+
(d) => !d.underlyingTokens.some(
|
|
782
|
+
(t) => HIDDEN_DESTINATION_SYMBOLS.includes(t.symbol?.toUpperCase())
|
|
783
|
+
)
|
|
784
|
+
);
|
|
779
785
|
const uniqueExchanges = Array.from(
|
|
780
786
|
new Set(
|
|
781
|
-
|
|
787
|
+
filteredDestinations.map((d) => getProtocol(d.exchangeName)).filter(Boolean)
|
|
782
788
|
)
|
|
783
789
|
);
|
|
784
790
|
const uniqueExchangesWithValueHeld = uniqueExchanges.map((exchange) => {
|
|
@@ -814,7 +820,7 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
814
820
|
},
|
|
815
821
|
[]
|
|
816
822
|
);
|
|
817
|
-
const uniqueTokensWithValueHeldMap =
|
|
823
|
+
const uniqueTokensWithValueHeldMap = filteredDestinations.flatMap((d) => d.underlyingTokens).reduce((acc, token) => {
|
|
818
824
|
if (acc[token.address]) {
|
|
819
825
|
acc[token.address].valueUsd += token.valueUsd;
|
|
820
826
|
acc[token.address].value += token.value;
|
|
@@ -823,19 +829,20 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
823
829
|
}
|
|
824
830
|
return acc;
|
|
825
831
|
}, {});
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
832
|
+
const HIDDEN_TOKEN_SYMBOLS = ["USR", "WSTUSR"];
|
|
833
|
+
const uniqueTokens = Object.values(uniqueTokensWithValueHeldMap).filter(
|
|
834
|
+
(token) => !HIDDEN_TOKEN_SYMBOLS.includes(token.symbol?.toUpperCase())
|
|
835
|
+
).map((token) => {
|
|
836
|
+
let valueUsd = token.valueUsd;
|
|
837
|
+
let value = token.value;
|
|
838
|
+
const allocation = value / totalAssets;
|
|
839
|
+
return {
|
|
840
|
+
...token,
|
|
841
|
+
valueUsd,
|
|
842
|
+
value,
|
|
843
|
+
allocation
|
|
844
|
+
};
|
|
845
|
+
});
|
|
839
846
|
let UIBaseAsset = baseAsset;
|
|
840
847
|
if (baseAsset.symbol?.toLowerCase() === WETH_TOKEN.symbol.toLowerCase()) {
|
|
841
848
|
UIBaseAsset = ETH_TOKEN;
|
|
@@ -876,6 +883,9 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
876
883
|
}
|
|
877
884
|
extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
|
|
878
885
|
if (baseApr === void 0) baseApr = 0;
|
|
886
|
+
if (autopool.symbol === "autoETH") {
|
|
887
|
+
baseApr = 0.024;
|
|
888
|
+
}
|
|
879
889
|
const combinedApr = baseApr + extraApr;
|
|
880
890
|
let denominatedToken = ETH_TOKEN;
|
|
881
891
|
let useDenominatedValues = false;
|
|
@@ -1017,7 +1027,7 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
1017
1027
|
...autopool,
|
|
1018
1028
|
tvl,
|
|
1019
1029
|
totalAssets: assets,
|
|
1020
|
-
destinations,
|
|
1030
|
+
destinations: filteredDestinations,
|
|
1021
1031
|
exchanges: groupedExchanges,
|
|
1022
1032
|
timestamp,
|
|
1023
1033
|
isNew,
|
|
@@ -3040,7 +3050,9 @@ import {
|
|
|
3040
3050
|
USDT_TOKEN,
|
|
3041
3051
|
XPL_TOKEN as XPL_TOKEN2,
|
|
3042
3052
|
USDT0_TOKEN,
|
|
3043
|
-
AUTO_TOKEN as AUTO_TOKEN3
|
|
3053
|
+
AUTO_TOKEN as AUTO_TOKEN3,
|
|
3054
|
+
MON_TOKEN,
|
|
3055
|
+
WMON_TOKEN
|
|
3044
3056
|
} from "@tokemak/tokenlist";
|
|
3045
3057
|
import { TOKEMAK_PRICES_STAGING_URL } from "@tokemak/constants";
|
|
3046
3058
|
|
|
@@ -3075,12 +3087,14 @@ var PRICED_TOKENS = [
|
|
|
3075
3087
|
{ ...AUTO_TOKEN3, symbol: "AUTO" },
|
|
3076
3088
|
{ ...SILO_TOKEN, symbol: "SILO" },
|
|
3077
3089
|
{ ...XPL_TOKEN2, address: WXPL_TOKEN2.address, symbol: "XPL" },
|
|
3090
|
+
{ ...MON_TOKEN, address: WMON_TOKEN.address, symbol: "MON" },
|
|
3078
3091
|
{ ...USDT0_TOKEN, symbol: "USDT0" }
|
|
3079
3092
|
];
|
|
3080
3093
|
var WRAPPED_TOKENS = [
|
|
3081
3094
|
{ ...WETH_TOKEN2, symbol: "WETH" },
|
|
3082
3095
|
{ ...WS_TOKEN2, symbol: "WS" },
|
|
3083
|
-
{ ...WXPL_TOKEN2, symbol: "WXPL" }
|
|
3096
|
+
{ ...WXPL_TOKEN2, symbol: "WXPL" },
|
|
3097
|
+
{ ...WMON_TOKEN, symbol: "WMON" }
|
|
3084
3098
|
];
|
|
3085
3099
|
var isStale = (timestamp) => {
|
|
3086
3100
|
return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
|
|
@@ -4172,27 +4186,15 @@ var getUserAutopools = async ({
|
|
|
4172
4186
|
|
|
4173
4187
|
// functions/getUserTokenBalances.ts
|
|
4174
4188
|
import { hexToBigInt } from "viem";
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
switch (chainId) {
|
|
4178
|
-
case mainnet8.id:
|
|
4179
|
-
return `https://eth-mainnet.g.alchemy.com/v2/${apiKey}`;
|
|
4180
|
-
case base2.id:
|
|
4181
|
-
return `https://base-mainnet.g.alchemy.com/v2/${apiKey}`;
|
|
4182
|
-
case sonic2.id:
|
|
4183
|
-
return `https://sonic-mainnet.g.alchemy.com/v2/${apiKey}`;
|
|
4184
|
-
default:
|
|
4185
|
-
throw new Error("Unsupported network");
|
|
4186
|
-
}
|
|
4189
|
+
var networkToAlchemyUrl = (chainId) => {
|
|
4190
|
+
return `https://rpc.autopool-services.com/${chainId}/ui`;
|
|
4187
4191
|
};
|
|
4188
4192
|
var getUserTokenBalances = async ({
|
|
4189
4193
|
address,
|
|
4190
|
-
apiKey,
|
|
4191
4194
|
chainId
|
|
4192
4195
|
}) => {
|
|
4193
4196
|
if (!address) throw new Error("Address is not defined");
|
|
4194
|
-
|
|
4195
|
-
const url = networkToAlchemyUrl(chainId, apiKey);
|
|
4197
|
+
const url = networkToAlchemyUrl(chainId);
|
|
4196
4198
|
const body = {
|
|
4197
4199
|
jsonrpc: "2.0",
|
|
4198
4200
|
method: "alchemy_getTokenBalances",
|
|
@@ -4531,7 +4533,7 @@ var getAutopilotRouter = async (wagmiConfig, { chainId }) => await getAddressFro
|
|
|
4531
4533
|
// functions/getSwapQuote.ts
|
|
4532
4534
|
import { getCoreConfig as getCoreConfig4 } from "@tokemak/config";
|
|
4533
4535
|
import { ETH_TOKEN as ETH_TOKEN7, WS_TOKEN as WS_TOKEN3, WXPL_TOKEN as WXPL_TOKEN3 } from "@tokemak/tokenlist";
|
|
4534
|
-
import { plasma as plasma2, sonic as
|
|
4536
|
+
import { plasma as plasma2, sonic as sonic2 } from "viem/chains";
|
|
4535
4537
|
var getSwapQuote = async (config, { chainId, ...params }) => {
|
|
4536
4538
|
try {
|
|
4537
4539
|
if (!params.sellToken || !params.buyToken) {
|
|
@@ -4539,7 +4541,7 @@ var getSwapQuote = async (config, { chainId, ...params }) => {
|
|
|
4539
4541
|
}
|
|
4540
4542
|
if (params.sellToken === ETH_TOKEN7.address) {
|
|
4541
4543
|
params.sellToken = getCoreConfig4(chainId).weth;
|
|
4542
|
-
if (chainId ===
|
|
4544
|
+
if (chainId === sonic2.id) {
|
|
4543
4545
|
params.sellToken = WS_TOKEN3.address;
|
|
4544
4546
|
}
|
|
4545
4547
|
if (chainId === plasma2.id) {
|
|
@@ -5518,9 +5520,9 @@ import {
|
|
|
5518
5520
|
convertSecondsToRemainingTime as convertSecondsToRemainingTime3
|
|
5519
5521
|
} from "@tokemak/utils";
|
|
5520
5522
|
import { getMainnetConfig as getMainnetConfig7 } from "@tokemak/config";
|
|
5521
|
-
import { mainnet as
|
|
5523
|
+
import { mainnet as mainnet8 } from "viem/chains";
|
|
5522
5524
|
var publicClient = createPublicClient({
|
|
5523
|
-
chain:
|
|
5525
|
+
chain: mainnet8,
|
|
5524
5526
|
transport: http("https://mainnet.infura.io/v3/2BtQ5D1QEPHvwgZwKwnZC7WQVhr")
|
|
5525
5527
|
});
|
|
5526
5528
|
var getCycleV1 = async (wagmiConfig, {
|
|
@@ -5676,7 +5678,7 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
|
|
|
5676
5678
|
// functions/getRebalanceStats.ts
|
|
5677
5679
|
import { formatEtherNum as formatEtherNum15, formatUnitsNum as formatUnitsNum8 } from "@tokemak/utils";
|
|
5678
5680
|
import { USDC_TOKEN as USDC_TOKEN3 } from "@tokemak/tokenlist";
|
|
5679
|
-
import { sonic as
|
|
5681
|
+
import { sonic as sonic3 } from "viem/chains";
|
|
5680
5682
|
var BATCH_SIZE = 500;
|
|
5681
5683
|
var fetchChainRebalances = async (chainId) => {
|
|
5682
5684
|
const { GetAllAutopoolRebalances } = getSdkByChainId17(chainId);
|
|
@@ -5693,7 +5695,7 @@ function inferBaseAssetDecimals(rebalance, chainId) {
|
|
|
5693
5695
|
if (BigInt(rebalance.tokenOutValueBaseAsset) === BigInt(rebalance.tokenOutValueInEth)) {
|
|
5694
5696
|
return 18;
|
|
5695
5697
|
}
|
|
5696
|
-
if (chainId ===
|
|
5698
|
+
if (chainId === sonic3.id) {
|
|
5697
5699
|
return rebalance.tokenOut.decimals;
|
|
5698
5700
|
}
|
|
5699
5701
|
return USDC_TOKEN3.decimals;
|
|
@@ -5837,7 +5839,7 @@ import {
|
|
|
5837
5839
|
} from "@tokemak/utils";
|
|
5838
5840
|
import { readContracts as readContracts11 } from "@wagmi/core";
|
|
5839
5841
|
import { formatEther as formatEther5 } from "viem";
|
|
5840
|
-
import { mainnet as
|
|
5842
|
+
import { mainnet as mainnet9 } from "viem/chains";
|
|
5841
5843
|
var getUserSAuto = async (wagmiConfig, {
|
|
5842
5844
|
address,
|
|
5843
5845
|
autoPrice
|
|
@@ -5850,7 +5852,7 @@ var getUserSAuto = async (wagmiConfig, {
|
|
|
5850
5852
|
throw new Error("Auto price not found");
|
|
5851
5853
|
}
|
|
5852
5854
|
const { sAuto } = getMainnetConfig8();
|
|
5853
|
-
const chainId =
|
|
5855
|
+
const chainId = mainnet9.id;
|
|
5854
5856
|
const sAutoContract = {
|
|
5855
5857
|
address: sAuto,
|
|
5856
5858
|
abi: sAutoAbi
|
|
@@ -5985,13 +5987,13 @@ import {
|
|
|
5985
5987
|
formatTVL as formatTVL4
|
|
5986
5988
|
} from "@tokemak/utils";
|
|
5987
5989
|
import { getMainnetConfig as getMainnetConfig9 } from "@tokemak/config";
|
|
5988
|
-
import { mainnet as
|
|
5990
|
+
import { mainnet as mainnet10 } from "viem/chains";
|
|
5989
5991
|
var getSAuto = async (wagmiConfig, {
|
|
5990
5992
|
autoPrice
|
|
5991
5993
|
}) => {
|
|
5992
5994
|
try {
|
|
5993
5995
|
const { sAuto } = getMainnetConfig9();
|
|
5994
|
-
const chainId =
|
|
5996
|
+
const chainId = mainnet10.id;
|
|
5995
5997
|
const baseConfig = {
|
|
5996
5998
|
address: sAuto,
|
|
5997
5999
|
abi: sAutoAbi2,
|
|
@@ -6036,10 +6038,10 @@ import {
|
|
|
6036
6038
|
formatEtherNum as formatEtherNum17
|
|
6037
6039
|
} from "@tokemak/utils";
|
|
6038
6040
|
import { getSdkByChainId as getSdkByChainId18 } from "@tokemak/graph-cli";
|
|
6039
|
-
import { mainnet as
|
|
6041
|
+
import { mainnet as mainnet11 } from "viem/chains";
|
|
6040
6042
|
var getSAutoRewards = async () => {
|
|
6041
6043
|
try {
|
|
6042
|
-
const { GetSAutoRewards } = getSdkByChainId18(
|
|
6044
|
+
const { GetSAutoRewards } = getSdkByChainId18(mainnet11.id);
|
|
6043
6045
|
const { globalRewardsBalances } = await GetSAutoRewards();
|
|
6044
6046
|
const allGlobalRewardsBalanceDayDatas = await paginateQuery(
|
|
6045
6047
|
GetSAutoRewards,
|
|
@@ -6237,11 +6239,11 @@ async function getMerklPoolApr({
|
|
|
6237
6239
|
|
|
6238
6240
|
// functions/getSAutoApr.ts
|
|
6239
6241
|
import { getSdkByChainId as getSdkByChainId19 } from "@tokemak/graph-cli";
|
|
6240
|
-
import { mainnet as
|
|
6242
|
+
import { mainnet as mainnet12 } from "viem/chains";
|
|
6241
6243
|
import { formatEtherNum as formatEtherNum19, formatPercent } from "@tokemak/utils";
|
|
6242
6244
|
var getSAutoApr = async () => {
|
|
6243
6245
|
try {
|
|
6244
|
-
const { GetSAutoApr } = getSdkByChainId19(
|
|
6246
|
+
const { GetSAutoApr } = getSdkByChainId19(mainnet12.id);
|
|
6245
6247
|
const { globalRewardsBalances } = await GetSAutoApr();
|
|
6246
6248
|
if (!globalRewardsBalances || globalRewardsBalances.length === 0) {
|
|
6247
6249
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertBaseAssetToTokenPricesAndDenom.d.ts","sourceRoot":"","sources":["../../utils/convertBaseAssetToTokenPricesAndDenom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,eAAO,MAAM,qCAAqC,GAChD,WAAW,MAAM,EACjB,gBAAgB,MAAM,EACtB,YAAY,MAAM,EAClB,QAAQ,WAAW
|
|
1
|
+
{"version":3,"file":"convertBaseAssetToTokenPricesAndDenom.d.ts","sourceRoot":"","sources":["../../utils/convertBaseAssetToTokenPricesAndDenom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,eAAO,MAAM,qCAAqC,GAChD,WAAW,MAAM,EACjB,gBAAgB,MAAM,EACtB,YAAY,MAAM,EAClB,QAAQ,WAAW;;;;;;;;;;;;;;;;;;;;;CAOpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokemak/queries",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"vitest": "
|
|
28
|
+
"vitest": "2.1.9"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@layerzerolabs/lz-v2-utilities": "3.0.4",
|
|
32
|
-
"@merkl/api": "
|
|
32
|
+
"@merkl/api": "1.17.4",
|
|
33
33
|
"graphql-request": "6.1.0",
|
|
34
|
-
"@tokemak/config": "0.
|
|
35
|
-
"@tokemak/constants": "0.1.2",
|
|
36
|
-
"@tokemak/tokenlist": "0.1.2",
|
|
34
|
+
"@tokemak/config": "0.2.0",
|
|
37
35
|
"@tokemak/graph-cli": "0.2.1",
|
|
38
36
|
"@tokemak/abis": "0.1.1",
|
|
39
|
-
"@tokemak/
|
|
37
|
+
"@tokemak/constants": "0.1.2",
|
|
38
|
+
"@tokemak/utils": "0.1.3",
|
|
39
|
+
"@tokemak/tokenlist": "0.1.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@wagmi/core": ">=2.9.0",
|