@haven-fi/solauto-sdk 1.0.587 → 1.0.589

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.
@@ -40,14 +40,14 @@ export class RebalanceSwapManager {
40
40
  }
41
41
 
42
42
  private postRebalanceLiqUtilizationRateBps(swapOutputAmount?: bigint) {
43
- let supplyUsd = this.client.solautoPosition.supplyUsd();
43
+ let supplyUsd = this.client.pos.supplyUsd();
44
44
  // TODO: add token balance change
45
- let debtUsd = this.client.solautoPosition.debtUsd();
45
+ let debtUsd = this.client.pos.debtUsd();
46
46
 
47
47
  const outputToken = toWeb3JsPublicKey(
48
48
  this.isBoost()
49
- ? this.client.solautoPosition.state().supply.mint
50
- : this.client.solautoPosition.state().debt.mint
49
+ ? this.client.pos.state().supply.mint
50
+ : this.client.pos.state().debt.mint
51
51
  );
52
52
  const swapOutputUsd = swapOutputAmount
53
53
  ? fromBaseUnit(swapOutputAmount, tokenInfo(outputToken).decimals) *
@@ -64,7 +64,7 @@ export class RebalanceSwapManager {
64
64
  return getLiqUtilzationRateBps(
65
65
  supplyUsd,
66
66
  debtUsd,
67
- this.client.solautoPosition.state().liqThresholdBps ?? 0
67
+ this.client.pos.state().liqThresholdBps ?? 0
68
68
  );
69
69
  }
70
70
 
@@ -106,11 +106,11 @@ export class RebalanceSwapManager {
106
106
 
107
107
  private swapDetails() {
108
108
  const input = this.isBoost()
109
- ? this.client.solautoPosition.state().debt
110
- : this.client.solautoPosition.state().supply;
109
+ ? this.client.pos.state().debt
110
+ : this.client.pos.state().supply;
111
111
  const output = this.isBoost()
112
- ? this.client.solautoPosition.state().supply
113
- : this.client.solautoPosition.state().debt;
112
+ ? this.client.pos.state().supply
113
+ : this.client.pos.state().debt;
114
114
 
115
115
  let inputAmount = toBaseUnit(
116
116
  this.usdToSwap() / safeGetPrice(input.mint)!,
@@ -180,8 +180,8 @@ export class RebalanceSwapManager {
180
180
  minOutputAmount: rebalanceToZero ? outputAmount : undefined,
181
181
  maxLiqUtilizationRateBps: this.values.repayingCloseToMaxLtv
182
182
  ? maxRepayToBps(
183
- this.client.solautoPosition.state().maxLtvBps ?? 0,
184
- this.client.solautoPosition.state().liqThresholdBps ?? 0
183
+ this.client.pos.state().maxLtvBps ?? 0,
184
+ this.client.pos.state().liqThresholdBps ?? 0
185
185
  ) - 15
186
186
  : undefined,
187
187
  });
@@ -199,7 +199,7 @@ export class RebalanceSwapManager {
199
199
  ...swapInput,
200
200
  destinationWallet: flashLoanRepayFromDebt
201
201
  ? toWeb3JsPublicKey(this.client.signer.publicKey)
202
- : this.client.solautoPosition.publicKey,
202
+ : this.client.pos.publicKey,
203
203
  slippageIncFactor: 0.2 + attemptNum * 0.25,
204
204
  };
205
205
  }
@@ -43,19 +43,19 @@ export class RebalanceTxBuilder {
43
43
 
44
44
  private async shouldProceedWithRebalance() {
45
45
  return (
46
- this.client.solautoPosition.supplyUsd() > 0 &&
46
+ this.client.pos.supplyUsd() > 0 &&
47
47
  (this.targetLiqUtilizationRateBps !== undefined ||
48
- this.client.solautoPosition.eligibleForRebalance())
48
+ this.client.pos.eligibleForRebalance())
49
49
  );
50
50
  }
51
51
 
52
52
  private getRebalanceValues(flFee?: number) {
53
53
  return getRebalanceValues(
54
- this.client.solautoPosition,
54
+ this.client.pos,
55
55
  new SolautoFeesBps(
56
56
  this.client.isReferred(),
57
57
  this.targetLiqUtilizationRateBps,
58
- this.client.solautoPosition.netWorthUsd()
58
+ this.client.pos.netWorthUsd()
59
59
  ),
60
60
  flFee ?? 0,
61
61
  this.targetLiqUtilizationRateBps
@@ -84,12 +84,12 @@ export class RebalanceTxBuilder {
84
84
  const insufficientSupplyLiquidity = insufficientLiquidity(
85
85
  debtAdjustmentUsd,
86
86
  supplyLiquidityAvailable,
87
- this.client.solautoPosition.supplyMint()
87
+ this.client.pos.supplyMint()
88
88
  );
89
89
  const insufficientDebtLiquidity = insufficientLiquidity(
90
90
  debtAdjustmentUsd,
91
91
  debtLiquidityAvailable,
92
- this.client.solautoPosition.debtMint()
92
+ this.client.pos.debtMint()
93
93
  );
94
94
 
95
95
  let useDebtLiquidity =
@@ -107,8 +107,8 @@ export class RebalanceTxBuilder {
107
107
  attemptNum: number
108
108
  ): Promise<FlashLoanRequirements | undefined> {
109
109
  const maxLtvRateBps = getMaxLiqUtilizationRateBps(
110
- this.client.solautoPosition.state().maxLtvBps,
111
- this.client.solautoPosition.state().liqThresholdBps,
110
+ this.client.pos.state().maxLtvBps,
111
+ this.client.pos.state().liqThresholdBps,
112
112
  0.02
113
113
  );
114
114
 
@@ -156,9 +156,9 @@ export class RebalanceTxBuilder {
156
156
 
157
157
  let flashLoanToken: PositionTokenState | undefined = undefined;
158
158
  if (boosting || useDebtLiquidity) {
159
- flashLoanToken = this.client.solautoPosition.state().debt;
159
+ flashLoanToken = this.client.pos.state().debt;
160
160
  } else {
161
- flashLoanToken = this.client.solautoPosition.state().supply;
161
+ flashLoanToken = this.client.pos.state().supply;
162
162
  }
163
163
 
164
164
  return {
@@ -225,14 +225,14 @@ export class RebalanceTxBuilder {
225
225
  this.client.selfManaged ||
226
226
  this.client.contextUpdates.supplyAdjustment > BigInt(0) ||
227
227
  this.client.contextUpdates.debtAdjustment > BigInt(0) ||
228
- !this.client.solautoPosition.exists()
228
+ !this.client.pos.exists()
229
229
  ) {
230
230
  return false;
231
231
  }
232
232
  // Rebalance ix will already refresh internally if position is self managed
233
233
 
234
234
  const utilizationRateDiff = Math.abs(
235
- await this.client.solautoPosition.utilizationRateBpsDrift()
235
+ await this.client.pos.utilizationRateBpsDrift()
236
236
  );
237
237
  consoleLog("Liq utilization rate diff:", utilizationRateDiff);
238
238
 
@@ -287,7 +287,7 @@ export class RebalanceTxBuilder {
287
287
 
288
288
  const flashBorrowDest = exactOut
289
289
  ? getTokenAccount(
290
- this.client.solautoPosition.publicKey,
290
+ this.client.pos.publicKey,
291
291
  new PublicKey(swapQuote.outputMint)
292
292
  )
293
293
  : getTokenAccount(
@@ -314,7 +314,7 @@ export class RebalanceTxBuilder {
314
314
  public async buildRebalanceTx(
315
315
  attemptNum: number
316
316
  ): Promise<TransactionItemInputs | undefined> {
317
- await this.client.solautoPosition.refreshPositionState();
317
+ await this.client.pos.refreshPositionState();
318
318
 
319
319
  if (!this.shouldProceedWithRebalance()) {
320
320
  this.client.log("Not eligible for a rebalance");
@@ -63,7 +63,7 @@ export abstract class SolautoClient extends ReferralStateManager {
63
63
 
64
64
  public positionId!: number;
65
65
  public selfManaged!: boolean;
66
- public solautoPosition!: SolautoPositionEx;
66
+ public pos!: SolautoPositionEx;
67
67
 
68
68
  public positionSupplyTa!: PublicKey;
69
69
  public signerSupplyTa!: PublicKey;
@@ -99,7 +99,7 @@ export abstract class SolautoClient extends ReferralStateManager {
99
99
  this.positionId,
100
100
  this.programId
101
101
  );
102
- this.solautoPosition = await getOrCreatePositionEx(
102
+ this.pos = await getOrCreatePositionEx(
103
103
  this.umi,
104
104
  positionPk,
105
105
  {
@@ -112,30 +112,30 @@ export abstract class SolautoClient extends ReferralStateManager {
112
112
  );
113
113
 
114
114
  this.positionSupplyTa = getTokenAccount(
115
- this.solautoPosition.publicKey,
116
- this.solautoPosition.supplyMint()
115
+ this.pos.publicKey,
116
+ this.pos.supplyMint()
117
117
  );
118
118
  this.signerSupplyTa = getTokenAccount(
119
119
  toWeb3JsPublicKey(this.signer.publicKey),
120
- this.solautoPosition.supplyMint()
120
+ this.pos.supplyMint()
121
121
  );
122
122
 
123
123
  this.positionDebtTa = getTokenAccount(
124
- this.solautoPosition.publicKey,
125
- this.solautoPosition.debtMint()
124
+ this.pos.publicKey,
125
+ this.pos.debtMint()
126
126
  );
127
127
  this.signerDebtTa = getTokenAccount(
128
128
  toWeb3JsPublicKey(this.signer.publicKey),
129
- this.solautoPosition.debtMint()
129
+ this.pos.debtMint()
130
130
  );
131
131
 
132
132
  this.solautoFeesSupplyTa = getTokenAccount(
133
133
  SOLAUTO_FEES_WALLET,
134
- this.solautoPosition.supplyMint()
134
+ this.pos.supplyMint()
135
135
  );
136
136
  this.solautoFeesDebtTa = getTokenAccount(
137
137
  SOLAUTO_FEES_WALLET,
138
- this.solautoPosition.debtMint()
138
+ this.pos.debtMint()
139
139
  );
140
140
 
141
141
  this.authorityLutAddress =
@@ -149,33 +149,27 @@ export abstract class SolautoClient extends ReferralStateManager {
149
149
  this.flProvider = new FlProviderAggregator(
150
150
  this.umi,
151
151
  this.signer,
152
- this.solautoPosition.supplyMint(),
153
- this.solautoPosition.debtMint()
152
+ this.pos.supplyMint(),
153
+ this.pos.debtMint()
154
154
  );
155
155
  await this.flProvider.initialize();
156
156
  this.otherSigners.push(...this.flProvider.otherSigners());
157
157
 
158
- this.log("Position state: ", this.solautoPosition.state());
159
- this.log("Position settings: ", this.solautoPosition.settings());
160
- this.log("Position DCA: ", this.solautoPosition.dca());
158
+ this.log("Position state: ", this.pos.state());
159
+ this.log("Position settings: ", this.pos.settings());
160
+ this.log("Position DCA: ", this.pos.dca());
161
161
  }
162
162
 
163
163
  referredBySupplyTa(): PublicKey | undefined {
164
164
  if (this.referredByState !== undefined) {
165
- return getTokenAccount(
166
- this.referredByState,
167
- this.solautoPosition.supplyMint()
168
- );
165
+ return getTokenAccount(this.referredByState, this.pos.supplyMint());
169
166
  }
170
167
  return undefined;
171
168
  }
172
169
 
173
170
  referredByDebtTa(): PublicKey | undefined {
174
171
  if (this.referredByState !== undefined) {
175
- return getTokenAccount(
176
- this.referredByState,
177
- this.solautoPosition.debtMint()
178
- );
172
+ return getTokenAccount(this.referredByState, this.pos.debtMint());
179
173
  }
180
174
  return undefined;
181
175
  }
@@ -183,15 +177,14 @@ export abstract class SolautoClient extends ReferralStateManager {
183
177
  async resetLiveTxUpdates(success?: boolean) {
184
178
  this.log("Resetting context updates...");
185
179
  if (success) {
186
- if (!this.solautoPosition.exists()) {
187
- await this.solautoPosition.refetchPositionData();
180
+ if (!this.pos.exists()) {
181
+ await this.pos.refetchPositionData();
188
182
  } else {
189
183
  if (this.contextUpdates.settings) {
190
- this.solautoPosition.data().position!.settings =
191
- this.contextUpdates.settings;
184
+ this.pos.data().position!.settings = this.contextUpdates.settings;
192
185
  }
193
186
  if (this.contextUpdates.dca) {
194
- this.solautoPosition.data().position!.dca = this.contextUpdates.dca;
187
+ this.pos.data().position!.dca = this.contextUpdates.dca;
195
188
  }
196
189
  // All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form contextUpdates
197
190
  }
@@ -217,7 +210,7 @@ export abstract class SolautoClient extends ReferralStateManager {
217
210
  ...(toWeb3JsPublicKey(this.signer.publicKey).equals(this.authority)
218
211
  ? [this.signerDebtTa]
219
212
  : []),
220
- this.solautoPosition.publicKey,
213
+ this.pos.publicKey,
221
214
  this.positionSupplyTa,
222
215
  this.positionDebtTa,
223
216
  this.referralState,
@@ -324,7 +317,7 @@ export abstract class SolautoClient extends ReferralStateManager {
324
317
  data = await this.connection.getTokenAccountBalance(
325
318
  getTokenAccount(
326
319
  toWeb3JsPublicKey(this.signer.publicKey),
327
- this.solautoPosition.supplyMint()
320
+ this.pos.supplyMint()
328
321
  ),
329
322
  "confirmed"
330
323
  );
@@ -337,7 +330,7 @@ export abstract class SolautoClient extends ReferralStateManager {
337
330
  const data = await this.connection.getTokenAccountBalance(
338
331
  getTokenAccount(
339
332
  toWeb3JsPublicKey(this.signer.publicKey),
340
- this.solautoPosition.debtMint()
333
+ this.pos.debtMint()
341
334
  ),
342
335
  "confirmed"
343
336
  );
@@ -387,11 +380,11 @@ export abstract class SolautoClient extends ReferralStateManager {
387
380
  let signerDcaTa: UmiPublicKey | undefined = undefined;
388
381
  if (isOption(args.dca) && isSome(args.dca)) {
389
382
  if (args.dca.value.tokenType === TokenType.Supply) {
390
- dcaMint = publicKey(this.solautoPosition.supplyMint());
383
+ dcaMint = publicKey(this.pos.supplyMint());
391
384
  positionDcaTa = publicKey(this.positionSupplyTa);
392
385
  signerDcaTa = publicKey(this.signerSupplyTa);
393
386
  } else {
394
- dcaMint = publicKey(this.solautoPosition.debtMint());
387
+ dcaMint = publicKey(this.pos.debtMint());
395
388
  positionDcaTa = publicKey(this.positionDebtTa);
396
389
  signerDcaTa = publicKey(this.signerDebtTa);
397
390
  }
@@ -427,7 +420,7 @@ export abstract class SolautoClient extends ReferralStateManager {
427
420
 
428
421
  return updatePosition(this.umi, {
429
422
  signer: this.signer,
430
- solautoPosition: publicKey(this.solautoPosition.publicKey),
423
+ solautoPosition: publicKey(this.pos.publicKey),
431
424
  dcaMint,
432
425
  positionDcaTa,
433
426
  signerDcaTa,
@@ -442,27 +435,27 @@ export abstract class SolautoClient extends ReferralStateManager {
442
435
  let positionDcaTa: UmiPublicKey | undefined = undefined;
443
436
  let signerDcaTa: UmiPublicKey | undefined = undefined;
444
437
 
445
- const currDca = this.solautoPosition.dca()!;
438
+ const currDca = this.pos.dca()!;
446
439
  if (currDca.dcaInBaseUnit > 0) {
447
440
  if (currDca.tokenType === TokenType.Supply) {
448
- dcaMint = publicKey(this.solautoPosition.supplyMint());
441
+ dcaMint = publicKey(this.pos.supplyMint());
449
442
  positionDcaTa = publicKey(this.positionSupplyTa);
450
443
  signerDcaTa = publicKey(this.signerSupplyTa);
451
444
  } else {
452
- dcaMint = publicKey(this.solautoPosition.debtMint());
445
+ dcaMint = publicKey(this.pos.debtMint());
453
446
  positionDcaTa = publicKey(this.positionDebtTa);
454
447
  signerDcaTa = publicKey(this.signerDebtTa);
455
448
  }
456
449
 
457
450
  this.contextUpdates.new({
458
451
  type: "cancellingDca",
459
- value: this.solautoPosition.dca()!.tokenType,
452
+ value: this.pos.dca()!.tokenType,
460
453
  });
461
454
  }
462
455
 
463
456
  return cancelDCA(this.umi, {
464
457
  signer: this.signer,
465
- solautoPosition: publicKey(this.solautoPosition.publicKey),
458
+ solautoPosition: publicKey(this.pos.publicKey),
466
459
  dcaMint,
467
460
  positionDcaTa,
468
461
  signerDcaTa,
@@ -505,9 +498,7 @@ export abstract class SolautoClient extends ReferralStateManager {
505
498
  toWeb3JsPublicKey(this.signer.publicKey),
506
499
  BigInt(
507
500
  Math.round(
508
- Number(
509
- this.solautoPosition.state().debt.amountUsed.baseUnit
510
- ) * 1.01
501
+ Number(this.pos.state().debt.amountUsed.baseUnit) * 1.01
511
502
  )
512
503
  )
513
504
  )
@@ -531,8 +522,8 @@ export abstract class SolautoClient extends ReferralStateManager {
531
522
  this.contextUpdates.new({
532
523
  type: "supply",
533
524
  value:
534
- (this.solautoPosition.state().supply.amountUsed.baseUnit ??
535
- BigInt(0)) * BigInt(-1),
525
+ (this.pos.state().supply.amountUsed.baseUnit ?? BigInt(0)) *
526
+ BigInt(-1),
536
527
  });
537
528
  }
538
529
  } else if (args.__kind === "Borrow") {
@@ -550,8 +541,8 @@ export abstract class SolautoClient extends ReferralStateManager {
550
541
  this.contextUpdates.new({
551
542
  type: "debt",
552
543
  value:
553
- (this.solautoPosition.state().debt.amountUsed.baseUnit ??
554
- BigInt(0)) * BigInt(-1),
544
+ (this.pos.state().debt.amountUsed.baseUnit ?? BigInt(0)) *
545
+ BigInt(-1),
555
546
  });
556
547
  }
557
548
  }
@@ -69,19 +69,19 @@ export class SolautoMarginfiClient extends SolautoClient {
69
69
  async initialize(args: SolautoMarginfiClientArgs) {
70
70
  await super.initialize(args);
71
71
 
72
- this.marginfiGroup = await this.solautoPosition.lendingPool();
72
+ this.marginfiGroup = await this.pos.lendingPool();
73
73
 
74
74
  if (this.selfManaged) {
75
75
  this.marginfiAccount =
76
76
  args.marginfiAccount ??
77
77
  createSignerFromKeypair(this.umi, this.umi.eddsa.generateKeypair());
78
78
  } else {
79
- if (this.solautoPosition.exists()) {
80
- this.marginfiAccount = this.solautoPosition.lpUserAccount!;
79
+ if (this.pos.exists()) {
80
+ this.marginfiAccount = this.pos.lpUserAccount!;
81
81
  } else {
82
82
  const accounts = await getAllMarginfiAccountsByAuthority(
83
83
  this.umi,
84
- this.solautoPosition.publicKey,
84
+ this.pos.publicKey,
85
85
  this.marginfiGroup,
86
86
  false
87
87
  );
@@ -114,11 +114,11 @@ export class SolautoMarginfiClient extends SolautoClient {
114
114
 
115
115
  this.marginfiSupplyAccounts =
116
116
  MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][
117
- this.solautoPosition.supplyMint().toString()
117
+ this.pos.supplyMint().toString()
118
118
  ]!;
119
119
  this.marginfiDebtAccounts =
120
120
  MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][
121
- this.solautoPosition.debtMint().toString()
121
+ this.pos.debtMint().toString()
122
122
  ]!;
123
123
 
124
124
  // TODO: Don't dynamically pull oracle from bank until Marginfi sorts out their price oracle issues.
@@ -182,16 +182,16 @@ export class SolautoMarginfiClient extends SolautoClient {
182
182
  referredBySupplyTa: this.referredBySupplyTa()
183
183
  ? publicKey(this.referredBySupplyTa()!)
184
184
  : undefined,
185
- solautoPosition: publicKey(this.solautoPosition.publicKey),
185
+ solautoPosition: publicKey(this.pos.publicKey),
186
186
  marginfiGroup: publicKey(this.marginfiGroup),
187
187
  marginfiAccount:
188
188
  "publicKey" in this.marginfiAccount
189
189
  ? (this.marginfiAccount as Signer)
190
190
  : publicKey(this.marginfiAccount),
191
- supplyMint: publicKey(this.solautoPosition.supplyMint()),
191
+ supplyMint: publicKey(this.pos.supplyMint()),
192
192
  supplyBank: publicKey(this.marginfiSupplyAccounts.bank),
193
193
  positionSupplyTa: publicKey(this.positionSupplyTa),
194
- debtMint: publicKey(this.solautoPosition.debtMint()),
194
+ debtMint: publicKey(this.pos.debtMint()),
195
195
  debtBank: publicKey(this.marginfiDebtAccounts.bank),
196
196
  positionDebtTa: publicKey(this.positionDebtTa),
197
197
  signerDebtTa: signerDebtTa,
@@ -207,7 +207,7 @@ export class SolautoMarginfiClient extends SolautoClient {
207
207
  closePositionIx(): TransactionBuilder {
208
208
  return closePosition(this.umi, {
209
209
  signer: this.signer,
210
- solautoPosition: publicKey(this.solautoPosition.publicKey),
210
+ solautoPosition: publicKey(this.pos.publicKey),
211
211
  signerSupplyTa: publicKey(this.signerSupplyTa),
212
212
  positionSupplyTa: publicKey(this.positionSupplyTa),
213
213
  positionDebtTa: publicKey(this.positionDebtTa),
@@ -226,7 +226,7 @@ export class SolautoMarginfiClient extends SolautoClient {
226
226
  supplyPriceOracle: publicKey(this.supplyPriceOracle),
227
227
  debtBank: publicKey(this.marginfiDebtAccounts.bank),
228
228
  debtPriceOracle: publicKey(this.debtPriceOracle),
229
- solautoPosition: publicKey(this.solautoPosition.publicKey),
229
+ solautoPosition: publicKey(this.pos.publicKey),
230
230
  });
231
231
  }
232
232
 
@@ -348,7 +348,7 @@ export class SolautoMarginfiClient extends SolautoClient {
348
348
  return marginfiProtocolInteraction(this.umi, {
349
349
  signer: this.signer,
350
350
  marginfiProgram: publicKey(MARGINFI_PROGRAM_ID),
351
- solautoPosition: publicKey(this.solautoPosition.publicKey),
351
+ solautoPosition: publicKey(this.pos.publicKey),
352
352
  marginfiGroup: publicKey(this.marginfiGroup),
353
353
  marginfiAccount: publicKey(this.marginfiAccountPk),
354
354
  supplyBank: publicKey(this.marginfiSupplyAccounts.bank),
@@ -370,10 +370,10 @@ export class SolautoMarginfiClient extends SolautoClient {
370
370
  data: RebalanceDetails
371
371
  ): TransactionBuilder {
372
372
  const inputIsSupply = new PublicKey(data.swapQuote.inputMint).equals(
373
- this.solautoPosition.supplyMint()
373
+ this.pos.supplyMint()
374
374
  );
375
375
  const outputIsSupply = new PublicKey(data.swapQuote.outputMint).equals(
376
- this.solautoPosition.supplyMint()
376
+ this.pos.supplyMint()
377
377
  );
378
378
 
379
379
  const preSwapRebalance = rebalanceStep === RebalanceStep.PreSwap;
@@ -417,7 +417,7 @@ export class SolautoMarginfiClient extends SolautoClient {
417
417
  data.values.tokenBalanceChange !== undefined
418
418
  ? publicKey(this.authority)
419
419
  : undefined,
420
- solautoPosition: publicKey(this.solautoPosition.publicKey),
420
+ solautoPosition: publicKey(this.pos.publicKey),
421
421
  marginfiGroup: publicKey(this.marginfiGroup),
422
422
  marginfiAccount: publicKey(this.marginfiAccountPk),
423
423
  intermediaryTa: publicKey(
@@ -431,7 +431,7 @@ export class SolautoMarginfiClient extends SolautoClient {
431
431
  positionSupplyTa: publicKey(this.positionSupplyTa),
432
432
  authoritySupplyTa: addAuthorityTas
433
433
  ? publicKey(
434
- getTokenAccount(this.authority, this.solautoPosition.supplyMint())
434
+ getTokenAccount(this.authority, this.pos.supplyMint())
435
435
  )
436
436
  : undefined,
437
437
  vaultSupplyTa: needSupplyAccounts
@@ -445,7 +445,7 @@ export class SolautoMarginfiClient extends SolautoClient {
445
445
  positionDebtTa: publicKey(this.positionDebtTa),
446
446
  authorityDebtTa: addAuthorityTas
447
447
  ? publicKey(
448
- getTokenAccount(this.authority, this.solautoPosition.debtMint())
448
+ getTokenAccount(this.authority, this.pos.debtMint())
449
449
  )
450
450
  : undefined,
451
451
  vaultDebtTa: needDebtAccounts
@@ -73,8 +73,8 @@ function getWSolUsage(
73
73
  },
74
74
  cancellingDcaIn?: TokenType
75
75
  ): wSolTokenUsage | undefined {
76
- const supplyIsWsol = client.solautoPosition.supplyMint().equals(NATIVE_MINT);
77
- const debtIsWsol = client.solautoPosition.debtMint().equals(NATIVE_MINT);
76
+ const supplyIsWsol = client.pos.supplyMint().equals(NATIVE_MINT);
77
+ const debtIsWsol = client.pos.debtMint().equals(NATIVE_MINT);
78
78
  if (!supplyIsWsol && !debtIsWsol) {
79
79
  return undefined;
80
80
  }
@@ -148,7 +148,7 @@ async function transactionChoresBefore(
148
148
  }
149
149
  // TODO: PF
150
150
 
151
- if (!client.solautoPosition.exists()) {
151
+ if (!client.pos.exists()) {
152
152
  chores = chores.add(client.openPositionIx());
153
153
  }
154
154
  }
@@ -229,8 +229,8 @@ async function transactionChoresBefore(
229
229
  client.signer,
230
230
  toWeb3JsPublicKey(client.signer.publicKey),
231
231
  isSolautoAction("Withdraw", solautoAction)
232
- ? client.solautoPosition.supplyMint()
233
- : client.solautoPosition.debtMint()
232
+ ? client.pos.supplyMint()
233
+ : client.pos.debtMint()
234
234
  )
235
235
  );
236
236
  accountsGettingCreated.push(tokenAccount.toString());
@@ -284,7 +284,7 @@ export async function rebalanceChoresBefore(
284
284
  createAssociatedTokenAccountUmiIx(
285
285
  client.signer,
286
286
  client.referredByState!,
287
- client.solautoPosition.supplyMint()
287
+ client.pos.supplyMint()
288
288
  )
289
289
  );
290
290
  }
@@ -295,7 +295,7 @@ export async function rebalanceChoresBefore(
295
295
  createAssociatedTokenAccountUmiIx(
296
296
  client.signer,
297
297
  client.referredByState!,
298
- client.solautoPosition.debtMint()
298
+ client.pos.debtMint()
299
299
  )
300
300
  );
301
301
  }
@@ -310,7 +310,7 @@ export async function rebalanceChoresBefore(
310
310
  createAssociatedTokenAccountUmiIx(
311
311
  client.signer,
312
312
  toWeb3JsPublicKey(client.signer.publicKey),
313
- client.solautoPosition.supplyMint()
313
+ client.pos.supplyMint()
314
314
  )
315
315
  );
316
316
  accountsGettingCreated.push(signerSupplyTa.publicKey.toString());
@@ -326,7 +326,7 @@ export async function rebalanceChoresBefore(
326
326
  createAssociatedTokenAccountUmiIx(
327
327
  client.signer,
328
328
  toWeb3JsPublicKey(client.signer.publicKey),
329
- client.solautoPosition.debtMint()
329
+ client.pos.debtMint()
330
330
  )
331
331
  );
332
332
  accountsGettingCreated.push(signerDebtTa.publicKey.toString());
@@ -15,7 +15,7 @@ export interface SolautoPositionDetails {
15
15
  positionId: number;
16
16
  positionType: PositionType;
17
17
  lendingPlatform: LendingPlatform;
18
- protocolAccount?: PublicKey;
18
+ lpUserAccount?: PublicKey;
19
19
  supplyMint?: PublicKey;
20
20
  debtMint?: PublicKey;
21
21
  }
@@ -350,7 +350,7 @@ async function getBank(
350
350
 
351
351
  export async function getMarginfiAccountPositionState(
352
352
  umi: Umi,
353
- protocolAccount: { pk?: PublicKey; data?: MarginfiAccount | null },
353
+ lpUserAccount: { pk?: PublicKey; data?: MarginfiAccount | null },
354
354
  marginfiGroup?: PublicKey,
355
355
  supply?: BankSelection,
356
356
  debt?: BankSelection,
@@ -360,9 +360,9 @@ export async function getMarginfiAccountPositionState(
360
360
  | undefined
361
361
  > {
362
362
  let marginfiAccount =
363
- protocolAccount.data ??
364
- (protocolAccount.pk
365
- ? await safeFetchMarginfiAccount(umi, publicKey(protocolAccount.pk), {
363
+ lpUserAccount.data ??
364
+ (lpUserAccount.pk
365
+ ? await safeFetchMarginfiAccount(umi, publicKey(lpUserAccount.pk), {
366
366
  commitment: "confirmed",
367
367
  })
368
368
  : null);
@@ -192,7 +192,7 @@ export async function getSolautoManagedPositions(
192
192
  positionId: position.positionId[0],
193
193
  lendingPlatform: position.position.lendingPlatform,
194
194
  positionType: position.positionType,
195
- protocolAccount: toWeb3JsPublicKey(position.position.protocolUserAccount),
195
+ lpUserAccount: toWeb3JsPublicKey(position.position.protocolUserAccount),
196
196
  supplyMint: tokens![0],
197
197
  debtMint: tokens![1],
198
198
  };
@@ -296,7 +296,7 @@ export async function getAllPositionsByAuthority(
296
296
  positionId: 0,
297
297
  positionType: PositionType.Leverage,
298
298
  lendingPlatform: LendingPlatform.Marginfi,
299
- protocolAccount: x.marginfiAccount,
299
+ lpUserAccount: x.marginfiAccount,
300
300
  supplyMint: x.supplyMint,
301
301
  debtMint: x.debtMint,
302
302
  }));
@@ -44,7 +44,7 @@ export async function e2eTransactionTest(
44
44
  });
45
45
 
46
46
  const [maxLtvBps, liqThresholdBps] =
47
- await client.solautoPosition.maxLtvAndLiqThresholdBps();
47
+ await client.pos.maxLtvAndLiqThresholdBps();
48
48
  const settings: SolautoSettingsParametersInpArgs = {
49
49
  boostToBps: maxBoostToBps(maxLtvBps, liqThresholdBps) - 200,
50
50
  boostGap: 50,
@@ -37,11 +37,11 @@ function assertAccurateRebalance(
37
37
  targetLiqUtilizationRateBps?: number
38
38
  ) {
39
39
  const { endResult } = getRebalanceValues(
40
- client.solautoPosition,
40
+ client.pos,
41
41
  new SolautoFeesBps(
42
42
  false,
43
43
  targetLiqUtilizationRateBps,
44
- client.solautoPosition.netWorthUsd()
44
+ client.pos.netWorthUsd()
45
45
  ),
46
46
  50,
47
47
  targetLiqUtilizationRateBps
@@ -50,7 +50,7 @@ function assertAccurateRebalance(
50
50
  const newLiqUtilizationRateBps = getLiqUtilzationRateBps(
51
51
  endResult.supplyUsd,
52
52
  endResult.debtUsd,
53
- client.solautoPosition.state().liqThresholdBps
53
+ client.pos.state().liqThresholdBps
54
54
  );
55
55
  assert(
56
56
  Math.round(newLiqUtilizationRateBps) ===
@@ -98,7 +98,7 @@ async function getFakePosition(
98
98
  liqThresholdBps
99
99
  );
100
100
 
101
- client.solautoPosition = new MarginfiSolautoPositionEx({
101
+ client.pos = new MarginfiSolautoPositionEx({
102
102
  umi: client.umi,
103
103
  publicKey: PublicKey.default,
104
104
  data: {