@haven-fi/solauto-sdk 1.0.211 → 1.0.213

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,12 +16,11 @@ export declare class ReferralStateManager extends TxHandler {
16
16
  referralAuthority: PublicKey;
17
17
  referralState: PublicKey;
18
18
  referralStateData: ReferralState | null;
19
- referredByState?: PublicKey;
20
19
  constructor(heliusApiUrl: string, localTest?: boolean | undefined);
21
20
  initialize(args: ReferralStateManagerArgs): Promise<void>;
22
21
  defaultLookupTables(): string[];
23
22
  setReferredBy(referredBy?: PublicKey): void;
24
- updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
23
+ updateReferralStatesIx(destFeesMint?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
25
24
  claimReferralFeesIx(destFeesMint?: PublicKey): TransactionBuilder;
26
25
  resetLiveTxUpdates(success?: boolean): Promise<void>;
27
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAEL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAGL,aAAa,EAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,UAAU,wBAAwB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAYxC,SAAS,CAAC,EAAE,OAAO;IAXrB,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC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AAM,EAAG,MAAM,CAAC;IAEhB,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;gBAG9C,YAAY,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,YAAA;IAUtB,UAAU,CAAC,IAAI,EAAE,wBAAwB;IAuB/C,mBAAmB,IAAI,MAAM,EAAE;IASxB,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS;IAe3C,sBAAsB,CACpB,YAAY,CAAC,EAAE,SAAS,EACxB,WAAW,CAAC,EAAE,SAAS,GACtB,kBAAkB;IAerB,mBAAmB,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,kBAAkB;IA8B3D,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3D"}
@@ -9,6 +9,7 @@ const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wa
9
9
  const generated_1 = require("../generated");
10
10
  const utils_1 = require("../utils");
11
11
  const txHandler_1 = require("./txHandler");
12
+ const constants_1 = require("../constants");
12
13
  class ReferralStateManager extends txHandler_1.TxHandler {
13
14
  constructor(heliusApiUrl, localTest) {
14
15
  super(heliusApiUrl, localTest);
@@ -32,9 +33,10 @@ class ReferralStateManager extends txHandler_1.TxHandler {
32
33
  this.setReferredBy(args.referredByAuthority);
33
34
  }
34
35
  defaultLookupTables() {
35
- return this.referralStateData?.lookupTable
36
- ? [this.referralStateData?.lookupTable.toString()]
37
- : [];
36
+ return this.referralStateData?.lookupTable &&
37
+ !(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
38
+ ? [constants_1.SOLAUTO_LUT, this.referralStateData?.lookupTable.toString()]
39
+ : [constants_1.SOLAUTO_LUT];
38
40
  }
39
41
  setReferredBy(referredBy) {
40
42
  const authorityReferralStateData = this.referralStateData;
@@ -46,24 +48,19 @@ class ReferralStateManager extends txHandler_1.TxHandler {
46
48
  !referredBy.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey))
47
49
  ? referredBy
48
50
  : undefined;
49
- this.referredByState = hasReferredBy
50
- ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.referredByState)
51
- : referredByAuthority
52
- ? (0, utils_1.getReferralState)(referredByAuthority)
53
- : undefined;
54
51
  this.referredBy = referredByAuthority;
55
52
  }
56
- updateReferralStatesIx(destFeesMint, referredBy, lookupTable) {
53
+ updateReferralStatesIx(destFeesMint, lookupTable) {
57
54
  return (0, generated_1.updateReferralStates)(this.umi, {
58
55
  signer: this.signer,
59
56
  signerReferralState: (0, umi_1.publicKey)(this.referralState),
60
57
  referralFeesDestMint: destFeesMint ? (0, umi_1.publicKey)(destFeesMint) : null,
61
- referredByState: referredBy
62
- ? (0, umi_1.publicKey)((0, utils_1.getReferralState)(referredBy))
63
- : this.referredByState
64
- ? (0, umi_1.publicKey)(this.referredByState)
65
- : undefined,
66
- referredByAuthority: referredBy ? (0, umi_1.publicKey)(referredBy) : undefined,
58
+ referredByState: this.referredBy
59
+ ? (0, umi_1.publicKey)((0, utils_1.getReferralState)(this.referredBy))
60
+ : undefined,
61
+ referredByAuthority: this.referredBy
62
+ ? (0, umi_1.publicKey)(this.referredBy)
63
+ : undefined,
67
64
  addressLookupTable: lookupTable ? (0, umi_1.publicKey)(lookupTable) : null,
68
65
  });
69
66
  }
@@ -65,8 +65,8 @@ class SolautoClient extends txHandler_1.TxHandler {
65
65
  signer: args.signer,
66
66
  wallet: args.wallet,
67
67
  });
68
- if (this.referralStateManager.referredByState !== undefined) {
69
- this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)(this.referralStateManager.referredByState, this.supplyMint);
68
+ if (this.referralStateManager.referredBy !== undefined) {
69
+ this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy), this.supplyMint);
70
70
  }
71
71
  this.solautoFeesWallet = generalAccounts_1.SOLAUTO_FEES_WALLET;
72
72
  this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoFeesWallet, this.supplyMint);
@@ -85,8 +85,8 @@ class SolautoClient extends txHandler_1.TxHandler {
85
85
  }
86
86
  setReferredBy(referredBy) {
87
87
  this.referralStateManager.setReferredBy(referredBy);
88
- if (this.referralStateManager.referredByState !== undefined) {
89
- this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)(this.referralStateManager.referredByState, this.supplyMint);
88
+ if (this.referralStateManager.referredBy !== undefined) {
89
+ this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy), this.supplyMint);
90
90
  }
91
91
  }
92
92
  async resetLiveTxUpdates(success) {
@@ -136,8 +136,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
136
136
  signer: this.signer,
137
137
  marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
138
138
  signerReferralState: (0, umi_1.publicKey)(this.referralStateManager.referralState),
139
- referredByState: this.referralStateManager.referredByState
140
- ? (0, umi_1.publicKey)(this.referralStateManager.referredByState)
139
+ referredByState: this.referralStateManager.referredBy
140
+ ? (0, umi_1.publicKey)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy))
141
141
  : undefined,
142
142
  referredBySupplyTa: this.referredBySupplyTa
143
143
  ? (0, umi_1.publicKey)(this.referredBySupplyTa)
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqCzD,OAAO,EAAE,oBA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AE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBAwCzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAkH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
@@ -52,13 +52,13 @@ function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn)
52
52
  async function transactionChoresBefore(client, accountsGettingCreated, solautoActions, initiatingDcaIn) {
53
53
  let chores = (0, umi_1.transactionBuilder)();
54
54
  if (client.referralStateManager.referralStateData === null ||
55
- (client.referralStateManager.referredByState !== undefined &&
55
+ (client.referralStateManager.referredBy !== undefined &&
56
56
  client.referralStateManager.referralStateData?.referredByState ===
57
57
  (0, umi_1.publicKey)(web3_js_1.PublicKey.default)) ||
58
58
  (client.authorityLutAddress !== undefined &&
59
59
  client.referralStateManager.referralStateData.lookupTable ==
60
60
  (0, umi_1.publicKey)(web3_js_1.PublicKey.default))) {
61
- chores = chores.add(client.referralStateManager.updateReferralStatesIx(undefined, client.referralStateManager.referredBy, client.authorityLutAddress));
61
+ chores = chores.add(client.referralStateManager.updateReferralStatesIx(undefined, client.authorityLutAddress));
62
62
  }
63
63
  if (client.selfManaged) {
64
64
  if (client.solautoPositionData === null) {
@@ -148,7 +148,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
148
148
  let chores = (0, umi_1.transactionBuilder)();
149
149
  if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
150
150
  client.log("Creating referred-by TA for ", client.supplyMint.toString());
151
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referralStateManager.referredByState, client.supplyMint));
151
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, accountUtils_1.getReferralState)(client.referralStateManager.referredBy), client.supplyMint));
152
152
  }
153
153
  if (checkSolautoFeesTa && !(0, generalUtils_1.rpcAccountCreated)(solautoFeesSupplyTa)) {
154
154
  client.log("Creating Solauto fees TA for ", client.supplyMint.toString());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.211",
3
+ "version": "1.0.213",
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",
@@ -21,6 +21,7 @@ import {
21
21
  } from "../generated";
22
22
  import { getReferralState, getTokenAccount } from "../utils";
23
23
  import { TxHandler } from "./txHandler";
24
+ import { SOLAUTO_LUT } from "../constants";
24
25
 
25
26
  interface ReferralStateManagerArgs {
26
27
  signer?: Signer;
@@ -37,8 +38,6 @@ export class ReferralStateManager extends TxHandler {
37
38
  public referralState!: PublicKey;
38
39
  public referralStateData!: ReferralState | null;
39
40
 
40
- public referredByState?: PublicKey;
41
-
42
41
  constructor(
43
42
  heliusApiUrl: string,
44
43
  public localTest?: boolean
@@ -75,9 +74,12 @@ export class ReferralStateManager extends TxHandler {
75
74
  }
76
75
 
77
76
  defaultLookupTables(): string[] {
78
- return this.referralStateData?.lookupTable
79
- ? [this.referralStateData?.lookupTable.toString()]
80
- : [];
77
+ return this.referralStateData?.lookupTable &&
78
+ !toWeb3JsPublicKey(this.referralStateData!.lookupTable).equals(
79
+ PublicKey.default
80
+ )
81
+ ? [SOLAUTO_LUT, this.referralStateData?.lookupTable.toString()]
82
+ : [SOLAUTO_LUT];
81
83
  }
82
84
 
83
85
  public setReferredBy(referredBy?: PublicKey) {
@@ -92,29 +94,23 @@ export class ReferralStateManager extends TxHandler {
92
94
  !referredBy.equals(toWeb3JsPublicKey(this.signer.publicKey))
93
95
  ? referredBy
94
96
  : undefined;
95
- this.referredByState = hasReferredBy
96
- ? toWeb3JsPublicKey(authorityReferralStateData!.referredByState)
97
- : referredByAuthority
98
- ? getReferralState(referredByAuthority!)
99
- : undefined;
100
97
  this.referredBy = referredByAuthority;
101
98
  }
102
99
 
103
100
  updateReferralStatesIx(
104
101
  destFeesMint?: PublicKey,
105
- referredBy?: PublicKey,
106
102
  lookupTable?: PublicKey
107
103
  ): TransactionBuilder {
108
104
  return updateReferralStates(this.umi, {
109
105
  signer: this.signer,
110
106
  signerReferralState: publicKey(this.referralState),
111
107
  referralFeesDestMint: destFeesMint ? publicKey(destFeesMint) : null,
112
- referredByState: referredBy
113
- ? publicKey(getReferralState(referredBy))
114
- : this.referredByState
115
- ? publicKey(this.referredByState)
116
- : undefined,
117
- referredByAuthority: referredBy ? publicKey(referredBy) : undefined,
108
+ referredByState: this.referredBy
109
+ ? publicKey(getReferralState(this.referredBy))
110
+ : undefined,
111
+ referredByAuthority: this.referredBy
112
+ ? publicKey(this.referredBy)
113
+ : undefined,
118
114
  addressLookupTable: lookupTable ? publicKey(lookupTable) : null,
119
115
  });
120
116
  }
@@ -174,9 +174,9 @@ export abstract class SolautoClient extends TxHandler {
174
174
  signer: args.signer,
175
175
  wallet: args.wallet,
176
176
  });
177
- if (this.referralStateManager.referredByState !== undefined) {
177
+ if (this.referralStateManager.referredBy !== undefined) {
178
178
  this.referredBySupplyTa = getTokenAccount(
179
- this.referralStateManager.referredByState,
179
+ getReferralState(this.referralStateManager.referredBy),
180
180
  this.supplyMint
181
181
  );
182
182
  }
@@ -213,9 +213,9 @@ export abstract class SolautoClient extends TxHandler {
213
213
 
214
214
  public setReferredBy(referredBy?: PublicKey) {
215
215
  this.referralStateManager.setReferredBy(referredBy);
216
- if (this.referralStateManager.referredByState !== undefined) {
216
+ if (this.referralStateManager.referredBy !== undefined) {
217
217
  this.referredBySupplyTa = getTokenAccount(
218
- this.referralStateManager.referredByState,
218
+ getReferralState(this.referralStateManager.referredBy),
219
219
  this.supplyMint
220
220
  );
221
221
  }
@@ -32,7 +32,7 @@ import {
32
32
  marginfiRebalance,
33
33
  marginfiRefreshData,
34
34
  } from "../generated";
35
- import { getMarginfiAccountPDA, getTokenAccount } from "../utils/accountUtils";
35
+ import { getMarginfiAccountPDA, getReferralState, getTokenAccount } from "../utils/accountUtils";
36
36
  import { generateRandomU64, safeGetPrice } from "../utils/generalUtils";
37
37
  import {
38
38
  MARGINFI_PROGRAM_ID,
@@ -263,8 +263,8 @@ export class SolautoMarginfiClient extends SolautoClient {
263
263
  signer: this.signer,
264
264
  marginfiProgram: publicKey(MARGINFI_PROGRAM_ID),
265
265
  signerReferralState: publicKey(this.referralStateManager.referralState),
266
- referredByState: this.referralStateManager.referredByState
267
- ? publicKey(this.referralStateManager.referredByState)
266
+ referredByState: this.referralStateManager.referredBy
267
+ ? publicKey(getReferralState(this.referralStateManager.referredBy))
268
268
  : undefined,
269
269
  referredBySupplyTa: this.referredBySupplyTa
270
270
  ? publicKey(this.referredBySupplyTa)
@@ -57,7 +57,7 @@ import {
57
57
  eligibleForRebalance,
58
58
  positionStateWithLatestPrices,
59
59
  } from "../utils/solauto/generalUtils";
60
- import { getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
60
+ import { getReferralState, getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
61
61
  import {
62
62
  createMarginfiProgram,
63
63
  getLendingAccountBorrowInstructionDataSerializer,
@@ -140,7 +140,7 @@ async function transactionChoresBefore(
140
140
 
141
141
  if (
142
142
  client.referralStateManager.referralStateData === null ||
143
- (client.referralStateManager.referredByState !== undefined &&
143
+ (client.referralStateManager.referredBy !== undefined &&
144
144
  client.referralStateManager.referralStateData?.referredByState ===
145
145
  publicKey(PublicKey.default)) ||
146
146
  (client.authorityLutAddress !== undefined &&
@@ -150,7 +150,6 @@ async function transactionChoresBefore(
150
150
  chores = chores.add(
151
151
  client.referralStateManager.updateReferralStatesIx(
152
152
  undefined,
153
- client.referralStateManager.referredBy,
154
153
  client.authorityLutAddress
155
154
  )
156
155
  );
@@ -315,7 +314,7 @@ export async function rebalanceChoresBefore(
315
314
  chores = chores.add(
316
315
  createAssociatedTokenAccountUmiIx(
317
316
  client.signer,
318
- client.referralStateManager.referredByState!,
317
+ getReferralState(client.referralStateManager.referredBy!),
319
318
  client.supplyMint
320
319
  )
321
320
  );
@@ -59,7 +59,7 @@ function assertAccurateRebalance(
59
59
  let adjustmentFeeBps = 0;
60
60
  if (increasingLeverage) {
61
61
  adjustmentFeeBps = getSolautoFeesBps(
62
- client.referredByState !== undefined,
62
+ client.referredBy !== undefined,
63
63
  targetLiqUtilizationRateBps,
64
64
  fromBaseUnit(
65
65
  client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),