@stake-dao/reader 0.4.97 → 0.4.99
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/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/number.js +64 -16
- package/dist/esm/number.js.map +1 -1
- package/dist/esm/strategies/angle/fetch.js +2 -0
- package/dist/esm/strategies/angle/fetch.js.map +1 -1
- package/dist/esm/strategies/balancer/fetch.js +2 -0
- package/dist/esm/strategies/balancer/fetch.js.map +1 -1
- package/dist/esm/strategies/curve/fetch/getOnlyboostData.js +6 -0
- package/dist/esm/strategies/curve/fetch/getOnlyboostData.js.map +1 -1
- package/dist/esm/strategies/curve/fetch/index.js +7 -10
- package/dist/esm/strategies/curve/fetch/index.js.map +1 -1
- package/dist/esm/strategies/curve/httpCalls.js +31 -35
- package/dist/esm/strategies/curve/httpCalls.js.map +1 -1
- package/dist/esm/strategies/passive/fetch.js +2 -0
- package/dist/esm/strategies/passive/fetch.js.map +1 -1
- package/dist/esm/strategies/pendle/fetch.js +2 -0
- package/dist/esm/strategies/pendle/fetch.js.map +1 -1
- package/dist/esm/strategies/utils/getTokenTypes.js +30 -0
- package/dist/esm/strategies/utils/getTokenTypes.js.map +1 -0
- package/dist/esm/strategies/v2/parse.js +176 -0
- package/dist/esm/strategies/v2/parse.js.map +1 -0
- package/dist/esm/strategies/yearn/fetch/index.js +2 -0
- package/dist/esm/strategies/yearn/fetch/index.js.map +1 -1
- package/dist/esm/votemarket/curve/fetchSnapshotUserData.js +2 -0
- package/dist/esm/votemarket/curve/fetchSnapshotUserData.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/number.d.ts +17 -2
- package/dist/types/number.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/fetch/getOnlyboostData.d.ts.map +1 -1
- package/dist/types/strategies/curve/fetch/index.d.ts +1 -2
- package/dist/types/strategies/curve/fetch/index.d.ts.map +1 -1
- package/dist/types/strategies/curve/httpCalls.d.ts +2 -2
- package/dist/types/strategies/curve/httpCalls.d.ts.map +1 -1
- package/dist/types/strategies/passive/fetch.d.ts +3 -0
- package/dist/types/strategies/passive/fetch.d.ts.map +1 -1
- package/dist/types/strategies/pendle/fetch.d.ts +1 -0
- package/dist/types/strategies/pendle/fetch.d.ts.map +1 -1
- package/dist/types/strategies/types.d.ts +2 -0
- package/dist/types/strategies/types.d.ts.map +1 -1
- package/dist/types/strategies/utils/getTokenTypes.d.ts +3 -0
- package/dist/types/strategies/utils/getTokenTypes.d.ts.map +1 -0
- package/dist/types/strategies/v2/parse.d.ts +52 -0
- package/dist/types/strategies/v2/parse.d.ts.map +1 -0
- package/dist/types/strategies/yearn/fetch/index.d.ts.map +1 -1
- package/dist/types/votemarket/curve/fetchSnapshotUserData.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/number.ts +77 -19
- package/src/strategies/angle/fetch.ts +2 -0
- package/src/strategies/balancer/fetch.ts +2 -0
- package/src/strategies/curve/fetch/getOnlyboostData.ts +7 -0
- package/src/strategies/curve/fetch/index.ts +6 -15
- package/src/strategies/curve/httpCalls.ts +31 -48
- package/src/strategies/passive/fetch.ts +2 -0
- package/src/strategies/pendle/fetch.ts +2 -0
- package/src/strategies/types.ts +2 -0
- package/src/strategies/utils/getTokenTypes.ts +35 -0
- package/src/strategies/v2/parse.ts +199 -0
- package/src/strategies/yearn/fetch/index.ts +2 -0
- package/src/votemarket/curve/fetchSnapshotUserData.ts +2 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const parseV2Strats: (global: any, rawStrats: any[], extra: any) => {
|
|
2
|
+
key: any;
|
|
3
|
+
tokensFilter: string[];
|
|
4
|
+
isLending: any;
|
|
5
|
+
name: any;
|
|
6
|
+
type: string;
|
|
7
|
+
version: number;
|
|
8
|
+
protocol: string;
|
|
9
|
+
chainId: any;
|
|
10
|
+
vault: any;
|
|
11
|
+
lpToken: {
|
|
12
|
+
id: any;
|
|
13
|
+
name: any;
|
|
14
|
+
symbol: any;
|
|
15
|
+
address: any;
|
|
16
|
+
decimals: any;
|
|
17
|
+
};
|
|
18
|
+
gaugeAddress: any;
|
|
19
|
+
gauge: {
|
|
20
|
+
address: any;
|
|
21
|
+
totalSupply: any;
|
|
22
|
+
totalSupplyUsd: any;
|
|
23
|
+
extraRewards: never[];
|
|
24
|
+
};
|
|
25
|
+
coins: any;
|
|
26
|
+
underlyingCoins: never[];
|
|
27
|
+
lpPriceInUsd: number;
|
|
28
|
+
streaming: boolean;
|
|
29
|
+
tvl: number;
|
|
30
|
+
apr: {
|
|
31
|
+
boost: number;
|
|
32
|
+
current: {
|
|
33
|
+
total: number;
|
|
34
|
+
details: {
|
|
35
|
+
label: string;
|
|
36
|
+
value: number[];
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
rewards: any;
|
|
41
|
+
tradingApy: number;
|
|
42
|
+
minApr: number;
|
|
43
|
+
maxApr: any;
|
|
44
|
+
totalSupply: any;
|
|
45
|
+
workingBalance: any;
|
|
46
|
+
onlyboost: import("../types.js").OnlyBoostData;
|
|
47
|
+
convexPool: {
|
|
48
|
+
id: number;
|
|
49
|
+
crvRewards: any;
|
|
50
|
+
} | undefined;
|
|
51
|
+
}[];
|
|
52
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/strategies/v2/parse.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,aAAa,WAAY,GAAG,aAAa,GAAG,EAAE,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiKtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/yearn/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAuB,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/strategies/yearn/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAuB,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAkCrF,UAAU,WAAW;IACnB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,GAAG,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,UAAU,wDAMpB,WAAW,KAAG,OAAO,CAAC,YAAY,CAmMpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSnapshotUserData.d.ts","sourceRoot":"","sources":["../../../../src/votemarket/curve/fetchSnapshotUserData.ts"],"names":[],"mappings":"AAMA,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE;QACL,UAAU,EAAE,gBAAgB,EAAE,CAAA;KAC/B,CAAA;CACF;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,cAAc,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAC7E;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,GAAG,CAAA;CACZ;AAyDD,eAAO,MAAM,wBAAwB,eAAgB,MAAM,KAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"fetchSnapshotUserData.d.ts","sourceRoot":"","sources":["../../../../src/votemarket/curve/fetchSnapshotUserData.ts"],"names":[],"mappings":"AAMA,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE;QACL,UAAU,EAAE,gBAAgB,EAAE,CAAA;KAC/B,CAAA;CACF;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,cAAc,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAC7E;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,GAAG,CAAA;CACZ;AAyDD,eAAO,MAAM,wBAAwB,eAAgB,MAAM,KAAG,MAAM,GAAG,SAatE,CAAA;AAED,eAAO,MAAM,qBAAqB,gBACnB,MAAM,UACX,MAAM,EAAE,gBACF,GAAG,KAChB,OAAO,CAAC,iBAAiB,EAAE,GAAG,SAAS,CA+DzC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stake-dao/reader",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.99",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"graphql-request": "^6.0.0",
|
|
36
36
|
"lodash-es": "^4.17.21",
|
|
37
37
|
"viem": "2.35.0",
|
|
38
|
-
"@stake-dao/constants": "0.4.
|
|
38
|
+
"@stake-dao/constants": "0.4.51"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "pnpm run clean && pnpm run build:esm+types",
|
|
51
51
|
"build:esm+types": "tsc --project tsconfig.build.json --outDir ./dist/esm --declaration --declarationMap --declarationDir ./dist/types",
|
|
52
|
-
"clean": "
|
|
52
|
+
"clean": "pnpm exec rimraf dist",
|
|
53
53
|
"test:build": "publint --strict",
|
|
54
54
|
"typecheck": "tsc --noEmit"
|
|
55
55
|
}
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export { parsePeg } from './lockers/fetch/parsePeg.js'
|
|
|
26
26
|
/// --- STATEGIES
|
|
27
27
|
|
|
28
28
|
export * from './strategies/utils/index.js'
|
|
29
|
+
export { parseV2Strats } from './strategies/v2/parse.js'
|
|
29
30
|
|
|
30
31
|
// Curve
|
|
31
32
|
export { buildCurveStrategies } from './strategies/curve/build.js'
|
package/src/number.ts
CHANGED
|
@@ -1,51 +1,109 @@
|
|
|
1
1
|
import { formatUnits } from 'viem'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const USD_PROPS = {
|
|
4
|
+
minimumFractionDigits: 2,
|
|
5
|
+
maximumFractionDigits: 2,
|
|
6
|
+
notation: 'compact',
|
|
7
|
+
compactDisplay: 'short',
|
|
8
|
+
} as any
|
|
9
|
+
|
|
10
|
+
export const getString = (data, nbDecimals = 2) => {
|
|
4
11
|
if (typeof data === 'string') {
|
|
5
12
|
return data
|
|
6
13
|
}
|
|
7
14
|
return data ? Number(data).toFixed(nbDecimals) : 0
|
|
8
15
|
}
|
|
9
16
|
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
export const getApr = (data) => `${getString(data, 2)}%`
|
|
18
|
+
|
|
19
|
+
export const getFixedNumber = (amount: string | number, reduce = false) => {
|
|
20
|
+
const earningsNumber = reduce ? formatUnits(BigInt(amount), 18) : `${amount}`
|
|
21
|
+
const nbEarningsNumber = Number(earningsNumber) > 0 ? Number(earningsNumber) : Number(earningsNumber) * -1
|
|
22
|
+
|
|
23
|
+
if (nbEarningsNumber > 0 && nbEarningsNumber < 1) {
|
|
24
|
+
const indexNotZero = earningsNumber.match('[1-9]')
|
|
14
25
|
return indexNotZero?.index ? indexNotZero.index - 2 + 4 : 4
|
|
15
26
|
}
|
|
16
|
-
if (
|
|
17
|
-
return 2
|
|
18
|
-
}
|
|
19
|
-
if (earningsNumber >= 100 && earningsNumber < 1000) {
|
|
27
|
+
if (nbEarningsNumber >= 1 && nbEarningsNumber < 1000) {
|
|
20
28
|
return 2
|
|
21
29
|
}
|
|
22
30
|
return 0
|
|
23
31
|
}
|
|
24
32
|
|
|
33
|
+
export const getSubNumber = (nb: string, decimals?: number) => {
|
|
34
|
+
const numberNb = Number(nb)
|
|
35
|
+
|
|
36
|
+
if (numberNb > 0 && numberNb < 1) {
|
|
37
|
+
const indexNotZero = nb.match('[1-9]')
|
|
38
|
+
const indexNotZeroIndex = indexNotZero?.index || 2
|
|
39
|
+
const nbWithoutZero = nb.replace(`0.${new Array(indexNotZeroIndex - 2).fill(0).join('')}`, '')
|
|
40
|
+
return indexNotZeroIndex - 2 > 2
|
|
41
|
+
? {
|
|
42
|
+
prefix: '0.0',
|
|
43
|
+
sub: indexNotZeroIndex - 2,
|
|
44
|
+
suffix: nbWithoutZero.slice(0, 2),
|
|
45
|
+
decimals: 1,
|
|
46
|
+
}
|
|
47
|
+
: { prefix: nb, decimals: 3 }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const fixedTo = decimals ? decimals : getFixedNumber(nb)
|
|
51
|
+
return { prefix: nb, decimals: fixedTo }
|
|
52
|
+
}
|
|
53
|
+
|
|
25
54
|
export const fixed = (nb: string, decimals?: number) => {
|
|
26
55
|
const fixedTo = decimals ? decimals : getFixedNumber(nb)
|
|
27
|
-
|
|
56
|
+
const fixed = Number(nb).toLocaleString('en-US', {
|
|
28
57
|
minimumFractionDigits: fixedTo,
|
|
29
58
|
maximumFractionDigits: fixedTo,
|
|
30
59
|
})
|
|
60
|
+
|
|
61
|
+
// Remove trailing zeros after the decimal point
|
|
62
|
+
// Remove trailing decimal point if there is no fractional part
|
|
63
|
+
return fixed.replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '')
|
|
31
64
|
}
|
|
32
65
|
|
|
33
|
-
export const
|
|
34
|
-
const
|
|
66
|
+
export const fixedNb = (nb: number, decimals?: number) => {
|
|
67
|
+
const fixedTo = decimals ? decimals : getFixedNumber(nb)
|
|
68
|
+
return nb.toLocaleString('en-US', {
|
|
69
|
+
minimumFractionDigits: fixedTo,
|
|
70
|
+
maximumFractionDigits: fixedTo,
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const reducedNb = (number, addNegative?: boolean) => {
|
|
75
|
+
let isNegative = false
|
|
76
|
+
|
|
77
|
+
if (typeof number === 'string') number = Number(number)
|
|
78
|
+
if (number < 0) {
|
|
79
|
+
number *= -1
|
|
80
|
+
isNegative = true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let res = fixed(number.toString())
|
|
84
|
+
if (number > 1000) res = number.toLocaleString('en-US', USD_PROPS)
|
|
85
|
+
|
|
86
|
+
return `${isNegative && addNegative ? '-' : ''}${res}`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const formatUsd = (number) => {
|
|
90
|
+
if (typeof number === 'string') {
|
|
91
|
+
number = Number(number)
|
|
92
|
+
}
|
|
35
93
|
|
|
36
|
-
if (
|
|
37
|
-
return `${getString(
|
|
94
|
+
if (number > 1000000000) {
|
|
95
|
+
return `${getString(number / 1000000000, 2)}B`
|
|
38
96
|
}
|
|
39
|
-
if (
|
|
40
|
-
return `${getString(
|
|
97
|
+
if (number > 1000000) {
|
|
98
|
+
return `${getString(number / 1000000, 2)}M`
|
|
41
99
|
}
|
|
42
|
-
if (
|
|
43
|
-
return `${getString(
|
|
100
|
+
if (number > 1000) {
|
|
101
|
+
return `${getString(number / 1000, 2)}k`
|
|
44
102
|
}
|
|
45
103
|
|
|
46
104
|
return fixed(number.toString())
|
|
47
105
|
}
|
|
48
106
|
|
|
49
107
|
export const withTwoDec = (num: number) => {
|
|
50
|
-
return (
|
|
108
|
+
return fixedNb(num, 2)
|
|
51
109
|
}
|
|
@@ -8,6 +8,7 @@ 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 getTokenTypes from '../utils/getTokenTypes.js'
|
|
11
12
|
import { ANGLE_APR_URL, ANGLE_PRICE_URL } from './endpoints.js'
|
|
12
13
|
|
|
13
14
|
interface TFetchAngle {
|
|
@@ -206,6 +207,7 @@ export const fetchAngle = async ({ prices, provider, rpc, chainId }: TFetchAngle
|
|
|
206
207
|
return {
|
|
207
208
|
key: s.key,
|
|
208
209
|
name: s.name,
|
|
210
|
+
tokensFilter: getTokenTypes(s),
|
|
209
211
|
protocol: s.protocol,
|
|
210
212
|
chainId: s.chainId,
|
|
211
213
|
vault: s.vault,
|
|
@@ -20,6 +20,7 @@ import { FACTORY_EVENT_TOPIC } from '../curve/endpoints.js'
|
|
|
20
20
|
import type { BalancerGlobalData, RewardsData, Strategy, StrategyData, ValidChainId } from '../types.js'
|
|
21
21
|
import decodeEtherscanFactoryEvent from '../utils/decodeEtherscanFactoryEvent.js'
|
|
22
22
|
import { getAprBreakdown } from '../utils/getAprBreakdown.js'
|
|
23
|
+
import getTokenTypes from '../utils/getTokenTypes.js'
|
|
23
24
|
import { buildBalancerStrategies } from './build.js'
|
|
24
25
|
import { BALANCER_POOLS_DATA_QUERY, BALANCER_SUBGRAPH_URL } from './endpoints.js'
|
|
25
26
|
|
|
@@ -230,6 +231,7 @@ export const fetchBalancer = async ({
|
|
|
230
231
|
return {
|
|
231
232
|
key: strat.key,
|
|
232
233
|
name: coins.reduce((res: string, current) => `${res}/${current.symbol}`, '').slice(1),
|
|
234
|
+
tokensFilter: getTokenTypes(strat),
|
|
233
235
|
protocol: strat.protocol,
|
|
234
236
|
chainId: strat.chainId,
|
|
235
237
|
vault: strat.vault,
|
|
@@ -44,6 +44,9 @@ const getOnlyboostData = (
|
|
|
44
44
|
const stakeDaoOptSupply = formatUnits(data.stakeDaoOptSupply, 0)
|
|
45
45
|
const convexOptSupply = formatUnits(data.convexOptSupply, 0)
|
|
46
46
|
|
|
47
|
+
const stakeDaoOptTvl = Number(formatUnits(data.stakeDaoOptSupply, 18)) * lpPriceInUsd
|
|
48
|
+
const convexOptTvl = Number(formatUnits(data.convexOptSupply, 18)) * lpPriceInUsd
|
|
49
|
+
|
|
47
50
|
const stakeDaoOptShare = Number(stakeDaoOptSupply) / Number(totalSupply)
|
|
48
51
|
const convexOptShare = Number(convexOptSupply) / Number(totalSupply)
|
|
49
52
|
|
|
@@ -82,9 +85,11 @@ const getOnlyboostData = (
|
|
|
82
85
|
tvl: stakeDaoTvl,
|
|
83
86
|
supply: stakeDaoSupply,
|
|
84
87
|
boost: stakeDaoBoost,
|
|
88
|
+
share: stakeDaoShare,
|
|
85
89
|
workingBalance: stakeDaoWorkingBalanceShare,
|
|
86
90
|
workingBalanceShare: stakeDaoWorkingBalanceShare,
|
|
87
91
|
optimal: {
|
|
92
|
+
tvl: stakeDaoOptTvl,
|
|
88
93
|
supply: stakeDaoOptSupply,
|
|
89
94
|
boost: stakeDaoOptBoost,
|
|
90
95
|
share: stakeDaoOptShare,
|
|
@@ -94,9 +99,11 @@ const getOnlyboostData = (
|
|
|
94
99
|
tvl: convexTvl,
|
|
95
100
|
supply: convexSupply,
|
|
96
101
|
boost: convexBoost,
|
|
102
|
+
share: convexShare,
|
|
97
103
|
workingBalance: formatUnits(data.convexWorkingBalance, 0),
|
|
98
104
|
workingBalanceShare: formatUnits(convexWorkingBalanceShare, 0),
|
|
99
105
|
optimal: {
|
|
106
|
+
tvl: convexOptTvl,
|
|
100
107
|
supply: convexOptSupply,
|
|
101
108
|
boost: convexOptBoost,
|
|
102
109
|
share: convexOptShare,
|
|
@@ -6,8 +6,8 @@ import { type SdtEmissionData, getSdtApr } from '../../../sdt.js'
|
|
|
6
6
|
import { equalTlc } from '../../../utils.js'
|
|
7
7
|
import type { CurveGlobalData, OnlyBoostData, RewardsData, StrategyData, ValidChainId } from '../../types.js'
|
|
8
8
|
import { getBoost } from '../../utils/boost.js'
|
|
9
|
-
import decodeEtherscanFactoryEvent, { decodeNewFactoryEvent } from '../../utils/decodeEtherscanFactoryEvent.js'
|
|
10
9
|
import { getAprBreakdown } from '../../utils/getAprBreakdown.js'
|
|
10
|
+
import getTokenTypes from '../../utils/getTokenTypes.js'
|
|
11
11
|
import { buildCurveStrategies } from '../build.js'
|
|
12
12
|
import { getCurveHttpCalls } from '../httpCalls.js'
|
|
13
13
|
import { getOnChainSdCurveData } from '../onChainCalls.js'
|
|
@@ -21,7 +21,6 @@ interface TFetchCurve {
|
|
|
21
21
|
prices: Price[]
|
|
22
22
|
provider: any
|
|
23
23
|
rpc: string
|
|
24
|
-
explorerApiKey: string
|
|
25
24
|
chainId: ValidChainId
|
|
26
25
|
sdtEmissionData: SdtEmissionData
|
|
27
26
|
gaugesWeights: GaugesWeightsData
|
|
@@ -31,23 +30,14 @@ export const fetchCurve = async ({
|
|
|
31
30
|
prices,
|
|
32
31
|
provider,
|
|
33
32
|
rpc,
|
|
34
|
-
explorerApiKey,
|
|
35
33
|
chainId,
|
|
36
34
|
sdtEmissionData,
|
|
37
35
|
gaugesWeights,
|
|
38
36
|
}: TFetchCurve): Promise<StrategyData> => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const apisData = await getCurveHttpCalls(explorerApiKey, rpc, chainId, fromBlock, toBlock, gaugesWeights)
|
|
37
|
+
const lastSyncBlock = curveStrats.meta.lastSyncBlock[chainId]!
|
|
38
|
+
const apisData = await getCurveHttpCalls(rpc, chainId, gaugesWeights)
|
|
42
39
|
|
|
43
|
-
const
|
|
44
|
-
chainId === mainnet.id
|
|
45
|
-
? decodeNewFactoryEvent(apisData.explorerData)
|
|
46
|
-
: decodeEtherscanFactoryEvent(apisData.explorerData)
|
|
47
|
-
|
|
48
|
-
const allVaultAndLp = curveStrats.strats[chainId]!.concat(newVaultAndLp).filter(
|
|
49
|
-
(s) => !BROKEN_VAULTS[chainId].includes(s.vault),
|
|
50
|
-
)
|
|
40
|
+
const allVaultAndLp = curveStrats.strats[chainId]!.filter((s) => !BROKEN_VAULTS[chainId].includes(s.vault))
|
|
51
41
|
|
|
52
42
|
const strats: any[] = await buildCurveStrategies(provider, allVaultAndLp, chainId, apisData.curveApiData)
|
|
53
43
|
|
|
@@ -66,7 +56,7 @@ export const fetchCurve = async ({
|
|
|
66
56
|
veCrvTotalSupply: '0',
|
|
67
57
|
stakeDaoVeBoost: '0',
|
|
68
58
|
convexVeBoost: '0',
|
|
69
|
-
lastSyncBlock
|
|
59
|
+
lastSyncBlock,
|
|
70
60
|
fees: {
|
|
71
61
|
veSdt: 5,
|
|
72
62
|
perf: 2,
|
|
@@ -197,6 +187,7 @@ export const fetchCurve = async ({
|
|
|
197
187
|
name: strat.name,
|
|
198
188
|
subname: strat.subname,
|
|
199
189
|
type: strat.type,
|
|
190
|
+
tokensFilter: getTokenTypes(strat),
|
|
200
191
|
protocol: strat.protocol,
|
|
201
192
|
chainId: strat.chainId,
|
|
202
193
|
isMetapool: strat.isMetapool,
|
|
@@ -1,38 +1,23 @@
|
|
|
1
|
-
import { contract } from '@stake-dao/constants'
|
|
2
|
-
import { getLogsFromEtherscan } from '../../utils/etherscan.js'
|
|
3
1
|
import { handlePromise } from '../utils/promise.js'
|
|
4
|
-
import {
|
|
5
|
-
CONVEX_LENDING_VAULTS_URL,
|
|
6
|
-
CONVEX_POOLS_URL,
|
|
7
|
-
CURVE_API_URL,
|
|
8
|
-
FACTORY_EVENT_TOPIC,
|
|
9
|
-
NEW_FACTORY_EVENT_TOPIC,
|
|
10
|
-
} from './endpoints.js'
|
|
2
|
+
import { CONVEX_LENDING_VAULTS_URL, CONVEX_POOLS_URL, CURVE_API_URL } from './endpoints.js'
|
|
11
3
|
import { getCurveApiData } from './fetch/curveApiData/getCurveApiData.js'
|
|
12
4
|
import { type GaugesWeightsData } from './fetch/curveApiData/getGaugesWeights.js'
|
|
13
5
|
|
|
14
|
-
export const getCurveHttpCalls = async (
|
|
15
|
-
explorerApiKey: string,
|
|
16
|
-
rpc: string,
|
|
17
|
-
chainId: number,
|
|
18
|
-
fromBlock: number,
|
|
19
|
-
toBlock: number,
|
|
20
|
-
gaugesWeights: GaugesWeightsData,
|
|
21
|
-
) => {
|
|
6
|
+
export const getCurveHttpCalls = async (rpc: string, chainId: number, gaugesWeights: GaugesWeightsData) => {
|
|
22
7
|
switch (chainId) {
|
|
23
8
|
case 1: {
|
|
24
9
|
const ethHttpCalls = [
|
|
25
10
|
// Etherscan Events
|
|
26
|
-
getLogsFromEtherscan({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}),
|
|
11
|
+
// getLogsFromEtherscan({
|
|
12
|
+
// chainId,
|
|
13
|
+
// address: contract('curveVaultFactory', chainId),
|
|
14
|
+
// apikey: explorerApiKey,
|
|
15
|
+
// extraQueryParams: {
|
|
16
|
+
// topic0: NEW_FACTORY_EVENT_TOPIC,
|
|
17
|
+
// fromBlock: `${fromBlock}`,
|
|
18
|
+
// toBlock: `${toBlock}`,
|
|
19
|
+
// },
|
|
20
|
+
// }),
|
|
36
21
|
// Curve Data (replace APIs calls)
|
|
37
22
|
getCurveApiData(rpc, chainId, gaugesWeights.gauges),
|
|
38
23
|
// Curve Trading Apy API
|
|
@@ -44,14 +29,13 @@ export const getCurveHttpCalls = async (
|
|
|
44
29
|
|
|
45
30
|
const ethHttpResponses = await handlePromise(ethHttpCalls, 'curveEthHttpCalls')
|
|
46
31
|
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const convexLendingVaults = ethHttpResponses[4].lendingVaults
|
|
32
|
+
const ethCurveData = ethHttpResponses[0]
|
|
33
|
+
const ethCurveSubgraph = ethHttpResponses[1].success ? ethHttpResponses[1].data.poolList : undefined
|
|
34
|
+
const convexPools = ethHttpResponses[2].pools
|
|
35
|
+
const convexLendingVaults = ethHttpResponses[3].lendingVaults
|
|
52
36
|
|
|
53
37
|
return {
|
|
54
|
-
explorerData:
|
|
38
|
+
explorerData: undefined,
|
|
55
39
|
curveSubgraphData: ethCurveSubgraph,
|
|
56
40
|
convexPools,
|
|
57
41
|
convexLendingVaults,
|
|
@@ -61,16 +45,16 @@ export const getCurveHttpCalls = async (
|
|
|
61
45
|
case 42161: {
|
|
62
46
|
const arbitrumHttpCalls = [
|
|
63
47
|
// Etherscan Events
|
|
64
|
-
getLogsFromEtherscan({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}),
|
|
48
|
+
// getLogsFromEtherscan({
|
|
49
|
+
// chainId,
|
|
50
|
+
// address: contract('curveVaultFactory', chainId),
|
|
51
|
+
// apikey: explorerApiKey,
|
|
52
|
+
// extraQueryParams: {
|
|
53
|
+
// topic0: FACTORY_EVENT_TOPIC,
|
|
54
|
+
// fromBlock: `${fromBlock}`,
|
|
55
|
+
// toBlock: `${toBlock}`,
|
|
56
|
+
// },
|
|
57
|
+
// }),
|
|
74
58
|
// Curve Data (replace APIs calls)
|
|
75
59
|
getCurveApiData(rpc, chainId, gaugesWeights.gauges),
|
|
76
60
|
// Curve Trading Apy API
|
|
@@ -79,14 +63,13 @@ export const getCurveHttpCalls = async (
|
|
|
79
63
|
|
|
80
64
|
const arbitrumHttpResponses = await handlePromise(arbitrumHttpCalls, 'curveArbitrumHttpCalls')
|
|
81
65
|
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
? arbitrumHttpResponses[2].data.poolList
|
|
66
|
+
const arbitrumCurveData = arbitrumHttpResponses[0]
|
|
67
|
+
const arbitrumCurveSubgraph = arbitrumHttpResponses[1].success
|
|
68
|
+
? arbitrumHttpResponses[1].data.poolList
|
|
86
69
|
: undefined
|
|
87
70
|
|
|
88
71
|
return {
|
|
89
|
-
explorerData:
|
|
72
|
+
explorerData: undefined,
|
|
90
73
|
curveSubgraphData: arbitrumCurveSubgraph,
|
|
91
74
|
convexPools: [],
|
|
92
75
|
convexLendingVaults: [],
|
|
@@ -5,6 +5,7 @@ import { mainnet } from 'viem/chains'
|
|
|
5
5
|
import multicallPassiveVaultsAbi from '../../abis/passiveVaultsMulticall.js'
|
|
6
6
|
import { multicall } from '../../utils.js'
|
|
7
7
|
import { getBoost } from '../utils/boost.js'
|
|
8
|
+
import getTokenTypes from '../utils/getTokenTypes.js'
|
|
8
9
|
import { getPassiveHttpCalls } from './httpCalls.js'
|
|
9
10
|
|
|
10
11
|
interface TFetchPassive {
|
|
@@ -64,6 +65,7 @@ export const fetchPassive = async ({ provider, chainId }: TFetchPassive) => {
|
|
|
64
65
|
|
|
65
66
|
return {
|
|
66
67
|
...s,
|
|
68
|
+
tokensFilter: getTokenTypes(s),
|
|
67
69
|
tradingApy: subgraphData.latestWeeklyApy,
|
|
68
70
|
minApy: curveApiData.gaugeCrvApy ? curveApiData.gaugeCrvApy[0] : 0,
|
|
69
71
|
maxApy: curveApiData.gaugeCrvApy ? curveApiData.gaugeCrvApy[1] : 0,
|
|
@@ -23,6 +23,7 @@ import type { RewardsData, SdtApr, ValidChainId } from '../types.js'
|
|
|
23
23
|
import { getBoost } from '../utils/boost.js'
|
|
24
24
|
import decodeEtherscanFactoryEvent from '../utils/decodeEtherscanFactoryEvent.js'
|
|
25
25
|
import { getAprBreakdown } from '../utils/getAprBreakdown.js'
|
|
26
|
+
import getTokenTypes from '../utils/getTokenTypes.js'
|
|
26
27
|
import { concatBytecode } from '../utils/index.js'
|
|
27
28
|
import { buildPendleStrategies } from './build.js'
|
|
28
29
|
import getPendleApiData from './getPendleApiData.js'
|
|
@@ -283,6 +284,7 @@ export const fetchPendle = async ({ prices, provider, rpc, explorerApiKey, chain
|
|
|
283
284
|
return {
|
|
284
285
|
key: s.key,
|
|
285
286
|
name: s.coins.reduce((res: string, current) => `${res}/${current.symbol}`, '').slice(1),
|
|
287
|
+
tokensFilter: getTokenTypes(s),
|
|
286
288
|
subname,
|
|
287
289
|
protocol: s.protocol,
|
|
288
290
|
chainId: s.chainId,
|
package/src/strategies/types.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { equalTlc, lc } from '../../utils.js'
|
|
2
|
+
|
|
3
|
+
const usdSymbols = ['usd', 'frax', 'dai', 'mim', 'dola', 'gho', 'usr', 'fxb20', 'fxb_20']
|
|
4
|
+
const excludeSymbols = ['usd0++']
|
|
5
|
+
|
|
6
|
+
const getTokenTypes = (s: any) => {
|
|
7
|
+
const types: string[] = []
|
|
8
|
+
const coins = s.isLending ? s.coins : s.underlyingCoins?.length > 0 ? s.underlyingCoins : s.coins
|
|
9
|
+
|
|
10
|
+
// USD
|
|
11
|
+
if (s.isLending && usdSymbols.some((usdS) => lc(s.coins[0].symbol).includes(usdS))) types.push('usd')
|
|
12
|
+
if (
|
|
13
|
+
coins.every((c) => usdSymbols.some((usdS) => lc(c.symbol).includes(usdS)) && !excludeSymbols.includes(lc(c.symbol)))
|
|
14
|
+
)
|
|
15
|
+
types.push('usd')
|
|
16
|
+
|
|
17
|
+
// SDT
|
|
18
|
+
if (coins.some((c) => equalTlc(c.symbol, 'sdt'))) types.push('sdt')
|
|
19
|
+
|
|
20
|
+
// CRV
|
|
21
|
+
if (coins.every((c) => !lc(c.symbol).includes('crvusd') && lc(c.symbol).includes('crv'))) types.push('crv')
|
|
22
|
+
|
|
23
|
+
// crvUSD
|
|
24
|
+
if (coins.some((c) => lc(c.symbol).includes('crvusd'))) types.push('crvusd')
|
|
25
|
+
|
|
26
|
+
// BTC
|
|
27
|
+
if (coins.some((c) => lc(c.symbol).includes('btc'))) types.push('btc')
|
|
28
|
+
|
|
29
|
+
// ETH
|
|
30
|
+
if (coins.some((c) => lc(c.symbol).includes('eth'))) types.push('eth')
|
|
31
|
+
|
|
32
|
+
return types
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default getTokenTypes
|