@sonarwatch/portfolio-plugins 0.8.29 → 0.8.31
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 +8 -0
- package/package.json +2 -2
- package/src/plugins/aave/constants.d.ts +1 -1
- package/src/plugins/aave/constants.js +10 -3
- package/src/plugins/aave/constants.js.map +1 -1
- package/src/plugins/aave/lendingPoolsJob.js +62 -1
- package/src/plugins/aave/lendingPoolsJob.js.map +1 -1
- package/src/plugins/aave/types.d.ts +1 -0
- package/src/plugins/curve/getPoolsTypes.d.ts +6 -2
- package/src/plugins/curve/getPoolsTypes.js.map +1 -1
- package/src/plugins/curve/getPositionsFetcher.js +7 -12
- package/src/plugins/curve/getPositionsFetcher.js.map +1 -1
- package/src/plugins/curve/helpers.d.ts +2 -2
- package/src/plugins/curve/helpers.js.map +1 -1
- package/src/plugins/curve/poolsJob.js +23 -1
- package/src/plugins/curve/poolsJob.js.map +1 -1
- package/src/utils/misc/tokenPriceToAssetToken.d.ts +1 -1
- package/src/utils/misc/tokenPriceToAssetToken.js +4 -3
- package/src/utils/misc/tokenPriceToAssetToken.js.map +1 -1
- package/src/utils/misc/tokenPriceToAssetTokens.d.ts +1 -1
- package/src/utils/misc/tokenPriceToAssetTokens.js +4 -2
- package/src/utils/misc/tokenPriceToAssetTokens.js.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.8.31](https://github.com/sonarwatch/portfolio/compare/plugins-0.8.30...plugins-0.8.31) (2023-10-18)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
## [0.8.30](https://github.com/sonarwatch/portfolio/compare/plugins-0.8.29...plugins-0.8.30) (2023-10-18)
|
10
|
+
|
11
|
+
|
12
|
+
|
5
13
|
## [0.8.29](https://github.com/sonarwatch/portfolio/compare/plugins-0.8.28...plugins-0.8.29) (2023-10-17)
|
6
14
|
|
7
15
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.31",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"web3-v1": "npm:web3@^1.5.0"
|
38
38
|
},
|
39
39
|
"peerDependencies": {
|
40
|
-
"@sonarwatch/portfolio-core": "0.8.
|
40
|
+
"@sonarwatch/portfolio-core": "0.8.31"
|
41
41
|
},
|
42
42
|
"main": "./src/index.js",
|
43
43
|
"types": "./src/index.d.ts"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { NetworkIdType, Platform } from '@sonarwatch/portfolio-core';
|
2
2
|
import { LendingConfig } from './types';
|
3
|
+
export declare const platformId = "aave";
|
3
4
|
export declare const aavePlatform: Platform;
|
4
5
|
export declare const lendingConfigs: Map<NetworkIdType, LendingConfig[]>;
|
5
|
-
export declare const platformId = "aave";
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.lendingConfigs = exports.aavePlatform = exports.platformId = void 0;
|
4
4
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
5
|
+
exports.platformId = 'aave';
|
5
6
|
exports.aavePlatform = {
|
6
|
-
id:
|
7
|
+
id: exports.platformId,
|
7
8
|
name: 'AAVE',
|
8
9
|
image: 'https://sonar.watch/img/platforms/aave.png',
|
9
10
|
defiLlamaId: 'parent#aave',
|
@@ -19,6 +20,7 @@ exports.lendingConfigs = new Map([
|
|
19
20
|
lendingPoolAddressProvider: '0xb6A86025F0FE1862B372cb0ca18CE3EDe02A318f',
|
20
21
|
uiIncentiveDataProviderAddress: '0x11979886A6dBAE27D7a72c49fCF3F23240D647bF',
|
21
22
|
uiPoolDataProviderAddress: '0x00e50FAB64eBB37b87df06Aa46b8B35d5f1A4e1A',
|
23
|
+
version: 2,
|
22
24
|
},
|
23
25
|
{
|
24
26
|
chainId: portfolio_core_1.networks.avalanche.chainId,
|
@@ -27,6 +29,7 @@ exports.lendingConfigs = new Map([
|
|
27
29
|
lendingPoolAddressProvider: '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
|
28
30
|
uiIncentiveDataProviderAddress: '0x265d414f80b0fca9505710e6F16dB4b67555D365',
|
29
31
|
uiPoolDataProviderAddress: '0xF71DBe0FAEF1473ffC607d4c555dfF0aEaDb878d',
|
32
|
+
version: 3,
|
30
33
|
},
|
31
34
|
],
|
32
35
|
],
|
@@ -40,6 +43,7 @@ exports.lendingConfigs = new Map([
|
|
40
43
|
lendingPoolAddressProvider: '0xd05e3E715d945B59290df0ae8eF85c1BdB684744',
|
41
44
|
uiIncentiveDataProviderAddress: '0x645654D59A5226CBab969b1f5431aA47CBf64ab8',
|
42
45
|
uiPoolDataProviderAddress: '0x204f2Eb81D996729829debC819f7992DCEEfE7b1',
|
46
|
+
version: 2,
|
43
47
|
},
|
44
48
|
{
|
45
49
|
chainId: portfolio_core_1.networks.polygon.chainId,
|
@@ -48,6 +52,7 @@ exports.lendingConfigs = new Map([
|
|
48
52
|
lendingPoolAddressProvider: '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
|
49
53
|
uiIncentiveDataProviderAddress: '0x874313A46e4957D29FAAC43BF5Eb2B144894f557',
|
50
54
|
uiPoolDataProviderAddress: '0xC69728f11E9E6127733751c8410432913123acf1',
|
55
|
+
version: 3,
|
51
56
|
},
|
52
57
|
],
|
53
58
|
],
|
@@ -61,6 +66,7 @@ exports.lendingConfigs = new Map([
|
|
61
66
|
lendingPoolAddressProvider: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
|
62
67
|
uiIncentiveDataProviderAddress: '0xD01ab9a6577E1D84F142e44D49380e23A340387d',
|
63
68
|
uiPoolDataProviderAddress: '0x00e50FAB64eBB37b87df06Aa46b8B35d5f1A4e1A',
|
69
|
+
version: 2,
|
64
70
|
},
|
65
71
|
{
|
66
72
|
chainId: portfolio_core_1.networks.ethereum.chainId,
|
@@ -69,6 +75,7 @@ exports.lendingConfigs = new Map([
|
|
69
75
|
lendingPoolAddressProvider: '0xAcc030EF66f9dFEAE9CbB0cd1B25654b82cFA8d5',
|
70
76
|
uiIncentiveDataProviderAddress: '0xD01ab9a6577E1D84F142e44D49380e23A340387d',
|
71
77
|
uiPoolDataProviderAddress: '0x00e50FAB64eBB37b87df06Aa46b8B35d5f1A4e1A',
|
78
|
+
version: 2,
|
72
79
|
},
|
73
80
|
{
|
74
81
|
chainId: portfolio_core_1.networks.ethereum.chainId,
|
@@ -77,9 +84,9 @@ exports.lendingConfigs = new Map([
|
|
77
84
|
lendingPoolAddressProvider: '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e',
|
78
85
|
uiIncentiveDataProviderAddress: '0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6',
|
79
86
|
uiPoolDataProviderAddress: '0x91c0eA31b49B69Ea18607702c5d9aC360bf3dE7d',
|
87
|
+
version: 3,
|
80
88
|
},
|
81
89
|
],
|
82
90
|
],
|
83
91
|
]);
|
84
|
-
exports.platformId = 'aave';
|
85
92
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aave/constants.ts"],"names":[],"mappings":";;;AAAA,+DAKoC;AAGvB,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aave/constants.ts"],"names":[],"mappings":";;;AAAA,+DAKoC;AAGvB,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,kBAAU;IACd,IAAI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E,OAAO,EAAE,yBAAQ,CAAC,QAAQ,CAAC,OAAO;gBAClC,SAAS,EAAE,0BAAS,CAAC,QAAQ;gBAC7B,WAAW,EAAE,cAAc;gBAC3B,0BAA0B,EACxB,4CAA4C;gBAC9C,8BAA8B,EAC5B,4CAA4C;gBAC9C,yBAAyB,EAAE,4CAA4C;gBACvE,OAAO,EAAE,CAAC;aACX;YACD;gBACE,OAAO,EAAE,yBAAQ,CAAC,QAAQ,CAAC,OAAO;gBAClC,SAAS,EAAE,0BAAS,CAAC,QAAQ;gBAC7B,WAAW,EAAE,aAAa;gBAC1B,0BAA0B,EACxB,4CAA4C;gBAC9C,8BAA8B,EAC5B,4CAA4C;gBAC9C,yBAAyB,EAAE,4CAA4C;gBACvE,OAAO,EAAE,CAAC;aACX;YACD;gBACE,OAAO,EAAE,yBAAQ,CAAC,QAAQ,CAAC,OAAO;gBAClC,SAAS,EAAE,0BAAS,CAAC,QAAQ;gBAC7B,WAAW,EAAE,aAAa;gBAC1B,0BAA0B,EACxB,4CAA4C;gBAC9C,8BAA8B,EAC5B,4CAA4C;gBAC9C,yBAAyB,EAAE,4CAA4C;gBACvE,OAAO,EAAE,CAAC;aACX;SACF;KACF;CACF,CAAC,CAAC"}
|
@@ -13,6 +13,7 @@ const providers_1 = require("@ethersproject/providers");
|
|
13
13
|
require("reflect-metadata");
|
14
14
|
const contract_helpers_1 = require("@aave/contract-helpers");
|
15
15
|
const math_utils_1 = require("@aave/math-utils");
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
17
|
const constants_1 = require("./constants");
|
17
18
|
const constants_2 = require("../../utils/clients/constants");
|
18
19
|
const helpers_1 = require("./helpers");
|
@@ -23,7 +24,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
24
|
const lendingConfig = lendingConfigsArray[i];
|
24
25
|
if (!lendingConfig)
|
25
26
|
continue;
|
26
|
-
const { uiPoolDataProviderAddress, uiIncentiveDataProviderAddress, lendingPoolAddressProvider, chainId, networkId, } = lendingConfig;
|
27
|
+
const { uiPoolDataProviderAddress, uiIncentiveDataProviderAddress, lendingPoolAddressProvider, chainId, networkId, elementName, } = lendingConfig;
|
27
28
|
const rpcEndpoint = (0, constants_2.getRpcEndpoint)(networkId);
|
28
29
|
const user = (_a = rpcEndpoint.basicAuth) === null || _a === void 0 ? void 0 : _a.username;
|
29
30
|
const password = (_b = rpcEndpoint.basicAuth) === null || _b === void 0 ? void 0 : _b.password;
|
@@ -66,6 +67,35 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
67
|
marketReferencePriceInUsd,
|
67
68
|
reserveIncentives,
|
68
69
|
});
|
70
|
+
// Borrow Lend Rates
|
71
|
+
for (const formattedReserve of formattedReserves) {
|
72
|
+
if (!formattedReserve.isActive)
|
73
|
+
continue;
|
74
|
+
const tokenAddress = formattedReserve.underlyingAsset;
|
75
|
+
const lendingApr = Number(formattedReserve.supplyAPR);
|
76
|
+
const borrowingApr = Number(formattedReserve.variableBorrowAPR);
|
77
|
+
const depositedAmount = Number(formattedReserve.totalLiquidity);
|
78
|
+
const borrowedAmount = Number(formattedReserve.totalDebt);
|
79
|
+
const rate = {
|
80
|
+
tokenAddress,
|
81
|
+
borrowYield: {
|
82
|
+
apy: (0, portfolio_core_1.aprToApy)(borrowingApr),
|
83
|
+
apr: borrowingApr,
|
84
|
+
},
|
85
|
+
borrowedAmount,
|
86
|
+
depositYield: {
|
87
|
+
apy: (0, portfolio_core_1.aprToApy)(lendingApr),
|
88
|
+
apr: lendingApr,
|
89
|
+
},
|
90
|
+
depositedAmount,
|
91
|
+
platformId: constants_1.platformId,
|
92
|
+
poolName: elementName,
|
93
|
+
};
|
94
|
+
yield cache.setItem(`${elementName}-${tokenAddress}`, rate, {
|
95
|
+
prefix: portfolio_core_1.borrowLendRatesPrefix,
|
96
|
+
networkId,
|
97
|
+
});
|
98
|
+
}
|
69
99
|
const lendingData = {
|
70
100
|
lendingPoolAddressProvider,
|
71
101
|
chainId,
|
@@ -80,6 +110,37 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
110
|
prefix: helpers_1.lendingPoolsPrefix,
|
81
111
|
networkId,
|
82
112
|
});
|
113
|
+
const underlyingAssetPrices = yield cache.getTokenPrices(lendingData.formattedReserves.map((r) => r.underlyingAsset), networkId);
|
114
|
+
for (let j = 0; j < lendingData.formattedReserves.length; j++) {
|
115
|
+
const formattedReserve = lendingData.formattedReserves[j];
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
117
|
+
const aTokenAddress = formattedReserve.aTokenAddress;
|
118
|
+
if (!aTokenAddress)
|
119
|
+
continue;
|
120
|
+
const underlyingAssetPrice = underlyingAssetPrices[j];
|
121
|
+
if (!underlyingAssetPrice)
|
122
|
+
continue;
|
123
|
+
yield cache.setTokenPriceSource({
|
124
|
+
id: constants_1.platformId,
|
125
|
+
weight: 1,
|
126
|
+
address: aTokenAddress,
|
127
|
+
networkId,
|
128
|
+
platformId: constants_1.platformId,
|
129
|
+
decimals: formattedReserve.decimals,
|
130
|
+
price: underlyingAssetPrice.price,
|
131
|
+
underlyings: [
|
132
|
+
{
|
133
|
+
address: formattedReserve.underlyingAsset,
|
134
|
+
amountPerLp: 1,
|
135
|
+
decimals: formattedReserve.decimals,
|
136
|
+
networkId,
|
137
|
+
price: underlyingAssetPrice.price,
|
138
|
+
},
|
139
|
+
],
|
140
|
+
elementName,
|
141
|
+
timestamp: Date.now(),
|
142
|
+
});
|
143
|
+
}
|
83
144
|
}
|
84
145
|
});
|
85
146
|
const job = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lendingPoolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aave/lendingPoolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wDAAiE;AACjE,4BAA0B;AAC1B,6DAGgC;AAChC,iDAA+D;
|
1
|
+
{"version":3,"file":"lendingPoolsJob.js","sourceRoot":"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YACtD,IAAI,CAAC,oBAAoB;gBAAE,SAAS;YAEpC,MAAM,KAAK,CAAC,mBAAmB,CAAC;gBAC9B,EAAE,EAAE,sBAAU;gBACd,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,aAAa;gBACtB,SAAS;gBACT,UAAU,EAAV,sBAAU;gBACV,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;gBACnC,KAAK,EAAE,oBAAoB,CAAC,KAAK;gBACjC,WAAW,EAAE;oBACX;wBACE,OAAO,EAAE,gBAAgB,CAAC,eAAe;wBACzC,WAAW,EAAE,CAAC;wBACd,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;wBACnC,SAAS;wBACT,KAAK,EAAE,oBAAoB,CAAC,KAAK;qBAClC;iBACF;gBACD,WAAW;gBACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;SACJ;KACF;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,gBAAgB;IACjC,QAAQ;CACT,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -1,14 +1,15 @@
|
|
1
|
+
import { TokenPrice } from '@sonarwatch/portfolio-core';
|
1
2
|
export type GetPoolsResponse = {
|
2
3
|
success: boolean;
|
3
4
|
data: GetPoolsData;
|
4
5
|
generatedTimeMs: number;
|
5
6
|
};
|
6
7
|
export type GetPoolsData = {
|
7
|
-
poolData:
|
8
|
+
poolData: PoolDatumRaw[];
|
8
9
|
tvlAll: number;
|
9
10
|
tvl: number;
|
10
11
|
};
|
11
|
-
export type
|
12
|
+
export type PoolDatumRaw = {
|
12
13
|
id: string;
|
13
14
|
address: string;
|
14
15
|
coinsAddresses: string[];
|
@@ -38,6 +39,9 @@ export type PoolDatum = {
|
|
38
39
|
underlyingCoins?: Coin[];
|
39
40
|
priceOracle?: number;
|
40
41
|
};
|
42
|
+
export type PoolDatum = PoolDatumRaw & {
|
43
|
+
coinsTokenPrices: Record<string, TokenPrice>;
|
44
|
+
};
|
41
45
|
export declare enum AssetTypeName {
|
42
46
|
Btc = "btc",
|
43
47
|
Eth = "eth",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getPoolsTypes.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/getPoolsTypes.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"getPoolsTypes.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/getPoolsTypes.ts"],"names":[],"mappings":";;;AAiDA,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,4BAAW,CAAA;IACX,gCAAe,CAAA;IACf,oCAAmB,CAAA;IACnB,4BAAW,CAAA;AACb,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB"}
|
@@ -19,6 +19,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
19
19
|
const constants_1 = require("./constants");
|
20
20
|
const clients_1 = require("../../utils/clients");
|
21
21
|
const abis_1 = require("./abis");
|
22
|
+
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
22
23
|
const zero = BigInt(0);
|
23
24
|
function getPositionsFetcher(crvNetworkId) {
|
24
25
|
const networkId = constants_1.crvNetworkIdBySwNetworkId[crvNetworkId];
|
@@ -77,22 +78,16 @@ function getPositionsFetcher(crvNetworkId) {
|
|
77
78
|
const coins = pool.underlyingCoins || pool.coins;
|
78
79
|
const supply = new bignumber_js_1.default(pool.totalSupply);
|
79
80
|
const shares = balance.div(supply);
|
80
|
-
const assets = coins
|
81
|
+
const assets = coins
|
82
|
+
.map((coin) => {
|
81
83
|
const amount = new bignumber_js_1.default(coin.poolBalance)
|
82
84
|
.times(shares)
|
83
85
|
.div(Math.pow(10, Number(coin.decimals)))
|
84
86
|
.toNumber();
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
address: (0, portfolio_core_1.formatTokenAddress)(coin.address, networkId),
|
90
|
-
amount,
|
91
|
-
price: coin.usdPrice || null,
|
92
|
-
},
|
93
|
-
value: coin.usdPrice ? coin.usdPrice * amount : null,
|
94
|
-
};
|
95
|
-
});
|
87
|
+
const tokenPrice = pool.coinsTokenPrices[coin.address];
|
88
|
+
return (0, tokenPriceToAssetTokens_1.default)(coin.address, amount, networkId, tokenPrice, coin.usdPrice || undefined);
|
89
|
+
})
|
90
|
+
.flat();
|
96
91
|
const value = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
|
97
92
|
const liquidity = {
|
98
93
|
assets,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getPositionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/getPositionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"getPositionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/getPositionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,+BAAkC;AAClC,gEAAqC;AAErC,2CAMqB;AAErB,iDAAmD;AAEnD,iCAAsC;AACtC,uGAA+E;AAE/E,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvB,SAAgB,mBAAmB,CAAC,YAA0B;IAC5D,MAAM,SAAS,GAAG,qCAAyB,CAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;QACtE,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,OAAO,CAEvC,gCAAoB,EAAE;YACvB,SAAS;YACT,MAAM,EAAE,gCAAoB;SAC7B,CAAC,CAAC;QACH,IAAI,CAAC,cAAc;YAAE,OAAO,EAAE,CAAC;QAE/B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,SAAS,CAAC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AI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,IAAI,EAAE;oBACJ,WAAW,EAAE,gBAAgB;iBAC9B;gBACD,KAAK,EAAE,IAAA,+BAAc,EAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;aAC5D,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAA,CAAC;IACF,OAAO;QACL,QAAQ;QACR,SAAS;QACT,EAAE,EAAE,GAAG,sBAAU,IAAI,SAAS,YAAY;KAC3C,CAAC;AACJ,CAAC;AAhID,kDAgIC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { NetworkIdType } from '@sonarwatch/portfolio-core';
|
2
2
|
import { CrvNetworkId } from './constants';
|
3
|
-
import {
|
3
|
+
import { PoolDatumRaw } from './getPoolsTypes';
|
4
4
|
import { GaugeDatum } from './getAllGaugesTypes';
|
5
|
-
export declare function getPoolsData(crvNetworkId: CrvNetworkId): Promise<
|
5
|
+
export declare function getPoolsData(crvNetworkId: CrvNetworkId): Promise<PoolDatumRaw[]>;
|
6
6
|
export declare function getAllGaugesData(): Promise<Partial<Record<NetworkIdType, GaugeDatum[]>>>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+DAAsE;AACtE,mCAAqC;AACrC,2CAIqB;AAIrB,SAAS,iBAAiB,CAAC,YAA0B;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAU,CAAC,CAAC,GAAG,CAClC,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,sBAAU,aAAa,YAAY,IAAI,UAAU,EAAE,CACvE,CAAC;AACJ,CAAC;AAED,SAAsB,YAAY,CAChC,YA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YAC/C,MAAA,MAAM,CAAC,SAAS,CAAC,0CAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAjBD,4CAiBC"}
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
12
13
|
const constants_1 = require("./constants");
|
13
14
|
const helpers_1 = require("./helpers");
|
14
15
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -16,9 +17,30 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
17
|
const crvNetworkId = constants_1.crvNetworkIds[i];
|
17
18
|
const networkId = constants_1.crvNetworkIdBySwNetworkId[crvNetworkId];
|
18
19
|
const pools = yield (0, helpers_1.getPoolsData)(crvNetworkId);
|
20
|
+
const coinsAddresses = [
|
21
|
+
...new Set(pools
|
22
|
+
.map((pool) => (pool.underlyingCoins || pool.coins).map((c) => c.address))
|
23
|
+
.flat()),
|
24
|
+
];
|
25
|
+
const tokenPrices = yield cache.getTokenPrices(coinsAddresses, networkId);
|
26
|
+
const tokenPricesByAddress = new Map();
|
27
|
+
tokenPrices.forEach((tp) => {
|
28
|
+
if (!tp)
|
29
|
+
return;
|
30
|
+
tokenPricesByAddress.set(tp.address, tp);
|
31
|
+
});
|
19
32
|
for (let j = 0; j < pools.length; j++) {
|
20
33
|
const pool = pools[j];
|
21
|
-
|
34
|
+
const coins = pool.underlyingCoins || pool.coins;
|
35
|
+
const coinsTokenPrices = coins.reduce((obj, coin) => {
|
36
|
+
const tokenPrice = tokenPricesByAddress.get((0, portfolio_core_1.formatTokenAddress)(coin.address, networkId));
|
37
|
+
if (!tokenPrice)
|
38
|
+
return obj;
|
39
|
+
// eslint-disable-next-line no-param-reassign
|
40
|
+
obj[coin.address] = tokenPrice;
|
41
|
+
return obj;
|
42
|
+
}, {});
|
43
|
+
yield cache.setItem(pool.address, Object.assign(Object.assign({}, pool), { coinsTokenPrices }), {
|
22
44
|
prefix: constants_1.poolsCachePrefix,
|
23
45
|
networkId,
|
24
46
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;
|
1
|
+
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/curve/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAA4E;AAG5E,2CAMqB;AAErB,uCAAyC;AAEzC,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,yBAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,YAAY,GAAG,yBAAa,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,qCAAyB,CAAC,YAAY,CAAC,CAAC;QAE1D,MAAM,KAAK,GAAG,MAAM,IAAA,sBAAY,EAAC,YAAY,CAAC,CAAC;QAC/C,MAAM,cAAc,GAAG;YACrB,GAAG,IAAI,GAAG,CACR,KAAK;iBACF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAC3D;iBACA,IAAI,EAAE,CACV;SACF,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC1E,MAAM,oBAAoB,GAA4B,IAAI,GAAG,EAAE,CAAC;QAChE,WAA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C,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CACjB,gCAAoB,EACpB,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,EACpC;YACE,MAAM,EAAE,gCAAoB;YAC5B,SAAS;SACV,CACF,CAAC;KACH;AACH,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;CACT,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { NetworkIdType, PortfolioAssetToken, TokenPrice, TokenPriceUnderlying } from '@sonarwatch/portfolio-core';
|
2
|
-
export default function tokenPriceToAssetToken(address: string, amount: number, networkId: NetworkIdType, tokenPrice?: TokenPrice | TokenPriceUnderlying | null): PortfolioAssetToken;
|
2
|
+
export default function tokenPriceToAssetToken(address: string, amount: number, networkId: NetworkIdType, tokenPrice?: TokenPrice | TokenPriceUnderlying | null, price?: number): PortfolioAssetToken;
|
@@ -1,15 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
4
|
-
function tokenPriceToAssetToken(address, amount, networkId, tokenPrice) {
|
4
|
+
function tokenPriceToAssetToken(address, amount, networkId, tokenPrice, price) {
|
5
|
+
const fPrice = (tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.price) || price || null;
|
5
6
|
return {
|
6
7
|
type: portfolio_core_1.PortfolioAssetType.token,
|
7
8
|
networkId,
|
8
|
-
value:
|
9
|
+
value: fPrice ? fPrice * amount : null,
|
9
10
|
data: {
|
10
11
|
address: (0, portfolio_core_1.formatTokenAddress)(address, networkId),
|
11
12
|
amount,
|
12
|
-
price:
|
13
|
+
price: fPrice,
|
13
14
|
},
|
14
15
|
};
|
15
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenPriceToAssetToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/tokenPriceToAssetToken.ts"],"names":[],"mappings":";;AAAA,+
|
1
|
+
{"version":3,"file":"tokenPriceToAssetToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/tokenPriceToAssetToken.ts"],"names":[],"mappings":";;AAAA,+DAQoC;AAEpC,SAAwB,sBAAsB,CAC5C,OAAe,EACf,MAAc,EACd,SAAwB,EACxB,UAAqD,EACrD,KAAc;IAEd,MAAM,MAAM,GAAa,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,KAAI,KAAK,IAAI,IAAI,CAAC;IAC5D,OAAO;QACL,IAAI,EAAE,mCAAkB,CAAC,KAAK;QAC9B,SAAS;QACT,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI;QACtC,IAAI,EAAE;YACJ,OAAO,EAAE,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC;YAC/C,MAAM;YACN,KAAK,EAAE,MAAM;SACd;KACF,CAAC;AACJ,CAAC;AAlBD,yCAkBC"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { NetworkIdType, PortfolioAssetToken, TokenPrice } from '@sonarwatch/portfolio-core';
|
2
|
-
export default function tokenPriceToAssetTokens(address: string, amount: number, networkId: NetworkIdType, tokenPrice?: TokenPrice | null): PortfolioAssetToken[];
|
2
|
+
export default function tokenPriceToAssetTokens(address: string, amount: number, networkId: NetworkIdType, tokenPrice?: TokenPrice | null, price?: number): PortfolioAssetToken[];
|
@@ -4,9 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const tokenPriceToAssetToken_1 = __importDefault(require("./tokenPriceToAssetToken"));
|
7
|
-
function tokenPriceToAssetTokens(address, amount, networkId, tokenPrice) {
|
7
|
+
function tokenPriceToAssetTokens(address, amount, networkId, tokenPrice, price) {
|
8
8
|
if (!tokenPrice || !tokenPrice.underlyings)
|
9
|
-
return [
|
9
|
+
return [
|
10
|
+
(0, tokenPriceToAssetToken_1.default)(address, amount, networkId, tokenPrice, price),
|
11
|
+
];
|
10
12
|
return tokenPrice.underlyings.map((tokenPriceUnderlying) => (0, tokenPriceToAssetToken_1.default)(tokenPriceUnderlying.address, amount * tokenPriceUnderlying.amountPerLp, tokenPriceUnderlying.networkId, tokenPriceUnderlying));
|
11
13
|
}
|
12
14
|
exports.default = tokenPriceToAssetTokens;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenPriceToAssetTokens.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/tokenPriceToAssetTokens.ts"],"names":[],"mappings":";;;;;AAKA,sFAA8D;AAE9D,SAAwB,uBAAuB,CAC7C,OAAe,EACf,MAAc,EACd,SAAwB,EACxB,UAA8B;
|
1
|
+
{"version":3,"file":"tokenPriceToAssetTokens.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/tokenPriceToAssetTokens.ts"],"names":[],"mappings":";;;;;AAKA,sFAA8D;AAE9D,SAAwB,uBAAuB,CAC7C,OAAe,EACf,MAAc,EACd,SAAwB,EACxB,UAA8B,EAC9B,KAAc;IAEd,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,WAAW;QACxC,OAAO;YACL,IAAA,gCAAsB,EAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC;SACtE,CAAC;IACJ,OAAO,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,oBAAoB,EAAE,EAAE,CACzD,IAAA,gCAAsB,EACpB,oBAAoB,CAAC,OAAO,EAC5B,MAAM,GAAG,oBAAoB,CAAC,WAAW,EACzC,oBAAoB,CAAC,SAAS,EAC9B,oBAAoB,CACrB,CACF,CAAC;AACJ,CAAC;AAnBD,0CAmBC"}
|