@defisaver/positions-sdk 0.0.32 → 0.0.33

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.
@@ -3,7 +3,7 @@ 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.bytesToString = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.isLayer2Network = void 0;
6
+ exports.mapRange = exports.bytesToString = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.isLayer2Network = void 0;
7
7
  const decimal_js_1 = __importDefault(require("decimal.js"));
8
8
  const tokens_1 = require("@defisaver/tokens");
9
9
  const common_1 = require("../types/common");
@@ -39,3 +39,15 @@ const bytesToString = (hex) => Buffer.from(hex.replace(/^0x/, ''), 'hex')
39
39
  // eslint-disable-next-line no-control-regex
40
40
  .replace(/\x00/g, '');
41
41
  exports.bytesToString = bytesToString;
42
+ /**
43
+ * Map an input value from one range (minInput, maxInput) to a value in another range (minOutput, maxOutput)
44
+ */
45
+ const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
46
+ // slope = 1.0 * (output_end - output_start) / (input_end - input_start)
47
+ const inputDiff = new decimal_js_1.default(maxInput).minus(minInput);
48
+ const outputDiff = new decimal_js_1.default(maxOutput).minus(minOutput);
49
+ const slope = new decimal_js_1.default(outputDiff).div(inputDiff);
50
+ // output = output_start + slope * (input - input_start)
51
+ return new decimal_js_1.default(minOutput).plus(new decimal_js_1.default(slope).mul(new decimal_js_1.default(input).minus(minInput))).toDP(2).toNumber();
52
+ };
53
+ exports.mapRange = mapRange;
@@ -138,7 +138,9 @@ export declare namespace CurveUsdView {
138
138
  [
139
139
  number | string | BN[],
140
140
  number | string | BN[]
141
- ]
141
+ ],
142
+ number | string | BN,
143
+ boolean
142
144
  ] | {
143
145
  loanExists: boolean;
144
146
  collateralPrice: number | string | BN;
@@ -152,6 +154,8 @@ export declare namespace CurveUsdView {
152
154
  health: number | string | BN;
153
155
  bandRange: [number | string | BN, number | string | BN];
154
156
  usersBands: [number | string | BN[], number | string | BN[]];
157
+ collRatio: number | string | BN;
158
+ isInSoftLiquidation: boolean;
155
159
  };
156
160
  type UserDataStructOutputArray = [
157
161
  boolean,
@@ -171,7 +175,9 @@ export declare namespace CurveUsdView {
171
175
  [
172
176
  string[],
173
177
  string[]
174
- ]
178
+ ],
179
+ string,
180
+ boolean
175
181
  ];
176
182
  type UserDataStructOutputStruct = {
177
183
  loanExists: boolean;
@@ -186,6 +192,8 @@ export declare namespace CurveUsdView {
186
192
  health: string;
187
193
  bandRange: [string, string];
188
194
  usersBands: [string[], string[]];
195
+ collRatio: string;
196
+ isInSoftLiquidation: boolean;
189
197
  };
190
198
  type UserDataStructOutput = UserDataStructOutputArray & UserDataStructOutputStruct;
191
199
  }
@@ -193,15 +201,33 @@ export interface CrvUSDView extends BaseContract {
193
201
  constructor(jsonInterface: any[], address?: string, options?: ContractOptions): CrvUSDView;
194
202
  clone(): CrvUSDView;
195
203
  methods: {
204
+ WBTC_HEALTH_ZAP(): NonPayableTransactionObject<string>;
205
+ WBTC_MARKET(): NonPayableTransactionObject<string>;
196
206
  createLoanData(market: string, collateral: number | string | BN, debt: number | string | BN, N: number | string | BN): NonPayableTransactionObject<CurveUsdView.CreateLoanDataStructOutput>;
197
207
  getBandData(market: string, n: number | string | BN): NonPayableTransactionObject<CurveUsdView.BandStructOutput>;
198
- "getBandsData(address,uint256,uint256,uint256)"(market: string, collateral: number | string | BN, debt: number | string | BN, N: number | string | BN): NonPayableTransactionObject<CurveUsdView.BandStructOutput[]>;
199
- "getBandsData(address,int256,int256)"(market: string, from: number | string | BN, to: number | string | BN): NonPayableTransactionObject<CurveUsdView.BandStructOutput[]>;
208
+ getBandsData(market: string, from: number | string | BN, to: number | string | BN): NonPayableTransactionObject<CurveUsdView.BandStructOutput[]>;
209
+ getBandsDataForPosition(market: string, collateral: number | string | BN, debt: number | string | BN, N: number | string | BN): NonPayableTransactionObject<CurveUsdView.BandStructOutput[]>;
210
+ getCollAmountsFromAMM(_controllerAddress: string, _user: string): NonPayableTransactionObject<[
211
+ string,
212
+ string
213
+ ] & {
214
+ crvUsdAmount: string;
215
+ collAmount: string;
216
+ }>;
217
+ getCollateralRatio(_user: string, _controllerAddr: string): NonPayableTransactionObject<[
218
+ string,
219
+ boolean
220
+ ] & {
221
+ collRatio: string;
222
+ isInSoftLiquidation: boolean;
223
+ }>;
200
224
  globalData(market: string): NonPayableTransactionObject<CurveUsdView.GlobalDataStructOutput>;
201
225
  healthCalculator(market: string, user: string, collChange: number | string | BN, debtChange: number | string | BN, isFull: boolean, numBands: number | string | BN): NonPayableTransactionObject<string>;
226
+ isControllerValid(_controllerAddr: string): NonPayableTransactionObject<boolean>;
202
227
  maxBorrow(market: string, collateral: number | string | BN, N: number | string | BN): NonPayableTransactionObject<string>;
203
228
  minCollateral(market: string, debt: number | string | BN, N: number | string | BN): NonPayableTransactionObject<string>;
204
229
  userData(market: string, user: string): NonPayableTransactionObject<CurveUsdView.UserDataStructOutput>;
230
+ userMaxWithdraw(_controllerAddress: string, _user: string): NonPayableTransactionObject<string>;
205
231
  };
206
232
  events: {
207
233
  allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
@@ -67,6 +67,12 @@ export interface CrvUSDAggregatedPositionData {
67
67
  borrowedUsd: string;
68
68
  borrowed: string;
69
69
  safetyRatio: string;
70
+ borrowLimitUsd: string;
71
+ minAllowedRatio: number;
72
+ collFactor: string;
73
+ leveragedType: string;
74
+ leveragedAsset?: string;
75
+ liquidationPrice?: string;
70
76
  }
71
77
  export interface CrvUSDUsedAsset {
72
78
  isSupplied: boolean;