@haven-fi/solauto-sdk 1.0.746 → 1.0.748

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"clientTransactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/clientTransactionsManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,mBAAmB;YA4BnB,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAiClD"}
1
+ {"version":3,"file":"clientTransactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/clientTransactionsManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,mBAAmB;YA4BnB,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAkClD"}
@@ -34,7 +34,7 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
34
34
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
35
35
  .map((x) => x.tx)));
36
36
  if (updateLutTx) {
37
- choresBefore.prepend(updateLutTx);
37
+ choresBefore = choresBefore.prepend(updateLutTx);
38
38
  }
39
39
  if (choresBefore.getInstructions().length) {
40
40
  const chore = new types_1.TransactionItem(async () => ({ tx: choresBefore }), constants_1.CHORES_TX_NAME);
@@ -53,7 +53,8 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
53
53
  const items = [...transactions];
54
54
  const client = this.txHandler;
55
55
  const updateLut = await client.updateLookupTable();
56
- if (updateLut && (updateLut?.new || updateLut.accountsToAdd.length > 4)) {
56
+ const updateLutInSepTx = updateLut?.new || (updateLut?.accountsToAdd ?? []).length > 4;
57
+ if (updateLut && updateLutInSepTx) {
57
58
  await this.updateLut(updateLut.tx, updateLut.new);
58
59
  }
59
60
  this.lookupTables.defaultLuts = client.defaultLookupTables();
@@ -61,7 +62,7 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
61
62
  for (const item of items) {
62
63
  await item.initialize();
63
64
  }
64
- await this.addChoreTxs(items, updateLut && !updateLut?.new ? updateLut.tx : undefined);
65
+ await this.addChoreTxs(items, updateLut && !updateLutInSepTx ? updateLut.tx : undefined);
65
66
  const result = await super.send(items).catch((e) => {
66
67
  client.resetLiveTxUpdates(false);
67
68
  throw e;
@@ -1,12 +1,14 @@
1
1
  import { Keypair, PublicKey } from "@solana/web3.js";
2
2
  import { createSignerFromKeypair } from "@metaplex-foundation/umi";
3
- import { fromWeb3JsKeypair } from "@metaplex-foundation/umi-web3js-adapters";
3
+ import { fromWeb3JsKeypair, fromWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
4
4
  import {
5
5
  ClientTransactionsManager,
6
6
  consoleLog,
7
+ fetchReferralState,
7
8
  getBatches,
8
9
  getClient,
9
10
  getPositionExBulk,
11
+ getReferralState,
10
12
  getSolanaRpcConnection,
11
13
  getSolautoManagedPositions,
12
14
  LendingPlatform,
@@ -26,7 +28,7 @@ const payForTransaction = false;
26
28
  const testProgram = false;
27
29
  const lpEnv: ProgramEnv = "Prod";
28
30
 
29
- let [, umi] = getSolanaRpcConnection(
31
+ let [conn, umi] = getSolanaRpcConnection(
30
32
  LOCAL_IRONFORGE_API_URL,
31
33
  testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM,
32
34
  lpEnv
@@ -38,32 +40,39 @@ const signer = createSignerFromKeypair(
38
40
  );
39
41
 
40
42
  export async function main() {
41
- const client = getClient(LendingPlatform.Marginfi, {
42
- signer,
43
- showLogs: true,
44
- rpcUrl: LOCAL_IRONFORGE_API_URL,
45
- programId: testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM,
46
- lpEnv,
47
- });
48
-
49
- await client.initializeExistingSolautoPosition({
50
- positionId: 1,
51
- authority: new PublicKey("Bk6mdg4mg9BD217vZwk8WDv7YJ66VyPPRhhQpaZsQPfL"),
52
- // lpUserAccount: new PublicKey(
53
- // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
54
- // ),
55
- });
56
-
57
- const transactionItems = [rebalance(client)];
58
-
59
- const txManager = new ClientTransactionsManager({
60
- txHandler: client,
61
- txRunType: payForTransaction ? "normal" : "only-simulate",
62
- priorityFeeSetting: PriorityFeeSetting.Default,
63
- retryConfig: { totalRetries: 4 },
64
- });
65
- const statuses = await txManager.send(transactionItems);
66
- consoleLog(statuses);
43
+ // const client = getClient(LendingPlatform.Marginfi, {
44
+ // signer,
45
+ // showLogs: true,
46
+ // rpcUrl: LOCAL_IRONFORGE_API_URL,
47
+ // programId: testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM,
48
+ // lpEnv,
49
+ // });
50
+
51
+ // await client.initializeExistingSolautoPosition({
52
+ // positionId: 1,
53
+ // authority: new PublicKey("Bk6mdg4mg9BD217vZwk8WDv7YJ66VyPPRhhQpaZsQPfL"),
54
+ // // lpUserAccount: new PublicKey(
55
+ // // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
56
+ // // ),
57
+ // });
58
+
59
+ // const transactionItems = [rebalance(client)];
60
+
61
+ // const txManager = new ClientTransactionsManager({
62
+ // txHandler: client,
63
+ // txRunType: payForTransaction ? "normal" : "only-simulate",
64
+ // priorityFeeSetting: PriorityFeeSetting.Default,
65
+ // retryConfig: { totalRetries: 4 },
66
+ // });
67
+ // const statuses = await txManager.send(transactionItems);
68
+ // consoleLog(statuses);
69
+
70
+ const ref = getReferralState(new PublicKey("9PCRbk8Gvt2zqewLKbxaSyTxA2JMtdQGhMff8EdELXNq"), SOLAUTO_PROD_PROGRAM);
71
+
72
+ const data = await fetchReferralState(umi, fromWeb3JsPublicKey(ref));
73
+
74
+ const accounts = await conn.getAddressLookupTable(new PublicKey(data.lookupTable));
75
+ console.log(accounts.value?.state?.addresses);
67
76
  }
68
77
 
69
78
  async function refreshAll() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.746",
3
+ "version": "1.0.748",
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",
@@ -75,7 +75,7 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
75
75
  );
76
76
 
77
77
  if (updateLutTx) {
78
- choresBefore.prepend(updateLutTx);
78
+ choresBefore = choresBefore.prepend(updateLutTx);
79
79
  }
80
80
 
81
81
  if (choresBefore.getInstructions().length) {
@@ -111,7 +111,8 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
111
111
 
112
112
  const updateLut = await client.updateLookupTable();
113
113
 
114
- if (updateLut && (updateLut?.new || updateLut.accountsToAdd.length > 4)) {
114
+ const updateLutInSepTx = updateLut?.new || (updateLut?.accountsToAdd ?? []).length > 4;
115
+ if (updateLut && updateLutInSepTx) {
115
116
  await this.updateLut(updateLut.tx, updateLut.new);
116
117
  }
117
118
  this.lookupTables.defaultLuts = client.defaultLookupTables();
@@ -124,7 +125,7 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
124
125
 
125
126
  await this.addChoreTxs(
126
127
  items,
127
- updateLut && !updateLut?.new ? updateLut.tx : undefined
128
+ updateLut && !updateLutInSepTx ? updateLut.tx : undefined
128
129
  );
129
130
 
130
131
  const result = await super.send(items).catch((e) => {