@defisaver/positions-sdk 0.0.166-dev → 0.0.166-dev10-liquity-v2

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.
Files changed (158) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +69 -69
  4. package/cjs/config/contracts.d.ts +7 -45
  5. package/cjs/config/contracts.js +3 -3
  6. package/cjs/contracts.d.ts +1 -1
  7. package/cjs/contracts.js +2 -2
  8. package/cjs/helpers/index.d.ts +1 -1
  9. package/cjs/helpers/index.js +2 -2
  10. package/cjs/helpers/liquityV2Helpers/index.d.ts +12 -0
  11. package/cjs/helpers/liquityV2Helpers/index.js +63 -0
  12. package/cjs/index.d.ts +2 -2
  13. package/cjs/index.js +3 -3
  14. package/cjs/liquityV2/index.d.ts +16 -0
  15. package/cjs/liquityV2/index.js +139 -0
  16. package/cjs/markets/compound/marketsAssets.js +3 -3
  17. package/cjs/markets/index.d.ts +1 -1
  18. package/cjs/markets/index.js +3 -3
  19. package/cjs/markets/liquityV2/index.d.ts +8 -0
  20. package/cjs/markets/liquityV2/index.js +34 -0
  21. package/cjs/markets/morphoBlue/index.d.ts +4 -0
  22. package/cjs/markets/morphoBlue/index.js +36 -1
  23. package/cjs/markets/spark/marketAssets.js +1 -1
  24. package/cjs/moneymarket/moneymarketCommonService.js +1 -1
  25. package/cjs/services/utils.d.ts +0 -2
  26. package/cjs/services/utils.js +1 -4
  27. package/cjs/staking/staking.d.ts +1 -0
  28. package/cjs/staking/staking.js +31 -2
  29. package/cjs/types/contracts/generated/LiquityV2View.d.ts +240 -0
  30. package/cjs/types/contracts/generated/index.d.ts +1 -1
  31. package/cjs/types/index.d.ts +1 -1
  32. package/cjs/types/index.js +1 -1
  33. package/cjs/types/liquityV2.d.ts +90 -0
  34. package/cjs/types/liquityV2.js +8 -0
  35. package/cjs/types/morphoBlue.d.ts +3 -1
  36. package/cjs/types/morphoBlue.js +2 -0
  37. package/esm/config/contracts.d.ts +7 -45
  38. package/esm/config/contracts.js +3 -3
  39. package/esm/contracts.d.ts +1 -1
  40. package/esm/contracts.js +1 -1
  41. package/esm/helpers/index.d.ts +1 -1
  42. package/esm/helpers/index.js +1 -1
  43. package/esm/helpers/liquityV2Helpers/index.d.ts +12 -0
  44. package/esm/helpers/liquityV2Helpers/index.js +55 -0
  45. package/esm/index.d.ts +2 -2
  46. package/esm/index.js +2 -2
  47. package/esm/liquityV2/index.d.ts +16 -0
  48. package/esm/liquityV2/index.js +129 -0
  49. package/esm/markets/compound/marketsAssets.js +3 -3
  50. package/esm/markets/index.d.ts +1 -1
  51. package/esm/markets/index.js +1 -1
  52. package/esm/markets/liquityV2/index.d.ts +8 -0
  53. package/esm/markets/liquityV2/index.js +28 -0
  54. package/esm/markets/morphoBlue/index.d.ts +4 -0
  55. package/esm/markets/morphoBlue/index.js +33 -0
  56. package/esm/markets/spark/marketAssets.js +1 -1
  57. package/esm/moneymarket/moneymarketCommonService.js +1 -1
  58. package/esm/services/utils.d.ts +0 -2
  59. package/esm/services/utils.js +0 -2
  60. package/esm/staking/staking.d.ts +1 -0
  61. package/esm/staking/staking.js +29 -1
  62. package/esm/types/contracts/generated/LiquityV2View.d.ts +240 -0
  63. package/esm/types/contracts/generated/index.d.ts +1 -1
  64. package/esm/types/index.d.ts +1 -1
  65. package/esm/types/index.js +1 -1
  66. package/esm/types/liquityV2.d.ts +90 -0
  67. package/esm/types/liquityV2.js +5 -0
  68. package/esm/types/morphoBlue.d.ts +3 -1
  69. package/esm/types/morphoBlue.js +2 -0
  70. package/package.json +49 -44
  71. package/src/aaveV2/index.ts +227 -227
  72. package/src/aaveV3/index.ts +590 -590
  73. package/src/assets/index.ts +60 -60
  74. package/src/chickenBonds/index.ts +123 -123
  75. package/src/compoundV2/index.ts +219 -219
  76. package/src/compoundV3/index.ts +281 -281
  77. package/src/config/contracts.js +1040 -1040
  78. package/src/constants/index.ts +6 -6
  79. package/src/contracts.ts +130 -130
  80. package/src/curveUsd/index.ts +229 -229
  81. package/src/exchange/index.ts +17 -17
  82. package/src/helpers/aaveHelpers/index.ts +194 -194
  83. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  84. package/src/helpers/compoundHelpers/index.ts +246 -246
  85. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  86. package/src/helpers/index.ts +9 -9
  87. package/src/helpers/liquityV2Helpers/index.ts +80 -0
  88. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  89. package/src/helpers/makerHelpers/index.ts +94 -94
  90. package/src/helpers/morphoBlueHelpers/index.ts +115 -115
  91. package/src/helpers/sparkHelpers/index.ts +150 -150
  92. package/src/index.ts +48 -48
  93. package/src/liquity/index.ts +116 -116
  94. package/src/liquityV2/index.ts +159 -0
  95. package/src/llamaLend/index.ts +275 -275
  96. package/src/maker/index.ts +117 -117
  97. package/src/markets/aave/index.ts +152 -152
  98. package/src/markets/aave/marketAssets.ts +46 -46
  99. package/src/markets/compound/index.ts +173 -173
  100. package/src/markets/compound/marketsAssets.ts +64 -64
  101. package/src/markets/curveUsd/index.ts +69 -69
  102. package/src/markets/index.ts +23 -24
  103. package/src/markets/liquityV2/index.ts +31 -0
  104. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  105. package/src/markets/llamaLend/index.ts +235 -235
  106. package/src/markets/morphoBlue/index.ts +728 -691
  107. package/src/markets/spark/index.ts +29 -29
  108. package/src/markets/spark/marketAssets.ts +10 -10
  109. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  110. package/src/morphoAaveV2/index.ts +256 -256
  111. package/src/morphoAaveV3/index.ts +630 -630
  112. package/src/morphoBlue/index.ts +171 -171
  113. package/src/multicall/index.ts +22 -22
  114. package/src/services/dsrService.ts +15 -15
  115. package/src/services/priceService.ts +21 -21
  116. package/src/services/utils.ts +54 -57
  117. package/src/setup.ts +8 -8
  118. package/src/spark/index.ts +424 -424
  119. package/src/staking/staking.ts +218 -189
  120. package/src/types/aave.ts +262 -262
  121. package/src/types/chickenBonds.ts +45 -45
  122. package/src/types/common.ts +84 -84
  123. package/src/types/compound.ts +129 -129
  124. package/src/types/contracts/generated/LiquityV2View.ts +311 -0
  125. package/src/types/contracts/generated/index.ts +1 -1
  126. package/src/types/curveUsd.ts +118 -118
  127. package/src/types/index.ts +10 -10
  128. package/src/types/liquity.ts +30 -30
  129. package/src/types/liquityV2.ts +96 -0
  130. package/src/types/llamaLend.ts +155 -155
  131. package/src/types/maker.ts +50 -50
  132. package/src/types/morphoBlue.ts +146 -144
  133. package/src/types/spark.ts +127 -127
  134. package/cjs/eulerV2/index.d.ts +0 -40
  135. package/cjs/eulerV2/index.js +0 -207
  136. package/cjs/helpers/eulerHelpers/index.d.ts +0 -27
  137. package/cjs/helpers/eulerHelpers/index.js +0 -232
  138. package/cjs/markets/euler/index.d.ts +0 -10
  139. package/cjs/markets/euler/index.js +0 -41
  140. package/cjs/types/contracts/generated/EulerV2View.d.ts +0 -333
  141. package/cjs/types/euler.d.ts +0 -148
  142. package/cjs/types/euler.js +0 -15
  143. package/esm/eulerV2/index.d.ts +0 -40
  144. package/esm/eulerV2/index.js +0 -199
  145. package/esm/helpers/eulerHelpers/index.d.ts +0 -27
  146. package/esm/helpers/eulerHelpers/index.js +0 -219
  147. package/esm/markets/euler/index.d.ts +0 -10
  148. package/esm/markets/euler/index.js +0 -34
  149. package/esm/types/contracts/generated/EulerV2View.d.ts +0 -333
  150. package/esm/types/euler.d.ts +0 -148
  151. package/esm/types/euler.js +0 -12
  152. package/src/eulerV2/index.ts +0 -286
  153. package/src/helpers/eulerHelpers/index.ts +0 -231
  154. package/src/markets/euler/index.ts +0 -38
  155. package/src/types/contracts/generated/EulerV2View.ts +0 -434
  156. package/src/types/euler.ts +0 -171
  157. /package/cjs/types/contracts/generated/{EulerV2View.js → LiquityV2View.js} +0 -0
  158. /package/esm/types/contracts/generated/{EulerV2View.js → LiquityV2View.js} +0 -0
@@ -454,6 +454,21 @@ export const MORPHO_BLUE_USDE_DAI_945 = (networkId = NetworkNumber.Eth) => ({
454
454
  marketId: '0xdb760246f6859780f6c1b272d47a8f64710777121118e56e0cdb4b8b744a3094',
455
455
  protocolName: 'morpho-blue',
456
456
  });
457
+ export const MORPHO_BLUE_RETH_ETH_945 = (networkId = NetworkNumber.Eth) => ({
458
+ chainIds: [1],
459
+ label: 'Morpho',
460
+ shortLabel: 'rETH/ETH',
461
+ value: MorphoBlueVersions.MorphoBlueREthEth_945,
462
+ url: 'retheth-3c83f77b',
463
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
464
+ collateralToken: '0xae78736Cd615f374D3085123A210448E74Fc6393',
465
+ oracle: '0x1b4A3F92e5Fffd1d35A98751c9FE4472483579bB',
466
+ oracleType: MorphoBlueOracleType.MARKET_RATE,
467
+ irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
468
+ lltv: 0.945,
469
+ marketId: '0x3c83f77bde9541f8d3d82533b19bbc1f97eb2f1098bb991728acbfbede09cc5d',
470
+ protocolName: 'morpho-blue',
471
+ });
457
472
  // BASE
458
473
  export const MORPHO_BLUE_CBETH_USDC_860_BASE = (networkId = NetworkNumber.Eth) => ({
459
474
  chainIds: [NetworkNumber.Base],
@@ -620,6 +635,21 @@ export const MORPHO_BLUE_CBBTC_USDC_860_BASE = (networkId = NetworkNumber.Eth) =
620
635
  marketId: '0x9103c3b4e834476c9a62ea009ba2c884ee42e94e6e314a26f04d312434191836',
621
636
  protocolName: 'morpho-blue',
622
637
  });
638
+ export const MORPHO_BLUE_WSUPEROETHB_WETH_915_BASE = (networkId = NetworkNumber.Eth) => ({
639
+ chainIds: [NetworkNumber.Base],
640
+ label: 'Morpho',
641
+ shortLabel: 'wsuperOETHb/WETH',
642
+ value: MorphoBlueVersions.MorphoBlueWsuperOETHbWETH_915_Base,
643
+ url: 'wsuperoethbweth-144bf18d',
644
+ loanToken: '0x4200000000000000000000000000000000000006',
645
+ collateralToken: '0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6',
646
+ oracle: '0x28C964c985fe84736fAdc7Cf0bBd58B54bc7CF93',
647
+ oracleType: MorphoBlueOracleType.MARKET_RATE,
648
+ irm: '0x46415998764C29aB2a25CbeA6254146D50D22687',
649
+ lltv: 0.915,
650
+ marketId: '0x144bf18d6bf4c59602548a825034f73bf1d20177fc5f975fc69d5a5eba929b45',
651
+ protocolName: 'morpho-blue',
652
+ });
623
653
  export const MorphoBlueMarkets = (networkId) => ({
624
654
  [MorphoBlueVersions.MorphoBlueWstEthUSDC]: MORPHO_BLUE_WSTETH_USDC(networkId),
625
655
  [MorphoBlueVersions.MorphoBlueSDAIUSDC]: MORPHO_BLUE_SDAI_USDC(networkId),
@@ -640,6 +670,7 @@ export const MorphoBlueMarkets = (networkId) => ({
640
670
  [MorphoBlueVersions.MorphoBlueTBTCUSDC]: MORPHO_BLUE_TBTC_USDC(networkId),
641
671
  [MorphoBlueVersions.MorphoBlueCbBTCEth_915]: MORPHO_BLUE_CBBTC_ETH_915(networkId),
642
672
  [MorphoBlueVersions.MorphoBlueCbBTCUSDC_860]: MORPHO_BLUE_CBBTC_USDC_860(networkId),
673
+ [MorphoBlueVersions.MorphoBlueREthEth_945]: MORPHO_BLUE_RETH_ETH_945(networkId),
643
674
  // wstETH/WETH
644
675
  [MorphoBlueVersions.MorphoBlueWstEthEth_945]: MORPHO_BLUE_WSTETH_ETH_945(networkId),
645
676
  [MorphoBlueVersions.MorphoBlueWstEthEth_945_Exchange_Rate]: MORPHO_BLUE_WSTETH_ETH_945_EXCHANGE_RATE(networkId),
@@ -662,6 +693,8 @@ export const MorphoBlueMarkets = (networkId) => ({
662
693
  [MorphoBlueVersions.MorphoBlueREthEth_945_Base]: MORPHO_BLUE_RETH_ETH_945_BASE(networkId),
663
694
  [MorphoBlueVersions.MorphoBlueCbBTCEth_915_Base]: MORPHO_BLUE_CBBTC_ETH_915_BASE(networkId),
664
695
  [MorphoBlueVersions.MorphoBlueCbBTCUSDC_860_Base]: MORPHO_BLUE_CBBTC_USDC_860_BASE(networkId),
696
+ // wsuperOETHb/WETH Base
697
+ [MorphoBlueVersions.MorphoBlueWsuperOETHbWETH_915_Base]: MORPHO_BLUE_WSUPEROETHB_WETH_915_BASE(networkId),
665
698
  // cbETH/WETH Base
666
699
  [MorphoBlueVersions.MorphoBlueCbEthEth_945_Base]: MORPHO_BLUE_CBETH_ETH_945_BASE(networkId),
667
700
  [MorphoBlueVersions.MorphoBlueCbEthEth_965_Base]: MORPHO_BLUE_CBETH_ETH_965_BASE(networkId),
@@ -1,5 +1,5 @@
1
1
  import { NetworkNumber } from '../../types/common';
2
- export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC'];
2
+ export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS'];
3
3
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
4
4
  export const sparkAssetsDefaultMarket = {
5
5
  [NetworkNumber.Eth]: sparkAssetsDefaultMarketEth,
@@ -16,7 +16,7 @@ export const calcLeverageLiqPrice = (leverageType, assetPrice, borrowedUsd, borr
16
16
  return '0';
17
17
  };
18
18
  export const calculateBorrowingAssetLimit = (assetBorrowedUsd, borrowLimitUsd) => new Dec(assetBorrowedUsd).div(borrowLimitUsd).times(100).toString();
19
- export const STABLE_ASSETS = ['DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'crvUSD'];
19
+ export const STABLE_ASSETS = ['DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'crvUSD', 'BOLD'];
20
20
  export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
21
21
  let borrowUnstable = 0;
22
22
  let supplyStable = 0;
@@ -20,5 +20,3 @@ export declare const bytesToString: (hex: string) => string;
20
20
  */
21
21
  export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
22
22
  export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) => bigint;
23
- export declare const MAXUINT: string;
24
- export declare const isMaxuint: (amount: string) => boolean;
@@ -33,5 +33,3 @@ export const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
33
33
  };
34
34
  // eslint-disable-next-line no-bitwise
35
35
  export const isEnabledOnBitmap = (bitmap, assetId) => (BigInt(bitmap) >> BigInt(assetId)) & BigInt(1);
36
- export const MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
37
- export const isMaxuint = (amount) => compareAddresses(MAXUINT, amount);
@@ -4,6 +4,7 @@ export declare const getStETHApr: (web3: Web3, fromBlock?: number, blockNumber?:
4
4
  export declare const getCbETHApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
5
5
  export declare const getREthApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
6
6
  export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
7
+ export declare const getSsrApy: () => Promise<string>;
7
8
  export declare const STAKING_ASSETS: string[];
8
9
  export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<any> | "0" | undefined;
9
10
  export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
@@ -76,13 +76,37 @@ export const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, voi
76
76
  .mul(100)
77
77
  .toString();
78
78
  });
79
+ export const getSsrApy = () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const res = yield fetch('https://app.defisaver.com/api/sky/data');
81
+ const data = yield res.json();
82
+ return new Dec(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
83
+ });
84
+ const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
85
+ console.log('getSuperOETHApy');
86
+ const res = yield fetch('https://origin.squids.live/origin-squid/graphql', {
87
+ method: 'POST',
88
+ headers: {
89
+ 'Content-Type': 'application/json',
90
+ },
91
+ body: JSON.stringify({
92
+ query: '\n query OTokenApy($chainId: Int!, $token: String!) {\n oTokenApies(\n limit: 1\n orderBy: timestamp_DESC\n where: {chainId_eq: $chainId, otoken_containsInsensitive: $token}\n ) {\n apy7DayAvg\n apy14DayAvg\n apy30DayAvg\n apr\n apy\n }\n}\n ',
93
+ variables: {
94
+ token: '0xdbfefd2e8460a6ee4955a68582f85708baea60a3',
95
+ chainId: 8453,
96
+ },
97
+ }),
98
+ });
99
+ const data = yield res.json();
100
+ return new Dec(data.data.oTokenApies[0].apy).mul(100).toString();
101
+ });
79
102
  const getApyFromDfsApi = (asset) => __awaiter(void 0, void 0, void 0, function* () {
80
103
  const res = yield fetch(`https://app.defisaver.com/api/staking/apy?asset=${asset}`);
81
104
  const data = yield res.json();
82
105
  return data.apy;
83
106
  });
84
- export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH'];
107
+ export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
85
108
  export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
109
+ console.log('getStakingApy', asset, blockNumber, fromBlock);
86
110
  try {
87
111
  if (asset === 'stETH' || asset === 'wstETH')
88
112
  return getStETHApr(web3, fromBlock, blockNumber);
@@ -106,6 +130,10 @@ export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = u
106
130
  return getApyFromDfsApi('rsETH');
107
131
  if (asset === 'pufETH')
108
132
  return getApyFromDfsApi('pufETH');
133
+ if (asset === 'wsuperOETHb')
134
+ return getSuperOETHApy();
135
+ if (asset === 'sUSDS')
136
+ return getSsrApy();
109
137
  }
110
138
  catch (e) {
111
139
  console.error(`Failed to fetch APY for ${asset}`);
@@ -0,0 +1,240 @@
1
+ /// <reference types="node" />
2
+ import type BN from "bn.js";
3
+ import type { ContractOptions } from "web3-eth-contract";
4
+ import type { EventLog } from "web3-core";
5
+ import type { EventEmitter } from "events";
6
+ import type { Callback, NonPayableTransactionObject, BlockType, BaseContract } from "./types";
7
+ export interface EventOptions {
8
+ filter?: object;
9
+ fromBlock?: BlockType;
10
+ topics?: string[];
11
+ }
12
+ export declare namespace LiquityV2View {
13
+ type MarketDataStruct = [
14
+ string,
15
+ number | string | BN,
16
+ number | string | BN,
17
+ number | string | BN,
18
+ number | string | BN,
19
+ number | string | BN,
20
+ number | string | BN,
21
+ number | string | BN,
22
+ string,
23
+ string,
24
+ string,
25
+ string,
26
+ string,
27
+ string,
28
+ string,
29
+ string,
30
+ string,
31
+ number | string | BN,
32
+ boolean
33
+ ] | {
34
+ market: string;
35
+ CCR: number | string | BN;
36
+ MCR: number | string | BN;
37
+ SCR: number | string | BN;
38
+ LIQUIDATION_PENALTY_SP: number | string | BN;
39
+ LIQUIDATION_PENALTY_REDISTRIBUTION: number | string | BN;
40
+ entireSystemColl: number | string | BN;
41
+ entireSystemDebt: number | string | BN;
42
+ collToken: string;
43
+ troveNFT: string;
44
+ borrowerOperations: string;
45
+ troveManager: string;
46
+ stabilityPool: string;
47
+ sortedTroves: string;
48
+ collSurplusPool: string;
49
+ hintHelpers: string;
50
+ priceFeed: string;
51
+ collPrice: number | string | BN;
52
+ isShutDown: boolean;
53
+ };
54
+ type MarketDataStructOutputArray = [
55
+ string,
56
+ string,
57
+ string,
58
+ string,
59
+ string,
60
+ string,
61
+ string,
62
+ string,
63
+ string,
64
+ string,
65
+ string,
66
+ string,
67
+ string,
68
+ string,
69
+ string,
70
+ string,
71
+ string,
72
+ string,
73
+ boolean
74
+ ];
75
+ type MarketDataStructOutputStruct = {
76
+ market: string;
77
+ CCR: string;
78
+ MCR: string;
79
+ SCR: string;
80
+ LIQUIDATION_PENALTY_SP: string;
81
+ LIQUIDATION_PENALTY_REDISTRIBUTION: string;
82
+ entireSystemColl: string;
83
+ entireSystemDebt: string;
84
+ collToken: string;
85
+ troveNFT: string;
86
+ borrowerOperations: string;
87
+ troveManager: string;
88
+ stabilityPool: string;
89
+ sortedTroves: string;
90
+ collSurplusPool: string;
91
+ hintHelpers: string;
92
+ priceFeed: string;
93
+ collPrice: string;
94
+ isShutDown: boolean;
95
+ };
96
+ type MarketDataStructOutput = MarketDataStructOutputArray & MarketDataStructOutputStruct;
97
+ type TroveDataStruct = [
98
+ number | string | BN,
99
+ string,
100
+ string,
101
+ number | string | BN,
102
+ number | string | BN,
103
+ number | string | BN,
104
+ number | string | BN,
105
+ number | string | BN,
106
+ number | string | BN,
107
+ string,
108
+ number | string | BN
109
+ ] | {
110
+ troveId: number | string | BN;
111
+ owner: string;
112
+ collToken: string;
113
+ status: number | string | BN;
114
+ collAmount: number | string | BN;
115
+ debtAmount: number | string | BN;
116
+ collPrice: number | string | BN;
117
+ TCRatio: number | string | BN;
118
+ annualInterestRate: number | string | BN;
119
+ interestBatchManager: string;
120
+ batchDebtShares: number | string | BN;
121
+ };
122
+ type TroveDataStructOutputArray = [
123
+ string,
124
+ string,
125
+ string,
126
+ string,
127
+ string,
128
+ string,
129
+ string,
130
+ string,
131
+ string,
132
+ string,
133
+ string
134
+ ];
135
+ type TroveDataStructOutputStruct = {
136
+ troveId: string;
137
+ owner: string;
138
+ collToken: string;
139
+ status: string;
140
+ collAmount: string;
141
+ debtAmount: string;
142
+ collPrice: string;
143
+ TCRatio: string;
144
+ annualInterestRate: string;
145
+ interestBatchManager: string;
146
+ batchDebtShares: string;
147
+ };
148
+ type TroveDataStructOutput = TroveDataStructOutputArray & TroveDataStructOutputStruct;
149
+ type ExistingTroveStruct = [number | string | BN, boolean] | {
150
+ troveId: number | string | BN;
151
+ ownedByUser: boolean;
152
+ };
153
+ type ExistingTroveStructOutputArray = [string, boolean];
154
+ type ExistingTroveStructOutputStruct = {
155
+ troveId: string;
156
+ ownedByUser: boolean;
157
+ };
158
+ type ExistingTroveStructOutput = ExistingTroveStructOutputArray & ExistingTroveStructOutputStruct;
159
+ }
160
+ export interface LiquityV2View extends BaseContract {
161
+ constructor(jsonInterface: any[], address?: string, options?: ContractOptions): LiquityV2View;
162
+ clone(): LiquityV2View;
163
+ methods: {
164
+ findInsertPosition(_market: string, _interestRate: number | string | BN, _prevId: number | string | BN, _nextId: number | string | BN): NonPayableTransactionObject<[
165
+ string,
166
+ string
167
+ ] & {
168
+ prevId: string;
169
+ nextId: string;
170
+ }>;
171
+ getApproxHint(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
172
+ string,
173
+ string,
174
+ string
175
+ ] & {
176
+ hintId: string;
177
+ diff: string;
178
+ latestRandomSeed: string;
179
+ }>;
180
+ getDebtInFront(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
181
+ string,
182
+ string
183
+ ] & {
184
+ next: string;
185
+ debt: string;
186
+ }>;
187
+ getDebtInFrontByInterestRate(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN, _targetIR: number | string | BN): NonPayableTransactionObject<[
188
+ string,
189
+ string
190
+ ] & {
191
+ next: string;
192
+ debt: string;
193
+ }>;
194
+ getDebtInFrontByTroveNum(_market: string, _numTroves: number | string | BN): NonPayableTransactionObject<string>;
195
+ getDepositorInfo(_market: string, _depositor: string): NonPayableTransactionObject<[
196
+ string,
197
+ string,
198
+ string
199
+ ] & {
200
+ compoundedBOLD: string;
201
+ collGain: string;
202
+ boldGain: string;
203
+ }>;
204
+ getInsertPosition(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
205
+ string,
206
+ string
207
+ ] & {
208
+ prevId: string;
209
+ nextId: string;
210
+ }>;
211
+ getMarketData(_market: string): NonPayableTransactionObject<LiquityV2View.MarketDataStructOutput>;
212
+ getNumOfTrovesInFrontOfTrove(_market: string, _troveId: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
213
+ string,
214
+ string
215
+ ] & {
216
+ next: string;
217
+ numTroves: string;
218
+ }>;
219
+ getTroveInfo(_market: string, _troveId: number | string | BN): NonPayableTransactionObject<LiquityV2View.TroveDataStructOutput>;
220
+ getTrovePosition(_market: string, _collIndex: number | string | BN, _troveId: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
221
+ string,
222
+ string
223
+ ] & {
224
+ prevId: string;
225
+ nextId: string;
226
+ }>;
227
+ getUserTroves(_user: string, _market: string, _startIndex: number | string | BN, _endIndex: number | string | BN): NonPayableTransactionObject<[
228
+ LiquityV2View.ExistingTroveStructOutput[],
229
+ string
230
+ ] & {
231
+ troves: LiquityV2View.ExistingTroveStructOutput[];
232
+ nextFreeTroveIndex: string;
233
+ }>;
234
+ isShutDown(_market: string): NonPayableTransactionObject<boolean>;
235
+ predictAdjustTroveUpfrontFee(_market: string, _collIndex: number | string | BN, _troveId: number | string | BN, _debtIncrease: number | string | BN): NonPayableTransactionObject<string>;
236
+ };
237
+ events: {
238
+ allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
239
+ };
240
+ }
@@ -26,7 +26,6 @@ export type { CompoundLoanInfo } from "./CompoundLoanInfo";
26
26
  export type { Comptroller } from "./Comptroller";
27
27
  export type { ETHPriceFeed } from "./ETHPriceFeed";
28
28
  export type { Erc20 } from "./Erc20";
29
- export type { EulerV2View } from "./EulerV2View";
30
29
  export type { FeedRegistry } from "./FeedRegistry";
31
30
  export type { GHO } from "./GHO";
32
31
  export type { GhoDiscountRateStrategy } from "./GhoDiscountRateStrategy";
@@ -35,6 +34,7 @@ export type { IVariableDebtToken } from "./IVariableDebtToken";
35
34
  export type { LendingPoolAddressesProvider } from "./LendingPoolAddressesProvider";
36
35
  export type { Lido } from "./Lido";
37
36
  export type { LiquityActivePool } from "./LiquityActivePool";
37
+ export type { LiquityV2View } from "./LiquityV2View";
38
38
  export type { LiquityView } from "./LiquityView";
39
39
  export type { LlamaLendControllerAbi } from "./LlamaLendControllerAbi";
40
40
  export type { LlamaLendView } from "./LlamaLendView";
@@ -3,8 +3,8 @@ export * from './compound';
3
3
  export * from './spark';
4
4
  export * from './curveUsd';
5
5
  export * from './liquity';
6
+ export * from './liquityV2';
6
7
  export * from './maker';
7
8
  export * from './chickenBonds';
8
9
  export * from './morphoBlue';
9
10
  export * from './llamaLend';
10
- export * from './euler';
@@ -3,8 +3,8 @@ export * from './compound';
3
3
  export * from './spark';
4
4
  export * from './curveUsd';
5
5
  export * from './liquity';
6
+ export * from './liquityV2';
6
7
  export * from './maker';
7
8
  export * from './chickenBonds';
8
9
  export * from './morphoBlue';
9
10
  export * from './llamaLend';
10
- export * from './euler';
@@ -0,0 +1,90 @@
1
+ import { EthAddress, NetworkNumber } from './common';
2
+ export declare enum LiquityV2Versions {
3
+ LiquityV2Eth = "liquityv2eth",
4
+ LiquityV2WstEth = "liquityv2wsteth"
5
+ }
6
+ export interface LiquityV2MarketInfo {
7
+ chainIds: NetworkNumber[];
8
+ label: string;
9
+ shortLabel: string;
10
+ url: string;
11
+ value: LiquityV2Versions;
12
+ debtToken: string;
13
+ collateralToken: string;
14
+ marketAddress: string;
15
+ protocolName: string;
16
+ }
17
+ export interface LiquityV2AssetData {
18
+ symbol: string;
19
+ address: string;
20
+ price: string;
21
+ incentiveSupplyApy?: string;
22
+ incentiveSupplyToken?: string;
23
+ totalSupply: string;
24
+ totalBorrow: string;
25
+ canBeSupplied: boolean;
26
+ canBeBorrowed: boolean;
27
+ }
28
+ export type LiquityV2AssetsData = {
29
+ [key: string]: LiquityV2AssetData;
30
+ };
31
+ export interface InnerLiquityV2MarketData {
32
+ minCollRatio: string;
33
+ hintHelperAddress: EthAddress;
34
+ troveNFTAddress: EthAddress;
35
+ borrowerOperationsAddress: EthAddress;
36
+ troveManagerAddress: EthAddress;
37
+ stabilityPoolAddress: EthAddress;
38
+ collSurplusPoolAddress: EthAddress;
39
+ }
40
+ export interface LiquityV2MarketData {
41
+ assetsData: LiquityV2AssetsData;
42
+ marketData: InnerLiquityV2MarketData;
43
+ }
44
+ export interface LiquityV2UsedAsset {
45
+ symbol: string;
46
+ collateral?: boolean;
47
+ supplied: string;
48
+ suppliedUsd: string;
49
+ borrowed: string;
50
+ borrowedUsd: string;
51
+ isSupplied: boolean;
52
+ isBorrowed: boolean;
53
+ }
54
+ export type LiquityV2UsedAssets = {
55
+ [key: string]: LiquityV2UsedAsset;
56
+ };
57
+ export interface LiquityV2AggregatedTroveData {
58
+ suppliedUsd: string;
59
+ borrowedUsd: string;
60
+ borrowLimitUsd: string;
61
+ leftToBorrowUsd: string;
62
+ netApy: string;
63
+ incentiveUsd: string;
64
+ totalInterestUsd: string;
65
+ leveragedType: string;
66
+ leveragedAsset: string;
67
+ liquidationPrice: string;
68
+ ratio: string;
69
+ collRatio: string;
70
+ }
71
+ export interface LiquityV2TroveData {
72
+ usedAssets: LiquityV2UsedAssets;
73
+ troveId: string;
74
+ ratio: string;
75
+ collRatio: string;
76
+ interestRate: string;
77
+ leftToBorrowUsd: string;
78
+ borrowLimitUsd: string;
79
+ suppliedUsd: string;
80
+ borrowedUsd: string;
81
+ netApy: string;
82
+ incentiveUsd: string;
83
+ totalInterestUsd: string;
84
+ interestBatchManager: EthAddress;
85
+ troveStatus: string;
86
+ leveragedType: string;
87
+ leveragedAsset: string;
88
+ liquidationPrice: string;
89
+ debtInFront: string;
90
+ }
@@ -0,0 +1,5 @@
1
+ export var LiquityV2Versions;
2
+ (function (LiquityV2Versions) {
3
+ LiquityV2Versions["LiquityV2Eth"] = "liquityv2eth";
4
+ LiquityV2Versions["LiquityV2WstEth"] = "liquityv2wsteth";
5
+ })(LiquityV2Versions || (LiquityV2Versions = {}));
@@ -9,6 +9,7 @@ export declare enum MorphoBlueVersions {
9
9
  MorphoBlueWstEthUSDA_Exchange_Rate = "morphobluewstethusda_exchange_rate",
10
10
  MorphoBlueWstEthPYUSD = "morphobluwstethpyusd",
11
11
  MorphoBlueWeEthEth = "morphoblueweetheth",
12
+ MorphoBlueREthEth_945 = "morphoblueretheth_945",
12
13
  MorphoBlueWBTCPYUSD = "morphobluewbtcpyusd",
13
14
  MorphoBlueWBTCEth = "morphobluewbtceth",
14
15
  MorphoBlueUSDeUSDT = "morphoblueusdeusdt",
@@ -40,7 +41,8 @@ export declare enum MorphoBlueVersions {
40
41
  MorphoBlueREthUSDC_860_Base = "morphobluerethusdc_860_base",
41
42
  MorphoBlueREthEth_945_Base = "morphoblueretheth_945_base",
42
43
  MorphoBlueCbBTCEth_915_Base = "morphobluecbbtceth_915_base",
43
- MorphoBlueCbBTCUSDC_860_Base = "morphobluecbbtcusdc_860_base"
44
+ MorphoBlueCbBTCUSDC_860_Base = "morphobluecbbtcusdc_860_base",
45
+ MorphoBlueWsuperOETHbWETH_915_Base = "morphobluewsuperoethbweth_915_base"
44
46
  }
45
47
  export declare enum MorphoBlueOracleType {
46
48
  MARKET_RATE = "Market rate",
@@ -10,6 +10,7 @@ export var MorphoBlueVersions;
10
10
  MorphoBlueVersions["MorphoBlueWstEthUSDA_Exchange_Rate"] = "morphobluewstethusda_exchange_rate";
11
11
  MorphoBlueVersions["MorphoBlueWstEthPYUSD"] = "morphobluwstethpyusd";
12
12
  MorphoBlueVersions["MorphoBlueWeEthEth"] = "morphoblueweetheth";
13
+ MorphoBlueVersions["MorphoBlueREthEth_945"] = "morphoblueretheth_945";
13
14
  MorphoBlueVersions["MorphoBlueWBTCPYUSD"] = "morphobluewbtcpyusd";
14
15
  MorphoBlueVersions["MorphoBlueWBTCEth"] = "morphobluewbtceth";
15
16
  MorphoBlueVersions["MorphoBlueUSDeUSDT"] = "morphoblueusdeusdt";
@@ -46,6 +47,7 @@ export var MorphoBlueVersions;
46
47
  MorphoBlueVersions["MorphoBlueREthEth_945_Base"] = "morphoblueretheth_945_base";
47
48
  MorphoBlueVersions["MorphoBlueCbBTCEth_915_Base"] = "morphobluecbbtceth_915_base";
48
49
  MorphoBlueVersions["MorphoBlueCbBTCUSDC_860_Base"] = "morphobluecbbtcusdc_860_base";
50
+ MorphoBlueVersions["MorphoBlueWsuperOETHbWETH_915_Base"] = "morphobluewsuperoethbweth_915_base";
49
51
  })(MorphoBlueVersions || (MorphoBlueVersions = {}));
50
52
  export var MorphoBlueOracleType;
51
53
  (function (MorphoBlueOracleType) {
package/package.json CHANGED
@@ -1,44 +1,49 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "0.0.166-dev",
4
- "description": "",
5
- "main": "./cjs/index.js",
6
- "module": "./esm/index.js",
7
- "types": "./esm/index.d.ts",
8
- "scripts": {
9
- "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
- "build:cjs": "rm -rf cjs && tsc -p tsconfig.json",
11
- "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
- "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
- "lint": "eslint src/ --fix",
14
- "lint-check": "eslint src/",
15
- "generate-contracts": "node scripts/generateContracts.js",
16
- "test": "mocha tests/*",
17
- "test-single": "mocha ./tests/$npm_config_name.js",
18
- "test:debugger": "mocha --inspect-brk tests/*",
19
- "build-test": "npm run build && npm run test"
20
- },
21
- "keywords": [],
22
- "author": "",
23
- "license": "ISC",
24
- "dependencies": {
25
- "@defisaver/tokens": "^1.5.37",
26
- "@ethersproject/bignumber": "^5.7.0",
27
- "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
28
- "decimal.js": "^10.4.3"
29
- },
30
- "devDependencies": {
31
- "@defisaver/eslint-config": "^1.0.1",
32
- "chai": "^4.3.8",
33
- "dotenv": "^16.3.1",
34
- "eslint": "^8.49.0",
35
- "mocha": "^10.2.0",
36
- "ts-node": "^10.9.2",
37
- "typechain": "^8.3.1",
38
- "typechain-target-web3-v1-3mihai3": "^6.0.2",
39
- "typescript": "^5.2.2"
40
- },
41
- "peerDependencies": {
42
- "web3": "^1.10.2"
43
- }
44
- }
1
+ {
2
+ "name": "@defisaver/positions-sdk",
3
+ "version": "0.0.166-dev10-liquity-v2",
4
+ "description": "",
5
+ "main": "./cjs/index.js",
6
+ "module": "./esm/index.js",
7
+ "types": "./esm/index.d.ts",
8
+ "scripts": {
9
+ "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
+ "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
+ "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
+ "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
+ "lint": "eslint src/ --fix",
14
+ "lint-check": "eslint src/",
15
+ "generate-contracts": "node scripts/generateContracts.js",
16
+ "test": "mocha tests/liquityV2.ts",
17
+ "test-single": "mocha ./tests/$npm_config_name.ts",
18
+ "test:debugger": "mocha --inspect-brk tests/*",
19
+ "build-test": "npm run build && npm run test",
20
+ "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "@defisaver/tokens": "^1.5.45-dev-3",
27
+ "@ethersproject/bignumber": "^5.7.0",
28
+ "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
+ "decimal.js": "^10.4.3"
30
+ },
31
+ "devDependencies": {
32
+ "@defisaver/eslint-config": "^1.0.1",
33
+ "@types/chai": "^5.0.0",
34
+ "@types/mocha": "^10.0.9",
35
+ "@types/web3": "^1.0.20",
36
+ "chai": "^4.3.8",
37
+ "dotenv": "^16.3.1",
38
+ "eslint": "^8.49.0",
39
+ "eslint-plugin-import": "^2.31.0",
40
+ "mocha": "^10.2.0",
41
+ "ts-node": "^10.9.2",
42
+ "typechain": "^8.3.1",
43
+ "typechain-target-web3-v1-3mihai3": "^6.0.2",
44
+ "typescript": "^5.2.2"
45
+ },
46
+ "peerDependencies": {
47
+ "web3": "^1.10.2"
48
+ }
49
+ }