@stake-dao/reader 0.4.88 → 0.4.90
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/votemarket/batchCampaigns.js +3 -2
- package/dist/esm/bytecodes/votemarket/batchCampaigns.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockers/utils/callsForLockers/feeCalls.js +2 -2
- package/dist/esm/lockers/utils/callsForLockers/feeCalls.js.map +1 -1
- package/dist/esm/strategies/pancakeswap/fetch/getPancakeV3Vaults.js +4 -2
- package/dist/esm/strategies/pancakeswap/fetch/getPancakeV3Vaults.js.map +1 -1
- package/dist/esm/tokens.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/votemarket/fetchCampaigns/pendingRemote.js +1 -0
- package/dist/esm/votemarket/fetchCampaigns/pendingRemote.js.map +1 -1
- package/dist/esm/votemarket/fetchCampaigns/processRawCampaigns.js +1 -0
- package/dist/esm/votemarket/fetchCampaigns/processRawCampaigns.js.map +1 -1
- package/dist/esm/votemarket/fetchClaimableData.js +1 -1
- package/dist/esm/votemarket/fetchClaimableData.js.map +1 -1
- package/dist/types/bytecodes/votemarket/batchCampaigns.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/strategies/pancakeswap/fetch/getPancakeV3Vaults.d.ts.map +1 -1
- package/dist/types/votemarket/fetchCampaigns/pendingRemote.d.ts +1 -0
- package/dist/types/votemarket/fetchCampaigns/pendingRemote.d.ts.map +1 -1
- package/dist/types/votemarket/fetchCampaigns/processRawCampaigns.d.ts.map +1 -1
- package/dist/types/votemarket/types.d.ts +1 -0
- package/dist/types/votemarket/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/bytecodes/votemarket/batchCampaigns.ts +3 -2
- package/src/index.ts +3 -0
- package/src/lockers/utils/callsForLockers/feeCalls.ts +2 -2
- package/src/strategies/pancakeswap/fetch/getPancakeV3Vaults.ts +27 -25
- package/src/tokens.ts +1 -1
- package/src/votemarket/fetchCampaigns/pendingRemote.ts +1 -0
- package/src/votemarket/fetchCampaigns/processRawCampaigns.ts +3 -2
- package/src/votemarket/fetchClaimableData.ts +1 -1
- package/src/votemarket/types.ts +1 -0
- package/dist/esm/strategies/pancakeswap/fetch/getPancakeNotDeployed.js +0 -102
- package/dist/esm/strategies/pancakeswap/fetch/getPancakeNotDeployed.js.map +0 -1
- package/dist/types/strategies/pancakeswap/fetch/getPancakeNotDeployed.d.ts +0 -3
- package/dist/types/strategies/pancakeswap/fetch/getPancakeNotDeployed.d.ts.map +0 -1
- package/src/strategies/pancakeswap/fetch/getPancakeNotDeployed.ts +0 -132
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { ONE_YEAR, STRAT_FEES, contracts, tokenWithId } from '@stake-dao/constants'
|
|
2
|
-
import { decodeAbiParameters, encodeAbiParameters, formatUnits, parseAbiParameters, zeroAddress } from 'viem'
|
|
3
|
-
|
|
4
|
-
import { range } from 'lodash-es'
|
|
5
|
-
import { buildPancakeswapNotDeployedErc20Strats } from '../../../bytecodes/index.js'
|
|
6
|
-
import { bytes32ToString, concatBytecode } from '../../../index.js'
|
|
7
|
-
import { type Price, mergePrices } from '../../../prices.js'
|
|
8
|
-
import { batchJsonRpc, equalTlc, rpcCall } from '../../../utils.js'
|
|
9
|
-
import { PCS_POOLS_NOT_DEPLOYED_CHUNK_SIZE } from '../config.js'
|
|
10
|
-
|
|
11
|
-
export const getPancakeNotDeployed = async (
|
|
12
|
-
rpc: string,
|
|
13
|
-
chainId: number,
|
|
14
|
-
basePrices: Price[],
|
|
15
|
-
feesApr: any,
|
|
16
|
-
managerFees: any,
|
|
17
|
-
deployedLp: string[],
|
|
18
|
-
) => {
|
|
19
|
-
const poolLengthRequest = await rpcCall(rpc, [{ to: contracts.pancakeFarmBooster![chainId]!, data: '0x081e3eda' }]) // poolLength()
|
|
20
|
-
const poolLength =
|
|
21
|
-
Number(decodeAbiParameters([{ type: 'uint256', name: 'n_gauges' }], poolLengthRequest[0].result)) + 1
|
|
22
|
-
|
|
23
|
-
const notDeployedCalls = range(1, poolLength, PCS_POOLS_NOT_DEPLOYED_CHUNK_SIZE).map((skip) => {
|
|
24
|
-
const inputParams = [
|
|
25
|
-
contracts.pancakeFarmBooster![chainId],
|
|
26
|
-
skip,
|
|
27
|
-
skip + PCS_POOLS_NOT_DEPLOYED_CHUNK_SIZE > poolLength ? poolLength : skip + PCS_POOLS_NOT_DEPLOYED_CHUNK_SIZE,
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
const inputData = encodeAbiParameters(
|
|
31
|
-
parseAbiParameters(buildPancakeswapNotDeployedErc20Strats.inputType[chainId]!) as any,
|
|
32
|
-
inputParams,
|
|
33
|
-
)
|
|
34
|
-
return concatBytecode(buildPancakeswapNotDeployedErc20Strats.bytecode[chainId]!, inputData)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const notDeployedData = await batchJsonRpc({
|
|
38
|
-
rpc,
|
|
39
|
-
calls: notDeployedCalls,
|
|
40
|
-
outputTypeAbi: buildPancakeswapNotDeployedErc20Strats.outputTypeHr[chainId],
|
|
41
|
-
callsKey: `strategies/pancakeswap/fetch/getPancakeNotDeployed.ts: notDeployedData - chainId ${chainId} - rpc ${rpc}`,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const pricesToFetch = notDeployedData
|
|
45
|
-
.flatMap((d) => {
|
|
46
|
-
if (d.lpToken._address === zeroAddress || deployedLp.includes(d.lpToken._address)) return undefined
|
|
47
|
-
|
|
48
|
-
return d.coins.map((c) => {
|
|
49
|
-
const coinPrice = basePrices.find((bp) => equalTlc(bp.address, c._address))?.usdPrice || 0
|
|
50
|
-
return coinPrice === 0 ? { address: c._address, symbol: bytes32ToString(c._symbol) } : undefined
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
.filter(Boolean)
|
|
54
|
-
const prices = await mergePrices(basePrices, pricesToFetch, chainId)
|
|
55
|
-
|
|
56
|
-
const cake = tokenWithId('cake', chainId)!
|
|
57
|
-
const cakeReward = { name: cake.name, symbol: cake.symbol, address: cake.address, decimals: cake.decimals }
|
|
58
|
-
const cakePriceUsd = prices.find((p) => equalTlc(p.address, cake.address))?.usdPrice || 0
|
|
59
|
-
|
|
60
|
-
// TODO type
|
|
61
|
-
const notDeployed: any[] = notDeployedData
|
|
62
|
-
.map((d) => {
|
|
63
|
-
if (d.lpToken._address === zeroAddress || deployedLp.includes(d.lpToken._address)) return undefined
|
|
64
|
-
|
|
65
|
-
const coins = d.coins.map((c) => ({
|
|
66
|
-
name: bytes32ToString(c._name),
|
|
67
|
-
symbol: bytes32ToString(c._symbol),
|
|
68
|
-
address: c._address,
|
|
69
|
-
decimals: Number(c._decimals),
|
|
70
|
-
}))
|
|
71
|
-
|
|
72
|
-
const lpName = bytes32ToString(d.lpToken._name)
|
|
73
|
-
const isStable = lpName.includes('StableSwap')
|
|
74
|
-
const isMetapool = coins.some((c) => c.name.includes(' LPs'))
|
|
75
|
-
const lpSymbol = `${coins.map((c) => c.symbol).join('-')} ${isStable ? 'Stable LP' : 'LP'}`
|
|
76
|
-
|
|
77
|
-
const lpToken = {
|
|
78
|
-
name: lpName,
|
|
79
|
-
symbol: lpSymbol,
|
|
80
|
-
address: d.lpToken._address,
|
|
81
|
-
decimals: Number(d.lpToken._decimals),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const token0PriceInUsd = prices.find((p) => equalTlc(p.address, coins[0]!.address))?.usdPrice || 0
|
|
85
|
-
const token1PriceInUsd = prices.find((p) => equalTlc(p.address, coins[1]!.address))?.usdPrice || 0
|
|
86
|
-
|
|
87
|
-
const lpPriceInUsd =
|
|
88
|
-
Number(formatUnits(d.token0PerShare, coins[0].decimals)) * token0PriceInUsd +
|
|
89
|
-
Number(formatUnits(d.token1PerShare, coins[1].decimals)) * token1PriceInUsd
|
|
90
|
-
|
|
91
|
-
const tvl = lpPriceInUsd * Number(formatUnits(d.sharesTotalSupply, 18))
|
|
92
|
-
|
|
93
|
-
let tradingApy = Number(feesApr[lpToken.address.toLowerCase()]?.apr7d || 0)
|
|
94
|
-
if (!tradingApy && managerFees[d.pool.toLowerCase()]) {
|
|
95
|
-
const feesData = managerFees[d.pool.toLowerCase()]
|
|
96
|
-
tradingApy = feesData
|
|
97
|
-
? ((Number(formatUnits(feesData.token0, coins[0].decimals)) * token0PriceInUsd +
|
|
98
|
-
Number(formatUnits(feesData.token1, coins[1].decimals)) * token1PriceInUsd) /
|
|
99
|
-
tvl) *
|
|
100
|
-
365 *
|
|
101
|
-
100
|
|
102
|
-
: 0
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const boost = d.manager === 'pancakeswap' ? 2.5 : 3 // Pancake max boost is 2.5, managers farm is 3
|
|
106
|
-
|
|
107
|
-
const rewardPerYear = cakePriceUsd * Number(formatUnits(d.rewardPerSecond, 18)) * ONE_YEAR
|
|
108
|
-
const stakedTvl = lpPriceInUsd * Number(formatUnits(d.stakedInGauge, 18))
|
|
109
|
-
|
|
110
|
-
const minApr = (rewardPerYear / (stakedTvl > 0 ? stakedTvl : tvl)) * ((100 - STRAT_FEES + 0.5) / 100)
|
|
111
|
-
const maxApr = minApr * boost
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
key: `${d.manager.toLowerCase()}-${coins.map((c) => c.symbol.toLowerCase()).join('-')}`,
|
|
115
|
-
protocol: 'pancakeswap',
|
|
116
|
-
chainId,
|
|
117
|
-
isMetapool,
|
|
118
|
-
isStable,
|
|
119
|
-
manager: d.manager,
|
|
120
|
-
pool: d.pool,
|
|
121
|
-
gaugeAddress: d.gagaugeAddressuge,
|
|
122
|
-
lpToken,
|
|
123
|
-
coins,
|
|
124
|
-
minApr,
|
|
125
|
-
maxApr,
|
|
126
|
-
rewards: [cakeReward],
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
.filter(Boolean)
|
|
130
|
-
|
|
131
|
-
return notDeployed
|
|
132
|
-
}
|