@haven-fi/solauto-sdk 1.0.84 → 1.0.86

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,9 +4,9 @@ import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
4
4
  import { ReferralState } from "../generated";
5
5
  import { TxHandler } from "./txHandler";
6
6
  interface ReferralStateManagerArgs {
7
- referralAuthority?: PublicKey;
8
7
  signer?: Signer;
9
8
  wallet?: WalletAdapter;
9
+ referralAuthority?: PublicKey;
10
10
  }
11
11
  export declare class ReferralStateManager extends TxHandler {
12
12
  localTest?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,MAAM,EAAkB,kBAAkB,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAyB,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAA2C,aAAa,EAAgD,MAAM,cAAc,CAAC;AAEpI,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,UAAU,wBAAwB;IAC9B,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAQN,SAAS,CAAC,EAAE,OAAO;IAPrD,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;gBAEpC,YAAY,EAAE,MAAM,EAAS,SAAS,CAAC,EAAE,OAAO,YAAA;IAStD,UAAU,CAAC,IAAI,EAAE,wBAAwB;IAe/C,mBAAmB,IAAI,MAAM,E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kB;IAiBrH,mBAAmB,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,kBAAkB;IAwB3D,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAC5C"}
@@ -2,7 +2,7 @@ import { AddressLookupTableInput, TransactionBuilder, Umi } from "@metaplex-foun
2
2
  import { SolautoClient } from "../clients/solautoClient";
3
3
  import { ErrorsToThrow } from "../utils/generalUtils";
4
4
  import { PriorityFeeSetting } from "../types";
5
- import { TxHandler } from "../clients";
5
+ import { ReferralStateManager, TxHandler } from "../clients";
6
6
  declare class LookupTables {
7
7
  defaultLuts: string[];
8
8
  private umi;
@@ -57,11 +57,11 @@ export declare class TransactionsManager {
57
57
  private errorsToThrow?;
58
58
  private statuses;
59
59
  private lookupTables;
60
- constructor(txHandler: TxHandler, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, simulateOnly?: boolean | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
60
+ constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, simulateOnly?: boolean | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
61
61
  private assembleTransactionSets;
62
62
  updateStatus(name: string, status: TransactionStatus, txSig?: string): void;
63
63
  debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
64
- sendWithClient(items: TransactionItem[], client: SolautoClient, prioritySetting?: PriorityFeeSetting): Promise<void>;
64
+ clientSend(items: TransactionItem[], prioritySetting?: PriorityFeeSetting): Promise<void>;
65
65
  send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean): Promise<void>;
66
66
  }
67
67
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA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AuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAkB7D,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB;IAkEzE,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,OAAO;CAyGjG"}
@@ -189,7 +189,8 @@ class TransactionsManager {
189
189
  }
190
190
  }
191
191
  }
192
- async sendWithClient(items, client, prioritySetting) {
192
+ async clientSend(items, prioritySetting) {
193
+ const client = this.txHandler;
193
194
  const updateLookupTable = await client.updateLookupTable();
194
195
  if (updateLookupTable &&
195
196
  updateLookupTable.updateLutTx.getInstructions().length > 0 &&
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IA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CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA+D3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CAqDA;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"}
@@ -15,6 +15,7 @@ const solautoConstants_1 = require("../constants/solautoConstants");
15
15
  const marginfiAccounts_1 = require("../constants/marginfiAccounts");
16
16
  const generalAccounts_1 = require("../constants/generalAccounts");
17
17
  const solanaUtils_1 = require("./solanaUtils");
18
+ const accountUtils_1 = require("./accountUtils");
18
19
  function findMarginfiAccounts(bank) {
19
20
  for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
20
21
  const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[key];
@@ -59,7 +60,7 @@ async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
59
60
  return [maxLtv, liqThreshold];
60
61
  }
61
62
  async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithSolauto) {
62
- const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
63
+ const getAccounts = async (authorityPk) => await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
63
64
  commitment: "finalized",
64
65
  dataSlice: {
65
66
  offset: 0,
@@ -71,14 +72,22 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
71
72
  },
72
73
  {
73
74
  memcmp: {
74
- bytes: new Uint8Array(authority.toBuffer()),
75
+ bytes: new Uint8Array(authorityPk.toBuffer()),
75
76
  offset: 40, // Anchor account discriminator + group pubkey
76
77
  },
77
78
  },
78
79
  ],
79
80
  });
81
+ let marginfiAccounts = [];
82
+ let selfManagedSolautoPositions = [];
80
83
  if (compatibleWithSolauto) {
81
- const positionStates = await Promise.all(marginfiAccounts.map(async (x) => ({
84
+ [marginfiAccounts, selfManagedSolautoPositions] = await Promise.all([getAccounts(authority), getAccounts((0, accountUtils_1.getSolautoPositionAccount)(authority, 0))]);
85
+ }
86
+ else {
87
+ marginfiAccounts = await getAccounts(authority);
88
+ }
89
+ if (compatibleWithSolauto) {
90
+ const positionStates = await Promise.all([...selfManagedSolautoPositions, ...marginfiAccounts].map(async (x) => ({
82
91
  publicKey: x.publicKey,
83
92
  state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
84
93
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
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",
@@ -4,13 +4,13 @@ import { publicKey, Signer, signerIdentity, TransactionBuilder, Umi } from "@met
4
4
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
5
5
  import { WalletAdapter, walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
6
6
  import { claimReferralFees, createSolautoProgram, ReferralState, safeFetchReferralState, updateReferralStates } from "../generated";
7
- import { getReferralState, getSolanaRpcConnection, getTokenAccount } from "../utils";
7
+ import { getReferralState, getTokenAccount } from "../utils";
8
8
  import { TxHandler } from "./txHandler";
9
9
 
10
10
  interface ReferralStateManagerArgs {
11
- referralAuthority?: PublicKey;
12
11
  signer?: Signer;
13
12
  wallet?: WalletAdapter;
13
+ referralAuthority?: PublicKey;
14
14
  }
15
15
 
16
16
  export class ReferralStateManager extends TxHandler {
@@ -17,7 +17,7 @@ import {
17
17
  import { getTransactionChores } from "./transactionUtils";
18
18
  import { PriorityFeeSetting } from "../types";
19
19
  import { Connection, PublicKey } from "@solana/web3.js";
20
- import { TxHandler } from "../clients";
20
+ import { ReferralStateManager, TxHandler } from "../clients";
21
21
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
22
22
 
23
23
  class LookupTables {
@@ -183,7 +183,7 @@ export class TransactionsManager {
183
183
  private lookupTables: LookupTables;
184
184
 
185
185
  constructor(
186
- private txHandler: TxHandler,
186
+ private txHandler: SolautoClient | ReferralStateManager,
187
187
  private statusCallback?: (statuses: TransactionManagerStatuses) => void,
188
188
  private simulateOnly?: boolean,
189
189
  private mustBeAtomic?: boolean,
@@ -265,7 +265,9 @@ export class TransactionsManager {
265
265
  }
266
266
  }
267
267
 
268
- async sendWithClient(items: TransactionItem[], client: SolautoClient, prioritySetting?: PriorityFeeSetting) {
268
+ async clientSend(items: TransactionItem[], prioritySetting?: PriorityFeeSetting) {
269
+ const client = this.txHandler as SolautoClient;
270
+
269
271
  const updateLookupTable = await client.updateLookupTable();
270
272
  if (
271
273
  updateLookupTable &&
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { publicKey, Umi } from "@metaplex-foundation/umi";
2
+ import { publicKey, RpcAccount, Umi } from "@metaplex-foundation/umi";
3
3
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
4
4
  import {
5
5
  Bank,
@@ -23,6 +23,7 @@ import { PositionState, PositionTokenUsage } from "../generated";
23
23
  import { USD_DECIMALS } from "../constants/generalAccounts";
24
24
  import { LivePositionUpdates } from "./solauto/generalUtils";
25
25
  import { currentUnixSecondsSolana } from "./solanaUtils";
26
+ import { getSolautoPositionAccount } from "./accountUtils";
26
27
 
27
28
  export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
28
29
  for (const key in MARGINFI_ACCOUNTS) {
@@ -94,7 +95,7 @@ export async function getMaxLtvAndLiqThreshold(
94
95
  BigInt(
95
96
  Math.round(
96
97
  bytesToI80F48(supply.bank!.totalAssetShares.value) *
97
- bytesToI80F48(supply.bank!.assetShareValue.value)
98
+ bytesToI80F48(supply.bank!.assetShareValue.value)
98
99
  )
99
100
  ),
100
101
  supply.bank!.mintDecimals
@@ -119,7 +120,7 @@ export async function getAllMarginfiAccountsByAuthority(
119
120
  ): Promise<
120
121
  { marginfiAccount: PublicKey; supplyMint?: PublicKey; debtMint?: PublicKey }[]
121
122
  > {
122
- const marginfiAccounts = await umi.rpc.getProgramAccounts(
123
+ const getAccounts = async (authorityPk: PublicKey) => await umi.rpc.getProgramAccounts(
123
124
  MARGINFI_PROGRAM_ID,
124
125
  {
125
126
  commitment: "finalized",
@@ -133,17 +134,25 @@ export async function getAllMarginfiAccountsByAuthority(
133
134
  },
134
135
  {
135
136
  memcmp: {
136
- bytes: new Uint8Array(authority.toBuffer()),
137
+ bytes: new Uint8Array(authorityPk.toBuffer()),
137
138
  offset: 40, // Anchor account discriminator + group pubkey
138
139
  },
139
140
  },
140
141
  ],
141
142
  }
142
- );
143
+ )
144
+
145
+ let marginfiAccounts: RpcAccount[] = [];
146
+ let selfManagedSolautoPositions: RpcAccount[] = [];
147
+ if (compatibleWithSolauto) {
148
+ [marginfiAccounts, selfManagedSolautoPositions] = await Promise.all([getAccounts(authority), getAccounts(getSolautoPositionAccount(authority, 0))]);
149
+ } else {
150
+ marginfiAccounts = await getAccounts(authority);
151
+ }
143
152
 
144
153
  if (compatibleWithSolauto) {
145
154
  const positionStates = await Promise.all(
146
- marginfiAccounts.map(async (x) => ({
155
+ [...selfManagedSolautoPositions, ...marginfiAccounts].map(async (x) => ({
147
156
  publicKey: x.publicKey,
148
157
  state: await getMarginfiAccountPositionState(
149
158
  umi,
@@ -190,7 +199,7 @@ async function getTokenUsage(
190
199
  amountCanBeUsed = isAsset
191
200
  ? Number(bank.config.depositLimit) - totalDeposited
192
201
  : totalDeposited -
193
- bytesToI80F48(bank.totalLiabilityShares.value) * liabilityShareValue;
202
+ bytesToI80F48(bank.totalLiabilityShares.value) * liabilityShareValue;
194
203
  }
195
204
 
196
205
  return {
@@ -200,22 +209,22 @@ async function getTokenUsage(
200
209
  baseUnit: BigInt(Math.round(amountUsed)),
201
210
  baseAmountUsdValue: bank
202
211
  ? toBaseUnit(
203
- fromBaseUnit(BigInt(Math.round(amountUsed)), bank.mintDecimals) *
204
- marketPrice,
205
- USD_DECIMALS
206
- )
212
+ fromBaseUnit(BigInt(Math.round(amountUsed)), bank.mintDecimals) *
213
+ marketPrice,
214
+ USD_DECIMALS
215
+ )
207
216
  : BigInt(0),
208
217
  },
209
218
  amountCanBeUsed: {
210
219
  baseUnit: BigInt(Math.round(amountCanBeUsed)),
211
220
  baseAmountUsdValue: bank
212
221
  ? toBaseUnit(
213
- fromBaseUnit(
214
- BigInt(Math.round(amountCanBeUsed)),
215
- bank.mintDecimals
216
- ) * marketPrice,
217
- USD_DECIMALS
218
- )
222
+ fromBaseUnit(
223
+ BigInt(Math.round(amountCanBeUsed)),
224
+ bank.mintDecimals
225
+ ) * marketPrice,
226
+ USD_DECIMALS
227
+ )
219
228
  : BigInt(0),
220
229
  },
221
230
  baseAmountMarketPriceUsd: toBaseUnit(marketPrice, USD_DECIMALS),
@@ -242,16 +251,16 @@ export async function getMarginfiAccountPositionState(
242
251
  let supplyBank: Bank | null =
243
252
  supplyMint && supplyMint !== PublicKey.default
244
253
  ? await safeFetchBank(
245
- umi,
246
- publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank)
247
- )
254
+ umi,
255
+ publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank)
256
+ )
248
257
  : null;
249
258
  let debtBank: Bank | null =
250
259
  debtMint && debtMint !== PublicKey.default
251
260
  ? await safeFetchBank(
252
- umi,
253
- publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank)
254
- )
261
+ umi,
262
+ publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank)
263
+ )
255
264
  : null;
256
265
 
257
266
  let supplyUsage: PositionTokenUsage | undefined = undefined;
@@ -159,6 +159,6 @@ describe("Solauto Marginfi tests", async () => {
159
159
  undefined,
160
160
  !payForTransactions,
161
161
  useJitoBundle
162
- ).sendWithClient(transactionItems, client);
162
+ ).clientSend(transactionItems);
163
163
  });
164
164
  });