@haven-fi/solauto-sdk 1.0.678 → 1.0.679

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.
@@ -1 +1 @@
1
- {"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAgCrB,qBAAa,kBAAkB;IAS3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IATtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;IAC/C,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAGhB,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,oBAAoB;IAyC5B,OAAO,CAAC,iCAAiC;YAgC3B,qBAAqB;IA0CnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,yBAAyB;YAqBnB,mBAAmB;YAwBnB,sBAAsB;YAyBtB,mBAAmB;IAmEpB,gBAAgB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAe9C"}
1
+ {"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAgCrB,qBAAa,kBAAkB;IAS3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IATtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;IAC/C,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAGhB,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,oBAAoB;IA2C5B,OAAO,CAAC,iCAAiC;YAgC3B,qBAAqB;IA2CnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,yBAAyB;YAqBnB,mBAAmB;YAwBnB,sBAAsB;YAyBtB,mBAAmB;IAmEpB,gBAAgB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAe9C"}
@@ -29,12 +29,14 @@ class RebalanceTxBuilder {
29
29
  getFlLiquiditySource(supplyLiquidityAvailable, debtLiquidityAvailable) {
30
30
  const debtAdjustmentUsd = Math.abs(this.values.debtAdjustmentUsd);
31
31
  const insufficientLiquidity = (amountNeededUsd, liquidityAvailable, tokenMint) => {
32
- return (amountNeededUsd >
33
- (0, utils_1.fromBaseUnit)(liquidityAvailable, (0, utils_1.tokenInfo)(tokenMint).decimals) *
34
- ((0, utils_1.safeGetPrice)(tokenMint) ?? 0) *
35
- 0.95);
32
+ const liquidityUsd = (0, utils_1.fromBaseUnit)(liquidityAvailable, (0, utils_1.tokenInfo)(tokenMint).decimals) *
33
+ ((0, utils_1.safeGetPrice)(tokenMint) ?? 0);
34
+ (0, utils_1.consoleLog)(liquidityUsd);
35
+ return amountNeededUsd > liquidityUsd * 0.95;
36
36
  };
37
+ (0, utils_1.consoleLog)("Supply liquidity available:", supplyLiquidityAvailable);
37
38
  const insufficientSupplyLiquidity = insufficientLiquidity(debtAdjustmentUsd, supplyLiquidityAvailable, this.client.pos.supplyMint);
39
+ (0, utils_1.consoleLog)("Debt liquidity available:", debtLiquidityAvailable);
38
40
  const insufficientDebtLiquidity = insufficientLiquidity(debtAdjustmentUsd, debtLiquidityAvailable, this.client.pos.debtMint);
39
41
  let useDebtLiquidity = this.values.rebalanceDirection === generated_1.RebalanceDirection.Boost ||
40
42
  insufficientSupplyLiquidity;
@@ -70,6 +72,7 @@ class RebalanceTxBuilder {
70
72
  }
71
73
  const stdFlLiquiditySource = this.getFlLiquiditySource(this.client.flProvider.liquidityAvailable(generated_1.TokenType.Supply), this.client.flProvider.liquidityAvailable(generated_1.TokenType.Debt));
72
74
  if ((attemptNum ?? 0) >= 3 || stdFlLiquiditySource === undefined) {
75
+ (0, utils_1.consoleLog)("Checking signer liquidity");
73
76
  const { supplyBalance, debtBalance } = await this.client.signerBalances();
74
77
  const signerFlLiquiditySource = this.getFlLiquiditySource(supplyBalance, debtBalance);
75
78
  if (signerFlLiquiditySource) {
@@ -3,6 +3,7 @@ import { createSignerFromKeypair } from "@metaplex-foundation/umi";
3
3
  import { fromWeb3JsKeypair } from "@metaplex-foundation/umi-web3js-adapters";
4
4
  import {
5
5
  consoleLog,
6
+ fromBaseUnit,
6
7
  getBatches,
7
8
  getClient,
8
9
  getPositionExBulk,
@@ -10,6 +11,7 @@ import {
10
11
  getSolautoManagedPositions,
11
12
  LendingPlatform,
12
13
  LOCAL_IRONFORGE_API_URL,
14
+ openSolautoPosition,
13
15
  PriceType,
14
16
  PriorityFeeSetting,
15
17
  ProgramEnv,
@@ -17,13 +19,18 @@ import {
17
19
  SOLAUTO_PROD_PROGRAM,
18
20
  SOLAUTO_TEST_PROGRAM,
19
21
  SolautoClient,
22
+ tokenInfo,
20
23
  TransactionItem,
21
24
  TransactionsManager,
25
+ USDC,
26
+ deposit,
27
+ toBaseUnit,
28
+ RETARDIO,
22
29
  } from "../src";
23
30
  import { getSecretKey } from "./shared";
24
31
 
25
- const payForTransaction = false;
26
- const testProgram = false;
32
+ const payForTransaction = true;
33
+ const testProgram = true;
27
34
  const lpEnv: ProgramEnv = "Prod";
28
35
 
29
36
  let [, umi] = getSolanaRpcConnection(
@@ -47,21 +54,33 @@ export async function main() {
47
54
  });
48
55
 
49
56
  await client.initialize({
50
- positionId: 1,
51
- authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
57
+ positionId: 2,
58
+ supplyMint: new PublicKey(USDC),
59
+ debtMint: new PublicKey(RETARDIO),
60
+ lpPoolAccount: new PublicKey("EpzY5EYF1A5eFDRfjtsPXSYMPmEx1FXKaXPnouTMF4dm")
61
+ // authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
52
62
  // lpUserAccount: new PublicKey(
53
63
  // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
54
64
  // ),
55
65
  });
56
66
 
57
- const transactionItems = [rebalance(client)];
67
+ const transactionItems = [
68
+ openSolautoPosition(client, {
69
+ boostGap: 250,
70
+ boostToBps: 8681,
71
+ repayGap: 250,
72
+ repayToBps: 8681,
73
+ }),
74
+ deposit(client, toBaseUnit(4.5, tokenInfo(new PublicKey(USDC)).decimals)),
75
+ rebalance(client, 8500),
76
+ ];
58
77
 
59
78
  const txManager = new TransactionsManager(
60
79
  client,
61
80
  undefined,
62
81
  payForTransaction ? "normal" : "only-simulate",
63
82
  PriorityFeeSetting.High,
64
- true,
83
+ false,
65
84
  undefined,
66
85
  { totalRetries: 5 }
67
86
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.678",
3
+ "version": "1.0.679",
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",
@@ -90,19 +90,21 @@ export class RebalanceTxBuilder {
90
90
  liquidityAvailable: bigint,
91
91
  tokenMint: PublicKey
92
92
  ) => {
93
- return (
94
- amountNeededUsd >
93
+ const liquidityUsd =
95
94
  fromBaseUnit(liquidityAvailable, tokenInfo(tokenMint).decimals) *
96
- (safeGetPrice(tokenMint) ?? 0) *
97
- 0.95
98
- );
95
+ (safeGetPrice(tokenMint) ?? 0);
96
+ consoleLog(liquidityUsd);
97
+ return amountNeededUsd > liquidityUsd * 0.95;
99
98
  };
100
99
 
100
+ consoleLog("Supply liquidity available:", supplyLiquidityAvailable);
101
101
  const insufficientSupplyLiquidity = insufficientLiquidity(
102
102
  debtAdjustmentUsd,
103
103
  supplyLiquidityAvailable,
104
104
  this.client.pos.supplyMint
105
105
  );
106
+
107
+ consoleLog("Debt liquidity available:", debtLiquidityAvailable);
106
108
  const insufficientDebtLiquidity = insufficientLiquidity(
107
109
  debtAdjustmentUsd,
108
110
  debtLiquidityAvailable,
@@ -172,6 +174,7 @@ export class RebalanceTxBuilder {
172
174
  );
173
175
 
174
176
  if ((attemptNum ?? 0) >= 3 || stdFlLiquiditySource === undefined) {
177
+ consoleLog("Checking signer liquidity");
175
178
  const { supplyBalance, debtBalance } = await this.client.signerBalances();
176
179
  const signerFlLiquiditySource = this.getFlLiquiditySource(
177
180
  supplyBalance,