@haven-fi/solauto-sdk 1.0.6 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/README.md +3 -0
  2. package/dist/clients/solautoClient.d.ts +3 -1
  3. package/dist/clients/solautoClient.d.ts.map +1 -1
  4. package/dist/clients/solautoClient.js +8 -3
  5. package/dist/clients/solautoMarginfiClient.d.ts +2 -1
  6. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  7. package/dist/clients/solautoMarginfiClient.js +2 -1
  8. package/dist/generated/types/lendingPlatform.d.ts +1 -2
  9. package/dist/generated/types/lendingPlatform.d.ts.map +1 -1
  10. package/dist/generated/types/lendingPlatform.js +0 -1
  11. package/dist/transactions/transactionsManager.d.ts +1 -0
  12. package/dist/transactions/transactionsManager.d.ts.map +1 -1
  13. package/dist/transactions/transactionsManager.js +16 -1
  14. package/dist/utils/accountUtils.d.ts +0 -1
  15. package/dist/utils/accountUtils.d.ts.map +1 -1
  16. package/dist/utils/accountUtils.js +1 -14
  17. package/dist/utils/index.d.ts +0 -1
  18. package/dist/utils/index.d.ts.map +1 -1
  19. package/dist/utils/index.js +0 -1
  20. package/dist/utils/numberUtils.d.ts.map +1 -1
  21. package/{src/utils/local → local}/shared.ts +1 -1
  22. package/{src/utils/local → local}/updateMarginfiLUT.ts +3 -3
  23. package/{src/utils/local → local}/updateSolautoLUT.ts +4 -4
  24. package/package.json +5 -4
  25. package/src/clients/solautoClient.ts +11 -5
  26. package/src/clients/solautoMarginfiClient.ts +4 -1
  27. package/src/generated/types/lendingPlatform.ts +0 -1
  28. package/src/transactions/transactionsManager.ts +32 -2
  29. package/src/utils/accountUtils.ts +2 -26
  30. package/src/utils/index.ts +0 -1
  31. package/src/utils/numberUtils.ts +0 -1
  32. package/tests/shared.ts +1 -1
  33. package/tests/transactions/solautoMarginfi.ts +1 -0
  34. package/dist/utils/local/shared.d.ts +0 -4
  35. package/dist/utils/local/shared.d.ts.map +0 -1
  36. package/dist/utils/local/shared.js +0 -75
  37. package/dist/utils/local/updateMarginfiLUT.d.ts +0 -2
  38. package/dist/utils/local/updateMarginfiLUT.d.ts.map +0 -1
  39. package/dist/utils/local/updateMarginfiLUT.js +0 -22
  40. package/dist/utils/local/updateSolautoLUT.d.ts +0 -2
  41. package/dist/utils/local/updateSolautoLUT.d.ts.map +0 -1
  42. package/dist/utils/local/updateSolautoLUT.js +0 -13
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Solauto SDK
2
+
3
+ TODO
@@ -1,6 +1,7 @@
1
1
  import "rpc-websockets/dist/lib/client";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
4
+ import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
4
5
  import { DCASettings, DCASettingsInpArgs, LendingPlatform, PositionState, ReferralState, SolautoActionArgs, SolautoPosition, SolautoRebalanceTypeArgs, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, UpdatePositionDataArgs } from "../generated";
5
6
  import { JupSwapDetails } from "../utils/jupiterUtils";
6
7
  import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
@@ -8,7 +9,8 @@ import { LivePositionUpdates } from "../utils/solauto/generalUtils";
8
9
  export interface SolautoClientArgs {
9
10
  authority?: PublicKey;
10
11
  positionId: number;
11
- signer: Signer;
12
+ signer?: Signer;
13
+ wallet?: WalletAdapter;
12
14
  supplyLiquidityMint?: PublicKey;
13
15
  debtLiquidityMint?: PublicKey;
14
16
  referralFeesDestMint?: PublicKey;
@@ -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,EACL,WAAW,EACX,kBAAkB,E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E,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAYlE"}
@@ -5,6 +5,7 @@ require("rpc-websockets/dist/lib/client");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const umi_1 = require("@metaplex-foundation/umi");
7
7
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
8
+ const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
8
9
  const generated_1 = require("../generated");
9
10
  const accountUtils_1 = require("../utils/accountUtils");
10
11
  const generalAccounts_1 = require("../constants/generalAccounts");
@@ -20,9 +21,13 @@ class SolautoClient {
20
21
  this.localTest = Boolean(localTest);
21
22
  }
22
23
  async initialize(args, lendingPlatform) {
23
- this.umi = solautoConstants_1.UMI.use((0, umi_1.signerIdentity)(args.signer));
24
- this.signer = args.signer;
25
- this.authority = args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(args.signer.publicKey);
24
+ this.umi = solautoConstants_1.UMI;
25
+ if (!args.signer && !args.wallet) {
26
+ throw new Error("Signer or wallet must be provided");
27
+ }
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));
29
+ this.signer = this.umi.identity;
30
+ this.authority = args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.umi.identity.publicKey);
26
31
  this.positionId = args.positionId;
27
32
  this.selfManaged = this.positionId === 0;
28
33
  this.lendingPlatform = lendingPlatform;
@@ -6,12 +6,13 @@ import { DCASettingsInpArgs, PositionState, SolautoActionArgs, SolautoRebalanceT
6
6
  import { MarginfiAccount } from "../marginfi-sdk";
7
7
  import { JupSwapDetails } from "../utils/jupiterUtils";
8
8
  import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
9
+ import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
9
10
  export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
10
11
  marginfiAccount?: PublicKey | Signer;
11
12
  marginfiAccountSeedIdx?: bigint;
12
13
  marginfiGroup?: PublicKey;
13
14
  }
14
- export declare function newMarginfiSolautoManagedPositionArgs(positionId: number, signer: Signer, supplyMint: PublicKey, debtMint: PublicKey, referredByAuthority?: PublicKey): SolautoMarginfiClientArgs;
15
+ export declare function newMarginfiSolautoManagedPositionArgs(positionId: number, signer: Signer | undefined, wallet: WalletAdapter | undefined, supplyMint: PublicKey, debtMint: PublicKey, referredByAuthority?: PublicKey): SolautoMarginfiClientArgs;
15
16
  export declare class SolautoMarginfiClient extends SolautoClient {
16
17
  marginfiProgram: PublicKey;
17
18
  marginfiAccountSeedIdx?: bigint;
@@ -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;AAQnE,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,wBA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eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,0BAA0B,EAAG,qBAAqB,CAAC;IACnD,wBAAwB,EAAG,qBAAqB,CAAC;IAGjD,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAgEhD,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;CAqBlE"}
@@ -12,10 +12,11 @@ const generalUtils_1 = require("../utils/generalUtils");
12
12
  const marginfi_sdk_1 = require("../marginfi-sdk");
13
13
  const marginfiUtils_1 = require("../utils/marginfiUtils");
14
14
  const numberUtils_1 = require("../utils/numberUtils");
15
- function newMarginfiSolautoManagedPositionArgs(positionId, signer, supplyMint, debtMint, referredByAuthority) {
15
+ function newMarginfiSolautoManagedPositionArgs(positionId, signer, wallet, supplyMint, debtMint, referredByAuthority) {
16
16
  return {
17
17
  positionId,
18
18
  signer,
19
+ wallet,
19
20
  marginfiAccountSeedIdx: positionId > 0 ? (0, generalUtils_1.generateRandomU64)() : undefined,
20
21
  supplyLiquidityMint: supplyMint,
21
22
  debtLiquidityMint: debtMint,
@@ -8,8 +8,7 @@
8
8
  import { Serializer } from '@metaplex-foundation/umi/serializers';
9
9
  export declare enum LendingPlatform {
10
10
  Marginfi = 0,
11
- Kamino = 1,
12
- Solend = 2
11
+ Kamino = 1
13
12
  }
14
13
  export type LendingPlatformArgs = LendingPlatform;
15
14
  export declare function getLendingPlatformSerializer(): Serializer<LendingPlatformArgs, LendingPlatform>;
@@ -1 +1 @@
1
- {"version":3,"file":"lendingPlatform.d.ts","sourceRoot":"","sources":["../../../src/generated/types/lendingPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,eAAe;IACzB,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,MAAM,IAAA;CACP;AAED,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAElD,wBAAgB,4BAA4B,IAAI,UAAU,CACxD,mBAAmB,EACnB,eAAe,CAChB,CAIA"}
1
+ {"version":3,"file":"lendingPlatform.d.ts","sourceRoot":"","sources":["../../../src/generated/types/lendingPlatform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,eAAe;IACzB,QAAQ,IAAA;IACR,MAAM,IAAA;CACP;AAED,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAElD,wBAAgB,4BAA4B,IAAI,UAAU,CACxD,mBAAmB,EACnB,eAAe,CAChB,CAIA"}
@@ -13,7 +13,6 @@ var LendingPlatform;
13
13
  (function (LendingPlatform) {
14
14
  LendingPlatform[LendingPlatform["Marginfi"] = 0] = "Marginfi";
15
15
  LendingPlatform[LendingPlatform["Kamino"] = 1] = "Kamino";
16
- LendingPlatform[LendingPlatform["Solend"] = 2] = "Solend";
17
16
  })(LendingPlatform = exports.LendingPlatform || (exports.LendingPlatform = {}));
18
17
  function getLendingPlatformSerializer() {
19
18
  return (0, serializers_1.scalarEnum)(LendingPlatform, {
@@ -14,6 +14,7 @@ export declare class TransactionItem {
14
14
  } | undefined>, name?: string | undefined);
15
15
  initialize(): Promise<void>;
16
16
  refetch(attemptNum: number): Promise<void>;
17
+ uniqueAccounts(): string[];
17
18
  }
18
19
  export declare enum TransactionStatus {
19
20
  Skipped = "Skipped",
@@ -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,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,oBAAQ;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;CAKjC;AAsED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IARvB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,eAAe,EAAE,EACxB,cAAc,CAAC,6CAA4C,IAAI,aAAA,EAC/D,YAAY,CAAC,qBAAS,EACtB,YAAY,CAAC,qBAAS;YAKlB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAgB9D,IAAI;CA8HX"}
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,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,oBAAQ;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IARvB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,eAAe,EAAE,EACxB,cAAc,CAAC,6CAA4C,IAAI,aAAA,EAC/D,YAAY,CAAC,qBAAS,EACtB,YAAY,CAAC,qBAAS;YAKlB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAgB9D,IAAI;CAqIX"}
@@ -45,6 +45,14 @@ class TransactionItem {
45
45
  this.tx = resp?.tx;
46
46
  this.lookupTableAddresses = resp?.lookupTableAddresses ?? [];
47
47
  }
48
+ uniqueAccounts() {
49
+ return Array.from(new Set(this.tx.getInstructions()
50
+ .map((x) => [
51
+ x.programId.toString(),
52
+ ...x.keys.map((y) => y.pubkey.toString()),
53
+ ])
54
+ .flat()));
55
+ }
48
56
  }
49
57
  exports.TransactionItem = TransactionItem;
50
58
  class TransactionSet {
@@ -57,6 +65,13 @@ class TransactionSet {
57
65
  if (!item.tx) {
58
66
  return true;
59
67
  }
68
+ const accountLocks = Array.from(new Set([
69
+ ...this.items.map((x) => x.uniqueAccounts()),
70
+ ...item.uniqueAccounts(),
71
+ ])).length;
72
+ if (accountLocks > 128) {
73
+ return false;
74
+ }
60
75
  return (await this.getSingleTransaction())
61
76
  .add(item.tx)
62
77
  .setAddressLookupTables(await this.lookupTables.getLutInputs([
@@ -177,7 +192,7 @@ class TransactionsManager {
177
192
  choresBefore.prepend(updateLookupTable.updateLutTx);
178
193
  }
179
194
  if (choresBefore.getInstructions().length > 0) {
180
- this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore })));
195
+ this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore }), "create account(s)"));
181
196
  this.client.log("Chores before: ", choresBefore.getInstructions().length);
182
197
  }
183
198
  if (choresAfter.getInstructions().length > 0) {
@@ -7,5 +7,4 @@ export declare function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKe
7
7
  export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number): Promise<PublicKey>;
8
8
  export declare function getReferralState(authority: PublicKey): Promise<PublicKey>;
9
9
  export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): Promise<PublicKey>;
10
- export declare function getSolendObligationAccount(solautoPositionAccount: PublicKey | undefined, signer: PublicKey, lendingMarket: PublicKey, solendProgram: PublicKey): Promise<PublicKey>;
11
10
  //# sourceMappingURL=accountUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,iBAAiB,CAAC;AAIzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD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
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSolendObligationAccount = exports.getMarginfiAccountPDA = exports.getReferralState = exports.getSolautoPositionAccount = exports.getTokenAccounts = exports.getTokenAccount = exports.bufferFromU64 = exports.bufferFromU8 = void 0;
3
+ exports.getMarginfiAccountPDA = exports.getReferralState = exports.getSolautoPositionAccount = exports.getTokenAccounts = exports.getTokenAccount = exports.bufferFromU64 = exports.bufferFromU8 = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const generated_1 = require("../generated");
@@ -45,16 +45,3 @@ async function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeed
45
45
  return marginfiAccount;
46
46
  }
47
47
  exports.getMarginfiAccountPDA = getMarginfiAccountPDA;
48
- async function getSolendObligationAccount(solautoPositionAccount, signer, lendingMarket, solendProgram) {
49
- const seeds = [
50
- signer.toBuffer(),
51
- lendingMarket.toBuffer(),
52
- solendProgram.toBuffer(),
53
- ];
54
- if (solautoPositionAccount !== undefined) {
55
- seeds.unshift(solautoPositionAccount.toBuffer());
56
- }
57
- const [obligationAccount, _] = await web3_js_1.PublicKey.findProgramAddress(seeds, new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
58
- return obligationAccount;
59
- }
60
- exports.getSolendObligationAccount = getSolendObligationAccount;
@@ -1,7 +1,6 @@
1
1
  export * from './solauto/index';
2
2
  export * from './accountUtils';
3
3
  export * from './generalUtils';
4
- export * from './jitoUtils';
5
4
  export * from './jupiterUtils';
6
5
  export * from './marginfiUtils';
7
6
  export * from './numberUtils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./solauto/index"), exports);
18
18
  __exportStar(require("./accountUtils"), exports);
19
19
  __exportStar(require("./generalUtils"), exports);
20
- __exportStar(require("./jitoUtils"), exports);
21
20
  __exportStar(require("./jupiterUtils"), exports);
22
21
  __exportStar(require("./marginfiUtils"), exports);
23
22
  __exportStar(require("./numberUtils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AACA,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAM3G;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAajE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAQ1B"}
1
+ {"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAM3G;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAajE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAQ1B"}
@@ -8,7 +8,7 @@ import {
8
8
  VersionedTransaction,
9
9
  PublicKey,
10
10
  } from "@solana/web3.js";
11
- import { CONNECTION } from "../../constants/solautoConstants";
11
+ import { CONNECTION } from "../src/constants/solautoConstants";
12
12
 
13
13
  function loadSecretKey(keypairPath: string) {
14
14
  const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
@@ -1,10 +1,10 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { MARGINFI_ACCOUNTS_LOOKUP_TABLE } from "../../constants/marginfiAccounts";
2
+ import { MARGINFI_ACCOUNTS_LOOKUP_TABLE } from "../constants/marginfiAccounts";
3
3
  import {
4
4
  MARGINFI_ACCOUNTS,
5
5
  DEFAULT_MARGINFI_GROUP,
6
- } from "../../constants/marginfiAccounts";
7
- import { MARGINFI_PROGRAM_ID } from "../../marginfi-sdk";
6
+ } from "../constants/marginfiAccounts";
7
+ import { MARGINFI_PROGRAM_ID } from "../marginfi-sdk";
8
8
  import { updateLookupTable } from "./shared";
9
9
 
10
10
  const LOOKUP_TABLE_ADDRESS = new PublicKey(MARGINFI_ACCOUNTS_LOOKUP_TABLE);
@@ -1,9 +1,9 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { getTokenAccounts } from "../accountUtils";
3
- import { SOLAUTO_MANAGER } from "../../constants/generalAccounts";
4
- import { ALL_SUPPORTED_TOKENS } from "../../constants/tokenConstants";
2
+ import { getTokenAccounts } from "../src/utils/accountUtils";
3
+ import { SOLAUTO_MANAGER } from "../src/constants/generalAccounts";
4
+ import { ALL_SUPPORTED_TOKENS } from "../src/constants/tokenConstants";
5
5
  import { updateLookupTable } from "./shared";
6
- import { STANDARD_LUT_ACCOUNTS } from "../../constants/solautoConstants";
6
+ import { STANDARD_LUT_ACCOUNTS } from "../src/constants/solautoConstants";
7
7
 
8
8
  const solautoManagerTokenAccounts = getTokenAccounts(SOLAUTO_MANAGER, ALL_SUPPORTED_TOKENS.map((x) => new PublicKey(x)));
9
9
 
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",
7
7
  "author": "Chelioso",
8
8
  "license": "MIT",
9
9
  "scripts": {
10
- "build": "tsc",
10
+ "build": "rm -r dist && npx tsc",
11
11
  "test:txs": "ts-mocha -p ./tsconfig.json -t 1000000 tests/transactions/**/*.ts",
12
12
  "test:unit": "ts-mocha -p ./tsconfig.json -t 1000000 tests/unit/**/*.ts",
13
13
  "test:all": "pnpm test:unit && pnpm test:txs",
14
- "update-lut:solauto": "npx ts-node src/utils/local/updateSolautoLUT.ts",
15
- "update-lut:marginfi": "npx ts-node src/utils/local/updateMarginfiLUT.ts"
14
+ "update-lut:solauto": "npx ts-node local/updateSolautoLUT.ts",
15
+ "update-lut:marginfi": "npx ts-node local/updateMarginfiLUT.ts"
16
16
  },
17
17
  "dependencies": {
18
18
  "@jup-ag/api": "^6.0.24",
19
19
  "@metaplex-foundation/umi": "^0.9.1",
20
20
  "@metaplex-foundation/umi-bundle-defaults": "^0.9.1",
21
+ "@metaplex-foundation/umi-signer-wallet-adapters": "^0.9.1",
21
22
  "@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
22
23
  "@solana/spl-token": "^0.4.0",
23
24
  "@solana/web3.js": "^1.92.1",
@@ -13,6 +13,7 @@ import {
13
13
  some,
14
14
  } from "@metaplex-foundation/umi";
15
15
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
16
+ import { WalletAdapter, walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
16
17
  import {
17
18
  DCASettings,
18
19
  DCASettingsInpArgs,
@@ -65,7 +66,8 @@ import {
65
66
  export interface SolautoClientArgs {
66
67
  authority?: PublicKey;
67
68
  positionId: number;
68
- signer: Signer;
69
+ signer?: Signer;
70
+ wallet?: WalletAdapter;
69
71
 
70
72
  supplyLiquidityMint?: PublicKey;
71
73
  debtLiquidityMint?: PublicKey;
@@ -119,10 +121,14 @@ export abstract class SolautoClient {
119
121
  }
120
122
 
121
123
  async initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform) {
122
- this.umi = UMI.use(signerIdentity(args.signer));
123
-
124
- this.signer = args.signer;
125
- this.authority = args.authority ?? toWeb3JsPublicKey(args.signer.publicKey);
124
+ this.umi = UMI;
125
+ if (!args.signer && !args.wallet) {
126
+ throw new Error("Signer or wallet must be provided");
127
+ }
128
+ this.umi = UMI.use(args.signer ? signerIdentity(args.signer) : walletAdapterIdentity(args.wallet!, true));
129
+
130
+ this.signer = this.umi.identity;
131
+ this.authority = args.authority ?? toWeb3JsPublicKey(this.umi.identity.publicKey);
126
132
 
127
133
  this.positionId = args.positionId;
128
134
  this.selfManaged = this.positionId === 0;
@@ -55,6 +55,7 @@ import {
55
55
  getMarginfiAccountPositionState,
56
56
  } from "../utils/marginfiUtils";
57
57
  import { bytesToI80F48 } from "../utils/numberUtils";
58
+ import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
58
59
 
59
60
  export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
60
61
  marginfiAccount?: PublicKey | Signer;
@@ -64,7 +65,8 @@ export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
64
65
 
65
66
  export function newMarginfiSolautoManagedPositionArgs(
66
67
  positionId: number,
67
- signer: Signer,
68
+ signer: Signer | undefined,
69
+ wallet: WalletAdapter | undefined,
68
70
  supplyMint: PublicKey,
69
71
  debtMint: PublicKey,
70
72
  referredByAuthority?: PublicKey
@@ -72,6 +74,7 @@ export function newMarginfiSolautoManagedPositionArgs(
72
74
  return {
73
75
  positionId,
74
76
  signer,
77
+ wallet,
75
78
  marginfiAccountSeedIdx: positionId > 0 ? generateRandomU64() : undefined,
76
79
  supplyLiquidityMint: supplyMint,
77
80
  debtLiquidityMint: debtMint,
@@ -11,7 +11,6 @@ import { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers';
11
11
  export enum LendingPlatform {
12
12
  Marginfi,
13
13
  Kamino,
14
- Solend,
15
14
  }
16
15
 
17
16
  export type LendingPlatformArgs = LendingPlatform;
@@ -65,6 +65,19 @@ export class TransactionItem {
65
65
  this.tx = resp?.tx;
66
66
  this.lookupTableAddresses = resp?.lookupTableAddresses ?? [];
67
67
  }
68
+
69
+ uniqueAccounts(): string[] {
70
+ return Array.from(
71
+ new Set(
72
+ this.tx!.getInstructions()
73
+ .map((x) => [
74
+ x.programId.toString(),
75
+ ...x.keys.map((y) => y.pubkey.toString()),
76
+ ])
77
+ .flat()
78
+ )
79
+ );
80
+ }
68
81
  }
69
82
 
70
83
  class TransactionSet {
@@ -79,6 +92,16 @@ class TransactionSet {
79
92
  return true;
80
93
  }
81
94
 
95
+ const accountLocks = Array.from(
96
+ new Set([
97
+ ...this.items.map((x) => x.uniqueAccounts()),
98
+ ...item.uniqueAccounts(),
99
+ ])
100
+ ).length;
101
+ if (accountLocks > 128) {
102
+ return false;
103
+ }
104
+
82
105
  return (await this.getSingleTransaction())
83
106
  .add(item.tx)
84
107
  .setAddressLookupTables(
@@ -249,7 +272,12 @@ export class TransactionsManager {
249
272
  choresBefore.prepend(updateLookupTable.updateLutTx);
250
273
  }
251
274
  if (choresBefore.getInstructions().length > 0) {
252
- this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore })));
275
+ this.items.unshift(
276
+ new TransactionItem(
277
+ async () => ({ tx: choresBefore }),
278
+ "create account(s)"
279
+ )
280
+ );
253
281
  this.client.log("Chores before: ", choresBefore.getInstructions().length);
254
282
  }
255
283
  if (choresAfter.getInstructions().length > 0) {
@@ -264,7 +292,9 @@ export class TransactionsManager {
264
292
  }
265
293
 
266
294
  if (this.mustBeAtomic && itemSets.length > 1) {
267
- throw new Error(`${itemSets.length} transactions required but jito bundles are not currently supported`);
295
+ throw new Error(
296
+ `${itemSets.length} transactions required but jito bundles are not currently supported`
297
+ );
268
298
  // itemSets.forEach((set) => {
269
299
  // this.updateStatus(set.name(), TransactionStatus.Processing);
270
300
  // });
@@ -1,4 +1,4 @@
1
- import { PublicKey, AccountMeta } from "@solana/web3.js";
1
+ import { PublicKey } from "@solana/web3.js";
2
2
  import { getAssociatedTokenAddressSync } from "@solana/spl-token";
3
3
  import { SOLAUTO_PROGRAM_ID } from "../generated";
4
4
 
@@ -65,28 +65,4 @@ export async function getMarginfiAccountPDA(
65
65
  );
66
66
 
67
67
  return marginfiAccount;
68
- }
69
-
70
- export async function getSolendObligationAccount(
71
- solautoPositionAccount: PublicKey | undefined,
72
- signer: PublicKey,
73
- lendingMarket: PublicKey,
74
- solendProgram: PublicKey
75
- ) {
76
- const seeds = [
77
- signer.toBuffer(),
78
- lendingMarket.toBuffer(),
79
- solendProgram.toBuffer(),
80
- ];
81
-
82
- if (solautoPositionAccount !== undefined) {
83
- seeds.unshift(solautoPositionAccount.toBuffer());
84
- }
85
-
86
- const [obligationAccount, _] = await PublicKey.findProgramAddress(
87
- seeds,
88
- new PublicKey(SOLAUTO_PROGRAM_ID)
89
- );
90
-
91
- return obligationAccount;
92
- }
68
+ }
@@ -1,7 +1,6 @@
1
1
  export * from './solauto/index';
2
2
  export * from './accountUtils';
3
3
  export * from './generalUtils';
4
- export * from './jitoUtils';
5
4
  export * from './jupiterUtils';
6
5
  export * from './marginfiUtils';
7
6
  export * from './numberUtils';
@@ -1,4 +1,3 @@
1
-
2
1
  export function getLiqUtilzationRateBps(supplyUsd: number, debtUsd: number, liqThresholdBps: number): number {
3
2
  if (supplyUsd === 0) {
4
3
  return 0;
package/tests/shared.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Signer, createSignerFromKeypair } from "@metaplex-foundation/umi";
2
2
  import { Connection, clusterApiUrl } from "@solana/web3.js";
3
3
  import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
4
- import { getSecretKey } from "../src/utils/local/shared";
4
+ import { getSecretKey } from "../local/shared";
5
5
 
6
6
  export function setupTest(keypairFilename?: string): Signer {
7
7
  const umi = createUmi(
@@ -36,6 +36,7 @@ describe("Solauto Marginfi tests", async () => {
36
36
  // newMarginfiSolautoManagedPositionArgs(
37
37
  // positionId,
38
38
  // signer,
39
+ // undefined,
39
40
  // supply,
40
41
  // debt
41
42
  // )
@@ -1,4 +0,0 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- export declare function getSecretKey(keypairFilename?: string): Uint8Array;
3
- export declare function updateLookupTable(accounts: string[], lookupTableAddress?: PublicKey): Promise<void>;
4
- //# sourceMappingURL=shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/utils/local/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,YAAY,CAAC,eAAe,GAAE,MAAa,GAAG,UAAU,CAIvE;AAoDD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAAE,EAClB,kBAAkB,CAAC,EAAE,SAAS,iBAqB/B"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateLookupTable = exports.getSecretKey = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const web3_js_1 = require("@solana/web3.js");
10
- const solautoConstants_1 = require("../../constants/solautoConstants");
11
- function loadSecretKey(keypairPath) {
12
- const secretKey = JSON.parse(fs_1.default.readFileSync(keypairPath, "utf8"));
13
- return new Uint8Array(secretKey);
14
- }
15
- function getSecretKey(keypairFilename = "id") {
16
- return loadSecretKey(path_1.default.join(process.env.HOME, ".config", "solana", keypairFilename + ".json"));
17
- }
18
- exports.getSecretKey = getSecretKey;
19
- const keypair = web3_js_1.Keypair.fromSecretKey(getSecretKey());
20
- async function createAndSendV0Tx(txInstructions) {
21
- let latestBlockhash = await solautoConstants_1.CONNECTION.getLatestBlockhash("finalized");
22
- const messageV0 = new web3_js_1.TransactionMessage({
23
- payerKey: keypair.publicKey,
24
- recentBlockhash: latestBlockhash.blockhash,
25
- instructions: txInstructions,
26
- }).compileToV0Message();
27
- const transaction = new web3_js_1.VersionedTransaction(messageV0);
28
- transaction.sign([keypair]);
29
- const txid = await solautoConstants_1.CONNECTION.sendTransaction(transaction, {
30
- maxRetries: 5,
31
- });
32
- const confirmation = await solautoConstants_1.CONNECTION.confirmTransaction({
33
- signature: txid,
34
- blockhash: latestBlockhash.blockhash,
35
- lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
36
- });
37
- if (confirmation.value.err) {
38
- throw new Error(confirmation.value.err.toString());
39
- }
40
- console.log(txid);
41
- }
42
- async function addAddressesIfNeeded(lookupTableAddress, existingAddresses, addressesToAdd) {
43
- const addresses = addressesToAdd
44
- .filter((x) => !existingAddresses.includes(x))
45
- .map((x) => new web3_js_1.PublicKey(x));
46
- if (addresses.length > 0) {
47
- await createAndSendV0Tx([
48
- web3_js_1.AddressLookupTableProgram.extendLookupTable({
49
- payer: keypair.publicKey,
50
- authority: keypair.publicKey,
51
- lookupTable: lookupTableAddress,
52
- addresses,
53
- }),
54
- ]);
55
- }
56
- }
57
- async function updateLookupTable(accounts, lookupTableAddress) {
58
- let lookupTable = lookupTableAddress
59
- ? await solautoConstants_1.CONNECTION.getAddressLookupTable(lookupTableAddress)
60
- : null;
61
- if (lookupTable === null) {
62
- const [createLutIx, addr] = web3_js_1.AddressLookupTableProgram.createLookupTable({
63
- authority: keypair.publicKey,
64
- payer: keypair.publicKey,
65
- recentSlot: await solautoConstants_1.CONNECTION.getSlot({ commitment: "finalized" }),
66
- });
67
- lookupTableAddress = addr;
68
- console.log("Lookup Table Address:", lookupTableAddress.toString());
69
- createAndSendV0Tx([createLutIx]);
70
- }
71
- const existingAccounts = lookupTable?.value?.state.addresses.map((x) => x.toString()) ?? [];
72
- console.log("Existing accounts: ", existingAccounts.length);
73
- await addAddressesIfNeeded(lookupTableAddress, existingAccounts, accounts);
74
- }
75
- exports.updateLookupTable = updateLookupTable;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=updateMarginfiLUT.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateMarginfiLUT.d.ts","sourceRoot":"","sources":["../../../src/utils/local/updateMarginfiLUT.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const web3_js_1 = require("@solana/web3.js");
4
- const marginfiAccounts_1 = require("../../constants/marginfiAccounts");
5
- const marginfiAccounts_2 = require("../../constants/marginfiAccounts");
6
- const marginfi_sdk_1 = require("../../marginfi-sdk");
7
- const shared_1 = require("./shared");
8
- const LOOKUP_TABLE_ADDRESS = new web3_js_1.PublicKey(marginfiAccounts_1.MARGINFI_ACCOUNTS_LOOKUP_TABLE);
9
- async function addBanks() {
10
- for (const key in marginfiAccounts_2.MARGINFI_ACCOUNTS) {
11
- const accounts = marginfiAccounts_2.MARGINFI_ACCOUNTS[key];
12
- await (0, shared_1.updateLookupTable)([
13
- accounts.mint,
14
- accounts.bank,
15
- accounts.liquidityVault,
16
- accounts.vaultAuthority,
17
- accounts.priceOracle,
18
- ], LOOKUP_TABLE_ADDRESS);
19
- }
20
- }
21
- (0, shared_1.updateLookupTable)([marginfiAccounts_2.DEFAULT_MARGINFI_GROUP, marginfi_sdk_1.MARGINFI_PROGRAM_ID], LOOKUP_TABLE_ADDRESS);
22
- addBanks();
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=updateSolautoLUT.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateSolautoLUT.d.ts","sourceRoot":"","sources":["../../../src/utils/local/updateSolautoLUT.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const web3_js_1 = require("@solana/web3.js");
4
- const accountUtils_1 = require("../accountUtils");
5
- const generalAccounts_1 = require("../../constants/generalAccounts");
6
- const tokenConstants_1 = require("../../constants/tokenConstants");
7
- const shared_1 = require("./shared");
8
- const solautoConstants_1 = require("../../constants/solautoConstants");
9
- const solautoManagerTokenAccounts = (0, accountUtils_1.getTokenAccounts)(generalAccounts_1.SOLAUTO_MANAGER, tokenConstants_1.ALL_SUPPORTED_TOKENS.map((x) => new web3_js_1.PublicKey(x)));
10
- (0, shared_1.updateLookupTable)([
11
- ...solautoConstants_1.STANDARD_LUT_ACCOUNTS,
12
- ...solautoManagerTokenAccounts.map((x) => x.toString())
13
- ]);