@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.
@@ -20,12 +20,12 @@ class RebalanceSwapManager {
20
20
  return Math.abs(this.values.debtAdjustmentUsd);
21
21
  }
22
22
  postRebalanceLiqUtilizationRateBps(swapOutputAmount) {
23
- let supplyUsd = this.client.solautoPosition.supplyUsd();
23
+ let supplyUsd = this.client.pos.supplyUsd();
24
24
  // TODO: add token balance change
25
- let debtUsd = this.client.solautoPosition.debtUsd();
25
+ let debtUsd = this.client.pos.debtUsd();
26
26
  const outputToken = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.isBoost()
27
- ? this.client.solautoPosition.state().supply.mint
28
- : this.client.solautoPosition.state().debt.mint);
27
+ ? this.client.pos.state().supply.mint
28
+ : this.client.pos.state().debt.mint);
29
29
  const swapOutputUsd = swapOutputAmount
30
30
  ? (0, utils_1.fromBaseUnit)(swapOutputAmount, (0, utils_1.tokenInfo)(outputToken).decimals) *
31
31
  ((0, utils_1.safeGetPrice)(outputToken) ?? 0)
@@ -36,7 +36,7 @@ class RebalanceSwapManager {
36
36
  debtUsd = this.isBoost()
37
37
  ? debtUsd + this.usdToSwap()
38
38
  : debtUsd - swapOutputUsd;
39
- return (0, utils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, this.client.solautoPosition.state().liqThresholdBps ?? 0);
39
+ return (0, utils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, this.client.pos.state().liqThresholdBps ?? 0);
40
40
  }
41
41
  async findSufficientQuote(swapInput, criteria) {
42
42
  let swapQuote;
@@ -63,11 +63,11 @@ class RebalanceSwapManager {
63
63
  }
64
64
  swapDetails() {
65
65
  const input = this.isBoost()
66
- ? this.client.solautoPosition.state().debt
67
- : this.client.solautoPosition.state().supply;
66
+ ? this.client.pos.state().debt
67
+ : this.client.pos.state().supply;
68
68
  const output = this.isBoost()
69
- ? this.client.solautoPosition.state().supply
70
- : this.client.solautoPosition.state().debt;
69
+ ? this.client.pos.state().supply
70
+ : this.client.pos.state().debt;
71
71
  let inputAmount = (0, utils_1.toBaseUnit)(this.usdToSwap() / (0, utils_1.safeGetPrice)(input.mint), input.decimals);
72
72
  return {
73
73
  input,
@@ -112,7 +112,7 @@ class RebalanceSwapManager {
112
112
  this.swapQuote = await this.findSufficientQuote(swapInput, {
113
113
  minOutputAmount: rebalanceToZero ? outputAmount : undefined,
114
114
  maxLiqUtilizationRateBps: this.values.repayingCloseToMaxLtv
115
- ? (0, utils_1.maxRepayToBps)(this.client.solautoPosition.state().maxLtvBps ?? 0, this.client.solautoPosition.state().liqThresholdBps ?? 0) - 15
115
+ ? (0, utils_1.maxRepayToBps)(this.client.pos.state().maxLtvBps ?? 0, this.client.pos.state().liqThresholdBps ?? 0) - 15
116
116
  : undefined,
117
117
  });
118
118
  }
@@ -127,7 +127,7 @@ class RebalanceSwapManager {
127
127
  ...swapInput,
128
128
  destinationWallet: flashLoanRepayFromDebt
129
129
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey)
130
- : this.client.solautoPosition.publicKey,
130
+ : this.client.pos.publicKey,
131
131
  slippageIncFactor: 0.2 + attemptNum * 0.25,
132
132
  };
133
133
  }
@@ -15,12 +15,12 @@ class RebalanceTxBuilder {
15
15
  this.targetLiqUtilizationRateBps = targetLiqUtilizationRateBps;
16
16
  }
17
17
  async shouldProceedWithRebalance() {
18
- return (this.client.solautoPosition.supplyUsd() > 0 &&
18
+ return (this.client.pos.supplyUsd() > 0 &&
19
19
  (this.targetLiqUtilizationRateBps !== undefined ||
20
- this.client.solautoPosition.eligibleForRebalance()));
20
+ this.client.pos.eligibleForRebalance()));
21
21
  }
22
22
  getRebalanceValues(flFee) {
23
- return (0, rebalanceValues_1.getRebalanceValues)(this.client.solautoPosition, new solautoFees_1.SolautoFeesBps(this.client.isReferred(), this.targetLiqUtilizationRateBps, this.client.solautoPosition.netWorthUsd()), flFee ?? 0, this.targetLiqUtilizationRateBps);
23
+ return (0, rebalanceValues_1.getRebalanceValues)(this.client.pos, new solautoFees_1.SolautoFeesBps(this.client.isReferred(), this.targetLiqUtilizationRateBps, this.client.pos.netWorthUsd()), flFee ?? 0, this.targetLiqUtilizationRateBps);
24
24
  }
25
25
  getFlLiquiditySource(supplyLiquidityAvailable, debtLiquidityAvailable) {
26
26
  const debtAdjustmentUsd = Math.abs(this.values.debtAdjustmentUsd);
@@ -30,8 +30,8 @@ class RebalanceTxBuilder {
30
30
  ((0, utils_1.safeGetPrice)(tokenMint) ?? 0) *
31
31
  0.95);
32
32
  };
33
- const insufficientSupplyLiquidity = insufficientLiquidity(debtAdjustmentUsd, supplyLiquidityAvailable, this.client.solautoPosition.supplyMint());
34
- const insufficientDebtLiquidity = insufficientLiquidity(debtAdjustmentUsd, debtLiquidityAvailable, this.client.solautoPosition.debtMint());
33
+ const insufficientSupplyLiquidity = insufficientLiquidity(debtAdjustmentUsd, supplyLiquidityAvailable, this.client.pos.supplyMint());
34
+ const insufficientDebtLiquidity = insufficientLiquidity(debtAdjustmentUsd, debtLiquidityAvailable, this.client.pos.debtMint());
35
35
  let useDebtLiquidity = this.values.rebalanceDirection === generated_1.RebalanceDirection.Boost ||
36
36
  insufficientSupplyLiquidity;
37
37
  if (useDebtLiquidity) {
@@ -42,7 +42,7 @@ class RebalanceTxBuilder {
42
42
  }
43
43
  }
44
44
  async flashLoanRequirements(attemptNum) {
45
- const maxLtvRateBps = (0, utils_1.getMaxLiqUtilizationRateBps)(this.client.solautoPosition.state().maxLtvBps, this.client.solautoPosition.state().liqThresholdBps, 0.02);
45
+ const maxLtvRateBps = (0, utils_1.getMaxLiqUtilizationRateBps)(this.client.pos.state().maxLtvBps, this.client.pos.state().liqThresholdBps, 0.02);
46
46
  if (this.values.intermediaryLiqUtilizationRateBps < maxLtvRateBps) {
47
47
  return undefined;
48
48
  }
@@ -75,10 +75,10 @@ class RebalanceTxBuilder {
75
75
  const useDebtLiquidity = this.flRequirements.liquiditySource === generated_1.TokenType.Debt;
76
76
  let flashLoanToken = undefined;
77
77
  if (boosting || useDebtLiquidity) {
78
- flashLoanToken = this.client.solautoPosition.state().debt;
78
+ flashLoanToken = this.client.pos.state().debt;
79
79
  }
80
80
  else {
81
- flashLoanToken = this.client.solautoPosition.state().supply;
81
+ flashLoanToken = this.client.pos.state().supply;
82
82
  }
83
83
  return {
84
84
  ...this.flRequirements,
@@ -129,11 +129,11 @@ class RebalanceTxBuilder {
129
129
  if (this.client.selfManaged ||
130
130
  this.client.contextUpdates.supplyAdjustment > BigInt(0) ||
131
131
  this.client.contextUpdates.debtAdjustment > BigInt(0) ||
132
- !this.client.solautoPosition.exists()) {
132
+ !this.client.pos.exists()) {
133
133
  return false;
134
134
  }
135
135
  // Rebalance ix will already refresh internally if position is self managed
136
- const utilizationRateDiff = Math.abs(await this.client.solautoPosition.utilizationRateBpsDrift());
136
+ const utilizationRateDiff = Math.abs(await this.client.pos.utilizationRateBpsDrift());
137
137
  (0, utils_1.consoleLog)("Liq utilization rate diff:", utilizationRateDiff);
138
138
  if (utilizationRateDiff >= 10) {
139
139
  (0, utils_1.consoleLog)("Refreshing before rebalance");
@@ -169,7 +169,7 @@ class RebalanceTxBuilder {
169
169
  const addFirstRebalance = (0, utils_1.hasFirstRebalance)(this.rebalanceType);
170
170
  const addLastRebalance = (0, utils_1.hasLastRebalance)(this.rebalanceType);
171
171
  const flashBorrowDest = exactOut
172
- ? (0, utils_1.getTokenAccount)(this.client.solautoPosition.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
172
+ ? (0, utils_1.getTokenAccount)(this.client.pos.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
173
173
  : (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey), new web3_js_1.PublicKey(swapQuote.inputMint));
174
174
  tx = tx.add([
175
175
  setupInstructions,
@@ -186,7 +186,7 @@ class RebalanceTxBuilder {
186
186
  };
187
187
  }
188
188
  async buildRebalanceTx(attemptNum) {
189
- await this.client.solautoPosition.refreshPositionState();
189
+ await this.client.pos.refreshPositionState();
190
190
  if (!this.shouldProceedWithRebalance()) {
191
191
  this.client.log("Not eligible for a rebalance");
192
192
  return undefined;
@@ -20,7 +20,7 @@ export declare abstract class SolautoClient extends ReferralStateManager {
20
20
  authority: PublicKey;
21
21
  positionId: number;
22
22
  selfManaged: boolean;
23
- solautoPosition: SolautoPositionEx;
23
+ pos: SolautoPositionEx;
24
24
  positionSupplyTa: PublicKey;
25
25
  signerSupplyTa: PublicKey;
26
26
  positionDebtTa: PublicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gCAAgC,EAEhC,sBAAsB,EAGvB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC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sBAAsB,GAAG,kBAAkB;IAsDlE,QAAQ,CAAC,eAAe,IAAI,kBAAkB;IAE9C,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,SAAS,IAAI,kBAAkB;IAExC,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAsFlE,QAAQ,CAAC,WAAW,CAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,gBAAgB,GACrB,kBAAkB;CACtB"}
@@ -28,55 +28,54 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
28
28
  throw new Error("Self managed position is missing arguments");
29
29
  }
30
30
  const positionPk = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId, this.programId);
31
- this.solautoPosition = await (0, solautoPosition_1.getOrCreatePositionEx)(this.umi, positionPk, {
31
+ this.pos = await (0, solautoPosition_1.getOrCreatePositionEx)(this.umi, positionPk, {
32
32
  supplyMint: args.supplyMint,
33
33
  debtMint: args.debtMint,
34
34
  lpUserAccount: args.lpUserAccount,
35
35
  lendingPlatform: this.lendingPlatform,
36
36
  }, this.contextUpdates);
37
- this.positionSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition.publicKey, this.solautoPosition.supplyMint());
38
- this.signerSupplyTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.solautoPosition.supplyMint());
39
- this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition.publicKey, this.solautoPosition.debtMint());
40
- this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.solautoPosition.debtMint());
41
- this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.solautoPosition.supplyMint());
42
- this.solautoFeesDebtTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.solautoPosition.debtMint());
37
+ this.positionSupplyTa = (0, accountUtils_1.getTokenAccount)(this.pos.publicKey, this.pos.supplyMint());
38
+ this.signerSupplyTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.supplyMint());
39
+ this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.pos.publicKey, this.pos.debtMint());
40
+ this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.debtMint());
41
+ this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.pos.supplyMint());
42
+ this.solautoFeesDebtTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.pos.debtMint());
43
43
  this.authorityLutAddress =
44
44
  this.referralStateData?.lookupTable &&
45
45
  !(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
46
46
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable)
47
47
  : undefined;
48
- this.flProvider = new flProviderAggregator_1.FlProviderAggregator(this.umi, this.signer, this.solautoPosition.supplyMint(), this.solautoPosition.debtMint());
48
+ this.flProvider = new flProviderAggregator_1.FlProviderAggregator(this.umi, this.signer, this.pos.supplyMint(), this.pos.debtMint());
49
49
  await this.flProvider.initialize();
50
50
  this.otherSigners.push(...this.flProvider.otherSigners());
51
- this.log("Position state: ", this.solautoPosition.state());
52
- this.log("Position settings: ", this.solautoPosition.settings());
53
- this.log("Position DCA: ", this.solautoPosition.dca());
51
+ this.log("Position state: ", this.pos.state());
52
+ this.log("Position settings: ", this.pos.settings());
53
+ this.log("Position DCA: ", this.pos.dca());
54
54
  }
55
55
  referredBySupplyTa() {
56
56
  if (this.referredByState !== undefined) {
57
- return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.solautoPosition.supplyMint());
57
+ return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.pos.supplyMint());
58
58
  }
59
59
  return undefined;
60
60
  }
61
61
  referredByDebtTa() {
62
62
  if (this.referredByState !== undefined) {
63
- return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.solautoPosition.debtMint());
63
+ return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.pos.debtMint());
64
64
  }
65
65
  return undefined;
66
66
  }
67
67
  async resetLiveTxUpdates(success) {
68
68
  this.log("Resetting context updates...");
69
69
  if (success) {
70
- if (!this.solautoPosition.exists()) {
71
- await this.solautoPosition.refetchPositionData();
70
+ if (!this.pos.exists()) {
71
+ await this.pos.refetchPositionData();
72
72
  }
73
73
  else {
74
74
  if (this.contextUpdates.settings) {
75
- this.solautoPosition.data().position.settings =
76
- this.contextUpdates.settings;
75
+ this.pos.data().position.settings = this.contextUpdates.settings;
77
76
  }
78
77
  if (this.contextUpdates.dca) {
79
- this.solautoPosition.data().position.dca = this.contextUpdates.dca;
78
+ this.pos.data().position.dca = this.contextUpdates.dca;
80
79
  }
81
80
  // 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
82
81
  }
@@ -100,7 +99,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
100
99
  ...((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey).equals(this.authority)
101
100
  ? [this.signerDebtTa]
102
101
  : []),
103
- this.solautoPosition.publicKey,
102
+ this.pos.publicKey,
104
103
  this.positionSupplyTa,
105
104
  this.positionDebtTa,
106
105
  this.referralState,
@@ -170,7 +169,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
170
169
  (async () => {
171
170
  let data;
172
171
  try {
173
- data = await this.connection.getTokenAccountBalance((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.solautoPosition.supplyMint()), "confirmed");
172
+ data = await this.connection.getTokenAccountBalance((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.supplyMint()), "confirmed");
174
173
  }
175
174
  catch { }
176
175
  return BigInt(parseInt(data?.value.amount ?? "0"));
@@ -178,7 +177,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
178
177
  (async () => {
179
178
  let data;
180
179
  try {
181
- const data = await this.connection.getTokenAccountBalance((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.solautoPosition.debtMint()), "confirmed");
180
+ const data = await this.connection.getTokenAccountBalance((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.debtMint()), "confirmed");
182
181
  }
183
182
  catch { }
184
183
  return BigInt(parseInt(data?.value.amount ?? "0"));
@@ -219,12 +218,12 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
219
218
  let signerDcaTa = undefined;
220
219
  if ((0, umi_1.isOption)(args.dca) && (0, umi_1.isSome)(args.dca)) {
221
220
  if (args.dca.value.tokenType === generated_1.TokenType.Supply) {
222
- dcaMint = (0, umi_1.publicKey)(this.solautoPosition.supplyMint());
221
+ dcaMint = (0, umi_1.publicKey)(this.pos.supplyMint());
223
222
  positionDcaTa = (0, umi_1.publicKey)(this.positionSupplyTa);
224
223
  signerDcaTa = (0, umi_1.publicKey)(this.signerSupplyTa);
225
224
  }
226
225
  else {
227
- dcaMint = (0, umi_1.publicKey)(this.solautoPosition.debtMint());
226
+ dcaMint = (0, umi_1.publicKey)(this.pos.debtMint());
228
227
  positionDcaTa = (0, umi_1.publicKey)(this.positionDebtTa);
229
228
  signerDcaTa = (0, umi_1.publicKey)(this.signerDebtTa);
230
229
  }
@@ -254,7 +253,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
254
253
  }
255
254
  return (0, generated_1.updatePosition)(this.umi, {
256
255
  signer: this.signer,
257
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
256
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
258
257
  dcaMint,
259
258
  positionDcaTa,
260
259
  signerDcaTa,
@@ -265,26 +264,26 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
265
264
  let dcaMint = undefined;
266
265
  let positionDcaTa = undefined;
267
266
  let signerDcaTa = undefined;
268
- const currDca = this.solautoPosition.dca();
267
+ const currDca = this.pos.dca();
269
268
  if (currDca.dcaInBaseUnit > 0) {
270
269
  if (currDca.tokenType === generated_1.TokenType.Supply) {
271
- dcaMint = (0, umi_1.publicKey)(this.solautoPosition.supplyMint());
270
+ dcaMint = (0, umi_1.publicKey)(this.pos.supplyMint());
272
271
  positionDcaTa = (0, umi_1.publicKey)(this.positionSupplyTa);
273
272
  signerDcaTa = (0, umi_1.publicKey)(this.signerSupplyTa);
274
273
  }
275
274
  else {
276
- dcaMint = (0, umi_1.publicKey)(this.solautoPosition.debtMint());
275
+ dcaMint = (0, umi_1.publicKey)(this.pos.debtMint());
277
276
  positionDcaTa = (0, umi_1.publicKey)(this.positionDebtTa);
278
277
  signerDcaTa = (0, umi_1.publicKey)(this.signerDebtTa);
279
278
  }
280
279
  this.contextUpdates.new({
281
280
  type: "cancellingDca",
282
- value: this.solautoPosition.dca().tokenType,
281
+ value: this.pos.dca().tokenType,
283
282
  });
284
283
  }
285
284
  return (0, generated_1.cancelDCA)(this.umi, {
286
285
  signer: this.signer,
287
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
286
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
288
287
  dcaMint,
289
288
  positionDcaTa,
290
289
  signerDcaTa,
@@ -301,7 +300,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
301
300
  tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(args.fields[0].fields[0])));
302
301
  }
303
302
  else {
304
- tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(Math.round(Number(this.solautoPosition.state().debt.amountUsed.baseUnit) * 1.01))));
303
+ tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(Math.round(Number(this.pos.state().debt.amountUsed.baseUnit) * 1.01))));
305
304
  }
306
305
  }
307
306
  }
@@ -321,8 +320,8 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
321
320
  else {
322
321
  this.contextUpdates.new({
323
322
  type: "supply",
324
- value: (this.solautoPosition.state().supply.amountUsed.baseUnit ??
325
- BigInt(0)) * BigInt(-1),
323
+ value: (this.pos.state().supply.amountUsed.baseUnit ?? BigInt(0)) *
324
+ BigInt(-1),
326
325
  });
327
326
  }
328
327
  }
@@ -342,8 +341,8 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
342
341
  else {
343
342
  this.contextUpdates.new({
344
343
  type: "debt",
345
- value: (this.solautoPosition.state().debt.amountUsed.baseUnit ??
346
- BigInt(0)) * BigInt(-1),
344
+ value: (this.pos.state().debt.amountUsed.baseUnit ?? BigInt(0)) *
345
+ BigInt(-1),
347
346
  });
348
347
  }
349
348
  }
@@ -18,18 +18,18 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
18
18
  }
19
19
  async initialize(args) {
20
20
  await super.initialize(args);
21
- this.marginfiGroup = await this.solautoPosition.lendingPool();
21
+ this.marginfiGroup = await this.pos.lendingPool();
22
22
  if (this.selfManaged) {
23
23
  this.marginfiAccount =
24
24
  args.marginfiAccount ??
25
25
  (0, umi_1.createSignerFromKeypair)(this.umi, this.umi.eddsa.generateKeypair());
26
26
  }
27
27
  else {
28
- if (this.solautoPosition.exists()) {
29
- this.marginfiAccount = this.solautoPosition.lpUserAccount;
28
+ if (this.pos.exists()) {
29
+ this.marginfiAccount = this.pos.lpUserAccount;
30
30
  }
31
31
  else {
32
- const accounts = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(this.umi, this.solautoPosition.publicKey, this.marginfiGroup, false);
32
+ const accounts = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(this.umi, this.pos.publicKey, this.marginfiGroup, false);
33
33
  const reusableAccounts = accounts.length > 0
34
34
  ? (await (0, marginfi_sdk_1.safeFetchAllMarginfiAccount)(this.umi, accounts.map((x) => (0, umi_1.publicKey)(x.marginfiAccount)))).filter((x) => (0, marginfiUtils_1.marginfiAccountEmpty)(x))
35
35
  : [];
@@ -47,9 +47,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
47
47
  this.otherSigners.push(this.marginfiAccount);
48
48
  }
49
49
  this.marginfiSupplyAccounts =
50
- marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.solautoPosition.supplyMint().toString()];
50
+ marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.supplyMint().toString()];
51
51
  this.marginfiDebtAccounts =
52
- marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.solautoPosition.debtMint().toString()];
52
+ marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.debtMint().toString()];
53
53
  // TODO: Don't dynamically pull oracle from bank until Marginfi sorts out their price oracle issues.
54
54
  // const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
55
55
  // publicKey(this.marginfiSupplyAccounts.bank),
@@ -95,15 +95,15 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
95
95
  referredBySupplyTa: this.referredBySupplyTa()
96
96
  ? (0, umi_1.publicKey)(this.referredBySupplyTa())
97
97
  : undefined,
98
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
98
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
99
99
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
100
100
  marginfiAccount: "publicKey" in this.marginfiAccount
101
101
  ? this.marginfiAccount
102
102
  : (0, umi_1.publicKey)(this.marginfiAccount),
103
- supplyMint: (0, umi_1.publicKey)(this.solautoPosition.supplyMint()),
103
+ supplyMint: (0, umi_1.publicKey)(this.pos.supplyMint()),
104
104
  supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyAccounts.bank),
105
105
  positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
106
- debtMint: (0, umi_1.publicKey)(this.solautoPosition.debtMint()),
106
+ debtMint: (0, umi_1.publicKey)(this.pos.debtMint()),
107
107
  debtBank: (0, umi_1.publicKey)(this.marginfiDebtAccounts.bank),
108
108
  positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
109
109
  signerDebtTa: signerDebtTa,
@@ -118,7 +118,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
118
118
  closePositionIx() {
119
119
  return (0, generated_1.closePosition)(this.umi, {
120
120
  signer: this.signer,
121
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
121
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
122
122
  signerSupplyTa: (0, umi_1.publicKey)(this.signerSupplyTa),
123
123
  positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
124
124
  positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
@@ -136,7 +136,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
136
136
  supplyPriceOracle: (0, umi_1.publicKey)(this.supplyPriceOracle),
137
137
  debtBank: (0, umi_1.publicKey)(this.marginfiDebtAccounts.bank),
138
138
  debtPriceOracle: (0, umi_1.publicKey)(this.debtPriceOracle),
139
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
139
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
140
140
  });
141
141
  }
142
142
  protocolInteractionIx(args) {
@@ -230,7 +230,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
230
230
  return (0, generated_1.marginfiProtocolInteraction)(this.umi, {
231
231
  signer: this.signer,
232
232
  marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
233
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
233
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
234
234
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
235
235
  marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
236
236
  supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyAccounts.bank),
@@ -247,8 +247,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
247
247
  });
248
248
  }
249
249
  rebalanceIx(rebalanceStep, data) {
250
- const inputIsSupply = new web3_js_1.PublicKey(data.swapQuote.inputMint).equals(this.solautoPosition.supplyMint());
251
- const outputIsSupply = new web3_js_1.PublicKey(data.swapQuote.outputMint).equals(this.solautoPosition.supplyMint());
250
+ const inputIsSupply = new web3_js_1.PublicKey(data.swapQuote.inputMint).equals(this.pos.supplyMint());
251
+ const outputIsSupply = new web3_js_1.PublicKey(data.swapQuote.outputMint).equals(this.pos.supplyMint());
252
252
  const preSwapRebalance = rebalanceStep === generated_1.RebalanceStep.PreSwap;
253
253
  const postSwapRebalance = rebalanceStep === generated_1.RebalanceStep.PostSwap;
254
254
  const needSupplyAccounts = (inputIsSupply && preSwapRebalance) ||
@@ -277,7 +277,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
277
277
  positionAuthority: data.values.tokenBalanceChange !== undefined
278
278
  ? (0, umi_1.publicKey)(this.authority)
279
279
  : undefined,
280
- solautoPosition: (0, umi_1.publicKey)(this.solautoPosition.publicKey),
280
+ solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
281
281
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
282
282
  marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
283
283
  intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), new web3_js_1.PublicKey(data.swapQuote.inputMint))),
@@ -285,7 +285,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
285
285
  supplyPriceOracle: (0, umi_1.publicKey)(this.supplyPriceOracle),
286
286
  positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
287
287
  authoritySupplyTa: addAuthorityTas
288
- ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.solautoPosition.supplyMint()))
288
+ ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.pos.supplyMint()))
289
289
  : undefined,
290
290
  vaultSupplyTa: needSupplyAccounts
291
291
  ? (0, umi_1.publicKey)(this.marginfiSupplyAccounts.liquidityVault)
@@ -297,7 +297,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
297
297
  debtPriceOracle: (0, umi_1.publicKey)(this.debtPriceOracle),
298
298
  positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
299
299
  authorityDebtTa: addAuthorityTas
300
- ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.solautoPosition.debtMint()))
300
+ ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.pos.debtMint()))
301
301
  : undefined,
302
302
  vaultDebtTa: needDebtAccounts
303
303
  ? (0, umi_1.publicKey)(this.marginfiDebtAccounts.liquidityVault)
@@ -19,8 +19,8 @@ const jupiter_sdk_1 = require("../../jupiter-sdk");
19
19
  const utils_1 = require("../../utils");
20
20
  const transactions_1 = require("../../types/transactions");
21
21
  function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn) {
22
- const supplyIsWsol = client.solautoPosition.supplyMint().equals(spl_token_1.NATIVE_MINT);
23
- const debtIsWsol = client.solautoPosition.debtMint().equals(spl_token_1.NATIVE_MINT);
22
+ const supplyIsWsol = client.pos.supplyMint().equals(spl_token_1.NATIVE_MINT);
23
+ const debtIsWsol = client.pos.debtMint().equals(spl_token_1.NATIVE_MINT);
24
24
  if (!supplyIsWsol && !debtIsWsol) {
25
25
  return undefined;
26
26
  }
@@ -61,7 +61,7 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
61
61
  chores = chores.add(client.marginfiAccountInitialize(client.marginfiAccount));
62
62
  }
63
63
  // TODO: PF
64
- if (!client.solautoPosition.exists()) {
64
+ if (!client.pos.exists()) {
65
65
  chores = chores.add(client.openPositionIx());
66
66
  }
67
67
  }
@@ -107,8 +107,8 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
107
107
  }
108
108
  if (!(0, generalUtils_1.getSolanaAccountCreated)(client.umi, tokenAccount)) {
109
109
  chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), (0, generated_1.isSolautoAction)("Withdraw", solautoAction)
110
- ? client.solautoPosition.supplyMint()
111
- : client.solautoPosition.debtMint()));
110
+ ? client.pos.supplyMint()
111
+ : client.pos.debtMint()));
112
112
  accountsGettingCreated.push(tokenAccount.toString());
113
113
  }
114
114
  }
@@ -138,24 +138,24 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
138
138
  let chores = (0, umi_1.transactionBuilder)();
139
139
  if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
140
140
  client.log("Creating referred-by supply TA");
141
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.solautoPosition.supplyMint()));
141
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.supplyMint()));
142
142
  }
143
143
  if (checkReferralDebtTa && !(0, generalUtils_1.rpcAccountCreated)(referredByDebtTa)) {
144
144
  client.log("Creating referred-by debt TA");
145
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.solautoPosition.debtMint()));
145
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.debtMint()));
146
146
  }
147
147
  if (checkSignerSupplyTa &&
148
148
  !(0, generalUtils_1.rpcAccountCreated)(signerSupplyTa) &&
149
149
  !accountsGettingCreated.includes(signerSupplyTa.publicKey.toString())) {
150
150
  client.log("Creating signer supply token account");
151
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.solautoPosition.supplyMint()));
151
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.supplyMint()));
152
152
  accountsGettingCreated.push(signerSupplyTa.publicKey.toString());
153
153
  }
154
154
  if (checkSignerDebtTa &&
155
155
  !(0, generalUtils_1.rpcAccountCreated)(signerDebtTa) &&
156
156
  !accountsGettingCreated.includes(signerDebtTa.publicKey.toString())) {
157
157
  client.log("Creating signer debt token account");
158
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.solautoPosition.debtMint()));
158
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.debtMint()));
159
159
  accountsGettingCreated.push(signerDebtTa.publicKey.toString());
160
160
  }
161
161
  return chores;
@@ -9,7 +9,7 @@ export interface SolautoPositionDetails {
9
9
  positionId: number;
10
10
  positionType: PositionType;
11
11
  lendingPlatform: LendingPlatform;
12
- protocolAccount?: PublicKey;
12
+ lpUserAccount?: PublicKey;
13
13
  supplyMint?: PublicKey;
14
14
  debtMint?: PublicKey;
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,wBAAwB,EAEhC,kBAAkB,EAAE,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,M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AI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,wBAAwB,EAEhC,kBAAkB,EAAE,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,SAAS,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,oBAAoB,CAAC;IACpC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC"}
@@ -32,7 +32,7 @@ type BanksCache = {
32
32
  [mint: string]: Bank;
33
33
  };
34
34
  };
35
- export declare function getMarginfiAccountPositionState(umi: Umi, protocolAccount: {
35
+ export declare function getMarginfiAccountPositionState(umi: Umi, lpUserAccount: {
36
36
  pk?: PublicKey;
37
37
  data?: MarginfiAccount | null;
38
38
  }, marginfiGroup?: PublicKey, supply?: BankSelection, debt?: BankSelection, contextUpdates?: ContextUpdates): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,M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AS,CAAA;CAAE,EAAE,CAC/E,CAyDA;AAED,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,kBAAkB,EAAE,OAAO,UAqB5B;AAsDD,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,KAAK,UAAU,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,CAAC;AAsBhE,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE;IAAE,EAAE,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;CAAE,EAChE,aAAa,CAAC,EAAE,SAAS,EACzB,MAAM,CAAC,EAAE,aAAa,EACtB,IAAI,CAAC,EAAE,aAAa,EACpB,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CACN;IAAE,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GACxE,SAAS,CACZ,CAyKA;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBnE;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,WASpE"}
@@ -200,10 +200,10 @@ async function getBank(umi, data, marginfiGroup) {
200
200
  ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][data?.mint.toString()].bank), { commitment: "confirmed" })
201
201
  : null;
202
202
  }
203
- async function getMarginfiAccountPositionState(umi, protocolAccount, marginfiGroup, supply, debt, contextUpdates) {
204
- let marginfiAccount = protocolAccount.data ??
205
- (protocolAccount.pk
206
- ? await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(protocolAccount.pk), {
203
+ async function getMarginfiAccountPositionState(umi, lpUserAccount, marginfiGroup, supply, debt, contextUpdates) {
204
+ let marginfiAccount = lpUserAccount.data ??
205
+ (lpUserAccount.pk
206
+ ? await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(lpUserAccount.pk), {
207
207
  commitment: "confirmed",
208
208
  })
209
209
  : null);
@@ -131,7 +131,7 @@ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
131
131
  positionId: position.positionId[0],
132
132
  lendingPlatform: position.position.lendingPlatform,
133
133
  positionType: position.positionType,
134
- protocolAccount: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.position.protocolUserAccount),
134
+ lpUserAccount: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.position.protocolUserAccount),
135
135
  supplyMint: tokens[0],
136
136
  debtMint: tokens[1],
137
137
  };
@@ -202,7 +202,7 @@ async function getAllPositionsByAuthority(umi, user, positionTypeFilter) {
202
202
  positionId: 0,
203
203
  positionType: generated_1.PositionType.Leverage,
204
204
  lendingPlatform: generated_1.LendingPlatform.Marginfi,
205
- protocolAccount: x.marginfiAccount,
205
+ lpUserAccount: x.marginfiAccount,
206
206
  supplyMint: x.supplyMint,
207
207
  debtMint: x.debtMint,
208
208
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.587",
3
+ "version": "1.0.589",
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",