@haven-fi/solauto-sdk 1.0.100 → 1.0.102

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,6 @@ export declare abstract class SolautoClient extends TxHandler {
40
40
  solautoFeesWallet: PublicKey;
41
41
  solautoFeesSupplyTa: PublicKey;
42
42
  authorityLutAddress?: PublicKey;
43
- upToDateLutAccounts: PublicKey[];
44
43
  livePositionUpdates: LivePositionUpdates;
45
44
  constructor(heliusApiKey: string, localTest?: boolean | undefined);
46
45
  initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAGL,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAQnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,UAA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,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,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -80,9 +80,6 @@ class SolautoClient extends txHandler_1.TxHandler {
80
80
  this.authorityLutAddress = authorityReferralStateData?.lookupTable && !(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
81
81
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable)
82
82
  : undefined;
83
- this.upToDateLutAccounts = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey).equals(this.authority)
84
- ? await this.fetchExistingAuthorityLutAccounts()
85
- : [];
86
83
  this.log("Position state: ", this.solautoPositionState);
87
84
  this.log("Position settings: ", this.solautoPositionData?.position?.settingParams);
88
85
  this.log("Position DCA: ", (this.solautoPositionData?.position?.dca?.automation?.targetPeriods ??
@@ -127,35 +124,41 @@ class SolautoClient extends txHandler_1.TxHandler {
127
124
  ];
128
125
  }
129
126
  async fetchExistingAuthorityLutAccounts() {
127
+ console.log("Fetching lut accounts", this.authorityLutAddress?.toString());
130
128
  const lookupTable = this.authorityLutAddress
131
129
  ? await this.connection.getAddressLookupTable(this.authorityLutAddress)
132
130
  : null;
131
+ console.log(lookupTable?.value);
133
132
  if (!lookupTable || lookupTable?.value === null) {
134
133
  this.authorityLutAddress = undefined;
135
134
  }
136
135
  return lookupTable?.value?.state.addresses ?? [];
137
136
  }
138
137
  async updateLookupTable() {
138
+ console.log("Getting existing accoutns");
139
139
  const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
140
+ console.log("existing accoutns", existingLutAccounts.length);
140
141
  if (this.lutAccountsToAdd().every((element) => existingLutAccounts
141
142
  .map((x) => x.toString().toLowerCase())
142
143
  .includes(element.toString().toLowerCase()))) {
143
144
  return undefined;
144
145
  }
145
146
  let tx = (0, umi_1.transactionBuilder)();
147
+ console.log("lut address", this.authorityLutAddress?.toString());
146
148
  if (this.authorityLutAddress === undefined) {
147
149
  const [createLookupTableInst, lookupTableAddress] = web3_js_1.AddressLookupTableProgram.createLookupTable({
148
150
  authority: this.authority,
149
151
  payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
150
152
  recentSlot: await this.umi.rpc.getSlot({ commitment: "finalized" }),
151
153
  });
154
+ console.log("new luit", lookupTableAddress.toString());
152
155
  this.authorityLutAddress = lookupTableAddress;
153
156
  tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, createLookupTableInst));
154
157
  }
155
158
  const accountsToAdd = this.lutAccountsToAdd().filter((x) => !existingLutAccounts
156
159
  .map((x) => x.toString().toLowerCase())
157
160
  .includes(x.toString().toLowerCase()));
158
- this.upToDateLutAccounts = [...existingLutAccounts, ...accountsToAdd];
161
+ console.log("add accounts", accountsToAdd.length);
159
162
  if (accountsToAdd.length > 0) {
160
163
  tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
161
164
  payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
@@ -164,12 +167,14 @@ class SolautoClient extends txHandler_1.TxHandler {
164
167
  addresses: accountsToAdd,
165
168
  })));
166
169
  }
170
+ console.log("Hello");
167
171
  const addingReferredBy = accountsToAdd.length === 1 &&
168
172
  accountsToAdd[0].toString().toLowerCase() ===
169
173
  this.referredBySupplyTa?.toString().toLowerCase();
170
174
  if (tx.getInstructions().length > 0) {
171
175
  this.log("Updating authority lookup table...");
172
176
  }
177
+ console.log("instructions", tx.getInstructions().length);
173
178
  return { updateLutTx: tx, needsToBeIsolated: !addingReferredBy };
174
179
  }
175
180
  solautoPositionSettings() {
@@ -1,5 +1,5 @@
1
1
  import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
- import { Account as SplTokenAccount } from "@solana/spl-token";
2
+ import { PublicKey } from "@solana/web3.js";
3
3
  import { ReferralState } from "../generated";
4
4
  import { SolautoClient } from "../clients/solautoClient";
5
5
  export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
@@ -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(umi: Umi, referralState: ReferralState, tokenAccount: SplTokenAccount): Promise<[TransactionBuilder, string[]]>;
11
+ export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: PublicKey): Promise<[TransactionBuilder, string[]] | undefined>;
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,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACA,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACC,SAAS,CACZ,CAyHA;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"}
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;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAMxE,OAAO,EAGL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC;IACT,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACG,SAAS,CACZ,CAyHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD"}
@@ -373,10 +373,14 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
373
373
  };
374
374
  }
375
375
  async function convertReferralFeesToDestination(umi, referralState, tokenAccount) {
376
+ const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(umi, tokenAccount);
377
+ if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
378
+ return undefined;
379
+ }
376
380
  const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(umi.identity, {
377
- amount: tokenAccount.amount,
381
+ amount: tokenAccountData.amount,
378
382
  destinationWallet: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.publicKey),
379
- inputMint: tokenAccount.mint,
383
+ inputMint: tokenAccountData.mint,
380
384
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.destFeesMint),
381
385
  exactIn: true,
382
386
  slippageBpsIncFactor: 0.15,
@@ -385,10 +389,10 @@ async function convertReferralFeesToDestination(umi, referralState, tokenAccount
385
389
  .add(setupInstructions)
386
390
  .add((0, generated_1.convertReferralFees)(umi, {
387
391
  signer: umi.identity,
388
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(umi.identity.publicKey), tokenAccount.mint)),
392
+ intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(umi.identity.publicKey), tokenAccountData.mint)),
389
393
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
390
394
  referralState: referralState.publicKey,
391
- referralFeesTa: (0, umi_1.publicKey)(tokenAccount.address),
395
+ referralFeesTa: (0, umi_1.publicKey)(tokenAccount),
392
396
  }))
393
397
  .add(swapIx);
394
398
  return [tx, lookupTableAddresses];
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAGG,WAAW,EAAE,MAAM,EAAE;IAAE,OAAO,CAAC,GAAG;IAFrD,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAEnB,WAAW,EAAE,MAAM,EAAE,EAAU,GAAG,EAAE,GAAG;IAGpD,YAAY,CAChB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC;CAoBtC;AAED,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,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,E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Ac,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,aAAa,CAAC;IARxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA;YAKzB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAkB7D,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB;IAkEzE,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,OAAO;CAyGjG"}
@@ -1,8 +1,10 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
+ import { Umi } from "@metaplex-foundation/umi";
2
3
  export declare function bufferFromU8(num: number): Buffer;
3
4
  export declare function bufferFromU64(num: bigint): Buffer;
4
5
  export declare function getTokenAccount(wallet: PublicKey, tokenMint: PublicKey): PublicKey;
5
6
  export declare function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKey[]): PublicKey[];
7
+ export declare function getTokenAccountData(umi: Umi, tokenAccount: PublicKey): Promise<import("@solana/spl-token").RawAccount | undefined>;
6
8
  export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number): PublicKey;
7
9
  export declare function getReferralState(authority: PublicKey): PublicKey;
8
10
  export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): Promise<PublicKey>;
@@ -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;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,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,aAQnB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,aAUpD;AAED,wBAAsB,qBAAqB,CACzC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,sBAa/B"}
1
+ {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,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,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,+DAO1E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,aAQnB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,aAUpD;AAED,wBAAsB,qBAAqB,CACzC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,sBAa/B"}
@@ -4,12 +4,14 @@ exports.bufferFromU8 = bufferFromU8;
4
4
  exports.bufferFromU64 = bufferFromU64;
5
5
  exports.getTokenAccount = getTokenAccount;
6
6
  exports.getTokenAccounts = getTokenAccounts;
7
+ exports.getTokenAccountData = getTokenAccountData;
7
8
  exports.getSolautoPositionAccount = getSolautoPositionAccount;
8
9
  exports.getReferralState = getReferralState;
9
10
  exports.getMarginfiAccountPDA = getMarginfiAccountPDA;
10
11
  const web3_js_1 = require("@solana/web3.js");
11
12
  const spl_token_1 = require("@solana/spl-token");
12
13
  const generated_1 = require("../generated");
14
+ const umi_1 = require("@metaplex-foundation/umi");
13
15
  function bufferFromU8(num) {
14
16
  const buffer = Buffer.alloc(1);
15
17
  buffer.writeUInt8(num);
@@ -26,6 +28,15 @@ function getTokenAccount(wallet, tokenMint) {
26
28
  function getTokenAccounts(wallet, tokenMints) {
27
29
  return tokenMints.map(x => getTokenAccount(wallet, x));
28
30
  }
31
+ async function getTokenAccountData(umi, tokenAccount) {
32
+ const resp = await umi.rpc.getAccount((0, umi_1.publicKey)(tokenAccount));
33
+ if (resp.exists) {
34
+ return spl_token_1.AccountLayout.decode(resp.data);
35
+ }
36
+ else {
37
+ return undefined;
38
+ }
39
+ }
29
40
  function getSolautoPositionAccount(signer, positionId) {
30
41
  const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([bufferFromU8(positionId), signer.toBuffer()], new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
31
42
  return positionAccount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
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",
@@ -1,13 +1,11 @@
1
1
  import "rpc-websockets/dist/lib/client";
2
2
  import {
3
3
  AddressLookupTableProgram,
4
- Connection,
5
4
  PublicKey,
6
5
  } from "@solana/web3.js";
7
6
  import {
8
7
  Signer,
9
8
  TransactionBuilder,
10
- Umi,
11
9
  isOption,
12
10
  publicKey,
13
11
  PublicKey as UmiPublicKey,
@@ -47,7 +45,6 @@ import {
47
45
  } from "../constants/generalAccounts";
48
46
  import { JupSwapDetails } from "../utils/jupiterUtils";
49
47
  import {
50
- getSolanaRpcConnection,
51
48
  getWrappedInstruction,
52
49
  splTokenTransferUmiIx,
53
50
  } from "../utils/solanaUtils";
@@ -103,7 +100,6 @@ export abstract class SolautoClient extends TxHandler {
103
100
  public solautoFeesSupplyTa!: PublicKey;
104
101
 
105
102
  public authorityLutAddress?: PublicKey;
106
- public upToDateLutAccounts!: PublicKey[];
107
103
 
108
104
  public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
109
105
 
@@ -207,11 +203,6 @@ export abstract class SolautoClient extends TxHandler {
207
203
  this.authorityLutAddress = authorityReferralStateData?.lookupTable && !toWeb3JsPublicKey(authorityReferralStateData.lookupTable).equals(PublicKey.default)
208
204
  ? toWeb3JsPublicKey(authorityReferralStateData.lookupTable)
209
205
  : undefined;
210
- this.upToDateLutAccounts = toWeb3JsPublicKey(this.signer.publicKey).equals(
211
- this.authority
212
- )
213
- ? await this.fetchExistingAuthorityLutAccounts()
214
- : [];
215
206
 
216
207
  this.log("Position state: ", this.solautoPositionState);
217
208
  this.log(
@@ -271,9 +262,11 @@ export abstract class SolautoClient extends TxHandler {
271
262
  }
272
263
 
273
264
  async fetchExistingAuthorityLutAccounts(): Promise<PublicKey[]> {
265
+ console.log("Fetching lut accounts", this.authorityLutAddress?.toString());
274
266
  const lookupTable = this.authorityLutAddress
275
267
  ? await this.connection.getAddressLookupTable(this.authorityLutAddress)
276
268
  : null;
269
+ console.log(lookupTable?.value);
277
270
  if (!lookupTable || lookupTable?.value === null) {
278
271
  this.authorityLutAddress = undefined;
279
272
  }
@@ -283,7 +276,9 @@ export abstract class SolautoClient extends TxHandler {
283
276
  async updateLookupTable(): Promise<
284
277
  { updateLutTx: TransactionBuilder; needsToBeIsolated: boolean } | undefined
285
278
  > {
279
+ console.log("Getting existing accoutns");
286
280
  const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
281
+ console.log("existing accoutns", existingLutAccounts.length);
287
282
  if (
288
283
  this.lutAccountsToAdd().every((element) =>
289
284
  existingLutAccounts
@@ -296,6 +291,7 @@ export abstract class SolautoClient extends TxHandler {
296
291
 
297
292
  let tx = transactionBuilder();
298
293
 
294
+ console.log("lut address", this.authorityLutAddress?.toString());
299
295
  if (this.authorityLutAddress === undefined) {
300
296
  const [createLookupTableInst, lookupTableAddress] =
301
297
  AddressLookupTableProgram.createLookupTable({
@@ -303,6 +299,7 @@ export abstract class SolautoClient extends TxHandler {
303
299
  payer: toWeb3JsPublicKey(this.signer.publicKey),
304
300
  recentSlot: await this.umi.rpc.getSlot({ commitment: "finalized" }),
305
301
  });
302
+ console.log("new luit", lookupTableAddress.toString());
306
303
  this.authorityLutAddress = lookupTableAddress;
307
304
  tx = tx.add(getWrappedInstruction(this.signer, createLookupTableInst));
308
305
  }
@@ -313,7 +310,7 @@ export abstract class SolautoClient extends TxHandler {
313
310
  .map((x) => x.toString().toLowerCase())
314
311
  .includes(x.toString().toLowerCase())
315
312
  );
316
- this.upToDateLutAccounts = [...existingLutAccounts, ...accountsToAdd];
313
+ console.log("add accounts", accountsToAdd.length);
317
314
 
318
315
  if (accountsToAdd.length > 0) {
319
316
  tx = tx.add(
@@ -328,6 +325,7 @@ export abstract class SolautoClient extends TxHandler {
328
325
  )
329
326
  );
330
327
  }
328
+ console.log("Hello");
331
329
 
332
330
  const addingReferredBy =
333
331
  accountsToAdd.length === 1 &&
@@ -337,6 +335,7 @@ export abstract class SolautoClient extends TxHandler {
337
335
  if (tx.getInstructions().length > 0) {
338
336
  this.log("Updating authority lookup table...");
339
337
  }
338
+ console.log("instructions", tx.getInstructions().length);
340
339
 
341
340
  return { updateLutTx: tx, needsToBeIsolated: !addingReferredBy };
342
341
  }
@@ -48,7 +48,7 @@ import {
48
48
  uint8ArrayToBigInt,
49
49
  } from "../utils/numberUtils";
50
50
  import { eligibleForRebalance } from "../utils/solauto/generalUtils";
51
- import { getTokenAccount } from "../utils/accountUtils";
51
+ import { getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
52
52
  import {
53
53
  getLendingAccountBorrowInstructionDataSerializer,
54
54
  getLendingAccountDepositInstructionDataSerializer,
@@ -553,11 +553,10 @@ export async function buildSolautoRebalanceTransaction(
553
553
  client: SolautoClient,
554
554
  targetLiqUtilizationRateBps?: number,
555
555
  attemptNum?: number
556
- ): Promise<
557
- | {
558
- tx: TransactionBuilder;
559
- lookupTableAddresses: string[];
560
- }
556
+ ): Promise<{
557
+ tx: TransactionBuilder;
558
+ lookupTableAddresses: string[];
559
+ }
561
560
  | undefined
562
561
  > {
563
562
  client.solautoPositionState = await client.getFreshPositionState();
@@ -685,13 +684,18 @@ export async function buildSolautoRebalanceTransaction(
685
684
  export async function convertReferralFeesToDestination(
686
685
  umi: Umi,
687
686
  referralState: ReferralState,
688
- tokenAccount: SplTokenAccount
689
- ): Promise<[TransactionBuilder, string[]]> {
687
+ tokenAccount: PublicKey
688
+ ): Promise<[TransactionBuilder, string[]] | undefined> {
689
+ const tokenAccountData = await getTokenAccountData(umi, tokenAccount);
690
+ if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
691
+ return undefined;
692
+ }
693
+
690
694
  const { lookupTableAddresses, setupInstructions, swapIx } =
691
695
  await getJupSwapTransaction(umi.identity, {
692
- amount: tokenAccount.amount,
696
+ amount: tokenAccountData.amount,
693
697
  destinationWallet: toWeb3JsPublicKey(referralState.publicKey),
694
- inputMint: tokenAccount.mint,
698
+ inputMint: tokenAccountData.mint,
695
699
  outputMint: toWeb3JsPublicKey(referralState.destFeesMint),
696
700
  exactIn: true,
697
701
  slippageBpsIncFactor: 0.15,
@@ -705,12 +709,12 @@ export async function convertReferralFeesToDestination(
705
709
  intermediaryTa: publicKey(
706
710
  getTokenAccount(
707
711
  toWeb3JsPublicKey(umi.identity.publicKey),
708
- tokenAccount.mint
712
+ tokenAccountData.mint
709
713
  )
710
714
  ),
711
715
  ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
712
716
  referralState: referralState.publicKey,
713
- referralFeesTa: publicKey(tokenAccount.address),
717
+ referralFeesTa: publicKey(tokenAccount),
714
718
  })
715
719
  )
716
720
  .add(swapIx);
@@ -16,7 +16,6 @@ import {
16
16
  } from "../utils/generalUtils";
17
17
  import { getTransactionChores } from "./transactionUtils";
18
18
  import { PriorityFeeSetting } from "../types";
19
- import { Connection, PublicKey } from "@solana/web3.js";
20
19
  import { ReferralStateManager, TxHandler } from "../clients";
21
20
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
22
21
 
@@ -1,6 +1,7 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { getAssociatedTokenAddressSync } from "@solana/spl-token";
2
+ import { AccountLayout as SplTokenAccountLayout, getAssociatedTokenAddressSync } from "@solana/spl-token";
3
3
  import { SOLAUTO_PROGRAM_ID } from "../generated";
4
+ import { publicKey, Umi } from "@metaplex-foundation/umi";
4
5
 
5
6
  export function bufferFromU8(num: number): Buffer {
6
7
  const buffer = Buffer.alloc(1);
@@ -26,6 +27,15 @@ export function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKey[]): Pu
26
27
  return tokenMints.map(x => getTokenAccount(wallet, x));
27
28
  }
28
29
 
30
+ export async function getTokenAccountData(umi: Umi, tokenAccount: PublicKey) {
31
+ const resp = await umi.rpc.getAccount(publicKey(tokenAccount));
32
+ if (resp.exists) {
33
+ return SplTokenAccountLayout.decode(resp.data);
34
+ } else {
35
+ return undefined;
36
+ }
37
+ }
38
+
29
39
  export function getSolautoPositionAccount(
30
40
  signer: PublicKey,
31
41
  positionId: number
@@ -1,5 +1,5 @@
1
1
  import { describe, it } from "mocha";
2
- import { none, some } from "@metaplex-foundation/umi";
2
+ import { none, publicKey, some } from "@metaplex-foundation/umi";
3
3
  import { setupTest } from "../shared";
4
4
  import {
5
5
  SolautoMarginfiClient,
@@ -154,11 +154,11 @@ describe("Solauto Marginfi tests", async () => {
154
154
  // )
155
155
  // );
156
156
 
157
- await new TransactionsManager(
158
- client,
159
- undefined,
160
- !payForTransactions,
161
- useJitoBundle
162
- ).clientSend(transactionItems);
157
+ // await new TransactionsManager(
158
+ // client,
159
+ // undefined,
160
+ // !payForTransactions,
161
+ // useJitoBundle
162
+ // ).clientSend(transactionItems);
163
163
  });
164
164
  });