@stake-dao/reader 0.4.29 → 0.4.31
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/esm/bytecodes/ccipFee.js +11 -0
- package/dist/esm/bytecodes/ccipFee.js.map +1 -0
- package/dist/esm/bytecodes/gaugeManager/curveGaugeRewardsData.js +1 -1
- package/dist/esm/bytecodes/gaugeManager/curveGaugeRewardsData.js.map +1 -1
- package/dist/esm/bytecodes/votemarket/batchCampaigns.js +5 -3
- package/dist/esm/bytecodes/votemarket/batchCampaigns.js.map +1 -1
- package/dist/esm/bytecodes/votemarket/curve/batchCurveGauges.js +3 -2
- package/dist/esm/bytecodes/votemarket/curve/batchCurveGauges.js.map +1 -1
- package/dist/esm/ccip/fetchCcipFee.js +25 -0
- package/dist/esm/ccip/fetchCcipFee.js.map +1 -0
- package/dist/esm/endpoints.js +3 -0
- package/dist/esm/endpoints.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockers/fetch/index.js +2 -2
- package/dist/esm/lockers/fetch/index.js.map +1 -1
- package/dist/esm/lockers/utils/cakeLockerAirdrop.js +1 -1
- package/dist/esm/lockers/utils/cakeLockerAirdrop.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/index.js +1 -2
- package/dist/esm/lockers/utils/callsForLockers/index.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/pegCalls.js +1 -2
- package/dist/esm/lockers/utils/callsForLockers/pegCalls.js.map +1 -1
- package/dist/esm/lockers/utils/getBribesRewardsData.js +1 -2
- package/dist/esm/lockers/utils/getBribesRewardsData.js.map +1 -1
- package/dist/esm/lockers/utils/getHttpCalls.js +3 -2
- package/dist/esm/lockers/utils/getHttpCalls.js.map +1 -1
- package/dist/esm/lockers/utils/index.js +1 -1
- package/dist/esm/lockers/utils/index.js.map +1 -1
- package/dist/esm/prices.js +17 -21
- package/dist/esm/prices.js.map +1 -1
- package/dist/esm/sdt/fetch.js +1 -2
- package/dist/esm/sdt/fetch.js.map +1 -1
- package/dist/esm/sdt.js +1 -5
- package/dist/esm/sdt.js.map +1 -1
- package/dist/esm/strategies/angle/fetch.js +1 -2
- package/dist/esm/strategies/angle/fetch.js.map +1 -1
- package/dist/esm/strategies/balancer/fetch.js +2 -2
- package/dist/esm/strategies/balancer/fetch.js.map +1 -1
- package/dist/esm/strategies/curve/build.js +5 -13
- package/dist/esm/strategies/curve/build.js.map +1 -1
- package/dist/esm/strategies/curve/fetch/curveApiData/getCurveApiData.js +2 -2
- package/dist/esm/strategies/curve/fetch/curveApiData/getCurveApiData.js.map +1 -1
- package/dist/esm/strategies/curve/fetch/getCvxApr.js +1 -1
- package/dist/esm/strategies/curve/fetch/getCvxApr.js.map +1 -1
- package/dist/esm/strategies/curve/fetch/index.js +1 -2
- package/dist/esm/strategies/curve/fetch/index.js.map +1 -1
- package/dist/esm/strategies/pancakeswap/endpoints.js +2 -1
- package/dist/esm/strategies/pancakeswap/endpoints.js.map +1 -1
- package/dist/esm/strategies/pancakeswap/fetch/getPancakeV3Vaults.js +2 -2
- package/dist/esm/strategies/pancakeswap/fetch/index.js +2 -1
- package/dist/esm/strategies/pancakeswap/fetch/index.js.map +1 -1
- package/dist/esm/strategies/pancakeswap/fetch/pancakeswapMath.js +2 -3
- package/dist/esm/strategies/pancakeswap/fetch/pancakeswapMath.js.map +1 -1
- package/dist/esm/strategies/pendle/fetch.js +2 -2
- package/dist/esm/strategies/pendle/fetch.js.map +1 -1
- package/dist/esm/strategies/utils/boost.js +1 -1
- package/dist/esm/strategies/utils/boost.js.map +1 -1
- package/dist/esm/strategies/utils/index.js +1 -4
- package/dist/esm/strategies/utils/index.js.map +1 -1
- package/dist/esm/strategies/yearn/build.js +5 -13
- package/dist/esm/strategies/yearn/build.js.map +1 -1
- package/dist/esm/strategies/yearn/fetch/index.js +2 -2
- package/dist/esm/strategies/yearn/fetch/index.js.map +1 -1
- package/dist/esm/tokens.js +34 -0
- package/dist/esm/tokens.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/utils.js +27 -24
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/votemarket/curve/config.js +12 -1
- package/dist/esm/votemarket/curve/config.js.map +1 -1
- package/dist/esm/votemarket/curve/fetchCurveGauges.js +5 -3
- package/dist/esm/votemarket/curve/fetchCurveGauges.js.map +1 -1
- package/dist/esm/votemarket/curve/fetchCurveUserVotes.js +1 -1
- package/dist/esm/votemarket/curve/fetchCurveUserVotes.js.map +1 -1
- package/dist/esm/votemarket/curve/fetchUserVlCvxClaimable.js +81 -0
- package/dist/esm/votemarket/curve/fetchUserVlCvxClaimable.js.map +1 -0
- package/dist/esm/votemarket/fetchCampaigns.js +46 -49
- package/dist/esm/votemarket/fetchCampaigns.js.map +1 -1
- package/dist/esm/votemarket/fetchClaimableData.js +7 -12
- package/dist/esm/votemarket/fetchClaimableData.js.map +1 -1
- package/dist/esm/votemarket/generateProofs/getBlockProof.js +2 -1
- package/dist/esm/votemarket/generateProofs/getBlockProof.js.map +1 -1
- package/dist/types/bytecodes/ccipFee.d.ts +4 -0
- package/dist/types/bytecodes/ccipFee.d.ts.map +1 -0
- package/dist/types/bytecodes/votemarket/batchCampaigns.d.ts.map +1 -1
- package/dist/types/bytecodes/votemarket/curve/batchCurveGauges.d.ts.map +1 -1
- package/dist/types/ccip/fetchCcipFee.d.ts +15 -0
- package/dist/types/ccip/fetchCcipFee.d.ts.map +1 -0
- package/dist/types/endpoints.d.ts +3 -0
- package/dist/types/endpoints.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/index.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/pegCalls.d.ts.map +1 -1
- package/dist/types/lockers/utils/getBribesRewardsData.d.ts.map +1 -1
- package/dist/types/lockers/utils/getHttpCalls.d.ts.map +1 -1
- package/dist/types/prices.d.ts +1 -0
- package/dist/types/prices.d.ts.map +1 -1
- package/dist/types/sdt/fetch.d.ts.map +1 -1
- package/dist/types/sdt.d.ts.map +1 -1
- package/dist/types/strategies/angle/fetch.d.ts.map +1 -1
- package/dist/types/strategies/balancer/fetch.d.ts.map +1 -1
- package/dist/types/strategies/curve/build.d.ts.map +1 -1
- package/dist/types/strategies/curve/fetch/index.d.ts.map +1 -1
- package/dist/types/strategies/pancakeswap/endpoints.d.ts.map +1 -1
- package/dist/types/strategies/pancakeswap/fetch/index.d.ts.map +1 -1
- package/dist/types/strategies/pancakeswap/fetch/pancakeswapMath.d.ts.map +1 -1
- package/dist/types/strategies/pendle/fetch.d.ts.map +1 -1
- package/dist/types/strategies/utils/index.d.ts +0 -3
- package/dist/types/strategies/utils/index.d.ts.map +1 -1
- package/dist/types/strategies/yearn/build.d.ts.map +1 -1
- package/dist/types/tokens.d.ts +3 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/votemarket/curve/config.d.ts +12 -1
- package/dist/types/votemarket/curve/config.d.ts.map +1 -1
- package/dist/types/votemarket/curve/fetchCurveGauges.d.ts.map +1 -1
- package/dist/types/votemarket/curve/fetchUserVlCvxClaimable.d.ts +16 -0
- package/dist/types/votemarket/curve/fetchUserVlCvxClaimable.d.ts.map +1 -0
- package/dist/types/votemarket/fetchCampaigns.d.ts +4 -2
- package/dist/types/votemarket/fetchCampaigns.d.ts.map +1 -1
- package/dist/types/votemarket/fetchClaimableData.d.ts +1 -5
- package/dist/types/votemarket/fetchClaimableData.d.ts.map +1 -1
- package/dist/types/votemarket/generateProofs/getBlockProof.d.ts.map +1 -1
- package/dist/types/votemarket/types.d.ts +9 -1
- package/dist/types/votemarket/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/bytecodes/ccipFee.ts +14 -0
- package/src/bytecodes/gaugeManager/curveGaugeRewardsData.ts +1 -1
- package/src/bytecodes/votemarket/batchCampaigns.ts +5 -3
- package/src/bytecodes/votemarket/curve/batchCurveGauges.ts +3 -2
- package/src/ccip/fetchCcipFee.ts +46 -0
- package/src/endpoints.ts +4 -0
- package/src/index.ts +13 -0
- package/src/lockers/fetch/index.ts +2 -2
- package/src/lockers/utils/cakeLockerAirdrop.ts +1 -1
- package/src/lockers/utils/callsForLockers/index.ts +1 -2
- package/src/lockers/utils/callsForLockers/pegCalls.ts +1 -2
- package/src/lockers/utils/getBribesRewardsData.ts +1 -2
- package/src/lockers/utils/getHttpCalls.ts +3 -2
- package/src/lockers/utils/index.ts +1 -1
- package/src/prices.ts +18 -21
- package/src/sdt/fetch.ts +1 -2
- package/src/sdt.ts +10 -5
- package/src/strategies/angle/fetch.ts +1 -2
- package/src/strategies/balancer/fetch.ts +3 -1
- package/src/strategies/curve/build.ts +6 -20
- package/src/strategies/curve/fetch/curveApiData/getCurveApiData.ts +2 -2
- package/src/strategies/curve/fetch/getCvxApr.ts +1 -1
- package/src/strategies/curve/fetch/index.ts +1 -2
- package/src/strategies/pancakeswap/endpoints.ts +3 -2
- package/src/strategies/pancakeswap/fetch/getPancakeV3Vaults.ts +2 -2
- package/src/strategies/pancakeswap/fetch/index.ts +2 -1
- package/src/strategies/pancakeswap/fetch/pancakeswapMath.ts +2 -3
- package/src/strategies/pendle/fetch.ts +12 -2
- package/src/strategies/utils/boost.ts +1 -1
- package/src/strategies/utils/index.ts +1 -5
- package/src/strategies/yearn/build.ts +6 -20
- package/src/strategies/yearn/fetch/index.ts +2 -2
- package/src/tokens.ts +44 -0
- package/src/utils.ts +41 -29
- package/src/votemarket/curve/config.ts +12 -1
- package/src/votemarket/curve/fetchCurveGauges.ts +5 -3
- package/src/votemarket/curve/fetchCurveUserVotes.ts +1 -1
- package/src/votemarket/curve/fetchUserVlCvxClaimable.ts +132 -0
- package/src/votemarket/fetchCampaigns.ts +61 -55
- package/src/votemarket/fetchClaimableData.ts +11 -16
- package/src/votemarket/generateProofs/getBlockProof.ts +2 -1
- package/src/votemarket/types.ts +9 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { contract } from '@stake-dao/constants'
|
|
2
|
+
import { encodeAbiParameters, parseAbiParameters } from 'viem'
|
|
3
|
+
import ccipFee from '../bytecodes/ccipFee.js'
|
|
4
|
+
import { batchJsonRpc, concatBytecode } from '../utils.js'
|
|
5
|
+
|
|
6
|
+
interface FetchCcipFeeProps {
|
|
7
|
+
rpc: string
|
|
8
|
+
sourceChainId: number
|
|
9
|
+
destChainId: number
|
|
10
|
+
destChainSelector: string
|
|
11
|
+
receiver: string
|
|
12
|
+
executionGasLimit: string
|
|
13
|
+
tokens: { address: string; amount: string }[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const fetchCcipFee = async ({
|
|
17
|
+
rpc,
|
|
18
|
+
sourceChainId,
|
|
19
|
+
destChainId,
|
|
20
|
+
destChainSelector,
|
|
21
|
+
receiver,
|
|
22
|
+
executionGasLimit,
|
|
23
|
+
tokens,
|
|
24
|
+
}: FetchCcipFeeProps): Promise<bigint> => {
|
|
25
|
+
const inputParams = [
|
|
26
|
+
contract('ccipRouter', sourceChainId),
|
|
27
|
+
destChainSelector,
|
|
28
|
+
destChainId,
|
|
29
|
+
receiver,
|
|
30
|
+
executionGasLimit,
|
|
31
|
+
tokens.map((t) => [t.address, t.amount]),
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const inputData = encodeAbiParameters(parseAbiParameters(ccipFee.inputType) as any, inputParams)
|
|
35
|
+
const call = concatBytecode(ccipFee.bytecode, inputData)
|
|
36
|
+
|
|
37
|
+
const rawCcipFee = await batchJsonRpc({
|
|
38
|
+
rpc,
|
|
39
|
+
calls: [call],
|
|
40
|
+
outputTypeAbi: ccipFee.outputType,
|
|
41
|
+
parse: false,
|
|
42
|
+
callsKey: `ccip/getCcipFee.ts: rawCcipFee - chainId ${sourceChainId} - rpc ${rpc}`,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return rawCcipFee?.length > 0 ? rawCcipFee[0] : BigInt('10000000000000000')
|
|
46
|
+
}
|
package/src/endpoints.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export const GH_STAKE_DAO_RAW_ORG = 'https://raw.githubusercontent.com/stake-dao'
|
|
2
|
+
export const GH_STAKE_DAO_BOUNTIES_REPORT = `${GH_STAKE_DAO_RAW_ORG}/bounties-report`
|
|
3
|
+
export const GH_STAKE_DAO_VM_DATA = `${GH_STAKE_DAO_RAW_ORG}/votemarket-data`
|
|
4
|
+
|
|
1
5
|
export const LLAMA_API_URL = 'https://coins.llama.fi'
|
|
2
6
|
export const THE_GRAPH_BASE_URL =
|
|
3
7
|
'https://gateway-arbitrum.network.thegraph.com/api/e3c2ef8231c88703a5b450c188ce2db6/subgraphs/id'
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,10 @@ export { generateBlockProof } from './votemarket/generateProofs/getBlockProof.js
|
|
|
77
77
|
export { generateGaugeProof } from './votemarket/generateProofs/getGaugeProof.js'
|
|
78
78
|
export { generateUserProof } from './votemarket/generateProofs/getUserProof.js'
|
|
79
79
|
|
|
80
|
+
// vlCVX Claims
|
|
81
|
+
|
|
82
|
+
export { fetchUserVlCvxClaimable } from './votemarket/curve/fetchUserVlCvxClaimable.js'
|
|
83
|
+
|
|
80
84
|
/// --- END VOTEMARKET
|
|
81
85
|
///////////////////////////////////////////////////////////////
|
|
82
86
|
|
|
@@ -89,3 +93,12 @@ export type { GmGaugeData } from './gaugeManager/curve/gmFetchGauge.js'
|
|
|
89
93
|
|
|
90
94
|
/// --- END GAUGE MANAGER
|
|
91
95
|
///////////////////////////////////////////////////////////////
|
|
96
|
+
|
|
97
|
+
////////////////////////////////////////////////////////////////
|
|
98
|
+
/// --- CCIP
|
|
99
|
+
|
|
100
|
+
// Curve
|
|
101
|
+
export { fetchCcipFee } from './ccip/fetchCcipFee.js'
|
|
102
|
+
|
|
103
|
+
/// --- CCIP
|
|
104
|
+
///////////////////////////////////////////////////////////////
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Locker, ONE_YEAR, delegationWithId, lockers } from '@stake-dao/constants'
|
|
1
|
+
import { type Locker, ONE_YEAR, Zero, delegationWithId, lockers } from '@stake-dao/constants'
|
|
2
2
|
import { formatUnits, parseAbi, zeroAddress } from 'viem'
|
|
3
3
|
import { fraxtal, mainnet } from 'viem/chains'
|
|
4
4
|
import lockersMulticallAbi from '../../abis/lockersMulticall.js'
|
|
5
|
-
import {
|
|
5
|
+
import { getSdtInflationData } from '../../index.js'
|
|
6
6
|
import type { Price } from '../../prices.js'
|
|
7
7
|
import { handlePromise } from '../../strategies/utils/promise.js'
|
|
8
8
|
import { type Call, type MultiChainCall, equalTlc, multicall, multichainMulticall } from '../../utils.js'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { FOUR_YEAR, type LockerSecondaryMarket } from '@stake-dao/constants'
|
|
2
|
-
import { OneEther } from '../../../index.js'
|
|
1
|
+
import { FOUR_YEAR, type LockerSecondaryMarket, OneEther } from '@stake-dao/constants'
|
|
3
2
|
|
|
4
3
|
import type { Address } from 'viem'
|
|
5
4
|
import depositorCalls from './depositorCalls.js'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { parseUnits, zeroAddress } from 'viem'
|
|
2
2
|
|
|
3
|
-
import { type LockerSecondaryMarket, contracts } from '@stake-dao/constants'
|
|
4
|
-
import { One, Zero } from '../../../index.js'
|
|
3
|
+
import { type LockerSecondaryMarket, One, Zero, contracts } from '@stake-dao/constants'
|
|
5
4
|
|
|
6
5
|
const pegCalls = (secondaryMarket: LockerSecondaryMarket | undefined, sdToken: string, token: string) => {
|
|
7
6
|
const secondaryMarketLabel = secondaryMarket?.label || ''
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { bsc, fraxtal, mainnet } from 'viem/chains'
|
|
2
|
+
import { GH_STAKE_DAO_BOUNTIES_REPORT } from '../../endpoints.js'
|
|
2
3
|
|
|
3
4
|
const getHttpCalls = async (chainId: number) => {
|
|
4
5
|
switch (chainId) {
|
|
5
6
|
case mainnet.id: {
|
|
6
7
|
const httpCalls = [
|
|
7
|
-
(await fetch(
|
|
8
|
+
(await fetch(`${GH_STAKE_DAO_BOUNTIES_REPORT}/main/delegationsAPRs.json`)).json(),
|
|
8
9
|
fetch('https://api.frax.finance/v1/vefpisdata/1-day')
|
|
9
10
|
.then((result) => result.json())
|
|
10
11
|
.catch((error) => {
|
|
@@ -44,7 +45,7 @@ const getHttpCalls = async (chainId: number) => {
|
|
|
44
45
|
case fraxtal.id:
|
|
45
46
|
case bsc.id: {
|
|
46
47
|
const httpCalls = [
|
|
47
|
-
(await fetch(
|
|
48
|
+
(await fetch(`${GH_STAKE_DAO_BOUNTIES_REPORT}/main/delegationsAPRs.json`)).json(),
|
|
48
49
|
(await fetch('https://api.stakedao.org/api/lockers/sdfxs-working-supply.json')).json(),
|
|
49
50
|
]
|
|
50
51
|
|
package/src/prices.ts
CHANGED
|
@@ -57,33 +57,30 @@ export const getPricesFromCurve = async (chainId: number) => {
|
|
|
57
57
|
return httpRequest
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export const getGeckoTerminalTokenPrefix = (chainId = 1): string => {
|
|
61
|
+
switch (chainId) {
|
|
62
|
+
case 1:
|
|
63
|
+
return 'eth'
|
|
64
|
+
case 56:
|
|
65
|
+
return 'bsc'
|
|
66
|
+
case 137:
|
|
67
|
+
return 'polygon_pos'
|
|
68
|
+
case 252:
|
|
69
|
+
return 'fraxtal'
|
|
70
|
+
case 42161:
|
|
71
|
+
return 'arbitrum'
|
|
72
|
+
default:
|
|
73
|
+
return 'eth'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
export const getPricesFromGeckoTerminal = async (
|
|
61
78
|
tokens: any[],
|
|
62
79
|
chainId = 1,
|
|
63
80
|
defaultErrorValue?: any,
|
|
64
81
|
): Promise<Price[]> => {
|
|
65
82
|
try {
|
|
66
|
-
|
|
67
|
-
switch (chainId) {
|
|
68
|
-
case 1:
|
|
69
|
-
network = 'eth'
|
|
70
|
-
break
|
|
71
|
-
case 56:
|
|
72
|
-
network = 'bsc'
|
|
73
|
-
break
|
|
74
|
-
case 137:
|
|
75
|
-
network = 'polygon_pos'
|
|
76
|
-
break
|
|
77
|
-
case 252:
|
|
78
|
-
network = 'fraxtal'
|
|
79
|
-
break
|
|
80
|
-
case 42161:
|
|
81
|
-
network = 'arbitrum'
|
|
82
|
-
break
|
|
83
|
-
default:
|
|
84
|
-
network = 'eth'
|
|
85
|
-
break
|
|
86
|
-
}
|
|
83
|
+
const network: string = getGeckoTerminalTokenPrefix(chainId)
|
|
87
84
|
|
|
88
85
|
const httpArgs = uniq(tokens.map((t) => t.address)).join(',')
|
|
89
86
|
const url = `${GECKO_TERMINAL_API_URL}/simple/networks/${network}/token_price/${httpArgs}`
|
package/src/sdt/fetch.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { decodeAbiParameters, formatUnits, parseAbi, parseUnits } from 'viem'
|
|
2
2
|
|
|
3
|
-
import { ONE_DAY, type Token, contracts, explorers, tokenWithId } from '@stake-dao/constants'
|
|
4
|
-
import { Zero } from '../index.js'
|
|
3
|
+
import { ONE_DAY, type Token, Zero, contracts, explorers, tokenWithId } from '@stake-dao/constants'
|
|
5
4
|
import { type Price } from '../prices.js'
|
|
6
5
|
import { multicall } from '../utils.js'
|
|
7
6
|
import veSdtAlternativeYields from './veSdtAlternativeYields.js'
|
package/src/sdt.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
ETH_SECONDS_PER_BLOCK,
|
|
3
|
+
LOCKERS_MASTERCHEF_PID,
|
|
4
|
+
ONE_WEEK,
|
|
5
|
+
ONE_YEAR,
|
|
6
|
+
OneEther,
|
|
7
|
+
STRATEGIES_MASTERCHEF_PID,
|
|
8
|
+
Zero,
|
|
9
|
+
contracts,
|
|
10
|
+
} from '@stake-dao/constants'
|
|
5
11
|
import { formatUnits, parseAbi, parseEther, parseUnits } from 'viem'
|
|
6
12
|
import type { RewardsData, SdtApr } from './strategies/types.js'
|
|
7
|
-
import { OneEther, Zero } from './strategies/utils/index.js'
|
|
8
13
|
import { multicall } from './utils.js'
|
|
9
14
|
|
|
10
15
|
export type SdtEmissionData = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STRAT_FEES, angleStrats, contracts } from '@stake-dao/constants'
|
|
1
|
+
import { STRAT_FEES, Zero, angleStrats, contracts } from '@stake-dao/constants'
|
|
2
2
|
import { chunk, uniq } from 'lodash-es'
|
|
3
3
|
import { encodeAbiParameters, formatUnits, parseAbiParameters } from 'viem'
|
|
4
4
|
import { mainnet } from 'viem/chains'
|
|
@@ -8,7 +8,6 @@ import { type Price, getPricesFromLlama } from '../../prices.js'
|
|
|
8
8
|
import { batchJsonRpc, equalTlc, multicall } from '../../utils.js'
|
|
9
9
|
import type { RewardsData, SdtApr } from '../types.js'
|
|
10
10
|
import { getAprBreakdown } from '../utils/getAprBreakdown.js'
|
|
11
|
-
import { Zero } from '../utils/index.js'
|
|
12
11
|
import { ANGLE_APR_URL, ANGLE_PRICE_URL } from './endpoints.js'
|
|
13
12
|
|
|
14
13
|
interface TFetchAngle {
|
|
@@ -6,13 +6,15 @@ import {
|
|
|
6
6
|
ETH_ONE_DAY_BLOCK,
|
|
7
7
|
ONE_WEEK,
|
|
8
8
|
ONE_YEAR,
|
|
9
|
+
OneEther,
|
|
9
10
|
STRAT_FEES,
|
|
11
|
+
Zero,
|
|
10
12
|
balancerStrats,
|
|
11
13
|
contracts,
|
|
12
14
|
tokenWithId,
|
|
13
15
|
} from '@stake-dao/constants'
|
|
14
16
|
import { batchBalancerStrats } from '../../bytecodes/index.js'
|
|
15
|
-
import {
|
|
17
|
+
import { concatBytecode, getBoost, getPricesFromLlama, getSdtApr } from '../../index.js'
|
|
16
18
|
import { equalTlc, graphql } from '../../utils.js'
|
|
17
19
|
import { FACTORY_EXPLORER_EVENTS } from '../curve/endpoints.js'
|
|
18
20
|
import type { BalancerGlobalData, RewardsData, Strategy, StrategyData, ValidChainId, ValidExplorer } from '../types.js'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { chunk
|
|
1
|
+
import { chunk } from 'lodash-es'
|
|
2
2
|
import { decodeAbiParameters, encodeAbiParameters, parseAbi, parseAbiParameters } from 'viem'
|
|
3
3
|
|
|
4
|
-
import { contract
|
|
5
|
-
import type { FetchedToken
|
|
6
|
-
import { batchSdtGaugeRewards
|
|
4
|
+
import { contract } from '@stake-dao/constants'
|
|
5
|
+
import type { FetchedToken } from '@stake-dao/constants'
|
|
6
|
+
import { batchSdtGaugeRewards } from '../../bytecodes/index.js'
|
|
7
|
+
import { fetchTokensData } from '../../tokens.js'
|
|
7
8
|
import { equalTlc, getTokenInfo } from '../../utils.js'
|
|
8
9
|
import type { BuiltStrat } from '../types.js'
|
|
9
10
|
import { concatBytecode } from '../utils/index.js'
|
|
@@ -78,22 +79,7 @@ export const buildCurveStrategies = async (
|
|
|
78
79
|
.filter((s) => s.type !== 'error')
|
|
79
80
|
|
|
80
81
|
// Fetch tokens infos
|
|
81
|
-
const
|
|
82
|
-
remove(uniq(tokensToFetch), (t) => !tokens.find((token: Token) => token.address === t)),
|
|
83
|
-
40,
|
|
84
|
-
)
|
|
85
|
-
const decodedPromise = await Promise.allSettled(
|
|
86
|
-
inputArgsChunks.map(async (inputArgs) => {
|
|
87
|
-
const inputData = encodeAbiParameters(parseAbiParameters(batchTokenData.inputType || []) as any, [inputArgs])
|
|
88
|
-
const contractCreationCode = concatBytecode(batchTokenData.bytecode, inputData)
|
|
89
|
-
const returnedData = await provider.call({
|
|
90
|
-
data: contractCreationCode,
|
|
91
|
-
})
|
|
92
|
-
return decodeAbiParameters(parseAbiParameters(batchTokenData.outputTypeHr || []) as any, returnedData.data)
|
|
93
|
-
}),
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
const fetchedTokenData = decodedPromise.flatMap((d) => (d.status === 'fulfilled' ? d.value : [])).flat()
|
|
82
|
+
const fetchedTokenData = await fetchTokensData(provider, tokensToFetch)
|
|
97
83
|
|
|
98
84
|
// Fetch Sdt Gauge rewards tokens infos
|
|
99
85
|
const sdtGaugeInputArgsChunks = chunk(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ONE_YEAR, tokenWithId } from '@stake-dao/constants'
|
|
1
|
+
import { ONE_YEAR, Zero, tokenWithId } from '@stake-dao/constants'
|
|
2
2
|
import { chunk, uniqBy } from 'lodash-es'
|
|
3
3
|
import { encodeAbiParameters, formatUnits, parseAbiParameters, zeroAddress } from 'viem'
|
|
4
4
|
import { mainnet } from 'viem/chains'
|
|
@@ -125,7 +125,7 @@ export const getCurveApiData = async (rpc: string, chainId: number, gaugesWeight
|
|
|
125
125
|
})
|
|
126
126
|
|
|
127
127
|
const usdTotal = coinsWithUsdBalance.reduce((total: number, x) => (total += x.usdBalance), 0)
|
|
128
|
-
const lpPriceInUsd = p.totalSupply >
|
|
128
|
+
const lpPriceInUsd = p.totalSupply > Zero ? usdTotal / Number(formatUnits(p.totalSupply, 18)) : 0
|
|
129
129
|
|
|
130
130
|
let gaugeFromPool = CUSTOM_GAUGES[p.lp] ? CUSTOM_GAUGES[p.lp] : p.gauge
|
|
131
131
|
const gaugeData = gauges.find((g) => equalTlc(g.gauge, gaugeFromPool) || equalTlc(g.lpToken, p.lp))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Zero } from '@stake-dao/constants'
|
|
1
2
|
import { formatUnits, parseUnits } from 'viem'
|
|
2
|
-
import { Zero } from '../../utils/index.js'
|
|
3
3
|
|
|
4
4
|
const CVX_CLIFF_SIZE = parseUnits('100000', 18) // new cliff every 100,000 tokens
|
|
5
5
|
const CVX_CLIFF_COUNT = BigInt(1000) // 1,000 cliffs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatUnits } from 'viem'
|
|
2
2
|
|
|
3
|
-
import { ONE_YEAR, curveStrats, mainnet, tokenWithId } from '@stake-dao/constants'
|
|
3
|
+
import { ONE_YEAR, OneEther, Zero, curveStrats, mainnet, tokenWithId } from '@stake-dao/constants'
|
|
4
4
|
import type { Price } from '../../../prices.js'
|
|
5
5
|
import { type SdtEmissionData, getSdtApr } from '../../../sdt.js'
|
|
6
6
|
import { equalTlc } from '../../../utils.js'
|
|
@@ -15,7 +15,6 @@ import type {
|
|
|
15
15
|
import { getBoost } from '../../utils/boost.js'
|
|
16
16
|
import decodeEtherscanFactoryEvent, { decodeNewFactoryEvent } from '../../utils/decodeEtherscanFactoryEvent.js'
|
|
17
17
|
import { getAprBreakdown } from '../../utils/getAprBreakdown.js'
|
|
18
|
-
import { OneEther, Zero } from '../../utils/index.js'
|
|
19
18
|
import { buildCurveStrategies } from '../build.js'
|
|
20
19
|
import { getCurveHttpCalls } from '../httpCalls.js'
|
|
21
20
|
import { getOnChainSdCurveData } from '../onChainCalls.js'
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GH_STAKE_DAO_VM_DATA } from '../../endpoints.js'
|
|
2
|
+
|
|
1
3
|
export const CHAINS_DENOMINATOR = {
|
|
2
4
|
1: 'ethereum',
|
|
3
5
|
56: 'bsc',
|
|
@@ -8,5 +10,4 @@ export const PANCAKESWAP_FEE_URL = (version: string, chainId: number) => {
|
|
|
8
10
|
return `https://explorer.pancakeswap.com/api/cached/pools/apr/${version}/${CHAINS_DENOMINATOR[chainId]}/farms-lp`
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export const MANAGER_FEES_ENDPOINT =
|
|
12
|
-
'https://raw.githubusercontent.com/stake-dao/votemarket-data/main/tvls/pancakeManagersFees.json'
|
|
13
|
+
export const MANAGER_FEES_ENDPOINT = `${GH_STAKE_DAO_VM_DATA}/main/tvls/pancakeManagersFees.json`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NEW_FACTORY_EXPLORER_EVENTS } from '../../curve/endpoints.js'
|
|
2
2
|
|
|
3
3
|
import { contracts, pancakeswapErc20Strats } from '@stake-dao/constants'
|
|
4
|
+
import { GH_STAKE_DAO_VM_DATA } from '../../../endpoints.js'
|
|
4
5
|
import type { Price } from '../../../prices.js'
|
|
5
6
|
import type { ValidChainId, ValidExplorer } from '../../types.js'
|
|
6
7
|
import { getPancakeSwapFeesAPR, getPancakeSwapManagerFeesAPR } from './getPancakeApisData.js'
|
|
@@ -31,7 +32,7 @@ export const fetchPancakeswap = async ({
|
|
|
31
32
|
const [feesApr, managerFees, stakedTVLS, events] = await Promise.all([
|
|
32
33
|
getPancakeSwapFeesAPR(chainId),
|
|
33
34
|
getPancakeSwapManagerFeesAPR(chainId),
|
|
34
|
-
(await fetch(
|
|
35
|
+
(await fetch(`${GH_STAKE_DAO_VM_DATA}/main/tvls/cake.json`)).json(),
|
|
35
36
|
(
|
|
36
37
|
await fetch(
|
|
37
38
|
NEW_FACTORY_EXPLORER_EVENTS(
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ONE_YEAR } from '@stake-dao/constants'
|
|
1
|
+
import { ONE_YEAR, One, Zero } from '@stake-dao/constants'
|
|
2
2
|
import { formatUnits, parseUnits } from 'viem'
|
|
3
|
-
import { Zero } from '../../../index.js'
|
|
4
3
|
|
|
5
4
|
const Q32 = BigInt(2 ** 32)
|
|
6
5
|
const Q96 = BigInt(2 ** 96)
|
|
@@ -79,7 +78,7 @@ function getSqrtRatioAtTick(tick: number): bigint {
|
|
|
79
78
|
if (tick > 0) ratio = MaxUint256 / ratio
|
|
80
79
|
|
|
81
80
|
// back to Q96
|
|
82
|
-
return ratio % Q32 > Zero ? ratio / Q32 +
|
|
81
|
+
return ratio % Q32 > Zero ? ratio / Q32 + One : ratio / Q32
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
function getAmount0Delta(sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, liquidity: bigint): bigint {
|
|
@@ -2,7 +2,17 @@ import dayjs from 'dayjs'
|
|
|
2
2
|
import { chunk } from 'lodash-es'
|
|
3
3
|
import { encodeAbiParameters, formatUnits, parseAbiParameters } from 'viem'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ONE_YEAR,
|
|
7
|
+
OneEther,
|
|
8
|
+
STRAT_FEES,
|
|
9
|
+
Zero,
|
|
10
|
+
contract,
|
|
11
|
+
contracts,
|
|
12
|
+
mainnet,
|
|
13
|
+
pendleStrats,
|
|
14
|
+
tokenWithId,
|
|
15
|
+
} from '@stake-dao/constants'
|
|
6
16
|
import multicallPendleStratsAbi from '../../abis/pendleVaultsMulticall.js'
|
|
7
17
|
import { batchPendleStrats } from '../../bytecodes/index.js'
|
|
8
18
|
import type { Price } from '../../prices.js'
|
|
@@ -12,7 +22,7 @@ import type { RewardsData, SdtApr, ValidChainId, ValidExplorer } from '../types.
|
|
|
12
22
|
import { getBoost } from '../utils/boost.js'
|
|
13
23
|
import decodeEtherscanFactoryEvent from '../utils/decodeEtherscanFactoryEvent.js'
|
|
14
24
|
import { getAprBreakdown } from '../utils/getAprBreakdown.js'
|
|
15
|
-
import {
|
|
25
|
+
import { concatBytecode } from '../utils/index.js'
|
|
16
26
|
import { buildPendleStrategies } from './build.js'
|
|
17
27
|
import getPendleApiData from './getPendleApiData.js'
|
|
18
28
|
import pendlePoints from './pendlePoints.js'
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { decodeAbiParameters, fromBytes, hexToBytes, parseAbiParameters
|
|
2
|
-
|
|
3
|
-
export const Zero = BigInt(0)
|
|
4
|
-
export const One = BigInt(1)
|
|
5
|
-
export const OneEther = parseEther('1')
|
|
1
|
+
import { decodeAbiParameters, fromBytes, hexToBytes, parseAbiParameters } from 'viem'
|
|
6
2
|
|
|
7
3
|
export const bytes32ToString = (bytes32: `0x${string}`) => {
|
|
8
4
|
try {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { chunk
|
|
1
|
+
import { chunk } from 'lodash-es'
|
|
2
2
|
import { decodeAbiParameters, encodeAbiParameters, parseAbiParameters } from 'viem'
|
|
3
3
|
|
|
4
|
-
import { contracts
|
|
5
|
-
import type { FetchedToken
|
|
6
|
-
import { batchSdtGaugeRewards,
|
|
4
|
+
import { contracts } from '@stake-dao/constants'
|
|
5
|
+
import type { FetchedToken } from '@stake-dao/constants'
|
|
6
|
+
import { batchSdtGaugeRewards, buildYearnStrats } from '../../bytecodes/index.js'
|
|
7
|
+
import { fetchTokensData } from '../../tokens.js'
|
|
7
8
|
import { equalTlc, getTokenInfo } from '../../utils.js'
|
|
8
9
|
import type { BuiltStrat } from '../types.js'
|
|
9
10
|
import { concatBytecode } from '../utils/index.js'
|
|
@@ -67,22 +68,7 @@ export const buildYearnStrategies = async (
|
|
|
67
68
|
})
|
|
68
69
|
|
|
69
70
|
// Fetch tokens infos
|
|
70
|
-
const
|
|
71
|
-
remove(uniq(tokensToFetch), (t) => !tokens.find((token: Token) => token.address === t)),
|
|
72
|
-
40,
|
|
73
|
-
)
|
|
74
|
-
const decodedPromise = await Promise.allSettled(
|
|
75
|
-
tokensInputArgsChunks.map(async (inputArgs) => {
|
|
76
|
-
const inputData = encodeAbiParameters(parseAbiParameters(batchTokenData.inputType || []) as any, [inputArgs])
|
|
77
|
-
const contractCreationCode = concatBytecode(batchTokenData.bytecode, inputData)
|
|
78
|
-
const returnedData = await provider.call({
|
|
79
|
-
data: contractCreationCode,
|
|
80
|
-
})
|
|
81
|
-
return decodeAbiParameters(parseAbiParameters(batchTokenData.outputTypeHr || []) as any, returnedData.data)
|
|
82
|
-
}),
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const fetchedTokenData = decodedPromise.flatMap((d) => (d.status === 'fulfilled' ? d.value : [])).flat()
|
|
71
|
+
const fetchedTokenData = await fetchTokensData(provider, tokensToFetch)
|
|
86
72
|
|
|
87
73
|
// Fetch Sdt Gauge rewards tokens infos
|
|
88
74
|
const sdtGaugeInputArgsChunks = chunk(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { chunk } from 'lodash-es'
|
|
2
2
|
import { formatUnits } from 'viem'
|
|
3
3
|
|
|
4
|
-
import { ONE_YEAR, yearnStrats } from '@stake-dao/constants'
|
|
4
|
+
import { ONE_YEAR, OneEther, Zero, yearnStrats } from '@stake-dao/constants'
|
|
5
5
|
import multicallYearnStratsAbi from '../../../abis/yearnVaultsMulticall.js'
|
|
6
6
|
import { equalTlc, multicall } from '../../../utils.js'
|
|
7
7
|
import { NEW_FACTORY_EXPLORER_EVENTS } from '../../curve/endpoints.js'
|
|
@@ -14,7 +14,7 @@ import type { Price } from '../../../prices.js'
|
|
|
14
14
|
import { type SdtEmissionData, getSdtApr } from '../../../sdt.js'
|
|
15
15
|
import type { RewardsData, StrategyData, ValidChainId, ValidExplorer } from '../../types.js'
|
|
16
16
|
import { getAprBreakdown } from '../../utils/getAprBreakdown.js'
|
|
17
|
-
import {
|
|
17
|
+
import { decodeNewFactoryEvent } from '../../utils/index.js'
|
|
18
18
|
import { fetchAllYearnGauges } from './fetchAllYearnGauges.js'
|
|
19
19
|
|
|
20
20
|
const globalCalls = [
|
package/src/tokens.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Token, tokens } from '@stake-dao/constants'
|
|
2
|
+
import { chunk, remove, uniq } from 'lodash-es'
|
|
3
|
+
import { decodeAbiParameters, encodeAbiParameters, parseAbiParameters } from 'viem'
|
|
4
|
+
import { batchTokenData } from './bytecodes/index.js'
|
|
5
|
+
import { batchJsonRpc, concatBytecode } from './utils.js'
|
|
6
|
+
|
|
7
|
+
export const fetchTokensData = async (provider: any, tokensToFetch: string[]) => {
|
|
8
|
+
const inputArgsChunks = chunk(
|
|
9
|
+
remove(uniq(tokensToFetch), (t) => !tokens.find((token: Token) => token.address === t)),
|
|
10
|
+
40,
|
|
11
|
+
)
|
|
12
|
+
const decodedPromise = await Promise.allSettled(
|
|
13
|
+
inputArgsChunks.map(async (inputArgs) => {
|
|
14
|
+
const inputData = encodeAbiParameters(parseAbiParameters(batchTokenData.inputType || []) as any, [inputArgs])
|
|
15
|
+
const contractCreationCode = concatBytecode(batchTokenData.bytecode, inputData)
|
|
16
|
+
const returnedData = await provider.call({
|
|
17
|
+
data: contractCreationCode,
|
|
18
|
+
})
|
|
19
|
+
return decodeAbiParameters(parseAbiParameters(batchTokenData.outputTypeHr || []) as any, returnedData.data)
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return decodedPromise.flatMap((d) => (d.status === 'fulfilled' ? d.value : [])).flat()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const rpcFetchTokensData = async (chainId: number, rpc: string, tokensToFetch: string[]) => {
|
|
27
|
+
if (tokensToFetch.length > 0) {
|
|
28
|
+
const tokensChunks = chunk(tokensToFetch, 40)
|
|
29
|
+
|
|
30
|
+
const tokensCalls = tokensChunks.map((chunk) => {
|
|
31
|
+
const inputData = encodeAbiParameters(parseAbiParameters(batchTokenData.inputType) as any, [chunk])
|
|
32
|
+
return concatBytecode(batchTokenData.bytecode, inputData)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return await batchJsonRpc({
|
|
36
|
+
rpc,
|
|
37
|
+
calls: tokensCalls,
|
|
38
|
+
outputTypeAbi: batchTokenData.outputTypeHr,
|
|
39
|
+
callsKey: `tokens.ts: rpcFetchTokensData - chainId ${chainId} - rpc ${rpc}`,
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return []
|
|
44
|
+
}
|