@stake-dao/reader 0.2.4 → 0.2.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getPancakeV3Vaults.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/pancakeswap/fetch/getPancakeV3Vaults.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAK3D,eAAO,MAAM,kBAAkB,QACxB,MAAM,WACF,MAAM,cACH,KAAK,EAAE,WACV,GAAG,cACA,GAAG;;;EA0KhB,CAAA"}
1
+ {"version":3,"file":"getPancakeV3Vaults.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/pancakeswap/fetch/getPancakeV3Vaults.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAK3D,eAAO,MAAM,kBAAkB,QACxB,MAAM,WACF,MAAM,cACH,KAAK,EAAE,WACV,GAAG,cACA,GAAG;;;EAsLhB,CAAA"}
@@ -1,11 +1,15 @@
1
- export declare const computePositionData: (s: any, p: any, stratParsedData: any, fees24H: number, prices: any[], token0PriceInUsd: number, token1PriceInUsd: number, totalAllocPoint: string, inflationRate: string) => {
1
+ type StratParsedData = {
2
+ allocPoint: number;
3
+ tick: number;
4
+ sqrtPriceX96: string;
5
+ totalLiquidity: string;
6
+ totalBoostLiquidity: string;
7
+ poolLiquidity: string;
8
+ };
9
+ export declare const computePositionData: (s: any, p: any, stratParsedData: StratParsedData, fees24H: number, prices: any[], token0PriceInUsd: number, token1PriceInUsd: number, totalAllocPoint: string, inflationRate: string) => {
2
10
  positionData: any;
3
11
  boost: number;
4
12
  tvlToAdd: number;
5
13
  };
6
- export declare const getPositionData: (chainId: number, tokenId: number, tickLower: number, tickUpper: number, user: string, strat: any, prices: any[], provider: any) => Promise<{
7
- tokenIdPositionData: any;
8
- tvlToAdd: number;
9
- boost: number;
10
- }>;
14
+ export {};
11
15
  //# sourceMappingURL=pancakePositions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pancakePositions.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/pancakeswap/fetch/pancakePositions.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mBAAmB,MAC3B,GAAG,KACH,GAAG,mBACW,GAAG,WACX,MAAM,UACP,GAAG,EAAE,oBACK,MAAM,oBACN,MAAM,mBACP,MAAM,iBACR,MAAM;;;;CA2EtB,CAAA;AAED,eAAO,MAAM,eAAe,YACjB,MAAM,WACN,MAAM,aACJ,MAAM,aACN,MAAM,QACX,MAAM,SACL,GAAG,UACF,GAAG,EAAE,YACH,GAAG;;;;EAuCd,CAAA"}
1
+ {"version":3,"file":"pancakePositions.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/pancakeswap/fetch/pancakePositions.ts"],"names":[],"mappings":"AAWA,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,mBAAmB,MAC3B,GAAG,KACH,GAAG,mBACW,eAAe,WACvB,MAAM,UACP,GAAG,EAAE,oBACK,MAAM,oBACN,MAAM,mBACP,MAAM,iBACR,MAAM;;;;CA2EtB,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stake-dao/reader",
3
3
  "description": "",
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",
@@ -33,7 +33,7 @@ export const lendingStartIndex = {
33
33
  }
34
34
 
35
35
  export const CHUNK_SIZE = 30
36
- export const GAUGES_CHUNK_SIZE = { 1: 60, 42161: 40 }
36
+ export const GAUGES_CHUNK_SIZE = { 1: 60, 42161: 30 }
37
37
  export const TOKENS_CHUNK_SIZE = 100
38
38
  export const GAUGES_WEIGHTS_CHUNK_SIZE = 100
39
39
  export const GAUGES_REGISTRY_CHUNK_SIZE = 30
@@ -90,11 +90,11 @@ export const getPancakeV3Vaults = async (
90
90
  const stratParsedData = {
91
91
  poolId: Number(stratData.id),
92
92
  allocPoint: Number(stratData.allocPoint),
93
- tick: stratData.tick,
94
- sqrtPriceX96: stratData.sqrtPriceX96.toString(),
95
- totalLiquidity: stratData.totalLiquidity.toString(),
96
- totalBoostLiquidity: stratData.totalBoostLiquidity.toString(),
97
- poolLiquidity: stratData.poolLiquidity.toString(),
93
+ tick: Number(stratData.tick),
94
+ sqrtPriceX96: formatUnits(stratData.sqrtPriceX96, 0),
95
+ totalLiquidity: formatUnits(stratData.totalLiquidity, 0),
96
+ totalBoostLiquidity: formatUnits(stratData.totalBoostLiquidity, 0),
97
+ poolLiquidity: formatUnits(stratData.poolLiquidity, 0),
98
98
  }
99
99
 
100
100
  const strat = pools.find((p) => p.poolId === stratParsedData.poolId)
@@ -111,7 +111,14 @@ export const getPancakeV3Vaults = async (
111
111
  const computedPositionData = computePositionData(
112
112
  strat,
113
113
  p,
114
- stratParsedData,
114
+ {
115
+ allocPoint: stratParsedData.allocPoint,
116
+ tick: stratParsedData.tick,
117
+ sqrtPriceX96: stratParsedData.sqrtPriceX96,
118
+ totalLiquidity: stratParsedData.totalLiquidity,
119
+ totalBoostLiquidity: stratParsedData.totalBoostLiquidity,
120
+ poolLiquidity: stratParsedData.poolLiquidity,
121
+ },
115
122
  fees24H,
116
123
  prices,
117
124
  token0PriceInUsd,
@@ -179,9 +186,14 @@ export const getPancakeV3Vaults = async (
179
186
  minApr: farmApr,
180
187
  maxApr: farmApr * 2,
181
188
  // Raw data
182
- tick: Number(stratParsedData.tick),
183
- sqrtPriceX96: stratParsedData.sqrtPriceX96.toString(),
184
189
  allocPoint: stratParsedData.allocPoint,
190
+ tick: stratParsedData.tick,
191
+ sqrtPriceX96: stratParsedData.sqrtPriceX96,
192
+ totalLiquidity: stratParsedData.totalLiquidity,
193
+ totalBoostLiquidity: stratParsedData.totalBoostLiquidity,
194
+ poolLiquidity: stratParsedData.poolLiquidity,
195
+ totalAllocPoint: global.totalAllocPoint,
196
+ inflationRate: global.inflationRate,
185
197
  }
186
198
 
187
199
  stratsData = stratsData.concat(parsedData)
@@ -1,8 +1,6 @@
1
1
  import { formatUnits } from 'viem'
2
2
 
3
- import pancakeMasterchefAbi from '../abis/PancakeSwapMasterchef.json'
4
-
5
- import { contracts, tokenWithId } from '@stake-dao/constants'
3
+ import { tokenWithId } from '@stake-dao/constants'
6
4
  import {
7
5
  getPositionFarmApr,
8
6
  getPositionTradingFee,
@@ -11,10 +9,19 @@ import {
11
9
  tickToPrice,
12
10
  } from './pancakeswapMath.js'
13
11
 
12
+ type StratParsedData = {
13
+ allocPoint: number
14
+ tick: number
15
+ sqrtPriceX96: string
16
+ totalLiquidity: string
17
+ totalBoostLiquidity: string
18
+ poolLiquidity: string
19
+ }
20
+
14
21
  export const computePositionData = (
15
22
  s: any,
16
23
  p: any,
17
- stratParsedData: any,
24
+ stratParsedData: StratParsedData,
18
25
  fees24H: number,
19
26
  prices: any[],
20
27
  token0PriceInUsd: number,
@@ -25,11 +32,11 @@ export const computePositionData = (
25
32
  const bnSqrtPriceX96 = BigInt(stratParsedData.sqrtPriceX96)
26
33
 
27
34
  const token0Amount = formatUnits(
28
- getToken0Amount(Number(stratParsedData.tick), p.tickLower, p.tickUpper, bnSqrtPriceX96, p.liquidity),
35
+ getToken0Amount(stratParsedData.tick, p.tickLower, p.tickUpper, bnSqrtPriceX96, p.liquidity),
29
36
  s.coins[0].decimals,
30
37
  )
31
38
  const token1Amount = formatUnits(
32
- getToken1Amount(Number(stratParsedData.tick), p.tickLower, p.tickUpper, bnSqrtPriceX96, p.liquidity),
39
+ getToken1Amount(stratParsedData.tick, p.tickLower, p.tickUpper, bnSqrtPriceX96, p.liquidity),
33
40
  s.coins[1].decimals,
34
41
  )
35
42
 
@@ -96,52 +103,3 @@ export const computePositionData = (
96
103
  tvlToAdd,
97
104
  }
98
105
  }
99
-
100
- export const getPositionData = async (
101
- chainId: number,
102
- tokenId: number,
103
- tickLower: number,
104
- tickUpper: number,
105
- user: string,
106
- strat: any,
107
- prices: any[],
108
- provider: any,
109
- ) => {
110
- const positionData = await provider.readContract({
111
- address: contracts.pancakeMasterchef![chainId],
112
- abi: pancakeMasterchefAbi,
113
- functionName: 'userPositionInfos',
114
- args: [tokenId],
115
- })
116
-
117
- const p = {
118
- tokenId,
119
- liquidity: positionData[0],
120
- boostLiquidity: positionData[1],
121
- tickLower,
122
- tickUpper,
123
- rewardGrowthInside: positionData[4],
124
- reward: positionData[5],
125
- owner: user,
126
- pid: positionData[7],
127
- boostMultiplier: positionData[8],
128
- }
129
-
130
- const {
131
- positionData: tokenIdPositionData,
132
- tvlToAdd,
133
- boost,
134
- } = computePositionData(
135
- strat,
136
- p,
137
- strat.stratsData,
138
- strat.stratsData.fees24H,
139
- prices,
140
- strat.token0PriceInUsd,
141
- strat.token1PriceInUsd,
142
- strat.stratsData.totalAllocPoint || strat.stratsData.allocPoints,
143
- strat.stratsData.inflationRate,
144
- )
145
-
146
- return { tokenIdPositionData, tvlToAdd, boost }
147
- }