@haven-fi/solauto-sdk 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Solauto SDK
2
+
3
+ TODO
@@ -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, {
@@ -177,7 +177,7 @@ class TransactionsManager {
177
177
  choresBefore.prepend(updateLookupTable.updateLutTx);
178
178
  }
179
179
  if (choresBefore.getInstructions().length > 0) {
180
- this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore })));
180
+ this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore }), "create account(s)"));
181
181
  this.client.log("Chores before: ", choresBefore.getInstructions().length);
182
182
  }
183
183
  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;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAMlF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAExF;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,sBAQnB;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,SAAS,sBAU1D;AAED,wBAAsB,qBAAqB,CACzC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,sBAa/B;AAED,wBAAsB,0BAA0B,CAC9C,sBAAsB,EAAE,SAAS,GAAG,SAAS,EAC7C,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,SAAS,EACxB,aAAa,EAAE,SAAS,sBAkBzB"}
1
+ {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAMlF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAExF;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,sBAQnB;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,SAAS,sBAU1D;AAED,wBAAsB,qBAAqB,CACzC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,sBAa/B"}
@@ -1,6 +1,6 @@
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,18 +1,18 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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",
@@ -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;
@@ -249,7 +249,7 @@ export class TransactionsManager {
249
249
  choresBefore.prepend(updateLookupTable.updateLutTx);
250
250
  }
251
251
  if (choresBefore.getInstructions().length > 0) {
252
- this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore })));
252
+ this.items.unshift(new TransactionItem(async () => ({ tx: choresBefore }), "create account(s)"));
253
253
  this.client.log("Chores before: ", choresBefore.getInstructions().length);
254
254
  }
255
255
  if (choresAfter.getInstructions().length > 0) {
@@ -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(
@@ -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
- ]);