@haven-fi/solauto-sdk 1.0.618 → 1.0.620

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.
@@ -23,7 +23,7 @@ export declare class RebalanceSwapManager {
23
23
  getSwapTxData(): Promise<{
24
24
  swapQuote: QuoteResponse;
25
25
  lookupTableAddresses: string[];
26
- setupInstructions: import("@metaplex-foundation/umi").TransactionBuilder;
26
+ setupIx: import("@metaplex-foundation/umi").TransactionBuilder;
27
27
  swapIx: import("@metaplex-foundation/umi").TransactionBuilder;
28
28
  }>;
29
29
  }
@@ -136,11 +136,11 @@ class RebalanceSwapManager {
136
136
  };
137
137
  }
138
138
  async getSwapTxData() {
139
- const { jupQuote, lookupTableAddresses, setupInstructions, swapIx } = await this.jupSwapManager.getJupSwapTxData(this.swapParams);
139
+ const { jupQuote, lookupTableAddresses, setupIx, swapIx } = await this.jupSwapManager.getJupSwapTxData(this.swapParams);
140
140
  return {
141
141
  swapQuote: jupQuote,
142
142
  lookupTableAddresses,
143
- setupInstructions,
143
+ setupIx,
144
144
  swapIx,
145
145
  };
146
146
  }
@@ -143,7 +143,7 @@ class RebalanceTxBuilder {
143
143
  return false;
144
144
  }
145
145
  async assembleTransaction() {
146
- const { swapQuote, lookupTableAddresses, setupInstructions, swapIx } = await this.swapManager.getSwapTxData();
146
+ const { swapQuote, lookupTableAddresses, setupIx, swapIx } = await this.swapManager.getSwapTxData();
147
147
  const flashLoanDetails = this.flRequirements
148
148
  ? this.getFlashLoanDetails()
149
149
  : undefined;
@@ -161,7 +161,7 @@ class RebalanceTxBuilder {
161
161
  const firstRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PreSwap, rebalanceDetails);
162
162
  const lastRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PostSwap, rebalanceDetails);
163
163
  if (!flashLoanDetails) {
164
- tx = tx.add([setupInstructions, firstRebalance, swapIx, lastRebalance]);
164
+ tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
165
165
  }
166
166
  else {
167
167
  (0, utils_1.consoleLog)("Flash loan details:", flashLoanDetails);
@@ -172,7 +172,7 @@ class RebalanceTxBuilder {
172
172
  ? (0, utils_1.getTokenAccount)(this.client.pos.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
173
173
  : (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey), new web3_js_1.PublicKey(swapQuote.inputMint));
174
174
  tx = tx.add([
175
- setupInstructions,
175
+ setupIx,
176
176
  this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
177
177
  ...(addFirstRebalance ? [firstRebalance] : []),
178
178
  swapIx,
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gCAAgC,EAEhC,sBAAsB,EAGvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE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B,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAsDlE,QAAQ,CAAC,eAAe,IAAI,kBAAkB;IAE9C,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,SAAS,IAAI,kBAAkB;IAExC,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAsFlE,QAAQ,CAAC,WAAW,CAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,gBAAgB,GACrB,kBAAkB;CACtB"}
@@ -163,15 +163,10 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
163
163
  };
164
164
  }
165
165
  async signerBalances() {
166
- if (this.signerSupplyBalance !== undefined &&
167
- this.signerDebtBalance !== undefined) {
168
- return {
169
- supplyBalance: this.signerSupplyBalance,
170
- debtBalance: this.signerDebtBalance,
171
- };
166
+ if (!this.signerSupplyBalance || !this.signerDebtBalance) {
167
+ [this.signerSupplyBalance, this.signerDebtBalance] =
168
+ await (0, solanaUtils_1.getWalletSplBalances)(this.connection, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), [this.pos.supplyMint(), this.pos.debtMint()]);
172
169
  }
173
- [this.signerSupplyBalance, this.signerDebtBalance] =
174
- await (0, solanaUtils_1.getWalletSplBalances)(this.connection, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), [this.pos.supplyMint(), this.pos.debtMint()]);
175
170
  return {
176
171
  supplyBalance: this.signerSupplyBalance,
177
172
  debtBalance: this.signerDebtBalance,
@@ -11,13 +11,13 @@ export interface SwapInput {
11
11
  slippageBps?: number;
12
12
  }
13
13
  export interface SwapParams extends SwapInput {
14
- destinationWallet: PublicKey;
14
+ destinationWallet?: PublicKey;
15
15
  slippageIncFactor?: number;
16
16
  wrapAndUnwrapSol?: boolean;
17
17
  }
18
18
  export interface JupSwapTransactionData {
19
19
  jupQuote: QuoteResponse;
20
- setupInstructions: TransactionBuilder;
20
+ setupIx: TransactionBuilder;
21
21
  swapIx: TransactionBuilder;
22
22
  cleanupIx: TransactionBuilder;
23
23
  lookupTableAddresses: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"jupSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/swap/jupSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,iBAAiB,EAAE,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,qBAAa,cAAc;IAKb,OAAO,CAAC,MAAM;IAJ1B,MAAM,mCAA4B;IAE3B,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAa;gBAEnC,MAAM,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;YAoBhD,kBAAkB;IAqChC,cAAc;IAId,OAAO,CAAC,0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,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;YAoBhD,kBAAkB;IAsChC,cAAc;IAId,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,0BAA0B;IAc5B,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2CnE,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAYlE"}
@@ -7,6 +7,7 @@ const solanaUtils_1 = require("../../utils/solanaUtils");
7
7
  const numberUtils_1 = require("../../utils/numberUtils");
8
8
  const accountUtils_1 = require("../../utils/accountUtils");
9
9
  const utils_1 = require("../../utils");
10
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
10
11
  class JupSwapManager {
11
12
  constructor(signer) {
12
13
  this.signer = signer;
@@ -38,7 +39,8 @@ class JupSwapManager {
38
39
  quoteResponse: this.jupQuote,
39
40
  wrapAndUnwrapSol: data.wrapAndUnwrapSol ?? false,
40
41
  useTokenLedger: !data.exactOut && !data.exactIn,
41
- destinationTokenAccount: (0, accountUtils_1.getTokenAccount)(data.destinationWallet, data.outputMint).toString(),
42
+ destinationTokenAccount: (0, accountUtils_1.getTokenAccount)(data.destinationWallet ??
43
+ (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), data.outputMint).toString(),
42
44
  },
43
45
  });
44
46
  if (!res) {
@@ -82,7 +84,7 @@ class JupSwapManager {
82
84
  return {
83
85
  jupQuote: this.jupQuote,
84
86
  lookupTableAddresses: instructions.addressLookupTableAddresses,
85
- setupInstructions: (0, umi_1.transactionBuilder)((instructions.setupInstructions ?? []).map((ix) => (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(ix)))),
87
+ setupIx: (0, umi_1.transactionBuilder)((instructions.setupInstructions ?? []).map((ix) => (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(ix)))),
86
88
  swapIx: (0, umi_1.transactionBuilder)([
87
89
  (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.swapInstruction)),
88
90
  ]),
@@ -97,7 +99,7 @@ class JupSwapManager {
97
99
  const swapData = await this.getJupSwapTxData(data);
98
100
  return {
99
101
  tx: (0, umi_1.transactionBuilder)().add([
100
- swapData.setupInstructions,
102
+ swapData.setupIx,
101
103
  swapData.swapIx,
102
104
  swapData.cleanupIx,
103
105
  ]),
@@ -320,7 +320,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
320
320
  return undefined;
321
321
  }
322
322
  const jupSwapManager = new __1.JupSwapManager(referralManager.umi.identity);
323
- const { lookupTableAddresses, setupInstructions, swapIx, cleanupIx } = await jupSwapManager.getJupSwapTxData({
323
+ const { lookupTableAddresses, setupIx, swapIx, cleanupIx } = await jupSwapManager.getJupSwapTxData({
324
324
  amount: tokenAccountData.amount,
325
325
  destinationWallet: referralManager.referralState,
326
326
  inputMint: tokenAccountData.mint,
@@ -329,7 +329,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
329
329
  slippageIncFactor: 0.25,
330
330
  });
331
331
  let tx = (0, umi_1.transactionBuilder)()
332
- .add(setupInstructions)
332
+ .add(setupIx)
333
333
  .add((0, generated_1.convertReferralFees)(referralManager.umi, {
334
334
  signer: referralManager.signer,
335
335
  intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.618",
3
+ "version": "1.0.620",
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",
@@ -211,13 +211,13 @@ export class RebalanceSwapManager {
211
211
  }
212
212
 
213
213
  async getSwapTxData() {
214
- const { jupQuote, lookupTableAddresses, setupInstructions, swapIx } =
214
+ const { jupQuote, lookupTableAddresses, setupIx, swapIx } =
215
215
  await this.jupSwapManager.getJupSwapTxData(this.swapParams);
216
216
 
217
217
  return {
218
218
  swapQuote: jupQuote,
219
219
  lookupTableAddresses,
220
- setupInstructions,
220
+ setupIx,
221
221
  swapIx,
222
222
  };
223
223
  }
@@ -246,7 +246,7 @@ export class RebalanceTxBuilder {
246
246
  }
247
247
 
248
248
  private async assembleTransaction(): Promise<TransactionItemInputs> {
249
- const { swapQuote, lookupTableAddresses, setupInstructions, swapIx } =
249
+ const { swapQuote, lookupTableAddresses, setupIx, swapIx } =
250
250
  await this.swapManager.getSwapTxData();
251
251
 
252
252
  const flashLoanDetails = this.flRequirements
@@ -277,7 +277,7 @@ export class RebalanceTxBuilder {
277
277
  );
278
278
 
279
279
  if (!flashLoanDetails) {
280
- tx = tx.add([setupInstructions, firstRebalance, swapIx, lastRebalance]);
280
+ tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
281
281
  } else {
282
282
  consoleLog("Flash loan details:", flashLoanDetails);
283
283
 
@@ -296,7 +296,7 @@ export class RebalanceTxBuilder {
296
296
  );
297
297
 
298
298
  tx = tx.add([
299
- setupInstructions,
299
+ setupIx,
300
300
  this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
301
301
  ...(addFirstRebalance ? [firstRebalance] : []),
302
302
  swapIx,
@@ -307,23 +307,15 @@ export abstract class SolautoClient extends ReferralStateManager {
307
307
  supplyBalance: bigint;
308
308
  debtBalance: bigint;
309
309
  }> {
310
- if (
311
- this.signerSupplyBalance !== undefined &&
312
- this.signerDebtBalance !== undefined
313
- ) {
314
- return {
315
- supplyBalance: this.signerSupplyBalance,
316
- debtBalance: this.signerDebtBalance,
317
- };
310
+ if (!this.signerSupplyBalance || !this.signerDebtBalance) {
311
+ [this.signerSupplyBalance, this.signerDebtBalance] =
312
+ await getWalletSplBalances(
313
+ this.connection,
314
+ toWeb3JsPublicKey(this.signer.publicKey),
315
+ [this.pos.supplyMint(), this.pos.debtMint()]
316
+ );
318
317
  }
319
318
 
320
- [this.signerSupplyBalance, this.signerDebtBalance] =
321
- await getWalletSplBalances(
322
- this.connection,
323
- toWeb3JsPublicKey(this.signer.publicKey),
324
- [this.pos.supplyMint(), this.pos.debtMint()]
325
- );
326
-
327
319
  return {
328
320
  supplyBalance: this.signerSupplyBalance,
329
321
  debtBalance: this.signerDebtBalance,
@@ -18,6 +18,7 @@ import {
18
18
  retryWithExponentialBackoff,
19
19
  } from "../../utils";
20
20
  import { TransactionItemInputs } from "../../types";
21
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
21
22
 
22
23
  export interface SwapInput {
23
24
  inputMint: PublicKey;
@@ -29,14 +30,14 @@ export interface SwapInput {
29
30
  }
30
31
 
31
32
  export interface SwapParams extends SwapInput {
32
- destinationWallet: PublicKey;
33
+ destinationWallet?: PublicKey;
33
34
  slippageIncFactor?: number;
34
35
  wrapAndUnwrapSol?: boolean;
35
36
  }
36
37
 
37
38
  export interface JupSwapTransactionData {
38
39
  jupQuote: QuoteResponse;
39
- setupInstructions: TransactionBuilder;
40
+ setupIx: TransactionBuilder;
40
41
  swapIx: TransactionBuilder;
41
42
  cleanupIx: TransactionBuilder;
42
43
  lookupTableAddresses: string[];
@@ -87,7 +88,8 @@ export class JupSwapManager {
87
88
  wrapAndUnwrapSol: data.wrapAndUnwrapSol ?? false,
88
89
  useTokenLedger: !data.exactOut && !data.exactIn,
89
90
  destinationTokenAccount: getTokenAccount(
90
- data.destinationWallet,
91
+ data.destinationWallet ??
92
+ toWeb3JsPublicKey(this.signer.publicKey),
91
93
  data.outputMint
92
94
  ).toString(),
93
95
  },
@@ -151,7 +153,7 @@ export class JupSwapManager {
151
153
  return {
152
154
  jupQuote: this.jupQuote,
153
155
  lookupTableAddresses: instructions.addressLookupTableAddresses,
154
- setupInstructions: transactionBuilder(
156
+ setupIx: transactionBuilder(
155
157
  (instructions.setupInstructions ?? []).map((ix) =>
156
158
  getWrappedInstruction(this.signer, jupIxToSolanaIx(ix))
157
159
  )
@@ -180,7 +182,7 @@ export class JupSwapManager {
180
182
 
181
183
  return {
182
184
  tx: transactionBuilder().add([
183
- swapData.setupInstructions,
185
+ swapData.setupIx,
184
186
  swapData.swapIx,
185
187
  swapData.cleanupIx,
186
188
  ]),
@@ -567,7 +567,7 @@ export async function convertReferralFeesToDestination(
567
567
  }
568
568
 
569
569
  const jupSwapManager = new JupSwapManager(referralManager.umi.identity);
570
- const { lookupTableAddresses, setupInstructions, swapIx, cleanupIx } =
570
+ const { lookupTableAddresses, setupIx, swapIx, cleanupIx } =
571
571
  await jupSwapManager.getJupSwapTxData({
572
572
  amount: tokenAccountData.amount,
573
573
  destinationWallet: referralManager.referralState,
@@ -578,7 +578,7 @@ export async function convertReferralFeesToDestination(
578
578
  });
579
579
 
580
580
  let tx = transactionBuilder()
581
- .add(setupInstructions)
581
+ .add(setupIx)
582
582
  .add(
583
583
  convertReferralFees(referralManager.umi, {
584
584
  signer: referralManager.signer,