@sonarwatch/portfolio-plugins 0.8.89 → 0.8.91
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/CHANGELOG.md +9 -1
- package/package.json +2 -2
- package/src/index.js +26 -31
- package/src/index.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/yearn/abis.d.ts +185 -0
- package/src/plugins/yearn/abis.js +144 -0
- package/src/plugins/yearn/abis.js.map +1 -0
- package/src/plugins/yearn/constants.d.ts +9 -0
- package/src/plugins/yearn/constants.js +33 -0
- package/src/plugins/yearn/constants.js.map +1 -0
- package/src/plugins/yearn/getLockersBalancesFetcher.d.ts +4 -0
- package/src/plugins/yearn/getLockersBalancesFetcher.js +56 -0
- package/src/plugins/yearn/getLockersBalancesFetcher.js.map +1 -0
- package/src/plugins/yearn/getStakesBalancesFetcher.d.ts +4 -0
- package/src/plugins/yearn/getStakesBalancesFetcher.js +70 -0
- package/src/plugins/yearn/getStakesBalancesFetcher.js.map +1 -0
- package/src/plugins/yearn/getVaultsBalancesFetcher.d.ts +3 -0
- package/src/plugins/yearn/getVaultsBalancesFetcher.js +95 -0
- package/src/plugins/yearn/getVaultsBalancesFetcher.js.map +1 -0
- package/src/plugins/yearn/getVaultsJob.d.ts +3 -0
- package/src/plugins/yearn/getVaultsJob.js +29 -0
- package/src/plugins/yearn/getVaultsJob.js.map +1 -0
- package/src/plugins/yearn/getYearnStakeBalancesFetcher.d.ts +4 -0
- package/src/plugins/yearn/getYearnStakeBalancesFetcher.js +85 -0
- package/src/plugins/yearn/getYearnStakeBalancesFetcher.js.map +1 -0
- package/src/plugins/yearn/helpers.d.ts +5 -0
- package/src/plugins/yearn/helpers.js +67 -0
- package/src/plugins/yearn/helpers.js.map +1 -0
- package/src/plugins/yearn/index.d.ts +6 -0
- package/src/plugins/yearn/index.js +22 -0
- package/src/plugins/yearn/index.js.map +1 -0
- package/src/plugins/yearn/types.d.ts +75 -0
- package/src/plugins/yearn/types.js +3 -0
- package/src/plugins/yearn/types.js.map +1 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styETHStake = exports.yETHStake = exports.lockersEth = exports.yearnApiUrl = exports.vaultsKey = exports.platform = exports.platformId = void 0;
|
4
|
+
exports.platformId = 'yearn';
|
5
|
+
exports.platform = {
|
6
|
+
id: exports.platformId,
|
7
|
+
name: 'Yearn',
|
8
|
+
image: 'https://sonar.watch/img/platforms/yearn.png',
|
9
|
+
website: 'https://yearn.fi/',
|
10
|
+
defiLlamaId: 'yearn-finance', // from https://defillama.com/docs/api
|
11
|
+
// twitter: 'https://twitter.com/myplatform',
|
12
|
+
};
|
13
|
+
exports.vaultsKey = 'vaults';
|
14
|
+
exports.yearnApiUrl = 'https://api.yexporter.io/v1/chains';
|
15
|
+
exports.lockersEth = [
|
16
|
+
{
|
17
|
+
address: '0x90c1f9220d90d3966fbee24045edd73e1d588ad5',
|
18
|
+
underlying: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e',
|
19
|
+
},
|
20
|
+
];
|
21
|
+
exports.yETHStake = [
|
22
|
+
{
|
23
|
+
address: '0x1bed97cbc3c24a4fb5c069c6e311a967386131f7',
|
24
|
+
underlying: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
25
|
+
},
|
26
|
+
];
|
27
|
+
exports.styETHStake = [
|
28
|
+
{
|
29
|
+
address: '0x583019ff0f430721ada9cfb4fac8f06ca104d0b4',
|
30
|
+
underlying: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
31
|
+
},
|
32
|
+
];
|
33
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,6CAA6C;IACpD,OAAO,EAAE,mBAAmB;IAC5B,WAAW,EAAE,eAAe,EAAE,sCAAsC;IACpE,6CAA6C;CAC9C,CAAC;AACW,QAAA,SAAS,GAAG,QAAQ,CAAC;AACrB,QAAA,WAAW,GAAG,oCAAoC,CAAC;AACnD,QAAA,UAAU,GAAe;IACpC;QACE,OAAO,EAAE,4CAA4C;QACrD,UAAU,EAAE,4CAA4C;KACzD;CACF,CAAC;AAEW,QAAA,SAAS,GAAe;IACnC;QACE,OAAO,EAAE,4CAA4C;QACrD,UAAU,EAAE,4CAA4C;KACzD;CACF,CAAC;AAEW,QAAA,WAAW,GAAe;IACrC;QACE,OAAO,EAAE,4CAA4C;QACrD,UAAU,EAAE,4CAA4C;KACzD;CACF,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { EvmNetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import { Fetcher } from '../../Fetcher';
|
3
|
+
import { Contract } from './types';
|
4
|
+
export default function getLockersBalancesFetcher(networkId: EvmNetworkIdType, platformId: string, lockers: Contract[]): Fetcher;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const helpers_1 = require("./helpers");
|
18
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
19
|
+
function getLockersBalancesFetcher(networkId, platformId, lockers) {
|
20
|
+
const executor = (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const lockedBalances = yield (0, helpers_1.getLockersBalances)(networkId, lockers.map((l) => l.address), owner);
|
22
|
+
const elements = [];
|
23
|
+
for (let index = 0; index < lockedBalances.length; index++) {
|
24
|
+
const balance = lockedBalances[index];
|
25
|
+
if (balance.amount > BigInt(0)) {
|
26
|
+
const { underlying } = lockers[index];
|
27
|
+
const tokenPrice = yield cache.getTokenPrice(underlying, networkId);
|
28
|
+
if (!tokenPrice)
|
29
|
+
continue;
|
30
|
+
const amount = new bignumber_js_1.default(balance.amount.toString())
|
31
|
+
.dividedBy(Math.pow(10, tokenPrice.decimals))
|
32
|
+
.toNumber();
|
33
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(underlying, amount, networkId, tokenPrice);
|
34
|
+
elements.push({
|
35
|
+
networkId,
|
36
|
+
label: 'Staked',
|
37
|
+
platformId,
|
38
|
+
name: `Locked`,
|
39
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
40
|
+
value: asset.value,
|
41
|
+
data: {
|
42
|
+
assets: [asset],
|
43
|
+
},
|
44
|
+
});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
return elements;
|
48
|
+
});
|
49
|
+
return {
|
50
|
+
networkId,
|
51
|
+
executor,
|
52
|
+
id: `${platformId}-${networkId}-lockers`,
|
53
|
+
};
|
54
|
+
}
|
55
|
+
exports.default = getLockersBalancesFetcher;
|
56
|
+
//# sourceMappingURL=getLockersBalancesFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getLockersBalancesFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/getLockersBalancesFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AACrC,uCAA+C;AAE/C,qGAA6E;AAI7E,SAAwB,yBAAyB,CAC/C,SAA2B,EAC3B,UAAkB,EAClB,OAAmB;IAEnB,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;QACtE,MAAM,cAAc,GAAG,MAAM,IAAA,4BAAkB,EAC7C,SAAS,EACT,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAC7B,KAAK,CACN,CAAC;QAEF,MAAM,QAAQ,GAAuB,EAAE,CAAC;QACxC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC1D,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE;gBAC9B,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;gBACtC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;gBACpE,IAAI,CAAC,UAAU;oBAAE,SAAS;gBAE1B,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;qBACpD,SAAS,CAAC,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAAC;qBACpC,QAAQ,EAAE,CAAC;gBACd,MAAM,KAAK,GAAG,IAAA,gCAAsB,EAClC,UAAU,EACV,MAAM,EACN,SAAS,EACT,UAAU,CACX,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC;oBACZ,SAAS;oBACT,KAAK,EAAE,QAAQ;oBACf,UAAU;oBACV,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,qCAAoB,CAAC,QAAQ;oBACnC,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,IAAI,EAAE;wBACJ,MAAM,EAAE,CAAC,KAAK,CAAC;qBAChB;iBACF,CAAC,CAAC;aACJ;SACF;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAA,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,UAAU;KACzC,CAAC;AACJ,CAAC;AAlDD,4CAkDC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { EvmNetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import { Contract } from './types';
|
3
|
+
import { Fetcher } from '../../Fetcher';
|
4
|
+
export default function getStakesBalancesFetcher(networkId: EvmNetworkIdType, platformId: string, contracts: Contract[]): Fetcher;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const helpers_1 = require("./helpers");
|
18
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
19
|
+
function getStakesBalancesFetcher(networkId, platformId, contracts) {
|
20
|
+
const executor = (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const balances = yield (0, helpers_1.getBalances)(networkId, contracts.map((c) => c.address), owner);
|
22
|
+
const tokenAddresses = contracts.map((v) => v.underlying);
|
23
|
+
const tokensPrices = yield cache.getTokenPrices(tokenAddresses, networkId);
|
24
|
+
const tokenPriceById = new Map();
|
25
|
+
tokensPrices.forEach((tP) => tP ? tokenPriceById.set(tP.address, tP) : []);
|
26
|
+
const liquidities = [];
|
27
|
+
for (let index = 0; index < balances.length; index++) {
|
28
|
+
const balance = balances[index];
|
29
|
+
if (balance > BigInt(0)) {
|
30
|
+
const { underlying } = contracts[index];
|
31
|
+
const tokenPrice = tokenPriceById.get(underlying);
|
32
|
+
if (!tokenPrice)
|
33
|
+
continue;
|
34
|
+
const amount = new bignumber_js_1.default(balance.toString())
|
35
|
+
.dividedBy(new bignumber_js_1.default(10).pow(tokenPrice.decimals))
|
36
|
+
.toNumber();
|
37
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(underlying, amount, networkId, tokenPrice);
|
38
|
+
liquidities.push({
|
39
|
+
assets: [asset],
|
40
|
+
assetsValue: asset.value,
|
41
|
+
rewardAssets: [],
|
42
|
+
rewardAssetsValue: null,
|
43
|
+
value: asset.value,
|
44
|
+
yields: [],
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (liquidities.length === 0)
|
49
|
+
return [];
|
50
|
+
return [
|
51
|
+
{
|
52
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
53
|
+
label: 'Staked',
|
54
|
+
networkId,
|
55
|
+
platformId,
|
56
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
57
|
+
data: {
|
58
|
+
liquidities,
|
59
|
+
},
|
60
|
+
},
|
61
|
+
];
|
62
|
+
});
|
63
|
+
return {
|
64
|
+
networkId,
|
65
|
+
executor,
|
66
|
+
id: `${platformId}-${networkId}-stake`,
|
67
|
+
};
|
68
|
+
}
|
69
|
+
exports.default = getStakesBalancesFetcher;
|
70
|
+
//# sourceMappingURL=getStakesBalancesFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getStakesBalancesFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/getStakesBalancesFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAErC,uCAAwC;AAGxC,qGAA6E;AAE7E,SAAwB,wBAAwB,CAC9C,SAA2B,EAC3B,UAAkB,EAClB,SAAqB;IAErB,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;QACtE,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAChC,SAAS,EACT,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAC/B,KAAK,CACN,CAAC;QAEF,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC3E,MAAM,cAAc,GAA4B,IAAI,GAAG,EAAE,CAAC;QAC1D,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAC1B,EAAE,CAAC,CAAC,CAAC,cAAc,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,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF;SACF,CAAC;IACJ,CAAC,CAAA,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,QAAQ;KACvC,CAAC;AACJ,CAAC;AArED,2CAqEC"}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const helpers_1 = require("./helpers");
|
19
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
20
|
+
function getVaultsBalancesFetcher(networkId, platformId) {
|
21
|
+
const executor = (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
22
|
+
const vaults = yield cache.getItem(constants_1.vaultsKey, {
|
23
|
+
prefix: platformId,
|
24
|
+
networkId,
|
25
|
+
});
|
26
|
+
if (!vaults)
|
27
|
+
return [];
|
28
|
+
const balances = yield (0, helpers_1.getBalances)(networkId, vaults.map((v) => v.address), owner);
|
29
|
+
if (balances.length === 0)
|
30
|
+
return [];
|
31
|
+
const tokenAddresses = vaults
|
32
|
+
.map((v) => (v.endorsed ? v.token.address : []))
|
33
|
+
.flat();
|
34
|
+
const tokensPrices = yield cache.getTokenPrices(tokenAddresses, networkId);
|
35
|
+
const tokenPriceById = new Map();
|
36
|
+
tokensPrices.forEach((tP) => tP ? tokenPriceById.set(tP.address, tP) : []);
|
37
|
+
const liquiditiesByVersion = {};
|
38
|
+
for (let index = 0; index < balances.length; index++) {
|
39
|
+
const balance = balances[index];
|
40
|
+
if (balance > BigInt(0)) {
|
41
|
+
const vaultData = vaults[index];
|
42
|
+
const amount = new bignumber_js_1.default(balance.toString())
|
43
|
+
.dividedBy(new bignumber_js_1.default(10).pow(vaultData.decimals))
|
44
|
+
.toNumber();
|
45
|
+
const tokenPrice = tokenPriceById.get(vaultData.token.address);
|
46
|
+
if (!tokenPrice)
|
47
|
+
continue;
|
48
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(vaultData.token.address, amount, networkId, tokenPrice);
|
49
|
+
const yields = [
|
50
|
+
{
|
51
|
+
apr: (0, portfolio_core_1.apyToApr)(Number(vaultData.apy.net_apy)),
|
52
|
+
apy: Number(vaultData.apy.net_apy),
|
53
|
+
},
|
54
|
+
];
|
55
|
+
const liquidity = {
|
56
|
+
assets: [asset],
|
57
|
+
assetsValue: asset.value,
|
58
|
+
rewardAssets: [],
|
59
|
+
rewardAssetsValue: null,
|
60
|
+
value: asset.value,
|
61
|
+
yields,
|
62
|
+
};
|
63
|
+
if (liquiditiesByVersion[vaultData.type]) {
|
64
|
+
liquiditiesByVersion[vaultData.type].push(liquidity);
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
liquiditiesByVersion[vaultData.type] = [liquidity];
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
const elements = [];
|
72
|
+
for (const [name, liquidities] of Object.entries(liquiditiesByVersion)) {
|
73
|
+
if (liquidities.length > 0)
|
74
|
+
elements.push({
|
75
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
76
|
+
label: 'Farming',
|
77
|
+
networkId,
|
78
|
+
platformId,
|
79
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
80
|
+
name: name.toUpperCase(),
|
81
|
+
data: {
|
82
|
+
liquidities,
|
83
|
+
},
|
84
|
+
});
|
85
|
+
}
|
86
|
+
return elements;
|
87
|
+
});
|
88
|
+
return {
|
89
|
+
networkId,
|
90
|
+
executor,
|
91
|
+
id: `${platformId}-${networkId}-vaults`,
|
92
|
+
};
|
93
|
+
}
|
94
|
+
exports.default = getVaultsBalancesFetcher;
|
95
|
+
//# sourceMappingURL=getVaultsBalancesFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getVaultsBalancesFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/getVaultsBalancesFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAErC,2CAAwC;AACxC,uCAAwC;AAGxC,qGAA6E;AAE7E,SAAwB,wBAAwB,CAC9C,SAA2B,EAC3B,UAAkB;IAElB,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;QACtE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAc,qBAAS,EAAE;YACzD,MAAM,EAAE,UAAU;YAClB,SAAS;SACV,CAAC,CAAC;QACH,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAW,EAChC,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,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CAAC;oBACtD,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE;oBACxB,IAAI,EAAE;wBACJ,WAAW;qBACZ;iBACF,CAAC,CAAC;SACN;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAA,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,SAAS;KACxC,CAAC;AACJ,CAAC;AAzFD,2CAyFC"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const helpers_1 = require("./helpers");
|
15
|
+
function getVaultsJob(networkId, platformId) {
|
16
|
+
const executor = (cache) => __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const vaults = (yield (0, helpers_1.getVaults)({
|
18
|
+
chainId: portfolio_core_1.networks[networkId].chainId,
|
19
|
+
network: portfolio_core_1.networks[networkId],
|
20
|
+
})).filter((vault) => vault.endorsed);
|
21
|
+
yield cache.setItem(constants_1.vaultsKey, vaults, { prefix: platformId, networkId });
|
22
|
+
});
|
23
|
+
return {
|
24
|
+
executor,
|
25
|
+
id: `${platformId}-${networkId}-vaults`,
|
26
|
+
};
|
27
|
+
}
|
28
|
+
exports.default = getVaultsJob;
|
29
|
+
//# sourceMappingURL=getVaultsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getVaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/getVaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAwE;AAGxE,2CAAwC;AACxC,uCAAsC;AAEtC,SAAwB,YAAY,CAClC,SAA2B,EAC3B,UAAkB;IAElB,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,CACb,MAAM,IAAA,mBAAS,EAAC;YACd,OAAO,EAAE,yBAAQ,CAAC,SAAS,CAAC,CAAC,OAAO;YACpC,OAAO,EAAE,yBAAQ,CAAC,SAAS,CAAC;SAC7B,CAAC,CACH,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEpC,MAAM,KAAK,CAAC,OAAO,CAAC,qBAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAA,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,SAAS;KACxC,CAAC;AACJ,CAAC;AAnBD,+BAmBC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { EvmNetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import { Contract } from './types';
|
3
|
+
import { Fetcher } from '../../Fetcher';
|
4
|
+
export default function getYearnStakeBalancesFetcher(networkId: EvmNetworkIdType, platformId: string, contracts: Contract[]): Fetcher;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const helpers_1 = require("./helpers");
|
18
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
19
|
+
const abis_1 = require("./abis");
|
20
|
+
const clients_1 = require("../../utils/clients");
|
21
|
+
function getYearnStakeBalancesFetcher(networkId, platformId, contracts) {
|
22
|
+
const executor = (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
23
|
+
const client = (0, clients_1.getEvmClient)(networkId);
|
24
|
+
const balances = yield (0, helpers_1.getBalances)(networkId, contracts.map((c) => c.address), owner);
|
25
|
+
const toAssetContracts = balances.map((balance, index) => ({
|
26
|
+
abi: [abis_1.yearnStakeAbi.convertToAssets],
|
27
|
+
address: contracts[index].address,
|
28
|
+
functionName: abis_1.yearnStakeAbi.convertToAssets.name,
|
29
|
+
args: [balance],
|
30
|
+
}));
|
31
|
+
const convertedBalancesRes = yield client.multicall({
|
32
|
+
contracts: toAssetContracts,
|
33
|
+
});
|
34
|
+
const tokenAddresses = contracts.map((v) => v.underlying);
|
35
|
+
const tokensPrices = yield cache.getTokenPrices(tokenAddresses, networkId);
|
36
|
+
const tokenPriceById = new Map();
|
37
|
+
tokensPrices.forEach((tP) => tP ? tokenPriceById.set(tP.address, tP) : []);
|
38
|
+
const liquidities = [];
|
39
|
+
for (let index = 0; index < convertedBalancesRes.length; index++) {
|
40
|
+
const balanceRes = convertedBalancesRes[index];
|
41
|
+
if (balanceRes.status === 'failure')
|
42
|
+
continue;
|
43
|
+
const balance = balanceRes.result;
|
44
|
+
if (balance > BigInt(0)) {
|
45
|
+
const { underlying } = contracts[index];
|
46
|
+
const tokenPrice = tokenPriceById.get(underlying);
|
47
|
+
if (!tokenPrice)
|
48
|
+
continue;
|
49
|
+
const amount = new bignumber_js_1.default(balance.toString())
|
50
|
+
.dividedBy(new bignumber_js_1.default(10).pow(tokenPrice.decimals))
|
51
|
+
.toNumber();
|
52
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(underlying, amount, networkId, tokenPrice);
|
53
|
+
liquidities.push({
|
54
|
+
assets: [asset],
|
55
|
+
assetsValue: asset.value,
|
56
|
+
rewardAssets: [],
|
57
|
+
rewardAssetsValue: null,
|
58
|
+
value: asset.value,
|
59
|
+
yields: [],
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}
|
63
|
+
if (liquidities.length === 0)
|
64
|
+
return [];
|
65
|
+
return [
|
66
|
+
{
|
67
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
68
|
+
label: 'Staked',
|
69
|
+
networkId,
|
70
|
+
platformId,
|
71
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
72
|
+
data: {
|
73
|
+
liquidities,
|
74
|
+
},
|
75
|
+
},
|
76
|
+
];
|
77
|
+
});
|
78
|
+
return {
|
79
|
+
networkId,
|
80
|
+
executor,
|
81
|
+
id: `${platformId}-${networkId}-yearn-stake`,
|
82
|
+
};
|
83
|
+
}
|
84
|
+
exports.default = getYearnStakeBalancesFetcher;
|
85
|
+
//# sourceMappingURL=getYearnStakeBalancesFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getYearnStakeBalancesFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/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OAAO,EAAE,CAAC;QAExC,OAAO;YACL;gBACE,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,KAAK,EAAE,QAAQ;gBACf,SAAS;gBACT,UAAU;gBACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF;SACF,CAAC;IACJ,CAAC,CAAA,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,EAAE,EAAE,GAAG,UAAU,IAAI,SAAS,cAAc;KAC7C,CAAC;AACJ,CAAC;AArFD,+CAqFC"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { EvmNetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import { LockerInfo, VaultData, YearnConfig } from './types';
|
3
|
+
export declare function getVaults(config: YearnConfig): Promise<VaultData[]>;
|
4
|
+
export declare function getBalances(evmNetworkId: EvmNetworkIdType, contracts: string[], owner: string): Promise<bigint[]>;
|
5
|
+
export declare function getLockersBalances(evmNetworkId: EvmNetworkIdType, contracts: string[], owner: string): Promise<LockerInfo[]>;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.getLockersBalances = exports.getBalances = exports.getVaults = void 0;
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
17
|
+
const erc20Abi_1 = require("../../utils/evm/erc20Abi");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const abis_1 = require("./abis");
|
20
|
+
const constants_1 = require("./constants");
|
21
|
+
function getVaults(config) {
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
23
|
+
if (!config.network.id)
|
24
|
+
return [];
|
25
|
+
const allPoolsRes = yield axios_1.default
|
26
|
+
.get(`${constants_1.yearnApiUrl}/${config.network.chainId}/vaults/all`)
|
27
|
+
.catch(() => null);
|
28
|
+
const allPoolsData = allPoolsRes === null || allPoolsRes === void 0 ? void 0 : allPoolsRes.data;
|
29
|
+
if (!allPoolsData)
|
30
|
+
return [];
|
31
|
+
return allPoolsData;
|
32
|
+
});
|
33
|
+
}
|
34
|
+
exports.getVaults = getVaults;
|
35
|
+
function getBalances(evmNetworkId, contracts, owner) {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
const client = (0, clients_1.getEvmClient)(evmNetworkId);
|
38
|
+
const balanceOfBase = {
|
39
|
+
abi: erc20Abi_1.balanceOfErc20ABI,
|
40
|
+
args: [owner],
|
41
|
+
functionName: erc20Abi_1.balanceOfErc20ABI[0].name,
|
42
|
+
};
|
43
|
+
const balancesRes = yield client.multicall({
|
44
|
+
contracts: contracts.map((ctx) => (Object.assign(Object.assign({}, balanceOfBase), { address: ctx }))),
|
45
|
+
});
|
46
|
+
return balancesRes.map((balance) => balance.status === 'failure' ? BigInt(0) : balance.result);
|
47
|
+
});
|
48
|
+
}
|
49
|
+
exports.getBalances = getBalances;
|
50
|
+
function getLockersBalances(evmNetworkId, contracts, owner) {
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
52
|
+
const client = (0, clients_1.getEvmClient)(evmNetworkId);
|
53
|
+
const lockerBalanceBase = {
|
54
|
+
abi: [abis_1.lockersAbi.locks],
|
55
|
+
args: [owner],
|
56
|
+
functionName: abis_1.lockersAbi.locks.name,
|
57
|
+
};
|
58
|
+
const balancesRes = yield client.multicall({
|
59
|
+
contracts: contracts.map((ctx) => (Object.assign(Object.assign({}, lockerBalanceBase), { address: ctx }))),
|
60
|
+
});
|
61
|
+
return balancesRes.map((balance) => balance.status === 'failure'
|
62
|
+
? { amount: BigInt(0), unlockTime: BigInt(0) }
|
63
|
+
: { amount: balance.result[0], unlockTime: balance.result[1] });
|
64
|
+
});
|
65
|
+
}
|
66
|
+
exports.getLockersBalances = getLockersBalances;
|
67
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA6C;AAE7C,uDAA6D;AAC7D,iDAAmD;AACnD,iCAAoC;AACpC,2CAA0C;AAE1C,SAAsB,SAAS,CAAC,MAAmB;;QACjD,IAAI,CAAE,MAAM,CAAC,OAAO,CAAC,EAAuB;YAAE,OAAO,EAAE,CAAC;QACxD,MAAM,WAAW,GAAsC,MAAM,eAAK;aAC/D,GAAG,CAAC,GAAG,uBAAW,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,aAAa,CAAC;aAC1D,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,YAAY,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,CAAC;QAEvC,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAE7B,OAAO,YAAY,CAAC;IACtB,CAAC;CAAA;AAVD,8BAUC;AAED,SAAsB,WAAW,CAC/B,YAA8B,EAC9B,SAAmB,EACnB,KAAa;;QAEb,MAAM,MAAM,GAAG,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AC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;YAC9C,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CACjE,CAAC;IACJ,CAAC;CAAA;AA3BD,gDA2BC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const getVaultsJob_1 = __importDefault(require("./getVaultsJob"));
|
10
|
+
const getVaultsBalancesFetcher_1 = __importDefault(require("./getVaultsBalancesFetcher"));
|
11
|
+
const getLockersBalancesFetcher_1 = __importDefault(require("./getLockersBalancesFetcher"));
|
12
|
+
const getStakesBalancesFetcher_1 = __importDefault(require("./getStakesBalancesFetcher"));
|
13
|
+
const getYearnStakeBalancesFetcher_1 = __importDefault(require("./getYearnStakeBalancesFetcher"));
|
14
|
+
exports.platforms = [constants_1.platform];
|
15
|
+
exports.jobs = [(0, getVaultsJob_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id)];
|
16
|
+
exports.fetchers = [
|
17
|
+
(0, getVaultsBalancesFetcher_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id),
|
18
|
+
(0, getLockersBalancesFetcher_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id, constants_1.lockersEth),
|
19
|
+
(0, getStakesBalancesFetcher_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id, constants_1.yETHStake),
|
20
|
+
(0, getYearnStakeBalancesFetcher_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id, constants_1.styETHStake),
|
21
|
+
];
|
22
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAiE;AAGjE,2CAA2E;AAC3E,kEAA0C;AAC1C,0FAAkE;AAClE,4FAAoE;AACpE,0FAAkE;AAClE,kGAA0E;AAE7D,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,IAAA,sBAAY,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9D,QAAA,QAAQ,GAAc;IACjC,IAAA,kCAAwB,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,CAAC;IACzD,IAAA,mCAAyB,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,EAAE,sBAAU,CAAC;IACtE,IAAA,kCAAwB,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,EAAE,qBAAS,CAAC;IACpE,IAAA,sCAA4B,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,EAAE,uBAAW,CAAC;CAC3E,CAAC"}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { Network } from '@sonarwatch/portfolio-core';
|
2
|
+
export type Contract = {
|
3
|
+
address: string;
|
4
|
+
underlying: string;
|
5
|
+
};
|
6
|
+
export type LockerInfo = {
|
7
|
+
amount: bigint;
|
8
|
+
unlockTime: bigint;
|
9
|
+
};
|
10
|
+
export type YearnConfig = {
|
11
|
+
network: Network;
|
12
|
+
chainId: number;
|
13
|
+
};
|
14
|
+
export type VaultData = {
|
15
|
+
address: string;
|
16
|
+
symbol: string;
|
17
|
+
display_name: string;
|
18
|
+
token: {
|
19
|
+
name: string;
|
20
|
+
symbol: string;
|
21
|
+
address: string;
|
22
|
+
decimals: string;
|
23
|
+
display_name: string;
|
24
|
+
icon: string;
|
25
|
+
};
|
26
|
+
tvl: {
|
27
|
+
total_assets: string;
|
28
|
+
price: string;
|
29
|
+
tvl: string;
|
30
|
+
};
|
31
|
+
apy: {
|
32
|
+
type: string;
|
33
|
+
gross_apr: string;
|
34
|
+
net_apy: string;
|
35
|
+
fees: {
|
36
|
+
performance: string;
|
37
|
+
withdrawal: string;
|
38
|
+
management: string;
|
39
|
+
keep_crv: string;
|
40
|
+
cvx_keep_crv: string;
|
41
|
+
keep_velo: string;
|
42
|
+
};
|
43
|
+
points: {
|
44
|
+
week_ago: string;
|
45
|
+
month_ago: string;
|
46
|
+
inception: string;
|
47
|
+
};
|
48
|
+
blocks: {
|
49
|
+
now: string;
|
50
|
+
week_ago: string;
|
51
|
+
month_ago: string;
|
52
|
+
inception: string;
|
53
|
+
};
|
54
|
+
composite: string;
|
55
|
+
error_reason: string;
|
56
|
+
staking_rewards_apr: string;
|
57
|
+
};
|
58
|
+
strategies: [
|
59
|
+
{
|
60
|
+
address: string;
|
61
|
+
name: string;
|
62
|
+
},
|
63
|
+
{
|
64
|
+
address: string;
|
65
|
+
name: string;
|
66
|
+
},
|
67
|
+
{
|
68
|
+
address: string;
|
69
|
+
name: string;
|
70
|
+
}
|
71
|
+
];
|
72
|
+
endorsed: boolean;
|
73
|
+
decimals: string;
|
74
|
+
type: string;
|
75
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/yearn/types.ts"],"names":[],"mappings":""}
|