@sonarwatch/portfolio-plugins 0.11.157 → 0.11.159

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +2 -2
  3. package/src/plugins/abex/marketsJob.js +2 -2
  4. package/src/plugins/abex/marketsJob.js.map +1 -1
  5. package/src/plugins/aftermath/poolsJob.js +36 -102
  6. package/src/plugins/aftermath/poolsJob.js.map +1 -1
  7. package/src/plugins/atrix/poolsV1Job.js +2 -2
  8. package/src/plugins/atrix/poolsV1Job.js.map +1 -1
  9. package/src/plugins/auxexchange/aptosLpJob.js +6 -4
  10. package/src/plugins/auxexchange/aptosLpJob.js.map +1 -1
  11. package/src/plugins/bskt/vestingFetcher.js +4 -24
  12. package/src/plugins/bskt/vestingFetcher.js.map +1 -1
  13. package/src/plugins/fluxbeam/poolsJob.js +6 -4
  14. package/src/plugins/fluxbeam/poolsJob.js.map +1 -1
  15. package/src/plugins/kai/vaultsJob.js +2 -2
  16. package/src/plugins/kai/vaultsJob.js.map +1 -1
  17. package/src/plugins/liquiditypools-sei/job.js +6 -4
  18. package/src/plugins/liquiditypools-sei/job.js.map +1 -1
  19. package/src/plugins/liquidswap/aptosLpJob.js +2 -2
  20. package/src/plugins/liquidswap/aptosLpJob.js.map +1 -1
  21. package/src/plugins/marginfi/banksJob.d.ts +3 -0
  22. package/src/plugins/marginfi/{jobExecutor.js → banksJob.js} +8 -3
  23. package/src/plugins/marginfi/banksJob.js.map +1 -0
  24. package/src/plugins/marginfi/depositsFetcher.d.ts +3 -0
  25. package/src/plugins/marginfi/{fetcherExecutor.js → depositsFetcher.js} +8 -3
  26. package/src/plugins/marginfi/{fetcherExecutor.js.map → depositsFetcher.js.map} +1 -1
  27. package/src/plugins/marginfi/index.js +4 -17
  28. package/src/plugins/marginfi/index.js.map +1 -1
  29. package/src/plugins/meteora/multiTokenPoolsJob.js +2 -2
  30. package/src/plugins/meteora/multiTokenPoolsJob.js.map +1 -1
  31. package/src/plugins/meteora/poolsJob.js +6 -4
  32. package/src/plugins/meteora/poolsJob.js.map +1 -1
  33. package/src/plugins/navi/collateralFetcher.js +5 -1
  34. package/src/plugins/navi/collateralFetcher.js.map +1 -1
  35. package/src/plugins/orca/lpTokensJob.js +6 -4
  36. package/src/plugins/orca/lpTokensJob.js.map +1 -1
  37. package/src/plugins/pancakeswap/aptosLpJob.js +6 -4
  38. package/src/plugins/pancakeswap/aptosLpJob.js.map +1 -1
  39. package/src/plugins/raydium/lpTokensJob.js +8 -10
  40. package/src/plugins/raydium/lpTokensJob.js.map +1 -1
  41. package/src/plugins/raydium/structs/amms.d.ts +5 -2
  42. package/src/plugins/raydium/structs/amms.js +6 -3
  43. package/src/plugins/raydium/structs/amms.js.map +1 -1
  44. package/src/plugins/sushiswap/aptos/poolsJob.js +2 -2
  45. package/src/plugins/sushiswap/aptos/poolsJob.js.map +1 -1
  46. package/src/plugins/symmetry/basketsJob.js +2 -2
  47. package/src/plugins/symmetry/basketsJob.js.map +1 -1
  48. package/src/plugins/tulip/lendingTokensJob.js +2 -2
  49. package/src/plugins/tulip/lendingTokensJob.js.map +1 -1
  50. package/src/plugins/tulip/strategyTokensJob.js +2 -2
  51. package/src/plugins/tulip/strategyTokensJob.js.map +1 -1
  52. package/src/utils/clmm/tokenPricesFromSqrt.js +11 -4
  53. package/src/utils/clmm/tokenPricesFromSqrt.js.map +1 -1
  54. package/src/utils/misc/getLpTokenSource.d.ts +13 -9
  55. package/src/utils/misc/getLpTokenSource.js +29 -8
  56. package/src/utils/misc/getLpTokenSource.js.map +1 -1
  57. package/src/utils/misc/getLpTokenSourceOld.d.ts +18 -0
  58. package/src/utils/misc/getLpTokenSourceOld.js +32 -0
  59. package/src/utils/misc/getLpTokenSourceOld.js.map +1 -0
  60. package/src/utils/misc/getLpTokenSourceRaw.d.ts +16 -5
  61. package/src/utils/misc/getLpTokenSourceRaw.js +22 -6
  62. package/src/utils/misc/getLpTokenSourceRaw.js.map +1 -1
  63. package/src/utils/misc/getLpTokenSourceRawOld.d.ts +25 -0
  64. package/src/utils/misc/getLpTokenSourceRawOld.js +20 -0
  65. package/src/utils/misc/getLpTokenSourceRawOld.js.map +1 -0
  66. package/src/utils/misc/getLpUnderlyingTokenSource.d.ts +14 -18
  67. package/src/utils/misc/getLpUnderlyingTokenSource.js +101 -70
  68. package/src/utils/misc/getLpUnderlyingTokenSource.js.map +1 -1
  69. package/src/utils/misc/getLpUnderlyingTokenSourceOld.d.ts +26 -0
  70. package/src/utils/misc/getLpUnderlyingTokenSourceOld.js +73 -0
  71. package/src/utils/misc/getLpUnderlyingTokenSourceOld.js.map +1 -0
  72. package/src/plugins/marginfi/fetcherExecutor.d.ts +0 -3
  73. package/src/plugins/marginfi/jobExecutor.d.ts +0 -3
  74. package/src/plugins/marginfi/jobExecutor.js.map +0 -1
@@ -3,80 +3,111 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.defaultAcceptedPairs = void 0;
6
+ exports.getLpUnderlyingTokenSource = exports.defaultAcceptedPairs = void 0;
7
7
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
8
- const getSourceWeight_1 = __importDefault(require("./getSourceWeight"));
9
8
  const constants_1 = require("../../plugins/tokens/constants");
10
- exports.defaultAcceptedPairs = [
11
- // Sei Addresses
12
- portfolio_core_1.seiNativeAddress,
13
- 'ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518', // OSMO
14
- 'factory/sei189adguawugk3e55zn63z8r9ll29xrjwca636ra7v7gxuzn98sxyqwzt47l/Hq4tuDzhRBnxw3tFA5n6M52NVMVcC19XggbyDiJKCD6H', // USDCet
15
- // Solana Addresses
16
- portfolio_core_1.solanaNativeAddress,
17
- portfolio_core_1.solanaNativeWrappedAddress,
18
- 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
19
- 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
20
- // Aptos Addresses
21
- portfolio_core_1.aptosNativeAddress,
22
- '0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T', // USDCet
23
- '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD', // MOD (Move Dollar)
24
- // Sui addresses
25
- portfolio_core_1.suiNativeAddress,
26
- '0x2::sui::SUI',
27
- '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', // USDCet
28
- '0x6864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS', // CETUS
29
- ];
30
- function getLpUnderlyingTokenSource(sourceId, networkId, poolUnderlyingsA, poolUnderlyingsB, minTvl = 5000, acceptedPairs = exports.defaultAcceptedPairs) {
31
- var _a, _b;
32
- if (!poolUnderlyingsA.tokenPrice && !poolUnderlyingsB.tokenPrice)
33
- return null;
34
- if (((_a = poolUnderlyingsA.tokenPrice) === null || _a === void 0 ? void 0 : _a.price) === 0)
35
- return null;
36
- if (((_b = poolUnderlyingsB.tokenPrice) === null || _b === void 0 ? void 0 : _b.price) === 0)
37
- return null;
38
- const isAcceptedTokenA = acceptedPairs.includes(poolUnderlyingsA.address);
39
- const isAcceptedTokenB = acceptedPairs.includes(poolUnderlyingsB.address);
40
- if (isAcceptedTokenA && isAcceptedTokenB)
41
- return null;
9
+ const getSourceWeight_1 = __importDefault(require("./getSourceWeight"));
10
+ exports.defaultAcceptedPairs = new Map([
11
+ [
12
+ portfolio_core_1.NetworkId.sei,
13
+ [
14
+ portfolio_core_1.seiNativeAddress,
15
+ 'ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518', // OSMO
16
+ 'factory/sei189adguawugk3e55zn63z8r9ll29xrjwca636ra7v7gxuzn98sxyqwzt47l/Hq4tuDzhRBnxw3tFA5n6M52NVMVcC19XggbyDiJKCD6H', // USDCet
17
+ ].map((a) => (0, portfolio_core_1.formatTokenAddress)(a, portfolio_core_1.NetworkId.sei)),
18
+ ],
19
+ [
20
+ portfolio_core_1.NetworkId.solana,
21
+ [
22
+ portfolio_core_1.solanaNativeAddress,
23
+ portfolio_core_1.solanaNativeWrappedAddress,
24
+ 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
25
+ 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
26
+ ].map((a) => (0, portfolio_core_1.formatTokenAddress)(a, portfolio_core_1.NetworkId.solana)),
27
+ ],
28
+ [
29
+ portfolio_core_1.NetworkId.aptos,
30
+ [
31
+ portfolio_core_1.aptosNativeAddress,
32
+ '0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T', // USDCet
33
+ '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD', // MOD (Move Dollar)
34
+ ].map((a) => (0, portfolio_core_1.formatTokenAddress)(a, portfolio_core_1.NetworkId.aptos)),
35
+ ],
36
+ [
37
+ portfolio_core_1.NetworkId.sui,
38
+ [
39
+ portfolio_core_1.suiNativeAddress,
40
+ '0x2::sui::SUI',
41
+ '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', // USDCet
42
+ '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', // USDCet
43
+ ].map((a) => (0, portfolio_core_1.formatTokenAddress)(a, portfolio_core_1.NetworkId.sui)),
44
+ ],
45
+ ]);
46
+ function getLpUnderlyingTokenSource(params) {
47
+ let { platformId, acceptedPairs, minReserveValue } = params;
48
+ const { networkId, poolUnderlyings, sourceId } = params;
49
+ if (!platformId)
50
+ platformId = constants_1.walletTokensPlatform.id;
51
+ if (!acceptedPairs)
52
+ acceptedPairs = exports.defaultAcceptedPairs.get(networkId);
53
+ if (acceptedPairs === undefined)
54
+ return [];
55
+ if (acceptedPairs.length === 0)
56
+ return [];
57
+ if (!minReserveValue)
58
+ minReserveValue = 2500;
59
+ const totalWeight = poolUnderlyings.reduce((partialSum, p) => partialSum + p.weight, 0);
60
+ if (totalWeight > 1.02)
61
+ throw new Error('Weights greater than 1');
62
+ if (totalWeight < 0.98)
63
+ throw new Error('Weights are less than 1');
42
64
  let knownUnderlaying;
43
- let unknownUnderlaying;
44
- if (poolUnderlyingsA.tokenPrice && isAcceptedTokenA) {
45
- knownUnderlaying = poolUnderlyingsA;
46
- unknownUnderlaying = poolUnderlyingsB;
47
- }
48
- else if (poolUnderlyingsB.tokenPrice && isAcceptedTokenB) {
49
- knownUnderlaying = poolUnderlyingsB;
50
- unknownUnderlaying = poolUnderlyingsA;
65
+ const fAddresses = poolUnderlyings.map((u) => (0, portfolio_core_1.formatTokenAddress)(u.address, networkId));
66
+ let knownReserveValue;
67
+ for (let i = 0; i < poolUnderlyings.length; i++) {
68
+ const u = poolUnderlyings[i];
69
+ if (!u.tokenPrice)
70
+ continue;
71
+ if (!acceptedPairs.includes(fAddresses[i]))
72
+ continue;
73
+ const reserveValue = u.tokenPrice.price * u.reserveAmount;
74
+ if (knownUnderlaying &&
75
+ knownReserveValue &&
76
+ knownReserveValue > reserveValue)
77
+ continue;
78
+ knownUnderlaying = u;
79
+ knownReserveValue = reserveValue;
51
80
  }
52
- if (!knownUnderlaying || !unknownUnderlaying)
53
- return null;
54
- if (unknownUnderlaying.tokenPrice &&
55
- unknownUnderlaying.tokenPrice.sources.some((source) => source.id === portfolio_core_1.coingeckoSourceId)) {
56
- return null;
81
+ if (!knownUnderlaying || !knownReserveValue)
82
+ return [];
83
+ if (knownReserveValue < minReserveValue)
84
+ return [];
85
+ const knownUnderlayingAddress = (0, portfolio_core_1.formatTokenAddress)(knownUnderlaying.address, networkId);
86
+ const sources = [];
87
+ for (let i = 0; i < poolUnderlyings.length; i++) {
88
+ const u = poolUnderlyings[i];
89
+ if (knownUnderlayingAddress === fAddresses[i])
90
+ continue;
91
+ if (acceptedPairs.includes(fAddresses[i]))
92
+ continue;
93
+ if (u.tokenPrice &&
94
+ u.tokenPrice.sources.some((s) => s.id === portfolio_core_1.coingeckoSourceId))
95
+ continue;
96
+ const price = ((u.weight / knownUnderlaying.weight) * knownReserveValue) /
97
+ u.reserveAmount;
98
+ const source = {
99
+ id: sourceId,
100
+ networkId,
101
+ platformId: constants_1.walletTokensPlatform.id,
102
+ address: fAddresses[i],
103
+ decimals: u.decimals,
104
+ price,
105
+ weight: (0, getSourceWeight_1.default)(knownReserveValue),
106
+ timestamp: Date.now(),
107
+ };
108
+ sources.push(source);
57
109
  }
58
- const knownReserveAmount = knownUnderlaying.reserveAmountRaw
59
- .div(Math.pow(10, knownUnderlaying.decimals))
60
- .toNumber();
61
- const knownReserveValue = knownReserveAmount * knownUnderlaying.tokenPrice.price;
62
- const poolTvl = knownReserveValue * 2;
63
- if (minTvl > poolTvl)
64
- return null;
65
- const unknownReserveAmount = unknownUnderlaying.reserveAmountRaw
66
- .div(Math.pow(10, unknownUnderlaying.decimals))
67
- .toNumber();
68
- const price = knownReserveValue / unknownReserveAmount;
69
- const source = {
70
- id: sourceId,
71
- networkId,
72
- platformId: constants_1.walletTokensPlatform.id,
73
- address: unknownUnderlaying.address,
74
- decimals: unknownUnderlaying.decimals,
75
- price,
76
- weight: (0, getSourceWeight_1.default)(poolTvl),
77
- timestamp: Date.now(),
78
- };
79
- return source;
110
+ return sources;
80
111
  }
81
- exports.default = getLpUnderlyingTokenSource;
112
+ exports.getLpUnderlyingTokenSource = getLpUnderlyingTokenSource;
82
113
  //# sourceMappingURL=getLpUnderlyingTokenSource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLpUnderlyingTokenSource.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLpUnderlyingTokenSource.ts"],"names":[],"mappings":";;;;;;AAAA,+DAUoC;AAEpC,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E,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AA3DD,6CA2DC"}
1
+ {"version":3,"file":"getLpUnderlyingTokenSource.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLpUnderlyingTokenSource.ts"],"names":[],"mappings":";;;;;;AAAA,+DAYoC;AACpC,8DAAsE;AACtE,wEAAgD;AAEnC,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAA0B;IACnE;QACE,0BAAS,CAAC,GAAG;QACb;YACE,iCAAgB;YAChB,sEAAsE,EAAE,OAAO;YAC/E,qHAAqH,EAAE,SAAS;SACjI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mCAAkB,EAAC,CAAC,EAAE,0BAAS,CAAC,GAAG,CAAC,CAAC;KACnD;IACD;QACE,0BAAS,CAAC,MAAM;QAChB;YACE,oCAAmB;YACnB,2CAA0B;YAC1B,8CAA8C,EAAE,OAAO;YACvD,8CAA8C,EAAE,OAAO;SACxD,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mCAAkB,EAAC,CAAC,EAAE,0BAAS,CAAC,MAAM,CAAC,CAAC;KACtD;IACD;QACE,0BAAS,CAAC,KAAK;QACf;YACE,mCAAkB;YAClB,6EAA6E,EAAE,SAAS;YACxF,mFAAmF,EAAE,oBAAoB;SAC1G,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mCAAkB,EAAC,CAAC,EAAE,0BAAS,CAAC,KAAK,CAAC,CAAC;KACrD;IACD;QACE,0BAAS,CAAC,GAAG;QACb;YACE,iCAAgB;YAChB,eAAe;YACf,gFAAgF,EAAE,SAAS;YAC3F,gFAAgF,EAAE,SAAS;SAC5F,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mCAAkB,EAAC,CAAC,EAAE,0BAAS,CAAC,GAAG,CAAC,CAAC;KACnD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,EAAE,QAAQ;YACZ,SAAS;YACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;YACnC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,KAAK;YACL,MAAM,EAAE,IAAA,yBAAe,EAAC,iBAAiB,CAAC;YAC1C,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA3ED,gEA2EC"}
@@ -0,0 +1,26 @@
1
+ import { NetworkIdType, TokenPrice, TokenPriceSource } from '@sonarwatch/portfolio-core';
2
+ import BigNumber from 'bignumber.js';
3
+ export type PoolData = {
4
+ id: string;
5
+ supply: BigNumber;
6
+ lpDecimals: number;
7
+ reserveTokenX: BigNumber;
8
+ reserveTokenY: BigNumber;
9
+ mintTokenX: string;
10
+ decimalX?: number;
11
+ mintTokenY: string;
12
+ decimalY?: number;
13
+ };
14
+ type PoolUnderlyingRaw = {
15
+ address: string;
16
+ reserveAmountRaw: BigNumber;
17
+ decimals: number;
18
+ tokenPrice: TokenPrice | undefined;
19
+ weight: number;
20
+ };
21
+ /**
22
+ * @deprecated
23
+ * This function has been deprecated. Use the new getLpUnderlyingTokenSource instead.
24
+ */
25
+ export default function getLpUnderlyingTokenSourceOld(sourceId: string, networkId: NetworkIdType, poolUnderlyingsA: PoolUnderlyingRaw, poolUnderlyingsB: PoolUnderlyingRaw, minTvl?: number, acceptedPairs?: Map<NetworkIdType, string[]>): TokenPriceSource | null;
26
+ export {};
@@ -0,0 +1,73 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
7
+ const getSourceWeight_1 = __importDefault(require("./getSourceWeight"));
8
+ const constants_1 = require("../../plugins/tokens/constants");
9
+ const getLpUnderlyingTokenSource_1 = require("./getLpUnderlyingTokenSource");
10
+ /**
11
+ * @deprecated
12
+ * This function has been deprecated. Use the new getLpUnderlyingTokenSource instead.
13
+ */
14
+ function getLpUnderlyingTokenSourceOld(sourceId, networkId, poolUnderlyingsA, poolUnderlyingsB, minTvl = 2000, acceptedPairs = getLpUnderlyingTokenSource_1.defaultAcceptedPairs) {
15
+ var _a, _b, _c, _d, _e, _f;
16
+ if (poolUnderlyingsA.weight + poolUnderlyingsB.weight > 1.02)
17
+ throw new Error('Weights greater than 1');
18
+ if (poolUnderlyingsA.weight + poolUnderlyingsB.weight < 0.98)
19
+ throw new Error('Weights are less than 1');
20
+ if (!poolUnderlyingsA.tokenPrice && !poolUnderlyingsB.tokenPrice)
21
+ return null;
22
+ if (((_a = poolUnderlyingsA.tokenPrice) === null || _a === void 0 ? void 0 : _a.price) === 0)
23
+ return null;
24
+ if (((_b = poolUnderlyingsB.tokenPrice) === null || _b === void 0 ? void 0 : _b.price) === 0)
25
+ return null;
26
+ const isAcceptedTokenA = (_d = (_c = acceptedPairs
27
+ .get(networkId)) === null || _c === void 0 ? void 0 : _c.includes((0, portfolio_core_1.formatTokenAddress)(poolUnderlyingsA.address, networkId))) !== null && _d !== void 0 ? _d : false;
28
+ const isAcceptedTokenB = (_f = (_e = acceptedPairs
29
+ .get(networkId)) === null || _e === void 0 ? void 0 : _e.includes((0, portfolio_core_1.formatTokenAddress)(poolUnderlyingsB.address, networkId))) !== null && _f !== void 0 ? _f : false;
30
+ if (isAcceptedTokenA && isAcceptedTokenB)
31
+ return null;
32
+ let knownUnderlaying;
33
+ let unknownUnderlaying;
34
+ if (poolUnderlyingsA.tokenPrice && isAcceptedTokenA) {
35
+ knownUnderlaying = poolUnderlyingsA;
36
+ unknownUnderlaying = poolUnderlyingsB;
37
+ }
38
+ else if (poolUnderlyingsB.tokenPrice && isAcceptedTokenB) {
39
+ knownUnderlaying = poolUnderlyingsB;
40
+ unknownUnderlaying = poolUnderlyingsA;
41
+ }
42
+ if (!knownUnderlaying || !unknownUnderlaying)
43
+ return null;
44
+ if (unknownUnderlaying.tokenPrice &&
45
+ unknownUnderlaying.tokenPrice.sources.some((source) => source.id === portfolio_core_1.coingeckoSourceId)) {
46
+ return null;
47
+ }
48
+ const knownReserveAmount = knownUnderlaying.reserveAmountRaw
49
+ .div(Math.pow(10, knownUnderlaying.decimals))
50
+ .toNumber();
51
+ const knownReserveValue = knownReserveAmount * knownUnderlaying.tokenPrice.price;
52
+ if (minTvl > knownReserveValue)
53
+ return null;
54
+ const unknownReserveAmount = unknownUnderlaying.reserveAmountRaw
55
+ .div(Math.pow(10, unknownUnderlaying.decimals))
56
+ .toNumber();
57
+ const price = ((unknownUnderlaying.weight / knownUnderlaying.weight) *
58
+ knownReserveValue) /
59
+ unknownReserveAmount;
60
+ const source = {
61
+ id: sourceId,
62
+ networkId,
63
+ platformId: constants_1.walletTokensPlatform.id,
64
+ address: (0, portfolio_core_1.formatTokenAddress)(unknownUnderlaying.address, networkId),
65
+ decimals: unknownUnderlaying.decimals,
66
+ price,
67
+ weight: (0, getSourceWeight_1.default)(knownReserveValue),
68
+ timestamp: Date.now(),
69
+ };
70
+ return source;
71
+ }
72
+ exports.default = getLpUnderlyingTokenSourceOld;
73
+ //# sourceMappingURL=getLpUnderlyingTokenSourceOld.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLpUnderlyingTokenSourceOld.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLpUnderlyingTokenSourceOld.ts"],"names":[],"mappings":";;;;;AAAA,+DAMoC;AAEpC,wEAAgD;AAChD,8DAAsE;AACtE,6EAAoE;AA0BpE;;;GAGG;AACH,SAAwB,6BAA6B,CACnD,QAAgB,EAChB,SAAwB,EACxB,gBAAmC,EACnC,gBAAmC,EACnC,MAAM,GAAG,IAAI,EACb,aAAa,GAAG,iDAAoB;;IAEpC,IA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AChB,CAAC;AA1ED,gDA0EC"}
@@ -1,3 +0,0 @@
1
- import { FetcherExecutor } from '../../Fetcher';
2
- declare const fetcherExecutor: FetcherExecutor;
3
- export default fetcherExecutor;
@@ -1,3 +0,0 @@
1
- import { JobExecutor } from '../../Job';
2
- declare const jobExecutor: JobExecutor;
3
- export default jobExecutor;
@@ -1 +0,0 @@
1
- {"version":3,"file":"jobExecutor.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/jobExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AACpC,2CAAkE;AAClE,yCAA4C;AAC5C,uCAAyC;AACzC,uCAAuE;AACvE,+CAA8D;AAC9D,iDAAsD;AAItD,MAAM,WAAW,GAAgB,CAAO,KAAY,EAAE,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,YAAY,GAAG,MAAM,IAAA,iCAAwB,EACjD,UAAU,EACV,iBAAU,EACV,2BAAe,EACf,IAAA,sBAAY,GAAE,CACf,CAAC;IAEF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,KAAK,CAAC,OAAO,CACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,kCAEjB,IAAI,KACP,sBAAsB,EAAE,IAAA,kCAAwB,EAC9C,IAAI,CAAC,eAAe,CACrB,CAAC,GAAG,CAAC,SAAA,EAAE,EAAI,IAAI,CAAC,YAAY,CAAA,CAAC,EAC9B,0BAA0B,EAAE,IAAA,kCAAwB,EAClD,IAAI,CAAC,mBAAmB,CACzB,CAAC,GAAG,CAAC,SAAA,EAAE,EAAI,IAAI,CAAC,YAAY,CAAA,CAAC,KAEhC;YACE,MAAM,EAAN,kBAAM;YACN,SAAS,EAAE,0BAAS,CAAC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