@stake-dao/reader 0.2.21 → 0.3.1
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/abis/lockersMulticall.js +17 -0
- package/dist/esm/abis/lockersMulticall.js.map +1 -1
- package/dist/esm/bytecodes/index.js +13 -0
- package/dist/esm/bytecodes/index.js.map +1 -1
- package/dist/esm/bytecodes/votemarket/batchCurveGauges.js +32 -0
- package/dist/esm/bytecodes/votemarket/batchCurveGauges.js.map +1 -0
- package/dist/esm/bytecodes/votemarket/batchGaugesMetadata.js +58 -0
- package/dist/esm/bytecodes/votemarket/batchGaugesMetadata.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockers/fetch/index.js +69 -169
- package/dist/esm/lockers/fetch/index.js.map +1 -1
- package/dist/esm/lockers/fetch/parsePeg.js +21 -0
- package/dist/esm/lockers/fetch/parsePeg.js.map +1 -0
- package/dist/esm/lockers/fetch/parseVoteBoosterData.js +28 -0
- package/dist/esm/lockers/fetch/parseVoteBoosterData.js.map +1 -0
- package/dist/esm/lockers/utils/callsForLockers/depositorCalls.js +5 -5
- package/dist/esm/lockers/utils/callsForLockers/depositorCalls.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/feeCalls.js +13 -11
- package/dist/esm/lockers/utils/callsForLockers/feeCalls.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/index.js +2 -4
- package/dist/esm/lockers/utils/callsForLockers/index.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/pegCalls.js +9 -11
- package/dist/esm/lockers/utils/callsForLockers/pegCalls.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/veCalls.js +4 -4
- package/dist/esm/lockers/utils/callsForLockers/veCalls.js.map +1 -1
- package/dist/esm/lockers/utils/endpoints.js +2 -22
- package/dist/esm/lockers/utils/endpoints.js.map +1 -1
- package/dist/esm/lockers/utils/getBribesRewardsData.js +0 -1
- package/dist/esm/lockers/utils/getBribesRewardsData.js.map +1 -1
- package/dist/esm/lockers/utils/getCherries.js +34 -0
- package/dist/esm/lockers/utils/getCherries.js.map +1 -0
- package/dist/esm/lockers/utils/getHttpCalls.js +5 -7
- package/dist/esm/lockers/utils/getHttpCalls.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/votemarket/curve/config.js +6 -0
- package/dist/esm/votemarket/curve/config.js.map +1 -0
- package/dist/esm/votemarket/curve/fetchCurveGauges.js +86 -0
- package/dist/esm/votemarket/curve/fetchCurveGauges.js.map +1 -0
- package/dist/types/abis/lockersMulticall.d.ts +16 -0
- package/dist/types/abis/lockersMulticall.d.ts.map +1 -1
- package/dist/types/bytecodes/index.d.ts +2 -0
- package/dist/types/bytecodes/index.d.ts.map +1 -1
- package/dist/types/bytecodes/votemarket/batchCurveGauges.d.ts +4 -0
- package/dist/types/bytecodes/votemarket/batchCurveGauges.d.ts.map +1 -0
- package/dist/types/bytecodes/votemarket/batchGaugesMetadata.d.ts +4 -0
- package/dist/types/bytecodes/votemarket/batchGaugesMetadata.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lockers/fetch/index.d.ts +96 -3
- package/dist/types/lockers/fetch/index.d.ts.map +1 -1
- package/dist/types/lockers/fetch/parsePeg.d.ts +3 -0
- package/dist/types/lockers/fetch/parsePeg.d.ts.map +1 -0
- package/dist/types/lockers/fetch/parseVoteBoosterData.d.ts +13 -0
- package/dist/types/lockers/fetch/parseVoteBoosterData.d.ts.map +1 -0
- package/dist/types/lockers/utils/callsForLockers/depositorCalls.d.ts +2 -1
- package/dist/types/lockers/utils/callsForLockers/depositorCalls.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/feeCalls.d.ts +3 -1
- package/dist/types/lockers/utils/callsForLockers/feeCalls.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/index.d.ts +2 -1
- package/dist/types/lockers/utils/callsForLockers/index.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/pegCalls.d.ts +3 -2
- package/dist/types/lockers/utils/callsForLockers/pegCalls.d.ts.map +1 -1
- package/dist/types/lockers/utils/callsForLockers/veCalls.d.ts +2 -1
- package/dist/types/lockers/utils/callsForLockers/veCalls.d.ts.map +1 -1
- package/dist/types/lockers/utils/endpoints.d.ts +2 -2
- package/dist/types/lockers/utils/endpoints.d.ts.map +1 -1
- package/dist/types/lockers/utils/getBribesRewardsData.d.ts +10 -12
- package/dist/types/lockers/utils/getBribesRewardsData.d.ts.map +1 -1
- package/dist/types/lockers/utils/getCherries.d.ts +4 -0
- package/dist/types/lockers/utils/getCherries.d.ts.map +1 -0
- package/dist/types/lockers/utils/getHttpCalls.d.ts +5 -1
- package/dist/types/lockers/utils/getHttpCalls.d.ts.map +1 -1
- package/dist/types/votemarket/curve/config.d.ts +4 -0
- package/dist/types/votemarket/curve/config.d.ts.map +1 -0
- package/dist/types/votemarket/curve/fetchCurveGauges.d.ts +16 -0
- package/dist/types/votemarket/curve/fetchCurveGauges.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/abis/lockersMulticall.ts +17 -0
- package/src/bytecodes/index.ts +18 -0
- package/src/bytecodes/votemarket/batchCurveGauges.ts +34 -0
- package/src/bytecodes/votemarket/batchGaugesMetadata.ts +67 -0
- package/src/index.ts +10 -0
- package/src/lockers/fetch/index.ts +113 -229
- package/src/lockers/fetch/parsePeg.ts +25 -0
- package/src/lockers/fetch/parseVoteBoosterData.ts +34 -0
- package/src/lockers/utils/callsForLockers/depositorCalls.ts +7 -6
- package/src/lockers/utils/callsForLockers/feeCalls.ts +17 -15
- package/src/lockers/utils/callsForLockers/index.ts +6 -10
- package/src/lockers/utils/callsForLockers/pegCalls.ts +11 -12
- package/src/lockers/utils/callsForLockers/veCalls.ts +6 -5
- package/src/lockers/utils/endpoints.ts +2 -25
- package/src/lockers/utils/getBribesRewardsData.ts +11 -2
- package/src/lockers/utils/getCherries.ts +48 -0
- package/src/lockers/utils/getHttpCalls.ts +6 -7
- package/src/votemarket/curve/config.ts +6 -0
- package/src/votemarket/curve/fetchCurveGauges.ts +119 -0
- package/dist/esm/lockers/utils/callsForLockers/gaugeControllerCalls.js +0 -8
- package/dist/esm/lockers/utils/callsForLockers/gaugeControllerCalls.js.map +0 -1
- package/dist/esm/lockers/utils/getCherriesLeaderBoard.js +0 -22
- package/dist/esm/lockers/utils/getCherriesLeaderBoard.js.map +0 -1
- package/dist/types/lockers/utils/callsForLockers/gaugeControllerCalls.d.ts +0 -11
- package/dist/types/lockers/utils/callsForLockers/gaugeControllerCalls.d.ts.map +0 -1
- package/dist/types/lockers/utils/getCherriesLeaderBoard.d.ts +0 -2
- package/dist/types/lockers/utils/getCherriesLeaderBoard.d.ts.map +0 -1
- package/src/lockers/utils/callsForLockers/gaugeControllerCalls.ts +0 -8
- package/src/lockers/utils/getCherriesLeaderBoard.ts +0 -34
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Locker, ONE_YEAR, delegationWithId, lockers } from '@stake-dao/constants'
|
|
2
|
+
import { formatUnits, parseAbi, zeroAddress } from 'viem'
|
|
2
3
|
import { mainnet } from 'viem/chains'
|
|
3
|
-
|
|
4
|
-
import { ONE_YEAR, lockers, tokenWithId } from '@stake-dao/constants'
|
|
5
|
-
import { delegationWithId } from '@stake-dao/constants'
|
|
6
|
-
import { OneEther, Zero, getSdtInflationData } from '../../index.js'
|
|
7
|
-
import { type Price } from '../../prices.js'
|
|
8
|
-
import { type Call, multicall } from '../../utils.js'
|
|
9
|
-
import { lockedAmountCallSideChain } from '../utils/index.js'
|
|
10
|
-
|
|
11
4
|
import lockersMulticallAbi from '../../abis/lockersMulticall.js'
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
5
|
+
import { Zero, getSdtInflationData } from '../../index.js'
|
|
6
|
+
import type { Price } from '../../prices.js'
|
|
7
|
+
import { handlePromise } from '../../strategies/utils/promise.js'
|
|
8
|
+
import { type Call, type MultiChainCall, multicall, multichainMulticall } from '../../utils.js'
|
|
15
9
|
import { extractFees, feeCalls } from '../utils/callsForLockers/feeCalls.js'
|
|
16
10
|
import callsForLockers from '../utils/callsForLockers/index.js'
|
|
17
|
-
import getBribesRewardsData from '../utils/getBribesRewardsData.js'
|
|
11
|
+
import getBribesRewardsData, { type TBribesRewards } from '../utils/getBribesRewardsData.js'
|
|
12
|
+
import { getCherriesLeaderBoard } from '../utils/getCherries.js'
|
|
18
13
|
import getFees from '../utils/getFees.js'
|
|
19
14
|
import getHttpCalls from '../utils/getHttpCalls.js'
|
|
15
|
+
import { lockedAmountCallSideChain } from '../utils/index.js'
|
|
20
16
|
import substractFees from '../utils/substractFees.js'
|
|
17
|
+
import { parsePeg } from './parsePeg.js'
|
|
18
|
+
import { parseVoteBoosterData } from './parseVoteBoosterData.js'
|
|
21
19
|
|
|
22
20
|
const callsForRewards = (gauge: string, rewards: any[]) =>
|
|
23
21
|
rewards.map((r) => ({ address: gauge, name: 'reward_data', params: [r.address] }))
|
|
@@ -32,8 +30,15 @@ const callsForLockersSideChains = (lockerId: any, sideChains: any[]) => {
|
|
|
32
30
|
}, [])
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
interface TFetchLockers {
|
|
34
|
+
provider: any
|
|
35
|
+
chainId: number
|
|
36
|
+
prices: Price[]
|
|
37
|
+
withAirdropGraph?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const fetchLockers = async ({ provider, chainId, prices, withAirdropGraph }: TFetchLockers) => {
|
|
41
|
+
const chainLockers: Locker[] = lockers.filter((l) => l.chainId === chainId)
|
|
37
42
|
|
|
38
43
|
const httpCalls = await getHttpCalls(chainId)
|
|
39
44
|
|
|
@@ -46,263 +51,148 @@ export const fetchLockers = async (provider: any, chainId: number, prices: Price
|
|
|
46
51
|
lockersCalls.push(
|
|
47
52
|
...callsForLockers(
|
|
48
53
|
locker.id,
|
|
49
|
-
locker.token
|
|
50
|
-
locker.sdToken
|
|
51
|
-
locker.
|
|
52
|
-
locker.
|
|
53
|
-
locker.
|
|
54
|
-
locker.
|
|
55
|
-
locker.
|
|
56
|
-
locker.
|
|
57
|
-
locker.pegCalculator,
|
|
58
|
-
locker.extensions.secondaryMarket,
|
|
59
|
-
locker.extensions.voteBooster,
|
|
54
|
+
locker.token.address,
|
|
55
|
+
locker.sdToken.address,
|
|
56
|
+
locker.modules.veToken,
|
|
57
|
+
locker.modules.depositor,
|
|
58
|
+
locker.modules.gauge,
|
|
59
|
+
locker.modules.locker,
|
|
60
|
+
locker.secondaryMarket,
|
|
61
|
+
locker.voteBooster,
|
|
60
62
|
),
|
|
61
63
|
)
|
|
62
|
-
lockersRewardsCalls.push(...callsForRewards(locker.
|
|
64
|
+
lockersRewardsCalls.push(...callsForRewards(locker.modules.gauge, locker.rewards))
|
|
63
65
|
if (locker.extensions.sideChains) {
|
|
64
66
|
lockersSideChainsCalls.push(...callsForLockersSideChains(locker.id, locker.extensions.sideChains))
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
// Add fee calls into another array
|
|
68
70
|
// We will concat it with #lockersRewardsCalls to do only one multicall, the concat will push all fee calls at the end
|
|
69
|
-
lockersFeeCalls.push(...feeCalls(locker.id, locker.
|
|
71
|
+
lockersFeeCalls.push(...feeCalls(locker.id, locker.modules.accumulator))
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
const [rawLockersData, rawLockersSideChainData] = (
|
|
73
|
-
|
|
74
|
+
const [rawLockersData, rawLockersSideChainData, rawLockersRewardsData] = await handlePromise(
|
|
75
|
+
[
|
|
74
76
|
multicall(provider, lockersCalls.concat(lockersFeeCalls), lockersMulticallAbi),
|
|
75
77
|
multichainMulticall(lockersSideChainsCalls, lockersMulticallAbi),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
multicall(
|
|
79
|
+
provider,
|
|
80
|
+
lockersRewardsCalls,
|
|
81
|
+
parseAbi([
|
|
82
|
+
'function reward_data(address) external view returns (address,address,uint256,uint256,uint256,uint256)',
|
|
83
|
+
]),
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
'lockerMulticalls',
|
|
87
|
+
)
|
|
78
88
|
|
|
79
89
|
const lockersFees = extractFees(chainLockers, rawLockersData)
|
|
80
90
|
|
|
81
|
-
const
|
|
82
|
-
getSdtInflationData(provider),
|
|
83
|
-
multicall(
|
|
84
|
-
provider,
|
|
85
|
-
lockersRewardsCalls,
|
|
86
|
-
parseAbi([
|
|
87
|
-
'function reward_data(address) external view returns (address,address,uint256,uint256,uint256,uint256)',
|
|
88
|
-
]),
|
|
89
|
-
),
|
|
90
|
-
])
|
|
91
|
+
const sdtInflationData = chainId === mainnet.id ? await getSdtInflationData(provider) : undefined
|
|
91
92
|
|
|
92
93
|
const lockerData = chainLockers.map(async (locker) => {
|
|
93
94
|
const lockerCallsLength = callsForLockers(
|
|
94
95
|
locker.id,
|
|
95
|
-
locker.token
|
|
96
|
-
locker.sdToken
|
|
97
|
-
locker.
|
|
98
|
-
locker.
|
|
99
|
-
locker.
|
|
100
|
-
locker.
|
|
101
|
-
locker.
|
|
102
|
-
locker.
|
|
103
|
-
locker.pegCalculator,
|
|
104
|
-
locker.extensions.secondaryMarket,
|
|
105
|
-
locker.extensions.voteBooster,
|
|
96
|
+
locker.token.address,
|
|
97
|
+
locker.sdToken.address,
|
|
98
|
+
locker.modules.veToken,
|
|
99
|
+
locker.modules.depositor,
|
|
100
|
+
locker.modules.gauge,
|
|
101
|
+
locker.modules.locker,
|
|
102
|
+
locker.secondaryMarket,
|
|
103
|
+
locker.voteBooster,
|
|
106
104
|
).length
|
|
107
105
|
const chunkedRawLockersData = rawLockersData.splice(0, lockerCallsLength)
|
|
108
106
|
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
let gaugeWeight = '0'
|
|
112
|
-
let nextEffectiveTimestamp = '0'
|
|
113
|
-
|
|
114
|
-
let airdropGraph: any = undefined
|
|
115
|
-
if (locker.id === 'cake') {
|
|
107
|
+
let airdropGraph: any
|
|
108
|
+
if (locker.id === 'cake' && withAirdropGraph) {
|
|
116
109
|
airdropGraph = await getCherriesLeaderBoard()
|
|
117
110
|
}
|
|
118
111
|
|
|
119
112
|
const lockerFee = lockersFees.find((l) => l.lockerId === locker.id)
|
|
120
113
|
const fees = getFees(locker, lockerFee)
|
|
121
114
|
|
|
122
|
-
const tokenLocked = formatUnits(chunkedRawLockersData[0].result[0],
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const veTotalSupplyBN = chunkedRawLockersData[3].result
|
|
127
|
-
const veTotalSupply = formatUnits(veTotalSupplyBN, locker.token!.decimals)
|
|
115
|
+
const tokenLocked = formatUnits(chunkedRawLockersData[0].result[0], locker.token.decimals)
|
|
116
|
+
const veBalanceOfLocker = formatUnits(chunkedRawLockersData[1].result, locker.token.decimals)
|
|
117
|
+
const totalTokenLocked = formatUnits(chunkedRawLockersData[2].result, locker.token.decimals)
|
|
118
|
+
const veTotalSupply = formatUnits(chunkedRawLockersData[3].result, locker.token.decimals)
|
|
128
119
|
const lockIncentive = formatUnits(chunkedRawLockersData[4].result, 0)
|
|
129
|
-
const incentiveAmountInToken = formatUnits(chunkedRawLockersData[5].result,
|
|
130
|
-
if (chainId === mainnet.id) {
|
|
131
|
-
gaugeRelativeWeight = formatUnits(chunkedRawLockersData[6].result, 0)
|
|
132
|
-
gaugeTotalWeight = formatUnits(chunkedRawLockersData[7].result, 0)
|
|
133
|
-
gaugeWeight = formatUnits(chunkedRawLockersData[8].result, 0)
|
|
134
|
-
nextEffectiveTimestamp = formatUnits(chunkedRawLockersData[9].result, 0)
|
|
135
|
-
}
|
|
120
|
+
const incentiveAmountInToken = formatUnits(chunkedRawLockersData[5].result, locker.token.decimals)
|
|
136
121
|
|
|
137
|
-
const totalSupplyStakedStr =
|
|
138
|
-
locker.extensions.gauge !== zeroAddress ? formatUnits(chunkedRawLockersData[10].result, 0) : '0'
|
|
139
122
|
const totalSupplyStaked =
|
|
140
|
-
locker.
|
|
141
|
-
? formatUnits(chunkedRawLockersData[10].result, locker.token!.decimals)
|
|
142
|
-
: '0'
|
|
143
|
-
|
|
144
|
-
const gaugeWorkingSupplyStr =
|
|
145
|
-
locker.chainId === mainnet.id && locker.extensions.gauge !== zeroAddress
|
|
146
|
-
? formatUnits(chunkedRawLockersData[11].result, 0)
|
|
147
|
-
: '0'
|
|
123
|
+
locker.modules.gauge !== zeroAddress ? formatUnits(chunkedRawLockersData[6].result, locker.token.decimals) : '0'
|
|
148
124
|
const gaugeWorkingSupply =
|
|
149
|
-
locker.chainId === mainnet.id && locker.
|
|
150
|
-
? formatUnits(chunkedRawLockersData[
|
|
125
|
+
locker.chainId === mainnet.id && locker.modules.gauge !== zeroAddress
|
|
126
|
+
? formatUnits(chunkedRawLockersData[7].result, locker.token.decimals)
|
|
151
127
|
: '0'
|
|
152
|
-
const amountTokenNotLock = formatUnits(chunkedRawLockersData[
|
|
153
|
-
const veSdtTotalSupply = chainId === mainnet.id ? chunkedRawLockersData[
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
token: formatUnits(chunkedRawLockersData[14].result, locker.token!.decimals),
|
|
158
|
-
sdToken: formatUnits(chunkedRawLockersData[15].result, locker.sdToken!.decimals),
|
|
159
|
-
staked:
|
|
160
|
-
locker.extensions.gauge !== zeroAddress
|
|
161
|
-
? formatUnits(chunkedRawLockersData[16].result, locker.sdToken!.decimals)
|
|
162
|
-
: '0',
|
|
163
|
-
working:
|
|
164
|
-
locker.chainId === mainnet.id && locker.extensions.gauge !== zeroAddress
|
|
165
|
-
? formatUnits(chunkedRawLockersData[17].result, locker.sdToken!.decimals)
|
|
166
|
-
: '0',
|
|
167
|
-
}
|
|
168
|
-
: undefined
|
|
169
|
-
|
|
170
|
-
const voteBoosterBoost = locker.extensions.voteBooster
|
|
171
|
-
? Number(voteBoosterBalance!.working) > 0 && Number(voteBoosterBalance!.staked) > 0
|
|
172
|
-
? Number(voteBoosterBalance!.working) / (Number(voteBoosterBalance!.staked) * 0.4)
|
|
173
|
-
: 1
|
|
174
|
-
: undefined
|
|
175
|
-
|
|
176
|
-
const voteBooster = locker.extensions.voteBooster
|
|
177
|
-
? { balance: voteBoosterBalance, boost: voteBoosterBoost }
|
|
178
|
-
: undefined
|
|
179
|
-
|
|
180
|
-
const rawPeg =
|
|
181
|
-
locker.extensions.pool !== zeroAddress
|
|
182
|
-
? chunkedRawLockersData[locker.extensions.voteBooster ? 18 : 14].result
|
|
183
|
-
: undefined
|
|
184
|
-
const veTokenRate =
|
|
185
|
-
locker.id === 'mav' ? formatUnits(chunkedRawLockersData[15].result[0], locker.token!.decimals) : '4'
|
|
128
|
+
const amountTokenNotLock = formatUnits(chunkedRawLockersData[8].result, locker.token.decimals)
|
|
129
|
+
const veSdtTotalSupply = chainId === mainnet.id ? chunkedRawLockersData[9].result : '0'
|
|
130
|
+
|
|
131
|
+
const voteBooster = parseVoteBoosterData(locker, chunkedRawLockersData)
|
|
132
|
+
const peg = parsePeg(locker, chunkedRawLockersData)
|
|
186
133
|
|
|
187
|
-
const
|
|
188
|
-
|
|
134
|
+
const veTokenRate =
|
|
135
|
+
locker.id === 'mav' ? formatUnits(chunkedRawLockersData[11].result[0], locker.token.decimals) : '4'
|
|
189
136
|
|
|
190
137
|
const sideChains = locker.extensions.sideChains?.map((sideChain) => {
|
|
191
138
|
const tokenLocked = rawLockersSideChainData[sideChain.chainId].shift().result
|
|
192
139
|
return {
|
|
193
140
|
...sideChain,
|
|
194
|
-
tokenLocked: formatUnits(locker.id === 'mav' ? tokenLocked[0] : tokenLocked,
|
|
195
|
-
veBalanceOfLocker: formatUnits(
|
|
196
|
-
|
|
141
|
+
tokenLocked: formatUnits(locker.id === 'mav' ? tokenLocked[0] : tokenLocked, locker.token.decimals),
|
|
142
|
+
veBalanceOfLocker: formatUnits(
|
|
143
|
+
rawLockersSideChainData[sideChain.chainId].shift().result,
|
|
144
|
+
locker.token.decimals,
|
|
145
|
+
),
|
|
146
|
+
veTotalSupply: formatUnits(rawLockersSideChainData[sideChain.chainId].shift().result, locker.token.decimals),
|
|
197
147
|
}
|
|
198
148
|
})
|
|
199
149
|
|
|
200
|
-
|
|
201
|
-
switch (locker.id) {
|
|
202
|
-
case 'bal': {
|
|
203
|
-
parsedPeg = rawPeg[1] * BigInt(-1)
|
|
204
|
-
break
|
|
205
|
-
}
|
|
206
|
-
case 'cake': {
|
|
207
|
-
parsedPeg = rawPeg[0]
|
|
208
|
-
break
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
const peg =
|
|
212
|
-
rawPeg && parsedPeg ? formatUnits(parsedPeg / parseUnits(locker.pegCalculator.basedOn.toString(), 0), 18) : '-'
|
|
213
|
-
|
|
214
|
-
const tokenPrice = prices.find((p) => p.address === locker.token!.address)
|
|
150
|
+
const tokenPrice = prices.find((p) => p.address === locker.token.address)
|
|
215
151
|
const tokenPriceInUsd = tokenPrice ? tokenPrice.usdPrice : 0
|
|
216
152
|
const sdTokenPriceInUsd = peg !== '-' ? tokenPriceInUsd * Number(peg) : tokenPriceInUsd
|
|
217
153
|
|
|
218
|
-
const tvl = totalSupplyStaked ? Number(totalSupplyStaked) * sdTokenPriceInUsd :
|
|
154
|
+
const tvl = totalSupplyStaked ? Number(totalSupplyStaked) * sdTokenPriceInUsd : 0
|
|
219
155
|
|
|
220
156
|
// Rewards APR
|
|
221
157
|
const rewardsData = locker.rewards.map((r) => {
|
|
222
158
|
const rawData = rawLockersRewardsData.shift().result
|
|
223
159
|
const rewardPrice = prices.find((p) => p.address === r.address)?.usdPrice || 0
|
|
224
160
|
|
|
225
|
-
const periodFinish = rawData ? rawData[2] : Zero
|
|
226
|
-
const
|
|
161
|
+
const periodFinish = Number(formatUnits(rawData ? rawData[2] : Zero, 0))
|
|
162
|
+
const streaming = periodFinish > Math.floor(Date.now() / 1000)
|
|
227
163
|
|
|
228
164
|
const rate = rawData ? rawData[3] : Zero
|
|
229
165
|
const oneYearRate = rate * BigInt(ONE_YEAR)
|
|
230
|
-
const oneYearRewardInUsd = parseUnits(`${rewardPrice}`, locker.token!.decimals) * oneYearRate
|
|
231
|
-
|
|
232
|
-
let maxApr = 0
|
|
233
|
-
switch (locker.id) {
|
|
234
|
-
case 'mav': {
|
|
235
|
-
const MAV_AIRDROP = 10_000_000
|
|
236
|
-
const veMavBalanceOfLocker =
|
|
237
|
-
Number(veBalanceOfLocker) + sideChains?.reduce((acc, value) => acc + Number(value.veBalanceOfLocker), 0)
|
|
238
|
-
const veMavTotalSupply =
|
|
239
|
-
Number(veTotalSupply) + sideChains?.reduce((acc, value) => acc + Number(value.veTotalSupply), 0)
|
|
240
|
-
|
|
241
|
-
const mavAirdropStakeDaoShare = MAV_AIRDROP * (veMavBalanceOfLocker / veMavTotalSupply)
|
|
242
|
-
const airdropPerSdMav = mavAirdropStakeDaoShare / (veMavBalanceOfLocker / Number(veTokenRate))
|
|
243
|
-
|
|
244
|
-
maxApr = airdropPerSdMav
|
|
245
|
-
break
|
|
246
|
-
}
|
|
247
|
-
default: {
|
|
248
|
-
if (isFinished) {
|
|
249
|
-
maxApr = 0
|
|
250
|
-
} else {
|
|
251
|
-
maxApr =
|
|
252
|
-
rewardPrice && (tvl || 0) > 0
|
|
253
|
-
? ((Number(formatUnits(oneYearRate, r.decimals)) * rewardPrice) / tvl!) * 100
|
|
254
|
-
: 0
|
|
255
|
-
}
|
|
256
|
-
break
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Remove fees from APR
|
|
261
|
-
maxApr = substractFees(locker.id, maxApr, lockerFee)
|
|
262
|
-
if (r.id === 'sdt' && locker.id !== 'cake') {
|
|
263
|
-
maxApr = isFinished ? 0 : maxApr
|
|
264
|
-
}
|
|
265
|
-
const minApr = maxApr / (locker.id !== 'cake' && r.address === tokenWithId('sdt')!.address ? 2.5 : 1)
|
|
266
166
|
|
|
267
|
-
let
|
|
268
|
-
|
|
167
|
+
let apr = streaming
|
|
168
|
+
? rewardPrice && tvl > 0
|
|
169
|
+
? ((Number(formatUnits(oneYearRate, r.decimals)) * rewardPrice) / tvl) * 100
|
|
170
|
+
: 0
|
|
171
|
+
: 0
|
|
269
172
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const futureOneYearRate = futureRate * BigInt(ONE_YEAR)
|
|
273
|
-
const futureOneYearRewardInUsd = rewardPrice * Number(formatUnits(futureOneYearRate, locker.token!.decimals))
|
|
274
|
-
|
|
275
|
-
futureMaxApr = rewardPrice && (tvl || 0) > 0 ? (futureOneYearRewardInUsd / tvl!) * 100 : 0
|
|
276
|
-
futureMinApr = futureMaxApr / 2.5
|
|
277
|
-
}
|
|
173
|
+
// Remove fees from APR
|
|
174
|
+
apr = substractFees(locker.id, apr, lockerFee)
|
|
278
175
|
|
|
279
176
|
return {
|
|
280
|
-
token: r
|
|
281
|
-
|
|
282
|
-
|
|
177
|
+
token: r,
|
|
178
|
+
price: rewardPrice,
|
|
179
|
+
apr,
|
|
180
|
+
streaming,
|
|
181
|
+
periodFinish,
|
|
283
182
|
rate: formatUnits(rate, 0),
|
|
284
|
-
|
|
285
|
-
oneYearRewardInUsd: formatUnits(oneYearRewardInUsd, 0),
|
|
286
|
-
lastUpdate: rawData ? Number(formatUnits(rawData[4], 0)) : 0,
|
|
287
|
-
integral: rawData ? formatUnits(rawData[5], 0) : '0',
|
|
288
|
-
minApr: minApr,
|
|
289
|
-
maxApr: maxApr,
|
|
290
|
-
futureMinApr,
|
|
291
|
-
futureMaxApr,
|
|
292
|
-
rewardPrice,
|
|
293
|
-
isFinished,
|
|
183
|
+
lastUpdate: rawData ? formatUnits(rawData[4], 0) : '0',
|
|
294
184
|
isAirdrop: r.isAirdrop,
|
|
295
185
|
}
|
|
296
186
|
})
|
|
297
187
|
|
|
298
188
|
let bribeMinApr = 0
|
|
299
189
|
let bribeMaxApr = 0
|
|
300
|
-
let bribeRewards:
|
|
190
|
+
let bribeRewards: TBribesRewards | undefined = undefined
|
|
301
191
|
|
|
302
192
|
if (chainId === mainnet.id) {
|
|
303
193
|
const data = getBribesRewardsData(
|
|
304
194
|
locker,
|
|
305
|
-
httpCalls
|
|
195
|
+
httpCalls.bribesData,
|
|
306
196
|
veSdtTotalSupply,
|
|
307
197
|
totalSupplyStaked,
|
|
308
198
|
veBalanceOfLocker,
|
|
@@ -314,7 +204,7 @@ export const fetchLockers = async (provider: any, chainId: number, prices: Price
|
|
|
314
204
|
bribeRewards = data.bribeRewards
|
|
315
205
|
} else if (locker.id === 'cake') {
|
|
316
206
|
const apr =
|
|
317
|
-
(httpCalls
|
|
207
|
+
(httpCalls.bribesData?.[delegationWithId('cake')!] || 0) *
|
|
318
208
|
(Number.parseFloat(veBalanceOfLocker) / Number.parseFloat(totalSupplyStaked))
|
|
319
209
|
bribeMinApr = apr
|
|
320
210
|
bribeMaxApr = apr
|
|
@@ -322,57 +212,51 @@ export const fetchLockers = async (provider: any, chainId: number, prices: Price
|
|
|
322
212
|
bribeMinApr: apr,
|
|
323
213
|
bribeMaxApr: apr,
|
|
324
214
|
bribeAverageApr: apr,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
maxBoost: 0,
|
|
215
|
+
minBoost: '0',
|
|
216
|
+
maxBoost: '0',
|
|
328
217
|
hideBoostTab: true,
|
|
329
218
|
token: 'sdcake',
|
|
330
219
|
}
|
|
331
220
|
}
|
|
332
221
|
|
|
333
222
|
// Total APR
|
|
334
|
-
const minRewardsAprs = rewardsData.reduce((x, y) => x + y.
|
|
335
|
-
const maxRewardsAprs = rewardsData.reduce((x, y) => x + y.
|
|
223
|
+
const minRewardsAprs = rewardsData.reduce((x, y) => x + y.apr, 0) + bribeMinApr
|
|
224
|
+
const maxRewardsAprs = rewardsData.reduce((x, y) => x + y.apr, 0) + bribeMaxApr
|
|
336
225
|
|
|
337
226
|
// Streaming status
|
|
338
|
-
const streaming = rewardsData.some((r) =>
|
|
227
|
+
const streaming = rewardsData.some((r) => r.streaming)
|
|
339
228
|
const alternativeYields = JSON.parse(JSON.stringify(locker.alternativeYields || {})) // parse and stringify to avoid extensible issue
|
|
340
|
-
if (httpCalls
|
|
229
|
+
if (httpCalls.cvgAprs?.[locker.modules.gauge]) {
|
|
341
230
|
alternativeYields.convergenceSdToken = {
|
|
342
|
-
label: locker.sdToken
|
|
231
|
+
label: locker.sdToken.symbol,
|
|
343
232
|
platform: 'Convergence',
|
|
344
233
|
href: 'https://app.cvg.finance/',
|
|
345
|
-
apr: httpCalls.cvgAprs[locker.
|
|
234
|
+
apr: httpCalls.cvgAprs[locker.modules.gauge].totalApr,
|
|
346
235
|
}
|
|
347
236
|
}
|
|
348
237
|
|
|
349
|
-
if (httpCalls
|
|
350
|
-
alternativeYields[`convergence${locker.sdToken
|
|
351
|
-
label: `${locker.sdToken
|
|
238
|
+
if (locker.extensions.strategyGauge && httpCalls.cvgAprs?.[locker.extensions.strategyGauge]) {
|
|
239
|
+
alternativeYields[`convergence${locker.sdToken.symbol}Pool`] = {
|
|
240
|
+
label: `${locker.sdToken.symbol}/${locker.token.symbol}`,
|
|
352
241
|
platform: 'Convergence',
|
|
353
242
|
href: 'https://app.cvg.finance/',
|
|
354
|
-
apr: httpCalls.cvgAprs[locker.extensions.strategyGauge
|
|
243
|
+
apr: locker.extensions.strategyGauge ? httpCalls.cvgAprs[locker.extensions.strategyGauge].totalApr : 0,
|
|
355
244
|
}
|
|
356
245
|
}
|
|
357
246
|
|
|
358
247
|
return {
|
|
359
248
|
...locker,
|
|
249
|
+
rewards: rewardsData,
|
|
360
250
|
fees,
|
|
361
251
|
tokenLocked: tokenLocked,
|
|
362
|
-
veBalanceOfLocker:
|
|
252
|
+
veBalanceOfLocker: veBalanceOfLocker,
|
|
363
253
|
totalTokenLocked: totalTokenLocked,
|
|
364
|
-
veTotalSupply:
|
|
254
|
+
veTotalSupply: veTotalSupply,
|
|
365
255
|
lockIncentive: lockIncentive,
|
|
366
256
|
incentiveAmountInToken: incentiveAmountInToken,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
gaugeWeight: gaugeWeight,
|
|
370
|
-
futureWeight: formatUnits(futureWeight, 16),
|
|
371
|
-
gaugeWorkingSupply: gaugeWorkingSupplyStr,
|
|
372
|
-
nextEffectiveTimestamp: nextEffectiveTimestamp,
|
|
373
|
-
totalSupplyStaked: totalSupplyStakedStr,
|
|
257
|
+
gaugeWorkingSupply: gaugeWorkingSupply,
|
|
258
|
+
totalSupplyStaked: totalSupplyStaked,
|
|
374
259
|
amountTokenNotLock: amountTokenNotLock,
|
|
375
|
-
rewardsData,
|
|
376
260
|
bribeRewards,
|
|
377
261
|
apr: [minRewardsAprs, maxRewardsAprs],
|
|
378
262
|
streaming,
|
|
@@ -392,9 +276,9 @@ export const fetchLockers = async (provider: any, chainId: number, prices: Price
|
|
|
392
276
|
})
|
|
393
277
|
|
|
394
278
|
return {
|
|
395
|
-
parsed:
|
|
279
|
+
parsed: await Promise.all(lockerData),
|
|
396
280
|
sdt:
|
|
397
|
-
chainId === mainnet.id
|
|
281
|
+
chainId === mainnet.id && sdtInflationData
|
|
398
282
|
? {
|
|
399
283
|
lockersSdtPerBlock: formatUnits(sdtInflationData.lockersSdtPerBlock, 18),
|
|
400
284
|
lockersSdtPerSecond: formatUnits(sdtInflationData.lockersSdtPerSecond, 18),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Locker } from '@stake-dao/constants'
|
|
2
|
+
import { formatUnits, parseUnits, zeroAddress } from 'viem'
|
|
3
|
+
|
|
4
|
+
export const parsePeg = (locker: Locker, chunkedRawLockersData: any) => {
|
|
5
|
+
const rawPeg =
|
|
6
|
+
locker.secondaryMarket?.pool !== zeroAddress
|
|
7
|
+
? chunkedRawLockersData[locker.voteBooster ? 14 : 10].result
|
|
8
|
+
: undefined
|
|
9
|
+
|
|
10
|
+
let parsedPeg = rawPeg
|
|
11
|
+
switch (locker.id) {
|
|
12
|
+
case 'bal':
|
|
13
|
+
parsedPeg = rawPeg[1] * BigInt(-1)
|
|
14
|
+
break
|
|
15
|
+
case 'cake':
|
|
16
|
+
parsedPeg = rawPeg[0]
|
|
17
|
+
break
|
|
18
|
+
}
|
|
19
|
+
const peg =
|
|
20
|
+
rawPeg && parsedPeg
|
|
21
|
+
? formatUnits(parsedPeg / parseUnits(locker.secondaryMarket?.pegBase?.toString() || '1', 0), 18)
|
|
22
|
+
: '-'
|
|
23
|
+
|
|
24
|
+
return peg
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Locker } from '@stake-dao/constants'
|
|
2
|
+
import { formatUnits, zeroAddress } from 'viem'
|
|
3
|
+
import { mainnet } from 'viem/chains'
|
|
4
|
+
|
|
5
|
+
export const parseVoteBoosterData = (locker: Locker, chunkedRawLockersData: any) => {
|
|
6
|
+
if (locker.voteBooster) {
|
|
7
|
+
const voteBoosterBalance = {
|
|
8
|
+
token: formatUnits(chunkedRawLockersData[10].result, locker.token.decimals),
|
|
9
|
+
sdToken: formatUnits(chunkedRawLockersData[11].result, locker.sdToken.decimals),
|
|
10
|
+
staked:
|
|
11
|
+
locker.modules.gauge !== zeroAddress
|
|
12
|
+
? formatUnits(chunkedRawLockersData[12].result, locker.sdToken.decimals)
|
|
13
|
+
: '0',
|
|
14
|
+
working:
|
|
15
|
+
locker.chainId === mainnet.id && locker.modules.gauge !== zeroAddress
|
|
16
|
+
? formatUnits(chunkedRawLockersData[13].result, locker.sdToken.decimals)
|
|
17
|
+
: '0',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const voteBoosterBoost =
|
|
21
|
+
voteBoosterBalance && Number(voteBoosterBalance.working) > 0 && Number(voteBoosterBalance.staked) > 0
|
|
22
|
+
? Number(voteBoosterBalance.working) / (Number(voteBoosterBalance.staked) * 0.4)
|
|
23
|
+
: 1
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
booster: locker.voteBooster.booster,
|
|
27
|
+
vSdToken: locker.voteBooster.vSdToken,
|
|
28
|
+
balance: voteBoosterBalance,
|
|
29
|
+
boost: voteBoosterBoost,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { lockerWithId } from '@stake-dao/constants'
|
|
2
|
+
import type { Address } from 'viem'
|
|
2
3
|
|
|
3
|
-
const depositorCalls = (depositor: string, locker:
|
|
4
|
+
const depositorCalls = (depositor: string, locker: Address) => {
|
|
4
5
|
const calls: any[] = []
|
|
5
6
|
|
|
6
7
|
if (
|
|
7
8
|
[
|
|
8
|
-
lockerWithId('crv')!.
|
|
9
|
-
lockerWithId('mav')!.
|
|
10
|
-
lockerWithId('cake', 56)!.
|
|
11
|
-
lockerWithId('fxn')!.
|
|
12
|
-
lockerWithId('yfi')!.
|
|
9
|
+
lockerWithId('crv')!.modules.locker,
|
|
10
|
+
lockerWithId('mav')!.modules.locker,
|
|
11
|
+
lockerWithId('cake', 56)!.modules.locker,
|
|
12
|
+
lockerWithId('fxn')!.modules.locker,
|
|
13
|
+
lockerWithId('yfi')!.modules.locker,
|
|
13
14
|
].includes(locker)
|
|
14
15
|
) {
|
|
15
16
|
calls.push({ address: depositor, name: 'lockIncentivePercent' })
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { zeroAddress } from 'viem'
|
|
2
|
-
|
|
1
|
+
import { type Address, zeroAddress } from 'viem'
|
|
3
2
|
import { Zero } from '../../../index.js'
|
|
3
|
+
import type { Call } from '../../../utils.js'
|
|
4
4
|
|
|
5
|
-
export const feeCalls = (lockerId: string, accumulatorAddress:
|
|
6
|
-
const calls:
|
|
5
|
+
export const feeCalls = (lockerId: string, accumulatorAddress: Address) => {
|
|
6
|
+
const calls: Call[] = []
|
|
7
7
|
|
|
8
8
|
if (accumulatorAddress === zeroAddress || lockerId === 'mav') {
|
|
9
9
|
return calls
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// Harvester fees
|
|
13
|
-
calls.push({ address: accumulatorAddress, name: 'claimerFee'
|
|
13
|
+
calls.push({ address: accumulatorAddress, name: 'claimerFee' })
|
|
14
14
|
|
|
15
15
|
// Treasury
|
|
16
|
-
if (['
|
|
17
|
-
calls.push({ address: accumulatorAddress, name: 'daoFee'
|
|
16
|
+
if (['cake', 'yfi', 'pendle', 'fpis'].includes(lockerId)) {
|
|
17
|
+
calls.push({ address: accumulatorAddress, name: 'daoFee' })
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
switch (lockerId) {
|
|
21
21
|
case 'crv':
|
|
22
|
-
calls.push({ address: accumulatorAddress, name: '
|
|
22
|
+
calls.push({ address: accumulatorAddress, name: 'getFeeSplit' })
|
|
23
23
|
break
|
|
24
24
|
case 'cake':
|
|
25
25
|
case 'yfi':
|
|
26
|
-
calls.push({ address: accumulatorAddress, name: 'liquidityFee'
|
|
26
|
+
calls.push({ address: accumulatorAddress, name: 'liquidityFee' })
|
|
27
27
|
break
|
|
28
28
|
case 'pendle':
|
|
29
|
-
calls.push({ address: accumulatorAddress, name: 'bountyFee'
|
|
29
|
+
calls.push({ address: accumulatorAddress, name: 'bountyFee' })
|
|
30
30
|
break
|
|
31
31
|
case 'fpis':
|
|
32
|
-
calls.push({ address: accumulatorAddress, name: 'bribeFee'
|
|
32
|
+
calls.push({ address: accumulatorAddress, name: 'bribeFee' })
|
|
33
33
|
break
|
|
34
34
|
case 'apw':
|
|
35
35
|
case 'bpt':
|
|
36
|
-
calls.push({ address: accumulatorAddress, name: 'lockerFee'
|
|
36
|
+
calls.push({ address: accumulatorAddress, name: 'lockerFee' })
|
|
37
37
|
break
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -82,10 +82,12 @@ export const extractFees = (lockers: any, feesData: any): ILockerFee[] => {
|
|
|
82
82
|
let lockerFee = Zero
|
|
83
83
|
|
|
84
84
|
switch (locker.id) {
|
|
85
|
-
case 'crv':
|
|
86
|
-
|
|
87
|
-
daoFee = BigInt(
|
|
85
|
+
case 'crv': {
|
|
86
|
+
const crvFees = feesData.pop()?.result
|
|
87
|
+
daoFee = BigInt(crvFees.fees[0])
|
|
88
|
+
liquidityFee = BigInt(crvFees.fees[1])
|
|
88
89
|
break
|
|
90
|
+
}
|
|
89
91
|
case 'cake':
|
|
90
92
|
case 'yfi':
|
|
91
93
|
liquidityFee = BigInt(feesData.pop()?.result)
|