@1delta/margin-fetcher 0.0.24 → 0.0.26
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/lending/user-data/compound-v3/index.d.ts +0 -1
- package/dist/lending/user-data/compound-v3/index.d.ts.map +1 -1
- package/dist/lending/user-data/compound-v3/index.js +0 -1
- package/dist/lending/user-data/compound-v3/userCallBuild.d.ts +2 -2
- package/dist/lending/user-data/compound-v3/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/compound-v3/userCallBuild.js +6 -10
- package/dist/lending/user-data/compound-v3/userCallParse.js +2 -2
- package/dist/lending/user-data/fetchUserData.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.js +8 -1
- package/dist/prices/main-prices/addresses/morpho.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/morpho.js +1311 -0
- package/dist/yields/index.d.ts.map +1 -1
- package/dist/yields/index.js +210 -5
- package/package.json +1 -1
- package/src/lending/user-data/compound-v3/index.ts +1 -2
- package/src/lending/user-data/compound-v3/userCallBuild.ts +18 -16
- package/src/lending/user-data/compound-v3/userCallParse.ts +2 -2
- package/src/lending/user-data/fetchUserData.ts +0 -1
- package/src/lending/user-data/morpho/userCallParse.ts +11 -3
- package/src/prices/main-prices/addresses/morpho.ts +1311 -0
- package/src/yields/index.ts +248 -5
- package/test/mainPrices.test.ts +2 -2
- package/test/morphoPrice.test.ts +1 -1
- package/test/userDataMorpho.test.ts +203 -13
- package/test/yields.test.ts +1 -1
- package/dist/lending/user-data/compound-v3/addresses.d.ts +0 -10
- package/dist/lending/user-data/compound-v3/addresses.d.ts.map +0 -1
- package/dist/lending/user-data/compound-v3/addresses.js +0 -33
- package/src/lending/user-data/compound-v3/addresses.ts +0 -59
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/compound-v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/compound-v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lender } from
|
|
2
|
-
import { Call } from
|
|
1
|
+
import { Lender } from '@1delta/asset-registry';
|
|
2
|
+
import { Call } from '../../../utils/multicall';
|
|
3
3
|
export declare const buildCompoundV3UserCall: (chainId: string, lender: Lender, account: string) => Call[];
|
|
4
4
|
//# sourceMappingURL=userCallBuild.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/compound-v3/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/compound-v3/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAQ/C,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,SAAS,MAAM,KACd,IAAI,EAkCN,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getLenderAssets } from
|
|
2
|
-
import { getCompoundV3BaseAsset, getCompoundV3CometAddress, getCompoundV3CometRewardsAddress } from
|
|
1
|
+
import { getLenderAssets } from '../../../utils';
|
|
2
|
+
import { getCompoundV3BaseAsset, getCompoundV3CometAddress, getCompoundV3CometRewardsAddress, } from '../../addresses/compoundV3';
|
|
3
3
|
export const buildCompoundV3UserCall = (chainId, lender, account) => {
|
|
4
|
-
const baseAsset = getCompoundV3BaseAsset(lender, chainId)
|
|
4
|
+
const baseAsset = getCompoundV3BaseAsset(lender, chainId)?.baseAsset;
|
|
5
5
|
const cometContractAddress = getCompoundV3CometAddress(chainId, lender);
|
|
6
6
|
const assets = getLenderAssets(chainId, lender);
|
|
7
|
-
const assetsNoBase = assets.filter(a => a !== baseAsset);
|
|
7
|
+
const assetsNoBase = assets.filter((a) => a !== baseAsset);
|
|
8
8
|
const baseCalls = [
|
|
9
9
|
{
|
|
10
10
|
address: cometContractAddress,
|
|
@@ -15,7 +15,7 @@ export const buildCompoundV3UserCall = (chainId, lender, account) => {
|
|
|
15
15
|
address: cometContractAddress,
|
|
16
16
|
name: 'borrowBalanceOf',
|
|
17
17
|
params: [account],
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
19
|
];
|
|
20
20
|
const callsNonBase = assetsNoBase.map((tk) => {
|
|
21
21
|
return {
|
|
@@ -29,10 +29,6 @@ export const buildCompoundV3UserCall = (chainId, lender, account) => {
|
|
|
29
29
|
name: 'getRewardOwed',
|
|
30
30
|
params: [cometContractAddress, account],
|
|
31
31
|
};
|
|
32
|
-
const calls = [
|
|
33
|
-
...callsNonBase,
|
|
34
|
-
...baseCalls,
|
|
35
|
-
callEarnedBalances
|
|
36
|
-
];
|
|
32
|
+
const calls = [...callsNonBase, ...baseCalls, callEarnedBalances];
|
|
37
33
|
return calls;
|
|
38
34
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getAssetMeta, getCompoundV3Assets, toGenericPriceKey, toOracleKey, } from '../../../assets';
|
|
2
|
-
import { getCompoundV3BaseAsset } from '
|
|
2
|
+
import { getCompoundV3BaseAsset } from '../../addresses/compoundV3';
|
|
3
3
|
import { parseRawAmount } from '../../../utils/parsing';
|
|
4
4
|
import { Asset as SupportedAssets } from '@1delta/asset-registry';
|
|
5
5
|
import { createBaseTypeUserState } from '../utils';
|
|
6
6
|
export const getCompoundV3UserDataConverter = (lender, chainId, account, prices, pricesHist, lenderData) => {
|
|
7
7
|
const assetAddresses = getCompoundV3Assets(chainId, lender);
|
|
8
|
-
const baseAsset = getCompoundV3BaseAsset(lender, chainId)
|
|
8
|
+
const baseAsset = getCompoundV3BaseAsset(lender, chainId)?.baseAsset;
|
|
9
9
|
const assetsNoBase = assetAddresses.filter((a) => a !== baseAsset);
|
|
10
10
|
const expectedNumberOfCalls = assetsNoBase.length + 2 + 1;
|
|
11
11
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchUserData.d.ts","sourceRoot":"","sources":["../../../src/lending/user-data/fetchUserData.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAuB,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AA6FlD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,EACf,YAAY,eAAe,EAAE,EAC7B,cAAc,oBAAoB,KACjC,OAAO,CAAC,GAAG,EAAE,CA4Bf,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,YAAY,eAAe,EAAE,EAC7B,YAAY,GAAG,EAAE,EACjB,QAAQ,GAAG,EACX,YAAY,GAAG,EACf,aAAa,GAAG,KACf;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchUserData.d.ts","sourceRoot":"","sources":["../../../src/lending/user-data/fetchUserData.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAuB,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AA6FlD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,EACf,YAAY,eAAe,EAAE,EAC7B,cAAc,oBAAoB,KACjC,OAAO,CAAC,GAAG,EAAE,CA4Bf,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,YAAY,eAAe,EAAE,EAC7B,YAAY,GAAG,EAAE,EACjB,QAAQ,GAAG,EACX,YAAY,GAAG,EACf,aAAa,GAAG,KACf;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAsCzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AA+CpD,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,YAAY;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACvC,YAAY,GAAG,KACd,CACD,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,yBAAyB,CAAA;CAAE,GAAG,SAAS,EAC5E,MAAM,
|
|
1
|
+
{"version":3,"file":"userCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AA+CpD,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,YAAY;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACvC,YAAY,GAAG,KACd,CACD,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,yBAAyB,CAAA;CAAE,GAAG,SAAS,EAC5E,MAAM,CAuFP,CAAA"}
|
|
@@ -49,6 +49,13 @@ export const getMorphoUserDataConverterWithlens = (lender, chainId, account, mar
|
|
|
49
49
|
if (data.length !== expectedNumberOfCalls) {
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
|
+
// we map the index from the return data
|
|
53
|
+
// to the real chunk
|
|
54
|
+
// it is
|
|
55
|
+
// (chunk number) * (chunksize = 100) + index
|
|
56
|
+
function mapMarketToChunk(i, c) {
|
|
57
|
+
return (c + 1) * 100 + i;
|
|
58
|
+
}
|
|
52
59
|
let marketsHandled = [];
|
|
53
60
|
// de-chunk the calldata
|
|
54
61
|
const returnDatas = data.flatMap((d) => decodePackedDataset(d));
|
|
@@ -57,7 +64,7 @@ export const getMorphoUserDataConverterWithlens = (lender, chainId, account, mar
|
|
|
57
64
|
let totalDebt24h = 0;
|
|
58
65
|
let totalDeposits24h = 0;
|
|
59
66
|
const balanceData = returnDatas[i];
|
|
60
|
-
const markeId = markets[balanceData.index];
|
|
67
|
+
const markeId = markets[mapMarketToChunk(balanceData.index, i)];
|
|
61
68
|
marketsHandled.push(markeId);
|
|
62
69
|
const market = lenderData[markeId]?.params?.market;
|
|
63
70
|
const { dataForMarket, addedDebt, addedDeposits } = createMorphoEntryFromMarketWithLens(balanceData, chainId, market, prices, pricesHist);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morpho.d.ts","sourceRoot":"","sources":["../../../../src/prices/main-prices/addresses/morpho.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,uBAAuB,EAAE,MAAM,CAAA;CAChC;AAED,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"morpho.d.ts","sourceRoot":"","sources":["../../../../src/prices/main-prices/addresses/morpho.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,uBAAuB,EAAE,MAAM,CAAA;CAChC;AAED,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAq9E5D,CAAA"}
|