@haven-fi/solauto-sdk 1.0.207 → 1.0.208

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,7 +1,7 @@
1
- import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
1
+ import { TransactionBuilder } from "@metaplex-foundation/umi";
2
2
  import { PublicKey } from "@solana/web3.js";
3
- import { ReferralState } from "../generated";
4
3
  import { SolautoClient } from "../clients/solautoClient";
4
+ import { ReferralStateManager } from "../clients";
5
5
  export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
6
6
  export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
7
7
  export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
@@ -9,7 +9,7 @@ export declare function buildSolautoRebalanceTransaction(client: SolautoClient,
9
9
  tx: TransactionBuilder;
10
10
  lookupTableAddresses: string[];
11
11
  } | undefined>;
12
- export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: PublicKey): Promise<[TransactionBuilder, string[]] | undefined>;
12
+ export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<[TransactionBuilder, string[]] | undefined>;
13
13
  export declare function getErrorInfo(tx: TransactionBuilder, error: any): {
14
14
  errorName: string | undefined;
15
15
  errorInfo: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAGL,aAAa,EAYd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0B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AE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBAwCzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAkHA;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
@@ -400,26 +400,26 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
400
400
  lookupTableAddresses,
401
401
  };
402
402
  }
403
- async function convertReferralFeesToDestination(umi, referralState, tokenAccount) {
404
- const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(umi, tokenAccount);
403
+ async function convertReferralFeesToDestination(referralManager, tokenAccount, destinationMint) {
404
+ const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(referralManager.umi, tokenAccount);
405
405
  if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
406
406
  return undefined;
407
407
  }
408
- const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(umi.identity, {
408
+ const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(referralManager.umi.identity, {
409
409
  amount: tokenAccountData.amount,
410
- destinationWallet: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.publicKey),
410
+ destinationWallet: referralManager.referralState,
411
411
  inputMint: tokenAccountData.mint,
412
- outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.destFeesMint),
412
+ outputMint: destinationMint,
413
413
  exactIn: true,
414
414
  slippageIncFactor: 0.25,
415
415
  });
416
416
  let tx = (0, umi_1.transactionBuilder)()
417
417
  .add(setupInstructions)
418
- .add((0, generated_1.convertReferralFees)(umi, {
419
- signer: umi.identity,
420
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(umi.identity.publicKey), tokenAccountData.mint)),
418
+ .add((0, generated_1.convertReferralFees)(referralManager.umi, {
419
+ signer: referralManager.umi.identity,
420
+ intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
421
421
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
422
- referralState: referralState.publicKey,
422
+ referralState: (0, umi_1.publicKey)(referralManager.referralState),
423
423
  referralFeesTa: (0, umi_1.publicKey)(tokenAccount),
424
424
  }))
425
425
  .add(swapIx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.207",
3
+ "version": "1.0.208",
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",
@@ -22,7 +22,6 @@
22
22
  "@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
23
23
  "@solana/spl-token": "^0.4.0",
24
24
  "@solana/web3.js": "^1.92.1",
25
- "@sqds/multisig": "^2.1.3",
26
25
  "bs58": "^5.0.0",
27
26
  "cross-fetch": "^4.0.0",
28
27
  "rpc-websockets": "7.11.0"
@@ -26,6 +26,7 @@ import {
26
26
  getMarginfiRebalanceInstructionDataSerializer,
27
27
  getSolautoErrorFromCode,
28
28
  isSolautoAction,
29
+ safeFetchReferralState,
29
30
  solautoAction,
30
31
  } from "../generated";
31
32
  import { SolautoClient } from "../clients/solautoClient";
@@ -65,7 +66,7 @@ import {
65
66
  getMarginfiErrorFromName,
66
67
  MARGINFI_PROGRAM_ID,
67
68
  } from "../marginfi-sdk";
68
- import { TxHandler } from "../clients";
69
+ import { ReferralStateManager, TxHandler } from "../clients";
69
70
  import {
70
71
  createJupiterProgram,
71
72
  getJupiterErrorFromName,
@@ -750,21 +751,21 @@ export async function buildSolautoRebalanceTransaction(
750
751
  }
751
752
 
752
753
  export async function convertReferralFeesToDestination(
753
- umi: Umi,
754
- referralState: ReferralState,
755
- tokenAccount: PublicKey
754
+ referralManager: ReferralStateManager,
755
+ tokenAccount: PublicKey,
756
+ destinationMint: PublicKey
756
757
  ): Promise<[TransactionBuilder, string[]] | undefined> {
757
- const tokenAccountData = await getTokenAccountData(umi, tokenAccount);
758
+ const tokenAccountData = await getTokenAccountData(referralManager.umi, tokenAccount);
758
759
  if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
759
760
  return undefined;
760
761
  }
761
762
 
762
763
  const { lookupTableAddresses, setupInstructions, swapIx } =
763
- await getJupSwapTransaction(umi.identity, {
764
+ await getJupSwapTransaction(referralManager.umi.identity, {
764
765
  amount: tokenAccountData.amount,
765
- destinationWallet: toWeb3JsPublicKey(referralState.publicKey),
766
+ destinationWallet: referralManager.referralState,
766
767
  inputMint: tokenAccountData.mint,
767
- outputMint: toWeb3JsPublicKey(referralState.destFeesMint),
768
+ outputMint: destinationMint,
768
769
  exactIn: true,
769
770
  slippageIncFactor: 0.25,
770
771
  });
@@ -772,16 +773,16 @@ export async function convertReferralFeesToDestination(
772
773
  let tx = transactionBuilder()
773
774
  .add(setupInstructions)
774
775
  .add(
775
- convertReferralFees(umi, {
776
- signer: umi.identity,
776
+ convertReferralFees(referralManager.umi, {
777
+ signer: referralManager.umi.identity,
777
778
  intermediaryTa: publicKey(
778
779
  getTokenAccount(
779
- toWeb3JsPublicKey(umi.identity.publicKey),
780
+ toWeb3JsPublicKey(referralManager.umi.identity.publicKey),
780
781
  tokenAccountData.mint
781
782
  )
782
783
  ),
783
784
  ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
784
- referralState: referralState.publicKey,
785
+ referralState: publicKey(referralManager.referralState),
785
786
  referralFeesTa: publicKey(tokenAccount),
786
787
  })
787
788
  )