@haven-fi/solauto-sdk 1.0.72 → 1.0.73

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
- export declare const DEFAULT_RISK_AVERSION_BPS = 1500;
1
+ export declare const BASIS_POINTS = 10000;
2
2
  export declare const DEFAULT_LIMIT_GAP_BPS = 1000;
3
3
  export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
4
- export declare const MAX_REPAY_GAP_BPS = 100;
4
+ export declare const MIN_REPAY_GAP_BPS = 100;
5
+ export declare const MIN_BOOST_GAP_BPS = 50;
5
6
  export declare const PRICES: {
6
7
  [key: string]: {
7
8
  price: number;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAQrC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAE1E,eAAO,MAAM,kBAAkB,gDAAgD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAQpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAE1E,eAAO,MAAM,kBAAkB,gDAAgD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.JUPITER_PROGRAM_ID = exports.SOLAUTO_LUT = exports.PRICES = exports.MAX_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.DEFAULT_LIMIT_GAP_BPS = exports.DEFAULT_RISK_AVERSION_BPS = void 0;
3
+ exports.STANDARD_LUT_ACCOUNTS = exports.JUPITER_PROGRAM_ID = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.DEFAULT_LIMIT_GAP_BPS = exports.BASIS_POINTS = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  // import { JitoRpcConnection } from "jito-ts";
7
7
  const generated_1 = require("../generated");
8
8
  const generalAccounts_1 = require("./generalAccounts");
9
- exports.DEFAULT_RISK_AVERSION_BPS = 1500;
9
+ exports.BASIS_POINTS = 10000;
10
10
  exports.DEFAULT_LIMIT_GAP_BPS = 1000;
11
11
  exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
12
- exports.MAX_REPAY_GAP_BPS = 100;
12
+ exports.MIN_REPAY_GAP_BPS = 100;
13
+ exports.MIN_BOOST_GAP_BPS = 50;
13
14
  // export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
14
15
  // export const JITO_CONNECTION = new JitoRpcConnection(
15
16
  // `https://${JITO_BLO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;CAAE,EAAE,CAC/E,CA6CA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -189,15 +189,15 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
189
189
  const supplyUsd = (0, numberUtils_1.fromBaseUnit)(supplyUsage.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
190
190
  const debtUsd = (0, numberUtils_1.fromBaseUnit)(debtUsage?.amountUsed?.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS);
191
191
  return {
192
- liqUtilizationRateBps: (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, Math.round(liqThreshold * 10000)),
192
+ liqUtilizationRateBps: (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, (0, numberUtils_1.toBps)(liqThreshold)),
193
193
  netWorth: {
194
194
  baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(supplyUsd - debtUsd, generalAccounts_1.USD_DECIMALS),
195
195
  baseUnit: (0, numberUtils_1.toBaseUnit)((supplyUsd - debtUsd) / supplyPrice, supplyUsage.decimals),
196
196
  },
197
197
  supply: supplyUsage,
198
198
  debt: debtUsage,
199
- maxLtvBps: Math.round(maxLtv * 10000),
200
- liqThresholdBps: Math.round(liqThreshold * 10000),
199
+ maxLtvBps: (0, numberUtils_1.toBps)(maxLtv),
200
+ liqThresholdBps: (0, numberUtils_1.toBps)(liqThreshold),
201
201
  lastUpdated: BigInt((0, generalUtils_1.currentUnixSeconds)()),
202
202
  padding1: [],
203
203
  padding2: [],
@@ -28,10 +28,10 @@ function fromBaseUnit(value, decimals) {
28
28
  return Number(value) / Math.pow(10, decimals);
29
29
  }
30
30
  function fromBps(value) {
31
- return value / 10000;
31
+ return value / constants_1.BASIS_POINTS;
32
32
  }
33
33
  function toBps(value) {
34
- return Math.round(value * 10000);
34
+ return Math.round(value * constants_1.BASIS_POINTS);
35
35
  }
36
36
  function bytesToI80F48(bytes) {
37
37
  if (bytes.length !== 16) {
@@ -107,5 +107,5 @@ function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
107
107
  return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.005));
108
108
  }
109
109
  function maxRepayToBps(maxLtvBps, liqThresholdBps) {
110
- return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MAX_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005));
110
+ return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005));
111
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -13,10 +13,12 @@ import {
13
13
  import { SOLAUTO_PROGRAM_ID } from "../generated";
14
14
  import { SOLAUTO_MANAGER } from "./generalAccounts";
15
15
 
16
- export const DEFAULT_RISK_AVERSION_BPS = 1500;
16
+ export const BASIS_POINTS = 10000;
17
+
17
18
  export const DEFAULT_LIMIT_GAP_BPS = 1000;
18
19
  export const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
19
- export const MAX_REPAY_GAP_BPS = 100;
20
+ export const MIN_REPAY_GAP_BPS = 100;
21
+ export const MIN_BOOST_GAP_BPS = 50;
20
22
 
21
23
  // export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
22
24
  // export const JITO_CONNECTION = new JitoRpcConnection(
@@ -14,6 +14,7 @@ import {
14
14
  fromBaseUnit,
15
15
  getLiqUtilzationRateBps,
16
16
  toBaseUnit,
17
+ toBps,
17
18
  } from "./numberUtils";
18
19
  import { PRICES } from "../constants/solautoConstants";
19
20
  import { MARGINFI_ACCOUNTS } from "../constants/marginfiAccounts";
@@ -353,7 +354,7 @@ export async function getMarginfiAccountPositionState(
353
354
  liqUtilizationRateBps: getLiqUtilzationRateBps(
354
355
  supplyUsd,
355
356
  debtUsd,
356
- Math.round(liqThreshold * 10000)
357
+ toBps(liqThreshold)
357
358
  ),
358
359
  netWorth: {
359
360
  baseAmountUsdValue: toBaseUnit(supplyUsd - debtUsd, USD_DECIMALS),
@@ -364,8 +365,8 @@ export async function getMarginfiAccountPositionState(
364
365
  },
365
366
  supply: supplyUsage!,
366
367
  debt: debtUsage!,
367
- maxLtvBps: Math.round(maxLtv * 10000),
368
- liqThresholdBps: Math.round(liqThreshold * 10000),
368
+ maxLtvBps: toBps(maxLtv),
369
+ liqThresholdBps: toBps(liqThreshold),
369
370
  lastUpdated: BigInt(currentUnixSeconds()),
370
371
  padding1: [],
371
372
  padding2: [],
@@ -1,4 +1,4 @@
1
- import { MAX_REPAY_GAP_BPS } from "../constants";
1
+ import { BASIS_POINTS, MIN_REPAY_GAP_BPS } from "../constants";
2
2
  import { FeeType } from "../generated";
3
3
 
4
4
  export function getLiqUtilzationRateBps(
@@ -22,11 +22,11 @@ export function fromBaseUnit(value: bigint, decimals: number): number {
22
22
  }
23
23
 
24
24
  export function fromBps(value: number): number {
25
- return value / 10000;
25
+ return value / BASIS_POINTS;
26
26
  }
27
27
 
28
28
  export function toBps(value: number): number {
29
- return Math.round(value * 10000);
29
+ return Math.round(value * BASIS_POINTS);
30
30
  }
31
31
 
32
32
  export function bytesToI80F48(bytes: number[]): number {
@@ -148,7 +148,7 @@ export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
148
148
 
149
149
  export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
150
150
  return Math.min(
151
- maxRepayFromBps(maxLtvBps, liqThresholdBps) - MAX_REPAY_GAP_BPS,
151
+ maxRepayFromBps(maxLtvBps, liqThresholdBps) - MIN_REPAY_GAP_BPS,
152
152
  getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.005)
153
153
  );
154
154
  }