@haven-fi/solauto-sdk 1.0.213 → 1.0.215

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;AAGxC,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;IAUxC,SAAS,CAAC,EAAE,OAAO;IATrB,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,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,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class ReferralStateManager extends txHandler_1.TxHandler {
43
43
  const hasReferredBy = authorityReferralStateData &&
44
44
  authorityReferralStateData.referredByState !==
45
45
  (0, umi_1.publicKey)(web3_js_1.PublicKey.default);
46
- const referredByAuthority = !hasReferredBy &&
46
+ const finalReferredBy = !hasReferredBy &&
47
47
  referredBy &&
48
48
  !referredBy.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey))
49
49
  ? referredBy
50
50
  : undefined;
51
- this.referredBy = referredByAuthority;
51
+ this.referredBy = finalReferredBy;
52
+ this.referredByState = finalReferredBy
53
+ ? (0, utils_1.getReferralState)(finalReferredBy)
54
+ : authorityReferralStateData
55
+ ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.referredByState)
56
+ : undefined;
52
57
  }
53
58
  updateReferralStatesIx(destFeesMint, lookupTable) {
54
59
  return (0, generated_1.updateReferralStates)(this.umi, {
55
60
  signer: this.signer,
56
61
  signerReferralState: (0, umi_1.publicKey)(this.referralState),
57
62
  referralFeesDestMint: destFeesMint ? (0, umi_1.publicKey)(destFeesMint) : null,
58
- referredByState: this.referredBy
59
- ? (0, umi_1.publicKey)((0, utils_1.getReferralState)(this.referredBy))
63
+ referredByState: this.referredByState
64
+ ? (0, umi_1.publicKey)(this.referredByState)
60
65
  : undefined,
61
66
  referredByAuthority: this.referredBy
62
67
  ? (0, umi_1.publicKey)(this.referredBy)
@@ -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,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBA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referralStateManager.referredBy !== undefined) {
69
- this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy), this.supplyMint);
68
+ console.log(this.referralStateManager.referredBy?.toString());
69
+ if (this.referralStateManager.referredByState !== undefined) {
70
+ this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)(this.referralStateManager.referredByState, this.supplyMint);
70
71
  }
71
72
  this.solautoFeesWallet = generalAccounts_1.SOLAUTO_FEES_WALLET;
72
73
  this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoFeesWallet, this.supplyMint);
@@ -85,8 +86,8 @@ class SolautoClient extends txHandler_1.TxHandler {
85
86
  }
86
87
  setReferredBy(referredBy) {
87
88
  this.referralStateManager.setReferredBy(referredBy);
88
- if (this.referralStateManager.referredBy !== undefined) {
89
- this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy), this.supplyMint);
89
+ if (this.referralStateManager.referredByState !== undefined) {
90
+ this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)(this.referralStateManager.referredByState, this.supplyMint);
90
91
  }
91
92
  }
92
93
  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.referredBy
140
- ? (0, umi_1.publicKey)((0, accountUtils_1.getReferralState)(this.referralStateManager.referredBy))
139
+ referredByState: this.referralStateManager.referredByState
140
+ ? (0, umi_1.publicKey)(this.referralStateManager.referredByState)
141
141
  : undefined,
142
142
  referredBySupplyTa: this.referredBySupplyTa
143
143
  ? (0, umi_1.publicKey)(this.referredBySupplyTa)
@@ -5,6 +5,7 @@ export declare abstract class TxHandler {
5
5
  umi: Umi;
6
6
  connection: Connection;
7
7
  referredBy?: PublicKey;
8
+ referredByState?: PublicKey;
8
9
  constructor(rpcUrl: string, localTest?: boolean);
9
10
  log(...args: any[]): void;
10
11
  abstract defaultLookupTables(): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;IAExB,UAAU,CAAC,EAAE,SAAS,CAAC;gBAG5B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,OAAO;IAYrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7D,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI;CACrD"}
1
+ {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;IAExB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;gBAGjC,MAAM,EAAE,MAAM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,EAAE,GAAG;;;;EAwC9D"}
@@ -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, (0, accountUtils_1.getReferralState)(client.referralStateManager.referredBy), client.supplyMint));
151
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referralStateManager.referredByState, 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());
@@ -338,13 +338,16 @@ async function requiresRefreshBeforeRebalance(client) {
338
338
  const oldStateWithLatestPrices = await (0, generalUtils_2.positionStateWithLatestPrices)(client.solautoPositionData.state, constants_1.PRICES[client.supplyMint.toString()].price, constants_1.PRICES[client.debtMint.toString()].price);
339
339
  const utilizationRateDiff = Math.abs((client.solautoPositionState?.liqUtilizationRateBps ?? 0) -
340
340
  oldStateWithLatestPrices.liqUtilizationRateBps);
341
+ client.log("Liq utilization rate diff:", utilizationRateDiff);
341
342
  if (client.livePositionUpdates.supplyAdjustment === BigInt(0) &&
342
343
  client.livePositionUpdates.debtAdjustment === BigInt(0) &&
343
- utilizationRateDiff >= 20) {
344
+ utilizationRateDiff >= 10) {
345
+ client.log("Choosing to refresh before rebalance");
344
346
  return true;
345
347
  }
346
348
  }
347
349
  // Rebalance ix will already refresh internally if position is self managed, has automation to update, or position state last updated >= 1 day ago
350
+ client.log("Not refreshing before rebalance");
348
351
  return false;
349
352
  }
350
353
  async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRateBps, attemptNum) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.213",
3
+ "version": "1.0.215",
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",
@@ -88,13 +88,19 @@ export class ReferralStateManager extends TxHandler {
88
88
  authorityReferralStateData &&
89
89
  authorityReferralStateData.referredByState !==
90
90
  publicKey(PublicKey.default);
91
- const referredByAuthority =
91
+ const finalReferredBy =
92
92
  !hasReferredBy &&
93
93
  referredBy &&
94
94
  !referredBy.equals(toWeb3JsPublicKey(this.signer.publicKey))
95
95
  ? referredBy
96
96
  : undefined;
97
- this.referredBy = referredByAuthority;
97
+
98
+ this.referredBy = finalReferredBy;
99
+ this.referredByState = finalReferredBy
100
+ ? getReferralState(finalReferredBy)
101
+ : authorityReferralStateData
102
+ ? toWeb3JsPublicKey(authorityReferralStateData.referredByState)
103
+ : undefined;
98
104
  }
99
105
 
100
106
  updateReferralStatesIx(
@@ -105,8 +111,8 @@ export class ReferralStateManager extends TxHandler {
105
111
  signer: this.signer,
106
112
  signerReferralState: publicKey(this.referralState),
107
113
  referralFeesDestMint: destFeesMint ? publicKey(destFeesMint) : null,
108
- referredByState: this.referredBy
109
- ? publicKey(getReferralState(this.referredBy))
114
+ referredByState: this.referredByState
115
+ ? publicKey(this.referredByState)
110
116
  : undefined,
111
117
  referredByAuthority: this.referredBy
112
118
  ? publicKey(this.referredBy)
@@ -174,9 +174,10 @@ export abstract class SolautoClient extends TxHandler {
174
174
  signer: args.signer,
175
175
  wallet: args.wallet,
176
176
  });
177
- if (this.referralStateManager.referredBy !== undefined) {
177
+ console.log(this.referralStateManager.referredBy?.toString());
178
+ if (this.referralStateManager.referredByState !== undefined) {
178
179
  this.referredBySupplyTa = getTokenAccount(
179
- getReferralState(this.referralStateManager.referredBy),
180
+ this.referralStateManager.referredByState,
180
181
  this.supplyMint
181
182
  );
182
183
  }
@@ -213,9 +214,9 @@ export abstract class SolautoClient extends TxHandler {
213
214
 
214
215
  public setReferredBy(referredBy?: PublicKey) {
215
216
  this.referralStateManager.setReferredBy(referredBy);
216
- if (this.referralStateManager.referredBy !== undefined) {
217
+ if (this.referralStateManager.referredByState !== undefined) {
217
218
  this.referredBySupplyTa = getTokenAccount(
218
- getReferralState(this.referralStateManager.referredBy),
219
+ this.referralStateManager.referredByState!,
219
220
  this.supplyMint
220
221
  );
221
222
  }
@@ -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.referredBy
267
- ? publicKey(getReferralState(this.referralStateManager.referredBy))
266
+ referredByState: this.referralStateManager.referredByState
267
+ ? publicKey(this.referralStateManager.referredByState)
268
268
  : undefined,
269
269
  referredBySupplyTa: this.referredBySupplyTa
270
270
  ? publicKey(this.referredBySupplyTa)
@@ -8,6 +8,7 @@ export abstract class TxHandler {
8
8
  public connection!: Connection;
9
9
 
10
10
  public referredBy?: PublicKey;
11
+ public referredByState?: PublicKey;
11
12
 
12
13
  constructor(
13
14
  rpcUrl: string,
@@ -314,7 +314,7 @@ export async function rebalanceChoresBefore(
314
314
  chores = chores.add(
315
315
  createAssociatedTokenAccountUmiIx(
316
316
  client.signer,
317
- getReferralState(client.referralStateManager.referredBy!),
317
+ client.referralStateManager.referredByState!,
318
318
  client.supplyMint
319
319
  )
320
320
  );
@@ -611,17 +611,20 @@ export async function requiresRefreshBeforeRebalance(client: SolautoClient) {
611
611
  oldStateWithLatestPrices.liqUtilizationRateBps
612
612
  );
613
613
 
614
+ client.log("Liq utilization rate diff:", utilizationRateDiff);
614
615
  if (
615
616
  client.livePositionUpdates.supplyAdjustment === BigInt(0) &&
616
617
  client.livePositionUpdates.debtAdjustment === BigInt(0) &&
617
- utilizationRateDiff >= 20
618
+ utilizationRateDiff >= 10
618
619
  ) {
620
+ client.log("Choosing to refresh before rebalance");
619
621
  return true;
620
622
  }
621
623
  }
622
624
 
623
625
  // Rebalance ix will already refresh internally if position is self managed, has automation to update, or position state last updated >= 1 day ago
624
626
 
627
+ client.log("Not refreshing before rebalance");
625
628
  return false;
626
629
  }
627
630
 
@@ -22,12 +22,13 @@ import {
22
22
  import { PublicKey } from "@solana/web3.js";
23
23
  import { USDC } from "../../src/constants";
24
24
  import { buildHeliusApiUrl } from "../../src/utils";
25
+ import { PriorityFeeSetting } from "../../src/types";
25
26
 
26
27
  describe("Solauto Marginfi tests", async () => {
27
- // const signer = setupTest();
28
- const signer = setupTest("solauto-manager");
28
+ const signer = setupTest();
29
+ // const signer = setupTest("solauto-manager");
29
30
 
30
- const payForTransactions = false;
31
+ const payForTransactions = true;
31
32
  const useJitoBundle = false;
32
33
  const positionId = 1;
33
34
 
@@ -127,7 +128,7 @@ describe("Solauto Marginfi tests", async () => {
127
128
  transactionItems.push(
128
129
  new TransactionItem(
129
130
  async (attemptNum) =>
130
- await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
131
+ await buildSolautoRebalanceTransaction(client, 7000, attemptNum),
131
132
  "rebalance"
132
133
  )
133
134
  );
@@ -163,7 +164,7 @@ describe("Solauto Marginfi tests", async () => {
163
164
  client,
164
165
  undefined,
165
166
  !payForTransactions ? "only-simulate" : "normal",
166
- useJitoBundle
167
- ).clientSend(transactionItems);
167
+ useJitoBundle,
168
+ ).clientSend(transactionItems, PriorityFeeSetting.Default);
168
169
  });
169
170
  });