@haven-fi/solauto-sdk 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/dist/clients/solautoClient.d.ts +3 -3
  2. package/dist/clients/solautoClient.d.ts.map +1 -1
  3. package/dist/clients/solautoClient.js +15 -46
  4. package/dist/clients/solautoMarginfiClient.d.ts +1 -1
  5. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  6. package/dist/clients/solautoMarginfiClient.js +4 -5
  7. package/dist/constants/solautoConstants.d.ts +0 -3
  8. package/dist/constants/solautoConstants.d.ts.map +1 -1
  9. package/dist/constants/solautoConstants.js +1 -8
  10. package/dist/transactions/transactionUtils.d.ts +2 -2
  11. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  12. package/dist/transactions/transactionUtils.js +9 -10
  13. package/dist/transactions/transactionsManager.d.ts.map +1 -1
  14. package/dist/transactions/transactionsManager.js +6 -7
  15. package/dist/utils/generalUtils.d.ts +2 -2
  16. package/dist/utils/generalUtils.d.ts.map +1 -1
  17. package/dist/utils/generalUtils.js +3 -3
  18. package/dist/utils/marginfiUtils.d.ts +4 -3
  19. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  20. package/dist/utils/marginfiUtils.js +17 -16
  21. package/dist/utils/solanaUtils.d.ts +6 -7
  22. package/dist/utils/solanaUtils.d.ts.map +1 -1
  23. package/dist/utils/solanaUtils.js +20 -21
  24. package/dist/utils/solauto/generalUtils.d.ts +4 -4
  25. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  26. package/dist/utils/solauto/generalUtils.js +50 -7
  27. package/package.json +1 -1
  28. package/src/clients/solautoClient.ts +39 -73
  29. package/src/clients/solautoMarginfiClient.ts +5 -8
  30. package/src/constants/solautoConstants.ts +1 -11
  31. package/src/transactions/transactionUtils.ts +11 -11
  32. package/src/transactions/transactionsManager.ts +11 -7
  33. package/src/utils/generalUtils.ts +5 -5
  34. package/src/utils/marginfiUtils.ts +28 -12
  35. package/src/utils/solanaUtils.ts +28 -23
  36. package/src/utils/solauto/generalUtils.ts +91 -14
  37. package/tests/transactions/solautoMarginfi.ts +2 -1
@@ -1,5 +1,5 @@
1
1
  import "rpc-websockets/dist/lib/client";
2
- import { PublicKey } from "@solana/web3.js";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
3
  import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
4
4
  import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
5
5
  import { DCASettings, DCASettingsInpArgs, LendingPlatform, PositionState, ReferralState, SolautoActionArgs, SolautoPosition, SolautoRebalanceTypeArgs, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, UpdatePositionDataArgs } from "../generated";
@@ -19,6 +19,7 @@ export interface SolautoClientArgs {
19
19
  export declare abstract class SolautoClient {
20
20
  localTest: boolean;
21
21
  umi: Umi;
22
+ connection: Connection;
22
23
  lendingPlatform: LendingPlatform;
23
24
  authority: PublicKey;
24
25
  signer: Signer;
@@ -46,7 +47,7 @@ export declare abstract class SolautoClient {
46
47
  upToDateLutAccounts: PublicKey[];
47
48
  livePositionUpdates: LivePositionUpdates;
48
49
  constructor(localTest?: boolean);
49
- initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
50
+ baseInitialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform, heliusApiKey: string): Promise<void>;
50
51
  log(...args: any[]): void;
51
52
  resetLivePositionUpdates(): Promise<void>;
52
53
  defaultLookupTables(): string[];
@@ -69,7 +70,6 @@ export declare abstract class SolautoClient {
69
70
  abstract flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
70
71
  abstract flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
71
72
  abstract rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
72
- positionStateWithLatestPrices(): Promise<PositionState | undefined>;
73
73
  getFreshPositionState(): Promise<PositionState | undefined>;
74
74
  }
75
75
  //# sourceMappingURL=solautoClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAAyB,MAAM,iDAAiD,CAAC;AACvG,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EAQvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAQnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAOpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAChC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAE9B,oBAAoB,CAAC,EAAE,SAAS,CAAC;IACjC,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,8BAAsB,aAAa;IAC1B,SAAS,EAAE,OAAO,CAAC;IAEnB,GAAG,EAAG,GAAG,CAAC;IACV,eAAe,EAAG,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,CAAC;IACtB,MAAM,EAAG,MAAM,CAAC;IAEhB,UAAU,E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;IA4BjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAYlE"}
@@ -14,20 +14,28 @@ const spl_token_1 = require("@solana/spl-token");
14
14
  const solautoConstants_1 = require("../constants/solautoConstants");
15
15
  const generalUtils_1 = require("../utils/generalUtils");
16
16
  const generalUtils_2 = require("../utils/solauto/generalUtils");
17
- const numberUtils_1 = require("../utils/numberUtils");
17
+ const umi_bundle_defaults_1 = require("@metaplex-foundation/umi-bundle-defaults");
18
18
  class SolautoClient {
19
19
  constructor(localTest) {
20
20
  this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
21
21
  this.localTest = Boolean(localTest);
22
22
  }
23
- async initialize(args, lendingPlatform) {
24
- this.umi = solautoConstants_1.UMI;
23
+ async baseInitialize(args, lendingPlatform, heliusApiKey) {
24
+ this.connection = new web3_js_1.Connection(`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`, "finalized");
25
+ this.umi = (0, umi_bundle_defaults_1.createUmi)(this.connection).use({
26
+ install(umi) {
27
+ umi.programs.add((0, generated_1.createSolautoProgram)(), false);
28
+ },
29
+ });
25
30
  if (!args.signer && !args.wallet) {
26
31
  throw new Error("Signer or wallet must be provided");
27
32
  }
28
- this.umi = solautoConstants_1.UMI.use(args.signer ? (0, umi_1.signerIdentity)(args.signer) : (0, umi_signer_wallet_adapters_1.walletAdapterIdentity)(args.wallet, true));
33
+ this.umi = this.umi.use(args.signer
34
+ ? (0, umi_1.signerIdentity)(args.signer)
35
+ : (0, umi_signer_wallet_adapters_1.walletAdapterIdentity)(args.wallet, true));
29
36
  this.signer = this.umi.identity;
30
- this.authority = args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.umi.identity.publicKey);
37
+ this.authority =
38
+ args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.umi.identity.publicKey);
31
39
  this.positionId = args.positionId;
32
40
  this.selfManaged = this.positionId === 0;
33
41
  this.lendingPlatform = lendingPlatform;
@@ -127,7 +135,7 @@ class SolautoClient {
127
135
  }
128
136
  async fetchExistingAuthorityLutAccounts() {
129
137
  const lookupTable = this.authorityLutAddress
130
- ? await solautoConstants_1.CONNECTION.getAddressLookupTable(this.authorityLutAddress)
138
+ ? await this.connection.getAddressLookupTable(this.authorityLutAddress)
131
139
  : null;
132
140
  if (lookupTable === null) {
133
141
  this.authorityLutAddress = undefined;
@@ -147,7 +155,7 @@ class SolautoClient {
147
155
  const [createLookupTableInst, lookupTableAddress] = web3_js_1.AddressLookupTableProgram.createLookupTable({
148
156
  authority: this.authority,
149
157
  payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
150
- recentSlot: await solautoConstants_1.CONNECTION.getSlot({ commitment: "finalized" }),
158
+ recentSlot: await this.umi.rpc.getSlot({ commitment: "finalized" }),
151
159
  });
152
160
  this.authorityLutAddress = lookupTableAddress;
153
161
  tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, createLookupTableInst));
@@ -369,45 +377,6 @@ class SolautoClient {
369
377
  }
370
378
  return tx;
371
379
  }
372
- async positionStateWithLatestPrices() {
373
- if (!this.solautoPositionData) {
374
- return undefined;
375
- }
376
- const state = this.solautoPositionState ?? this.solautoPositionData.state;
377
- if ((0, generalUtils_1.currentUnixSeconds)() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
378
- return this.getFreshPositionState();
379
- }
380
- const [supplyPrice, debtPrice] = await (0, generalUtils_1.getTokenPrices)([
381
- (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint),
382
- (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint),
383
- ]);
384
- const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseUnit, state.supply.decimals) *
385
- supplyPrice;
386
- const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseUnit, state.debt.decimals) *
387
- debtPrice;
388
- return {
389
- ...state,
390
- liqUtilizationRateBps: (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, state.liqThresholdBps),
391
- netWorth: {
392
- ...state.netWorth,
393
- baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(supplyUsd - debtUsd, generalAccounts_1.USD_DECIMALS),
394
- },
395
- supply: {
396
- ...state.supply,
397
- amountUsed: {
398
- ...state.supply.amountUsed,
399
- baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(supplyUsd, generalAccounts_1.USD_DECIMALS),
400
- },
401
- },
402
- debt: {
403
- ...state.debt,
404
- amountUsed: {
405
- ...state.debt.amountUsed,
406
- baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(debtUsd, generalAccounts_1.USD_DECIMALS),
407
- },
408
- },
409
- };
410
- }
411
380
  async getFreshPositionState() {
412
381
  if (Boolean(this.solautoPositionState) &&
413
382
  Number(this.solautoPositionState.lastUpdated) >
@@ -24,7 +24,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
24
24
  intermediaryMarginfiAccountSigner?: Signer;
25
25
  intermediaryMarginfiAccountPk: PublicKey;
26
26
  intermediaryMarginfiAccount?: MarginfiAccount;
27
- initialize(args: SolautoMarginfiClientArgs): Promise<void>;
27
+ initialize(args: SolautoMarginfiClientArgs, heliusApiKey: string): Promise<void>;
28
28
  defaultLookupTables(): string[];
29
29
  lutAccountsToAdd(): PublicKey[];
30
30
  openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,SAAS,EAEV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAOhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOnE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,EACnB,mBAAmB,CAAC,EAAE,SAAS,GAC9B,yBAAyB,CAU3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IAC/C,eAAe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IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM;IAiEtE,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAQ/B,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA2C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAMhE,OAAO,CAAC,6BAA6B;IA8DrC,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA4CrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IA8ElE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiBlE"}
@@ -25,11 +25,11 @@ function newMarginfiSolautoManagedPositionArgs(positionId, signer, wallet, suppl
25
25
  }
26
26
  exports.newMarginfiSolautoManagedPositionArgs = newMarginfiSolautoManagedPositionArgs;
27
27
  class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
28
- async initialize(args) {
28
+ async initialize(args, heliusApiKey) {
29
29
  if (args.marginfiAccount) {
30
30
  this.marginfiAccount = args.marginfiAccount;
31
31
  }
32
- await super.initialize(args, generated_1.LendingPlatform.Marginfi);
32
+ await this.baseInitialize(args, generated_1.LendingPlatform.Marginfi, heliusApiKey);
33
33
  this.marginfiAccountSeedIdx = args.marginfiAccountSeedIdx;
34
34
  this.marginfiAccount =
35
35
  this.marginfiAccountSeedIdx !== undefined
@@ -50,7 +50,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
50
50
  this.marginfiDebtBankAccounts = (0, marginfiUtils_1.findMarginfiBankAccounts)({
51
51
  mint: this.debtLiquidityMint.toString(),
52
52
  });
53
- const existingMarginfiAccounts = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey));
53
+ const existingMarginfiAccounts = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(this.umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey));
54
54
  const emptyMarginfiAccounts = existingMarginfiAccounts.filter((x) => x.lendingAccount.balances.find((y) => y.bankPk.toString() !== web3_js_1.PublicKey.default.toString() &&
55
55
  (Math.round((0, numberUtils_1.bytesToI80F48)(y.assetShares.value)) != 0 ||
56
56
  Math.round((0, numberUtils_1.bytesToI80F48)(y.liabilityShares.value)) != 0)) === undefined);
@@ -305,8 +305,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
305
305
  if (state) {
306
306
  return state;
307
307
  }
308
- const marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(this.umi, (0, umi_1.publicKey)(this.marginfiAccountPk));
309
- const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.supplyLiquidityMint, this.debtLiquidityMint, marginfiAccount, this.livePositionUpdates);
308
+ const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.supplyLiquidityMint, this.debtLiquidityMint, this.marginfiAccountPk, this.livePositionUpdates);
310
309
  this.log(freshState);
311
310
  return freshState;
312
311
  }
@@ -1,10 +1,7 @@
1
- import { Connection } from "@solana/web3.js";
2
1
  export declare const DEFAULT_RISK_AVERSION_BPS = 1500;
3
2
  export declare const DEFAULT_LIMIT_GAP_BPS = 1000;
4
3
  export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
5
4
  export declare const MAX_REPAY_GAP_BPS = 100;
6
- export declare const CONNECTION: Connection;
7
- export declare const UMI: import("@metaplex-foundation/umi").Umi;
8
5
  export declare const PRICES: {
9
6
  [key: string]: {
10
7
  price: number;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,UAAU,EAEX,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,eAAO,MAAM,UAAU,YAGtB,CAAC;AAOF,eAAO,MAAM,GAAG,wCAId,CAAC;AAEH,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,kBAAkB,gDAAgD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAiBA,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,kBAAkB,gDAAgD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.JUPITER_PROGRAM_ID = exports.PRICES = exports.UMI = exports.CONNECTION = exports.MAX_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.DEFAULT_LIMIT_GAP_BPS = exports.DEFAULT_RISK_AVERSION_BPS = void 0;
4
- const umi_bundle_defaults_1 = require("@metaplex-foundation/umi-bundle-defaults");
3
+ exports.STANDARD_LUT_ACCOUNTS = exports.JUPITER_PROGRAM_ID = 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;
5
4
  const web3_js_1 = require("@solana/web3.js");
6
5
  const spl_token_1 = require("@solana/spl-token");
7
6
  // import { JitoRpcConnection } from "jito-ts";
@@ -11,17 +10,11 @@ exports.DEFAULT_RISK_AVERSION_BPS = 1500;
11
10
  exports.DEFAULT_LIMIT_GAP_BPS = 1000;
12
11
  exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
13
12
  exports.MAX_REPAY_GAP_BPS = 100;
14
- exports.CONNECTION = new web3_js_1.Connection(`https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`, "finalized");
15
13
  // export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
16
14
  // export const JITO_CONNECTION = new JitoRpcConnection(
17
15
  // `https://${JITO_BLOCK_ENGINE}`,
18
16
  // "finalized"
19
17
  // );
20
- exports.UMI = (0, umi_bundle_defaults_1.createUmi)(exports.CONNECTION).use({
21
- install(umi) {
22
- umi.programs.add((0, generated_1.createSolautoProgram)(), false);
23
- },
24
- });
25
18
  exports.PRICES = {};
26
19
  exports.JUPITER_PROGRAM_ID = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
27
20
  exports.STANDARD_LUT_ACCOUNTS = [
@@ -1,4 +1,4 @@
1
- import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
1
+ import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
2
  import { Account as SplTokenAccount } from "@solana/spl-token";
3
3
  import { ReferralState } from "../generated";
4
4
  import { SolautoClient } from "../clients/solautoClient";
@@ -8,5 +8,5 @@ export declare function buildSolautoRebalanceTransaction(client: SolautoClient,
8
8
  tx: TransactionBuilder;
9
9
  lookupTableAddresses: string[];
10
10
  } | undefined>;
11
- export declare function convertReferralFeesToDestination(referralState: ReferralState, tokenAccount: SplTokenAccount, signer: Signer): Promise<[TransactionBuilder, string[]]>;
11
+ export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: SplTokenAccount): Promise<[TransactionBuilder, string[]]>;
12
12
  //# sourceMappingURL=transactionUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EAQd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAkLzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAsE7B;AA0DD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;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,CA2GA;AAED,wBAAsB,gCAAgC,CACpD,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
1
+ {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EAQd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAiLzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAsE7B;AA0DD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;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,CA2GA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
@@ -10,7 +10,6 @@ const solanaUtils_1 = require("../utils/solanaUtils");
10
10
  const jupiterUtils_1 = require("../utils/jupiterUtils");
11
11
  const rebalanceUtils_1 = require("../utils/solauto/rebalanceUtils");
12
12
  const generalUtils_1 = require("../utils/generalUtils");
13
- const solautoConstants_1 = require("../constants/solautoConstants");
14
13
  const numberUtils_1 = require("../utils/numberUtils");
15
14
  const generalUtils_2 = require("../utils/solauto/generalUtils");
16
15
  const accountUtils_1 = require("../utils/accountUtils");
@@ -58,7 +57,7 @@ async function transactionChoresBefore(client, solautoActions, initiatingDcaIn)
58
57
  }
59
58
  const wSolUsage = getWSolUsage(client, solautoActions, initiatingDcaIn, undefined);
60
59
  if (wSolUsage !== undefined) {
61
- if (!(0, generalUtils_1.getSolanaAccountCreated)(wSolUsage.wSolTokenAccount)) {
60
+ if (!(0, generalUtils_1.getSolanaAccountCreated)(client.umi, wSolUsage.wSolTokenAccount)) {
62
61
  client.log(`Closing signer wSol TA`);
63
62
  chores = chores.add((0, solanaUtils_1.closeTokenAccountUmiIx)(client.signer, wSolUsage.wSolTokenAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)));
64
63
  }
@@ -76,7 +75,7 @@ async function transactionChoresBefore(client, solautoActions, initiatingDcaIn)
76
75
  }
77
76
  if (amountToTransfer > 0) {
78
77
  const amount = amountToTransfer +
79
- (await solautoConstants_1.UMI.rpc.getRent(spl_token_1.ACCOUNT_SIZE)).basisPoints;
78
+ (await client.umi.rpc.getRent(spl_token_1.ACCOUNT_SIZE)).basisPoints;
80
79
  client.log(`Transferring ${amount} lamports to signer wSol TA`);
81
80
  chores = chores.add((0, solanaUtils_1.systemTransferUmiIx)(client.signer, wSolUsage.wSolTokenAccount, amount));
82
81
  }
@@ -95,7 +94,7 @@ async function transactionChoresBefore(client, solautoActions, initiatingDcaIn)
95
94
  if (accountsGettingCreated.includes(tokenAccount.toString())) {
96
95
  continue;
97
96
  }
98
- if (!(0, generalUtils_1.getSolanaAccountCreated)(tokenAccount)) {
97
+ if (!(0, generalUtils_1.getSolanaAccountCreated)(client.umi, tokenAccount)) {
99
98
  chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), (0, generated_1.isSolautoAction)("Withdraw", solautoAction)
100
99
  ? client.supplyLiquidityMint
101
100
  : client.debtLiquidityMint));
@@ -121,7 +120,7 @@ async function rebalanceChoresBefore(client, tx) {
121
120
  : web3_js_1.PublicKey.default,
122
121
  ],
123
122
  ];
124
- const [referredBySupplyTa, solautoFeesSupplyTa, intermediaryMarginfiAccount] = await solautoConstants_1.UMI.rpc.getAccounts(accountsNeeded.map((x) => (0, umi_1.publicKey)(x ?? web3_js_1.PublicKey.default)));
123
+ const [referredBySupplyTa, solautoFeesSupplyTa, intermediaryMarginfiAccount] = await client.umi.rpc.getAccounts(accountsNeeded.map((x) => (0, umi_1.publicKey)(x ?? web3_js_1.PublicKey.default)));
125
124
  let chores = (0, umi_1.transactionBuilder)();
126
125
  if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
127
126
  client.log("Creating referred-by TA for ", client.supplyLiquidityMint.toString());
@@ -238,8 +237,8 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
238
237
  };
239
238
  }
240
239
  exports.buildSolautoRebalanceTransaction = buildSolautoRebalanceTransaction;
241
- async function convertReferralFeesToDestination(referralState, tokenAccount, signer) {
242
- const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(signer, {
240
+ async function convertReferralFeesToDestination(umi, referralState, tokenAccount) {
241
+ const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(umi.identity, {
243
242
  amount: tokenAccount.amount,
244
243
  destinationWallet: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.publicKey),
245
244
  inputMint: tokenAccount.mint,
@@ -249,9 +248,9 @@ async function convertReferralFeesToDestination(referralState, tokenAccount, sig
249
248
  });
250
249
  let tx = (0, umi_1.transactionBuilder)()
251
250
  .add(setupInstructions)
252
- .add((0, generated_1.convertReferralFees)(solautoConstants_1.UMI, {
253
- signer,
254
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey), (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.destFeesMint))),
251
+ .add((0, generated_1.convertReferralFees)(umi, {
252
+ signer: umi.identity,
253
+ intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(umi.identity.publicKey), tokenAccount.mint)),
255
254
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
256
255
  referralState: referralState.publicKey,
257
256
  referralFeesTa: (0, umi_1.publicKey)(tokenAccount.address),
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuCzD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC;IATd,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,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AI;CAuIX"}
@@ -7,7 +7,6 @@ exports.TransactionsManager = exports.TransactionStatus = exports.TransactionIte
7
7
  const bs58_1 = __importDefault(require("bs58"));
8
8
  const umi_1 = require("@metaplex-foundation/umi");
9
9
  const solanaUtils_1 = require("../utils/solanaUtils");
10
- const solautoConstants_1 = require("../constants/solautoConstants");
11
10
  const generalUtils_1 = require("../utils/generalUtils");
12
11
  const transactionUtils_1 = require("./transactionUtils");
13
12
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
@@ -26,7 +25,7 @@ class LookupTables {
26
25
  const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
27
26
  const missingAddresses = addresses.filter((x) => !currentCacheAddresses.includes(x));
28
27
  if (missingAddresses) {
29
- const additionalInputs = await (0, solanaUtils_1.getAdressLookupInputs)(missingAddresses);
28
+ const additionalInputs = await (0, solanaUtils_1.getAdressLookupInputs)(this.client.umi, missingAddresses);
30
29
  this.cache.push(...additionalInputs);
31
30
  }
32
31
  return this.cache.filter((x) => addresses.includes(x.publicKey.toString()));
@@ -78,7 +77,7 @@ class TransactionSet {
78
77
  ...this.lutAddresses(),
79
78
  ...item.lookupTableAddresses,
80
79
  ]))
81
- .fitsInOneTransaction(solautoConstants_1.UMI);
80
+ .fitsInOneTransaction(this.client.umi);
82
81
  }
83
82
  add(...items) {
84
83
  this.items.push(...items.filter((x) => x.tx && x.tx.getInstructions().length > 0));
@@ -139,8 +138,8 @@ class TransactionsManager {
139
138
  continue;
140
139
  }
141
140
  const transaction = item.tx.setAddressLookupTables(await this.lookupTables.getLutInputs(item.lookupTableAddresses));
142
- if (!transaction.fitsInOneTransaction(solautoConstants_1.UMI)) {
143
- throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(solautoConstants_1.UMI)})`);
141
+ if (!transaction.fitsInOneTransaction(this.client.umi)) {
142
+ throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.client.umi)})`);
144
143
  }
145
144
  else {
146
145
  let newSet = new TransactionSet(this.client, this.lookupTables, [item]);
@@ -179,7 +178,7 @@ class TransactionsManager {
179
178
  const updateLookupTable = await this.client.updateLookupTable();
180
179
  if (updateLookupTable && updateLookupTable?.needsToBeIsolated) {
181
180
  this.updateStatus("update lookup table", TransactionStatus.Processing);
182
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum), 2);
181
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client.umi, this.client.connection, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum), 2);
183
182
  this.updateStatus("update lookup table", TransactionStatus.Successful);
184
183
  }
185
184
  for (const item of this.items) {
@@ -252,7 +251,7 @@ class TransactionsManager {
252
251
  }
253
252
  else {
254
253
  this.updateStatus(itemSet.name(), TransactionStatus.Processing);
255
- const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client, tx, this.simulateOnly, attemptNum);
254
+ const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client.umi, this.client.connection, tx, this.simulateOnly, attemptNum);
256
255
  this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
257
256
  }
258
257
  }, 3);
@@ -1,9 +1,9 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { MaybeRpcAccount } from "@metaplex-foundation/umi";
2
+ import { MaybeRpcAccount, Umi } from "@metaplex-foundation/umi";
3
3
  export declare function generateRandomU8(): number;
4
4
  export declare function generateRandomU64(): bigint;
5
5
  export declare function currentUnixSeconds(): number;
6
- export declare function getSolanaAccountCreated(pk: PublicKey): Promise<boolean>;
6
+ export declare function getSolanaAccountCreated(umi: Umi, pk: PublicKey): Promise<boolean>;
7
7
  export declare function rpcAccountCreated(account: MaybeRpcAccount): boolean;
8
8
  export declare function arraysAreEqual(arrayA: number[], arrayB: number[]): boolean;
9
9
  export declare function getTokenPrices(mints: PublicKey[]): Promise<number[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,MAAM,0BAA0B,CAAC;AAKtE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAG7E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+C1E;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
1
+ {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAK3E,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAGvF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+C1E;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
@@ -22,8 +22,8 @@ function currentUnixSeconds() {
22
22
  return Math.round(new Date().getTime() / 1000);
23
23
  }
24
24
  exports.currentUnixSeconds = currentUnixSeconds;
25
- async function getSolanaAccountCreated(pk) {
26
- const account = await solautoConstants_1.UMI.rpc.getAccount((0, umi_1.publicKey)(pk));
25
+ async function getSolanaAccountCreated(umi, pk) {
26
+ const account = await umi.rpc.getAccount((0, umi_1.publicKey)(pk));
27
27
  return rpcAccountCreated(account);
28
28
  }
29
29
  exports.getSolanaAccountCreated = getSolanaAccountCreated;
@@ -45,7 +45,7 @@ function arraysAreEqual(arrayA, arrayB) {
45
45
  exports.arraysAreEqual = arraysAreEqual;
46
46
  async function getTokenPrices(mints) {
47
47
  const currentTime = currentUnixSeconds();
48
- if (!mints.some(mint => !(mint.toString() in solautoConstants_1.PRICES) || currentTime - solautoConstants_1.PRICES[mint.toString()].time > 3)) {
48
+ if (!mints.some(mint => !(mint.toString() in solautoConstants_1.PRICES) || currentTime - solautoConstants_1.PRICES[mint.toString()].time > 5)) {
49
49
  console.log("Accessing price cache");
50
50
  return mints.map(mint => solautoConstants_1.PRICES[mint.toString()].price);
51
51
  }
@@ -1,4 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
+ import { Umi } from "@metaplex-foundation/umi";
2
3
  import { Bank, MarginfiAccount } from "../marginfi-sdk";
3
4
  import { MarginfiTokenAccounts } from "../types/accounts";
4
5
  import { PositionState } from "../generated";
@@ -8,7 +9,7 @@ export declare function findMarginfiBankAccounts({ mint, bank, }: {
8
9
  bank?: string;
9
10
  }): MarginfiTokenAccounts;
10
11
  export declare function getMaxLtvAndLiqThreshold(supplyBank: Bank, debtBank: Bank, supplyPrice?: number): Promise<[number, number]>;
11
- export declare function getAllMarginfiAccountsByAuthority(authority: PublicKey): Promise<MarginfiAccount[]>;
12
- export declare function getMarginfiAccountPositionState(supplyMint: PublicKey, debtMint: PublicKey, marginfiAccount: MarginfiAccount | null, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
13
- export declare function getUpToDateShareValues(bank: Bank): Promise<[number, number]>;
12
+ export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: PublicKey): Promise<MarginfiAccount[]>;
13
+ export declare function getMarginfiAccountPositionState(umi: Umi, supplyMint: PublicKey, debtMint: PublicKey, marginfiAccountPk: PublicKey, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
14
+ export declare function getUpToDateShareValues(umi: Umi, bank: Bank): Promise<[number, number]>;
14
15
  //# sourceMappingURL=marginfiUtils.d.ts.map
@@ -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;AAG5C,OAAO,EACL,IAAI,EAGJ,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAUz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;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,wBAAwB,CAAC,EACvC,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkC3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,eAAe,EAAE,CAAC,CA2B5B;AAoDD,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,EACnB,iBAAiB,EAAE,SAAS,EAC5B,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAoIpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -44,8 +44,8 @@ async function getMaxLtvAndLiqThreshold(supplyBank, debtBank, supplyPrice) {
44
44
  return [maxLtv, liqThreshold];
45
45
  }
46
46
  exports.getMaxLtvAndLiqThreshold = getMaxLtvAndLiqThreshold;
47
- async function getAllMarginfiAccountsByAuthority(authority) {
48
- const marginfiAccounts = await solautoConstants_1.UMI.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
47
+ async function getAllMarginfiAccountsByAuthority(umi, authority) {
48
+ const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
49
49
  commitment: "finalized",
50
50
  dataSlice: {
51
51
  offset: 0,
@@ -63,12 +63,12 @@ async function getAllMarginfiAccountsByAuthority(authority) {
63
63
  },
64
64
  ],
65
65
  });
66
- return (0, marginfi_sdk_1.safeFetchAllMarginfiAccount)(solautoConstants_1.UMI, marginfiAccounts.map((x) => x.publicKey));
66
+ return (0, marginfi_sdk_1.safeFetchAllMarginfiAccount)(umi, marginfiAccounts.map((x) => x.publicKey));
67
67
  }
68
68
  exports.getAllMarginfiAccountsByAuthority = getAllMarginfiAccountsByAuthority;
69
- async function getTokenUsage(bank, isAsset, shares, amountUsedAdjustment) {
69
+ async function getTokenUsage(umi, bank, isAsset, shares, amountUsedAdjustment) {
70
70
  let [marketPrice] = await (0, generalUtils_1.getTokenPrices)([(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(bank.mint)]);
71
- const [assetShareValue, liabilityShareValue] = await getUpToDateShareValues(bank);
71
+ const [assetShareValue, liabilityShareValue] = await getUpToDateShareValues(umi, bank);
72
72
  const shareValue = isAsset ? assetShareValue : liabilityShareValue;
73
73
  const amountUsed = shares * shareValue + Number(amountUsedAdjustment ?? 0);
74
74
  const totalDeposited = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) * assetShareValue;
@@ -97,12 +97,13 @@ async function getTokenUsage(bank, isAsset, shares, amountUsedAdjustment) {
97
97
  padding: new Uint8Array([]),
98
98
  };
99
99
  }
100
- async function getMarginfiAccountPositionState(supplyMint, debtMint, marginfiAccount, livePositionUpdates) {
100
+ async function getMarginfiAccountPositionState(umi, supplyMint, debtMint, marginfiAccountPk, livePositionUpdates) {
101
+ let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk));
101
102
  let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
102
- ? await (0, marginfi_sdk_1.safeFetchBank)(solautoConstants_1.UMI, (0, umi_1.publicKey)(findMarginfiBankAccounts({ mint: supplyMint.toString() }).bank))
103
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiBankAccounts({ mint: supplyMint.toString() }).bank))
103
104
  : null;
104
105
  let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
105
- ? await (0, marginfi_sdk_1.safeFetchBank)(solautoConstants_1.UMI, (0, umi_1.publicKey)(findMarginfiBankAccounts({ mint: debtMint.toString() }).bank))
106
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiBankAccounts({ mint: debtMint.toString() }).bank))
106
107
  : null;
107
108
  let supplyUsage = undefined;
108
109
  let debtUsage = undefined;
@@ -112,24 +113,24 @@ async function getMarginfiAccountPositionState(supplyMint, debtMint, marginfiAcc
112
113
  const debtBalances = marginfiAccount.lendingAccount.balances.filter((balance) => balance.active && (0, numberUtils_1.bytesToI80F48)(balance.liabilityShares.value) > 0);
113
114
  for (const balance of supplyBalances) {
114
115
  if (supplyBank === null) {
115
- supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(solautoConstants_1.UMI, balance.bankPk);
116
+ supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, balance.bankPk);
116
117
  }
117
- supplyUsage = await getTokenUsage(supplyBank, true, (0, numberUtils_1.bytesToI80F48)(balance.assetShares.value), livePositionUpdates?.supplyAdjustment);
118
+ supplyUsage = await getTokenUsage(umi, supplyBank, true, (0, numberUtils_1.bytesToI80F48)(balance.assetShares.value), livePositionUpdates?.supplyAdjustment);
118
119
  break;
119
120
  }
120
121
  for (const balance of debtBalances) {
121
122
  if (debtBank === null) {
122
- debtBank = await (0, marginfi_sdk_1.safeFetchBank)(solautoConstants_1.UMI, balance.bankPk);
123
+ debtBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, balance.bankPk);
123
124
  }
124
- debtUsage = await getTokenUsage(debtBank, false, (0, numberUtils_1.bytesToI80F48)(balance.liabilityShares.value), livePositionUpdates?.debtAdjustment);
125
+ debtUsage = await getTokenUsage(umi, debtBank, false, (0, numberUtils_1.bytesToI80F48)(balance.liabilityShares.value), livePositionUpdates?.debtAdjustment);
125
126
  break;
126
127
  }
127
128
  }
128
129
  if (supplyBank !== null && !supplyUsage) {
129
- supplyUsage = await getTokenUsage(supplyBank, true, 0, livePositionUpdates?.supplyAdjustment);
130
+ supplyUsage = await getTokenUsage(umi, supplyBank, true, 0, livePositionUpdates?.supplyAdjustment);
130
131
  }
131
132
  if (debtBank !== null && !debtUsage) {
132
- debtUsage = await getTokenUsage(debtBank, false, 0, livePositionUpdates?.debtAdjustment);
133
+ debtUsage = await getTokenUsage(umi, debtBank, false, 0, livePositionUpdates?.debtAdjustment);
133
134
  }
134
135
  if (supplyBank === null || debtBank === null) {
135
136
  return undefined;
@@ -184,8 +185,8 @@ function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
184
185
  const newValue = shareValue * (1 + irPerPeriod);
185
186
  return newValue;
186
187
  }
187
- async function getUpToDateShareValues(bank) {
188
- const currentTime = await (0, solanaUtils_1.currentUnixSecondsSolana)();
188
+ async function getUpToDateShareValues(umi, bank) {
189
+ const currentTime = await (0, solanaUtils_1.currentUnixSecondsSolana)(umi);
189
190
  let timeDelta = currentTime - Number(bank.lastUpdate);
190
191
  const totalAssets = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) *
191
192
  (0, numberUtils_1.bytesToI80F48)(bank.assetShareValue.value);
@@ -1,7 +1,6 @@
1
- import { AddressLookupTableInput, Signer, TransactionBuilder, WrappedInstruction } from "@metaplex-foundation/umi";
2
- import { PublicKey, TransactionInstruction } from "@solana/web3.js";
3
- import { SolautoClient } from "../clients/solautoClient";
4
- export declare function currentUnixSecondsSolana(): Promise<number>;
1
+ import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstruction } from "@metaplex-foundation/umi";
2
+ import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
+ export declare function currentUnixSecondsSolana(umi: Umi): Promise<number>;
5
4
  export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
6
5
  export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
7
6
  export declare function setComputeUnitPriceUmiIx(signer: Signer, lamports: number): WrappedInstruction;
@@ -9,8 +8,8 @@ export declare function createAssociatedTokenAccountUmiIx(signer: Signer, wallet
9
8
  export declare function systemTransferUmiIx(signer: Signer, destination: PublicKey, lamports: bigint): WrappedInstruction;
10
9
  export declare function closeTokenAccountUmiIx(signer: Signer, tokenAccount: PublicKey, authority: PublicKey): WrappedInstruction;
11
10
  export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey, toTa: PublicKey, authority: PublicKey, amount: bigint): WrappedInstruction;
12
- export declare function getAdressLookupInputs(lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
11
+ export declare function getAdressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
13
12
  export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice: number, computeUnitLimit?: number): TransactionBuilder;
14
- export declare function getComputeUnitPriceEstimate(tx: TransactionBuilder, attemptNum?: number): Promise<number>;
15
- export declare function sendSingleOptimizedTransaction(client: SolautoClient, tx: TransactionBuilder, simulateOnly?: boolean, attemptNum?: number): Promise<Uint8Array | undefined>;
13
+ export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, attemptNum?: number): Promise<number>;
14
+ export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, simulateOnly?: boolean, attemptNum?: number): Promise<Uint8Array | undefined>;
16
15
  //# sourceMappingURL=solanaUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;A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