@defisaver/positions-sdk 0.0.165 → 0.0.166-dev-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 (117) 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 +43 -0
  5. package/cjs/config/contracts.js +6 -0
  6. package/cjs/contracts.d.ts +1 -0
  7. package/cjs/contracts.js +2 -1
  8. package/cjs/helpers/index.d.ts +1 -0
  9. package/cjs/helpers/index.js +2 -1
  10. package/cjs/helpers/liquityV2Helpers/index.d.ts +12 -0
  11. package/cjs/helpers/liquityV2Helpers/index.js +53 -0
  12. package/cjs/index.d.ts +2 -1
  13. package/cjs/index.js +3 -1
  14. package/cjs/liquityV2/index.d.ts +10 -0
  15. package/cjs/liquityV2/index.js +94 -0
  16. package/cjs/markets/index.d.ts +1 -0
  17. package/cjs/markets/index.js +3 -1
  18. package/cjs/markets/liquityV2/index.d.ts +8 -0
  19. package/cjs/markets/liquityV2/index.js +34 -0
  20. package/cjs/staking/staking.d.ts +1 -0
  21. package/cjs/staking/staking.js +10 -2
  22. package/cjs/types/contracts/generated/LiquityV2View.d.ts +222 -0
  23. package/cjs/types/contracts/generated/LiquityV2View.js +5 -0
  24. package/cjs/types/contracts/generated/index.d.ts +1 -0
  25. package/cjs/types/index.d.ts +1 -0
  26. package/cjs/types/index.js +1 -0
  27. package/cjs/types/liquityV2.d.ts +73 -0
  28. package/cjs/types/liquityV2.js +8 -0
  29. package/esm/config/contracts.d.ts +43 -0
  30. package/esm/config/contracts.js +6 -0
  31. package/esm/contracts.d.ts +1 -0
  32. package/esm/contracts.js +1 -0
  33. package/esm/helpers/index.d.ts +1 -0
  34. package/esm/helpers/index.js +1 -0
  35. package/esm/helpers/liquityV2Helpers/index.d.ts +12 -0
  36. package/esm/helpers/liquityV2Helpers/index.js +45 -0
  37. package/esm/index.d.ts +2 -1
  38. package/esm/index.js +2 -1
  39. package/esm/liquityV2/index.d.ts +10 -0
  40. package/esm/liquityV2/index.js +86 -0
  41. package/esm/markets/index.d.ts +1 -0
  42. package/esm/markets/index.js +1 -0
  43. package/esm/markets/liquityV2/index.d.ts +8 -0
  44. package/esm/markets/liquityV2/index.js +28 -0
  45. package/esm/staking/staking.d.ts +1 -0
  46. package/esm/staking/staking.js +8 -1
  47. package/esm/types/contracts/generated/LiquityV2View.d.ts +222 -0
  48. package/esm/types/contracts/generated/LiquityV2View.js +4 -0
  49. package/esm/types/contracts/generated/index.d.ts +1 -0
  50. package/esm/types/index.d.ts +1 -0
  51. package/esm/types/index.js +1 -0
  52. package/esm/types/liquityV2.d.ts +73 -0
  53. package/esm/types/liquityV2.js +5 -0
  54. package/package.json +49 -48
  55. package/src/aaveV2/index.ts +227 -227
  56. package/src/aaveV3/index.ts +590 -590
  57. package/src/assets/index.ts +60 -60
  58. package/src/chickenBonds/index.ts +123 -123
  59. package/src/compoundV2/index.ts +219 -219
  60. package/src/compoundV3/index.ts +281 -281
  61. package/src/config/contracts.js +1040 -1034
  62. package/src/constants/index.ts +6 -6
  63. package/src/contracts.ts +130 -128
  64. package/src/curveUsd/index.ts +229 -229
  65. package/src/exchange/index.ts +17 -17
  66. package/src/helpers/aaveHelpers/index.ts +194 -194
  67. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  68. package/src/helpers/compoundHelpers/index.ts +246 -246
  69. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  70. package/src/helpers/index.ts +9 -8
  71. package/src/helpers/liquityV2Helpers/index.ts +69 -0
  72. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  73. package/src/helpers/makerHelpers/index.ts +94 -94
  74. package/src/helpers/morphoBlueHelpers/index.ts +115 -115
  75. package/src/helpers/sparkHelpers/index.ts +150 -150
  76. package/src/index.ts +48 -46
  77. package/src/liquity/index.ts +116 -116
  78. package/src/liquityV2/index.ts +111 -0
  79. package/src/llamaLend/index.ts +275 -275
  80. package/src/maker/index.ts +117 -117
  81. package/src/markets/aave/index.ts +152 -152
  82. package/src/markets/aave/marketAssets.ts +46 -46
  83. package/src/markets/compound/index.ts +173 -173
  84. package/src/markets/compound/marketsAssets.ts +64 -64
  85. package/src/markets/curveUsd/index.ts +69 -69
  86. package/src/markets/index.ts +23 -22
  87. package/src/markets/liquityV2/index.ts +31 -0
  88. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  89. package/src/markets/llamaLend/index.ts +235 -235
  90. package/src/markets/morphoBlue/index.ts +728 -728
  91. package/src/markets/spark/index.ts +29 -29
  92. package/src/markets/spark/marketAssets.ts +10 -10
  93. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  94. package/src/morphoAaveV2/index.ts +256 -256
  95. package/src/morphoAaveV3/index.ts +630 -630
  96. package/src/morphoBlue/index.ts +171 -171
  97. package/src/multicall/index.ts +22 -22
  98. package/src/services/dsrService.ts +15 -15
  99. package/src/services/priceService.ts +21 -21
  100. package/src/services/utils.ts +54 -54
  101. package/src/setup.ts +8 -8
  102. package/src/spark/index.ts +424 -424
  103. package/src/staking/staking.ts +218 -211
  104. package/src/types/aave.ts +262 -262
  105. package/src/types/chickenBonds.ts +45 -45
  106. package/src/types/common.ts +84 -84
  107. package/src/types/compound.ts +129 -129
  108. package/src/types/contracts/generated/LiquityV2View.ts +280 -0
  109. package/src/types/contracts/generated/index.ts +1 -0
  110. package/src/types/curveUsd.ts +118 -118
  111. package/src/types/index.ts +9 -8
  112. package/src/types/liquity.ts +30 -30
  113. package/src/types/liquityV2.ts +79 -0
  114. package/src/types/llamaLend.ts +155 -155
  115. package/src/types/maker.ts +50 -50
  116. package/src/types/morphoBlue.ts +146 -146
  117. package/src/types/spark.ts +127 -127
@@ -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;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
15
+ exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getSsrApy = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
16
16
  const decimal_js_1 = __importDefault(require("decimal.js"));
17
17
  const contracts_1 = require("../contracts");
18
18
  const common_1 = require("../types/common");
@@ -86,6 +86,12 @@ const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, vo
86
86
  .toString();
87
87
  });
88
88
  exports.getDsrApy = getDsrApy;
89
+ const getSsrApy = () => __awaiter(void 0, void 0, void 0, function* () {
90
+ const res = yield fetch('https://app.defisaver.com/api/sky/data');
91
+ const data = yield res.json();
92
+ return new decimal_js_1.default(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
93
+ });
94
+ exports.getSsrApy = getSsrApy;
89
95
  const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
90
96
  console.log('getSuperOETHApy');
91
97
  const res = yield fetch('https://origin.squids.live/origin-squid/graphql', {
@@ -109,7 +115,7 @@ const getApyFromDfsApi = (asset) => __awaiter(void 0, void 0, void 0, function*
109
115
  const data = yield res.json();
110
116
  return data.apy;
111
117
  });
112
- exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb'];
118
+ exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
113
119
  const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
114
120
  console.log('getStakingApy', asset, blockNumber, fromBlock);
115
121
  try {
@@ -137,6 +143,8 @@ const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefine
137
143
  return getApyFromDfsApi('pufETH');
138
144
  if (asset === 'wsuperOETHb')
139
145
  return getSuperOETHApy();
146
+ if (asset === 'sUSDS')
147
+ return (0, exports.getSsrApy)();
140
148
  }
141
149
  catch (e) {
142
150
  console.error(`Failed to fetch APY for ${asset}`);
@@ -0,0 +1,222 @@
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
+ }
150
+ export interface LiquityV2View extends BaseContract {
151
+ constructor(jsonInterface: any[], address?: string, options?: ContractOptions): LiquityV2View;
152
+ clone(): LiquityV2View;
153
+ methods: {
154
+ findInsertPosition(_market: string, _interestRate: number | string | BN, _prevId: number | string | BN, _nextId: number | string | BN): NonPayableTransactionObject<[
155
+ string,
156
+ string
157
+ ] & {
158
+ prevId: string;
159
+ nextId: string;
160
+ }>;
161
+ getApproxHint(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
162
+ string,
163
+ string,
164
+ string
165
+ ] & {
166
+ hintId: string;
167
+ diff: string;
168
+ latestRandomSeed: string;
169
+ }>;
170
+ getDebtInFront(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
171
+ string,
172
+ string
173
+ ] & {
174
+ next: string;
175
+ debt: string;
176
+ }>;
177
+ getDebtInFrontByInterestRate(_market: string, _troveId: number | string | BN, _acc: number | string | BN, _iterations: number | string | BN, _targetIR: number | string | BN): NonPayableTransactionObject<[
178
+ string,
179
+ string
180
+ ] & {
181
+ next: string;
182
+ debt: string;
183
+ }>;
184
+ getDebtInFrontByTroveNum(_market: string, _numTroves: number | string | BN): NonPayableTransactionObject<string>;
185
+ getDepositorInfo(_market: string, _depositor: string): NonPayableTransactionObject<[
186
+ string,
187
+ string,
188
+ string
189
+ ] & {
190
+ compoundedBOLD: string;
191
+ collGain: string;
192
+ boldGain: string;
193
+ }>;
194
+ getInsertPosition(_market: string, _collIndex: number | string | BN, _interestRate: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
195
+ string,
196
+ string
197
+ ] & {
198
+ prevId: string;
199
+ nextId: string;
200
+ }>;
201
+ getMarketData(_market: string): NonPayableTransactionObject<LiquityV2View.MarketDataStructOutput>;
202
+ getNumOfTrovesInFrontOfTrove(_market: string, _troveId: number | string | BN, _iterations: number | string | BN): NonPayableTransactionObject<[
203
+ string,
204
+ string
205
+ ] & {
206
+ next: string;
207
+ numTroves: string;
208
+ }>;
209
+ getTroveInfo(_market: string, _troveId: number | string | BN): NonPayableTransactionObject<LiquityV2View.TroveDataStructOutput>;
210
+ getTrovePosition(_market: string, _collIndex: number | string | BN, _troveId: number | string | BN, _numTrials: number | string | BN, _inputRandomSeed: number | string | BN): NonPayableTransactionObject<[
211
+ string,
212
+ string
213
+ ] & {
214
+ prevId: string;
215
+ nextId: string;
216
+ }>;
217
+ isShutDown(_market: string): NonPayableTransactionObject<boolean>;
218
+ };
219
+ events: {
220
+ allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
221
+ };
222
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /* Autogenerated file. Do not edit manually. */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -34,6 +34,7 @@ export type { IVariableDebtToken } from "./IVariableDebtToken";
34
34
  export type { LendingPoolAddressesProvider } from "./LendingPoolAddressesProvider";
35
35
  export type { Lido } from "./Lido";
36
36
  export type { LiquityActivePool } from "./LiquityActivePool";
37
+ export type { LiquityV2View } from "./LiquityV2View";
37
38
  export type { LiquityView } from "./LiquityView";
38
39
  export type { LlamaLendControllerAbi } from "./LlamaLendControllerAbi";
39
40
  export type { LlamaLendView } from "./LlamaLendView";
@@ -3,6 +3,7 @@ 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';
@@ -19,6 +19,7 @@ __exportStar(require("./compound"), exports);
19
19
  __exportStar(require("./spark"), exports);
20
20
  __exportStar(require("./curveUsd"), exports);
21
21
  __exportStar(require("./liquity"), exports);
22
+ __exportStar(require("./liquityV2"), exports);
22
23
  __exportStar(require("./maker"), exports);
23
24
  __exportStar(require("./chickenBonds"), exports);
24
25
  __exportStar(require("./morphoBlue"), exports);
@@ -0,0 +1,73 @@
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
+ minRatio: string;
33
+ }
34
+ export interface LiquityV2MarketData {
35
+ assetsData: LiquityV2AssetsData;
36
+ marketData: InnerLiquityV2MarketData;
37
+ }
38
+ export interface LiquityV2UsedAsset {
39
+ symbol: string;
40
+ address: string;
41
+ price: string;
42
+ supplied: string;
43
+ suppliedUsd: string;
44
+ borrowed: string;
45
+ borrowedUsd: string;
46
+ }
47
+ export type LiquityV2UsedAssets = {
48
+ [key: string]: LiquityV2UsedAsset;
49
+ };
50
+ export interface LiquityV2AggregatedTroveData {
51
+ suppliedUsd: string;
52
+ borrowedUsd: string;
53
+ borrowLimitUsd: string;
54
+ leftToBorrowUsd: string;
55
+ netApy: string;
56
+ incentiveUsd: string;
57
+ totalInterestUsd: string;
58
+ }
59
+ export interface LiquityV2TroveData {
60
+ usedAssets: LiquityV2UsedAssets;
61
+ troveId: string;
62
+ ratio: string;
63
+ interestRate: string;
64
+ leftToBorrowUsd: string;
65
+ borrowLimitUsd: string;
66
+ suppliedUsd: string;
67
+ borrowedUsd: string;
68
+ netApy: string;
69
+ incentiveUsd: string;
70
+ totalInterestUsd: string;
71
+ interestBatchManager: EthAddress;
72
+ troveStatus: string;
73
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiquityV2Versions = void 0;
4
+ var LiquityV2Versions;
5
+ (function (LiquityV2Versions) {
6
+ LiquityV2Versions["LiquityV2Eth"] = "liquityv2eth";
7
+ LiquityV2Versions["LiquityV2WstEth"] = "liquityv2wsteth";
8
+ })(LiquityV2Versions || (exports.LiquityV2Versions = LiquityV2Versions = {}));
@@ -6696,3 +6696,46 @@ export namespace LlamaLendControllerAbi {
6696
6696
  let networks_76: {};
6697
6697
  export { networks_76 as networks };
6698
6698
  }
6699
+ export namespace LiquityV2View {
6700
+ let abi_77: ({
6701
+ inputs: {
6702
+ internalType: string;
6703
+ name: string;
6704
+ type: string;
6705
+ }[];
6706
+ name: string;
6707
+ outputs: {
6708
+ internalType: string;
6709
+ name: string;
6710
+ type: string;
6711
+ }[];
6712
+ stateMutability: string;
6713
+ type: string;
6714
+ } | {
6715
+ inputs: {
6716
+ internalType: string;
6717
+ name: string;
6718
+ type: string;
6719
+ }[];
6720
+ name: string;
6721
+ outputs: {
6722
+ components: {
6723
+ internalType: string;
6724
+ name: string;
6725
+ type: string;
6726
+ }[];
6727
+ internalType: string;
6728
+ name: string;
6729
+ type: string;
6730
+ }[];
6731
+ stateMutability: string;
6732
+ type: string;
6733
+ })[];
6734
+ export { abi_77 as abi };
6735
+ let networks_77: {
6736
+ "1": {
6737
+ address: string;
6738
+ };
6739
+ };
6740
+ export { networks_77 as networks };
6741
+ }
@@ -1030,4 +1030,10 @@ module.exports = {
1030
1030
  "abi": [{ "name": "UserState", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }, { "name": "n1", "type": "int256", "indexed": false }, { "name": "n2", "type": "int256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Borrow", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_increase", "type": "uint256", "indexed": false }, { "name": "loan_increase", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Repay", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }, { "name": "loan_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "RemoveCollateral", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Liquidate", "inputs": [{ "name": "liquidator", "type": "address", "indexed": true }, { "name": "user", "type": "address", "indexed": true }, { "name": "collateral_received", "type": "uint256", "indexed": false }, { "name": "stablecoin_received", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetMonetaryPolicy", "inputs": [{ "name": "monetary_policy", "type": "address", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetBorrowingDiscounts", "inputs": [{ "name": "loan_discount", "type": "uint256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "CollectFees", "inputs": [{ "name": "amount", "type": "uint256", "indexed": false }, { "name": "new_supply", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [{ "name": "collateral_token", "type": "address" }, { "name": "monetary_policy", "type": "address" }, { "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }, { "name": "amm", "type": "address" }], "outputs": [] }, { "stateMutability": "pure", "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "amm", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "collateral_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "borrowed_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "save_rate", "inputs": [], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "debt", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_exists", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "total_debt", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "current_debt", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "min_collateral", "inputs": [{ "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "calculate_debt_n1", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay_extended", "inputs": [{ "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate_extended", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "frac", "type": "uint256" }, { "name": "use_eth", "type": "bool" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "frac", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }, { "name": "_limit", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "amm_price", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "user_prices", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[2]" }] }, { "stateMutability": "view", "type": "function", "name": "user_state", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[4]" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_admin_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_monetary_policy", "inputs": [{ "name": "monetary_policy", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_borrowing_discounts", "inputs": [{ "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_callback", "inputs": [{ "name": "cb", "type": "address" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "admin_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "collect_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "check_lock", "inputs": [], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discounts", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loans", "inputs": [{ "name": "arg0", "type": "uint256" }], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "loan_ix", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "n_loans", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "minted", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "redeemed", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "monetary_policy", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }],
1031
1031
  "networks": {}
1032
1032
  },
1033
+ "LiquityV2View": {
1034
+ "abi": [{ "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_prevId", "type": "uint256" }, { "internalType": "uint256", "name": "_nextId", "type": "uint256" }], "name": "findInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getApproxHint", "outputs": [{ "internalType": "uint256", "name": "hintId", "type": "uint256" }, { "internalType": "uint256", "name": "diff", "type": "uint256" }, { "internalType": "uint256", "name": "latestRandomSeed", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getDebtInFront", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }, { "internalType": "uint256", "name": "_targetIR", "type": "uint256" }], "name": "getDebtInFrontByInterestRate", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_numTroves", "type": "uint256" }], "name": "getDebtInFrontByTroveNum", "outputs": [{ "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_depositor", "type": "address" }], "name": "getDepositorInfo", "outputs": [{ "internalType": "uint256", "name": "compoundedBOLD", "type": "uint256" }, { "internalType": "uint256", "name": "collGain", "type": "uint256" }, { "internalType": "uint256", "name": "boldGain", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getMarketData", "outputs": [{ "components": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "CCR", "type": "uint256" }, { "internalType": "uint256", "name": "MCR", "type": "uint256" }, { "internalType": "uint256", "name": "SCR", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_SP", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_REDISTRIBUTION", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemColl", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemDebt", "type": "uint256" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "address", "name": "troveNFT", "type": "address" }, { "internalType": "address", "name": "borrowerOperations", "type": "address" }, { "internalType": "address", "name": "troveManager", "type": "address" }, { "internalType": "address", "name": "stabilityPool", "type": "address" }, { "internalType": "address", "name": "sortedTroves", "type": "address" }, { "internalType": "address", "name": "collSurplusPool", "type": "address" }, { "internalType": "address", "name": "hintHelpers", "type": "address" }, { "internalType": "address", "name": "priceFeed", "type": "address" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "bool", "name": "isShutDown", "type": "bool" }], "internalType": "struct LiquityV2View.MarketData", "name": "data", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getNumOfTrovesInFrontOfTrove", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "numTroves", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }], "name": "getTroveInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "troveId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "enum ITroveManager.Status", "name": "status", "type": "uint8" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "uint256", "name": "TCRatio", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "address", "name": "interestBatchManager", "type": "address" }, { "internalType": "uint256", "name": "batchDebtShares", "type": "uint256" }], "internalType": "struct LiquityV2View.TroveData", "name": "trove", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getTrovePosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "isShutDown", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }],
1035
+ "networks": {
1036
+ "1": { "address": "0x88bBa5Ce5cE20286Cf866b9f310354FFB701A296" },
1037
+ }
1038
+ }
1033
1039
  };
@@ -45,3 +45,4 @@ export declare const USDCPriceFeedContract: (web3: Web3, network: NetworkNumber,
45
45
  export declare const FeedRegistryContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FeedRegistry;
46
46
  export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.MorphoBlueView;
47
47
  export declare const LlamaLendViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LlamaLendView;
48
+ export declare const LiquityV2ViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LiquityV2View;
package/esm/contracts.js CHANGED
@@ -77,3 +77,4 @@ export const USDCPriceFeedContract = createContractFromConfigFunc('USDCPriceFeed
77
77
  export const FeedRegistryContract = createContractFromConfigFunc('FeedRegistry');
78
78
  export const MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueView');
79
79
  export const LlamaLendViewContract = createContractFromConfigFunc('LlamaLendView');
80
+ export const LiquityV2ViewContract = createContractFromConfigFunc('LiquityV2View');
@@ -6,3 +6,4 @@ export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
7
  export * as morphoBlueHelpers from './morphoBlueHelpers';
8
8
  export * as llamaLendHelpers from './llamaLendHelpers';
9
+ export * as liquityV2Helpers from './liquityV2Helpers';
@@ -6,3 +6,4 @@ export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
7
  export * as morphoBlueHelpers from './morphoBlueHelpers';
8
8
  export * as llamaLendHelpers from './llamaLendHelpers';
9
+ export * as liquityV2Helpers from './liquityV2Helpers';
@@ -0,0 +1,12 @@
1
+ import { LiquityV2AggregatedTroveData, LiquityV2AssetsData, LiquityV2UsedAssets } from '../../types';
2
+ export declare const calculateNetApyLiquityV2: (usedAssets: LiquityV2UsedAssets, assetsData: LiquityV2AssetsData, interestRate: string) => {
3
+ netApy: string;
4
+ totalInterestUsd: string;
5
+ incentiveUsd: string;
6
+ };
7
+ export declare const getLiquityV2AggregatedPositionData: ({ usedAssets, assetsData, minRatio, interestRate, }: {
8
+ usedAssets: LiquityV2UsedAssets;
9
+ assetsData: LiquityV2AssetsData;
10
+ minRatio: string;
11
+ interestRate: string;
12
+ }) => LiquityV2AggregatedTroveData;
@@ -0,0 +1,45 @@
1
+ import Dec from 'decimal.js';
2
+ import { getAssetsTotal } from '../../moneymarket';
3
+ import { calculateInterestEarned } from '../../staking';
4
+ export const calculateNetApyLiquityV2 = (usedAssets, assetsData, interestRate) => {
5
+ const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
6
+ const acc = Object.assign({}, _acc);
7
+ const assetData = assetsData[usedAsset.symbol];
8
+ if (usedAsset.suppliedUsd) {
9
+ const amount = usedAsset.suppliedUsd;
10
+ acc.suppliedUsd = new Dec(acc.suppliedUsd).add(amount).toString();
11
+ if (assetData.incentiveSupplyApy) {
12
+ const incentiveInterest = calculateInterestEarned(amount, assetData.incentiveSupplyApy, 'year', true);
13
+ acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
14
+ }
15
+ }
16
+ if (usedAsset.borrowedUsd) {
17
+ const amount = usedAsset.borrowedUsd;
18
+ acc.borrowedUsd = new Dec(acc.borrowedUsd).add(amount).toString();
19
+ const rate = interestRate;
20
+ const borrowInterest = calculateInterestEarned(amount, rate, 'year', true);
21
+ acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
22
+ }
23
+ return acc;
24
+ }, {
25
+ borrowInterest: '0', supplyInterest: '0', incentiveUsd: '0', borrowedUsd: '0', suppliedUsd: '0',
26
+ });
27
+ const { borrowedUsd, suppliedUsd, borrowInterest, supplyInterest, incentiveUsd, } = sumValues;
28
+ const totalInterestUsd = new Dec(borrowInterest).add(supplyInterest).add(incentiveUsd).toString();
29
+ const balance = new Dec(suppliedUsd).sub(borrowedUsd);
30
+ const netApy = new Dec(totalInterestUsd).div(balance).times(100).toString();
31
+ return { netApy, totalInterestUsd, incentiveUsd };
32
+ };
33
+ export const getLiquityV2AggregatedPositionData = ({ usedAssets, assetsData, minRatio, interestRate, }) => {
34
+ const payload = {};
35
+ payload.suppliedUsd = getAssetsTotal(usedAssets, (usedAsset) => usedAsset, ({ suppliedUsd }) => suppliedUsd);
36
+ payload.borrowedUsd = getAssetsTotal(usedAssets, (usedAsset) => usedAsset, ({ borrowedUsd }) => borrowedUsd);
37
+ payload.borrowLimitUsd = new Dec(payload.suppliedUsd).div(minRatio).mul(100).toString();
38
+ const leftToBorrowUsd = new Dec(payload.borrowLimitUsd).sub(payload.borrowedUsd);
39
+ payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
40
+ const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApyLiquityV2(usedAssets, assetsData, interestRate);
41
+ payload.netApy = netApy;
42
+ payload.incentiveUsd = incentiveUsd;
43
+ payload.totalInterestUsd = totalInterestUsd;
44
+ return payload;
45
+ };
package/esm/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import * as compoundV2 from './compoundV2';
8
8
  import * as spark from './spark';
9
9
  import * as curveUsd from './curveUsd';
10
10
  import * as liquity from './liquity';
11
+ import * as liquityV2 from './liquityV2';
11
12
  import * as maker from './maker';
12
13
  import * as staking from './staking';
13
14
  import * as multicall from './multicall';
@@ -19,4 +20,4 @@ import * as exchange from './exchange';
19
20
  import * as morphoBlue from './morphoBlue';
20
21
  import * as llamaLend from './llamaLend';
21
22
  export * from './types';
22
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };
23
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };
package/esm/index.js CHANGED
@@ -8,6 +8,7 @@ import * as compoundV2 from './compoundV2';
8
8
  import * as spark from './spark';
9
9
  import * as curveUsd from './curveUsd';
10
10
  import * as liquity from './liquity';
11
+ import * as liquityV2 from './liquityV2';
11
12
  import * as maker from './maker';
12
13
  import * as staking from './staking';
13
14
  import * as multicall from './multicall';
@@ -19,4 +20,4 @@ import * as exchange from './exchange';
19
20
  import * as morphoBlue from './morphoBlue';
20
21
  import * as llamaLend from './llamaLend';
21
22
  export * from './types';
22
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };
23
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };