@haven-fi/solauto-sdk 1.0.155 → 1.0.157

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,8 @@ export declare abstract class SolautoClient extends TxHandler {
27
27
  solautoPosition: PublicKey;
28
28
  solautoPositionData: SolautoPosition | null;
29
29
  solautoPositionState: PositionState | undefined;
30
+ maxLtvBps?: number;
31
+ liqThresholdBps?: number;
30
32
  supplyMint: PublicKey;
31
33
  positionSupplyTa: PublicKey;
32
34
  signerSupplyTa: PublicKey;
@@ -54,6 +56,7 @@ export declare abstract class SolautoClient extends TxHandler {
54
56
  } | undefined>;
55
57
  solautoPositionSettings(): SolautoSettingsParameters | undefined;
56
58
  solautoPositionActiveDca(): DCASettings | undefined;
59
+ maxLtvAndLiqThreshold(): Promise<[number, number] | undefined>;
57
60
  openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
58
61
  updatePositionIx(args: UpdatePositionDataArgs): TransactionBuilder;
59
62
  closePositionIx(): TransactionBuilder;
@@ -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,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAA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OhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAO7C,qBAAqB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOpE,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAwDlE,eAAe,IAAI,kBAAkB;IAYrC,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -189,6 +189,12 @@ class SolautoClient extends txHandler_1.TxHandler {
189
189
  return (this.livePositionUpdates.activeDca ??
190
190
  this.solautoPositionData?.position.dca);
191
191
  }
192
+ async maxLtvAndLiqThreshold() {
193
+ if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
194
+ return [0, 0];
195
+ }
196
+ return undefined;
197
+ }
192
198
  openPosition(settingParams, dca) {
193
199
  if (dca && dca.dcaInBaseUnit > 0) {
194
200
  this.livePositionUpdates.new({
@@ -30,6 +30,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
30
30
  protocolAccount(): PublicKey;
31
31
  defaultLookupTables(): string[];
32
32
  lutAccountsToAdd(): PublicKey[];
33
+ maxLtvAndLiqThreshold(): Promise<[number, number] | undefined>;
33
34
  marginfiAccountInitialize(): TransactionBuilder;
34
35
  openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
35
36
  private marginfiOpenPositionIx;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,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e,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAmE1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,qBAAqB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IA2BpE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAoErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAwClE"}
@@ -96,6 +96,28 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
96
96
  : []),
97
97
  ];
98
98
  }
99
+ async maxLtvAndLiqThreshold() {
100
+ const result = super.maxLtvAndLiqThreshold();
101
+ if (result) {
102
+ return result;
103
+ }
104
+ else {
105
+ if (this.supplyMint.equals(web3_js_1.PublicKey.default) ||
106
+ this.debtMint.equals(web3_js_1.PublicKey.default)) {
107
+ return [0, 0];
108
+ }
109
+ else {
110
+ const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, {
111
+ mint: this.supplyMint,
112
+ }, {
113
+ mint: this.debtMint,
114
+ });
115
+ this.maxLtvBps = maxLtv;
116
+ this.liqThresholdBps = liqThreshold;
117
+ return [this.maxLtvBps, this.liqThresholdBps];
118
+ }
119
+ }
120
+ }
99
121
  marginfiAccountInitialize() {
100
122
  return (0, marginfi_sdk_1.marginfiAccountInitialize)(this.umi, {
101
123
  marginfiAccount: this.marginfiAccount,
@@ -314,9 +336,11 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
314
336
  : undefined,
315
337
  rebalanceType,
316
338
  targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
317
- targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
339
+ targetInAmountBaseUnit: targetLiqUtilizationRateBps
340
+ ? swapDetails.amount
341
+ : null,
318
342
  limitGapBps: limitGapBps ?? null,
319
- slippageBps: slippageBps ?? 0
343
+ slippageBps: slippageBps ?? 0,
320
344
  });
321
345
  }
322
346
  flashBorrow(flashLoanDetails, destinationTokenAccount) {
@@ -415,7 +439,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
415
439
  if (state) {
416
440
  return state;
417
441
  }
418
- const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.selfManaged ? undefined : this.supplyMint, this.selfManaged ? undefined : this.debtMint, this.livePositionUpdates);
442
+ const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, undefined, undefined, this.livePositionUpdates);
419
443
  if (freshState) {
420
444
  this.log("Fresh state", freshState);
421
445
  const supplyPrice = (0, generalUtils_1.safeGetPrice)(freshState?.supply.mint);
@@ -1,16 +1,8 @@
1
- import { AddressLookupTableInput, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
1
+ import { TransactionBuilder } from "@metaplex-foundation/umi";
2
2
  import { SolautoClient } from "../clients/solautoClient";
3
3
  import { ErrorsToThrow } from "../utils/generalUtils";
4
4
  import { PriorityFeeSetting, TransactionRunType } from "../types";
5
- import { ReferralStateManager, TxHandler } from "../clients";
6
- declare class LookupTables {
7
- defaultLuts: string[];
8
- private umi;
9
- cache: AddressLookupTableInput[];
10
- constructor(defaultLuts: string[], umi: Umi);
11
- getLutInputs(additionalAddresses: string[]): Promise<AddressLookupTableInput[]>;
12
- reset(): void;
13
- }
5
+ import { ReferralStateManager } from "../clients";
14
6
  export declare class TransactionItem {
15
7
  fetchTx: (attemptNum: number) => Promise<{
16
8
  tx: TransactionBuilder;
@@ -27,18 +19,6 @@ export declare class TransactionItem {
27
19
  refetch(attemptNum: number): Promise<void>;
28
20
  uniqueAccounts(): string[];
29
21
  }
30
- declare class TransactionSet {
31
- private txHandler;
32
- lookupTables: LookupTables;
33
- items: TransactionItem[];
34
- constructor(txHandler: TxHandler, lookupTables: LookupTables, items?: TransactionItem[]);
35
- fitsWith(item: TransactionItem): Promise<boolean>;
36
- add(...items: TransactionItem[]): void;
37
- refetchAll(attemptNum: number): Promise<void>;
38
- getSingleTransaction(): Promise<TransactionBuilder>;
39
- lutAddresses(): string[];
40
- name(): string;
41
- }
42
22
  export declare enum TransactionStatus {
43
23
  Skipped = "Skipped",
44
24
  Processing = "Processing",
@@ -49,6 +29,7 @@ export declare enum TransactionStatus {
49
29
  export type TransactionManagerStatuses = {
50
30
  name: string;
51
31
  status: TransactionStatus;
32
+ simulationSuccessful?: boolean;
52
33
  txSig?: string;
53
34
  attemptNum: number;
54
35
  }[];
@@ -64,10 +45,10 @@ export declare class TransactionsManager {
64
45
  private lookupTables;
65
46
  constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined, retries?: number, retryDelay?: number);
66
47
  private assembleTransactionSets;
67
- updateStatus(name: string, status: TransactionStatus, attemptNum: number, txSig?: string): void;
68
- debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
48
+ private updateStatus;
49
+ private debugAccounts;
69
50
  clientSend(transactions: TransactionItem[], prioritySetting?: PriorityFeeSetting): Promise<TransactionManagerStatuses>;
70
51
  send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean): Promise<TransactionManagerStatuses>;
52
+ private sendTransaction;
71
53
  }
72
- export {};
73
54
  //# sourceMappingURL=transactionsManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAIP,WAAW,EAAE,MAAM,EAAE;IAC5B,OAAO,CAAC,GAAG;IAJb,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAG7B,WAAW,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,GAAG;IAGZ,YAAY,CAChB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAkBrC,KAAK;CAKN;AAED,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA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;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YAwCN,aAAa;IAoBd,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,EAC/B,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAyEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YA0GxB,eAAe;CAmC9B"}
@@ -161,18 +161,33 @@ class TransactionsManager {
161
161
  }
162
162
  return transactionSets;
163
163
  }
164
- updateStatus(name, status, attemptNum, txSig) {
164
+ updateStatus(name, status, attemptNum, txSig, simulationSuccessful) {
165
165
  if (!this.statuses.filter((x) => x.name === name)) {
166
- this.statuses.push({ name, status, txSig, attemptNum });
166
+ this.statuses.push({
167
+ name,
168
+ status,
169
+ txSig,
170
+ attemptNum,
171
+ simulationSuccessful,
172
+ });
167
173
  }
168
174
  else {
169
175
  const idx = this.statuses.findIndex((x) => x.name === name && x.attemptNum === attemptNum);
170
176
  if (idx !== -1) {
171
177
  this.statuses[idx].status = status;
172
178
  this.statuses[idx].txSig = txSig;
179
+ if (simulationSuccessful) {
180
+ this.statuses[idx].simulationSuccessful = simulationSuccessful;
181
+ }
173
182
  }
174
183
  else {
175
- this.statuses.push({ name, status, txSig, attemptNum });
184
+ this.statuses.push({
185
+ name,
186
+ status,
187
+ txSig,
188
+ attemptNum,
189
+ simulationSuccessful,
190
+ });
176
191
  }
177
192
  }
178
193
  this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
@@ -202,17 +217,7 @@ class TransactionsManager {
202
217
  if (updateLookupTable &&
203
218
  updateLookupTable.updateLutTx.getInstructions().length > 0 &&
204
219
  updateLookupTable?.needsToBeIsolated) {
205
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => {
206
- this.updateStatus(updateLutTxName, TransactionStatus.Processing, attemptNum);
207
- try {
208
- const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.txType, attemptNum, prioritySetting);
209
- this.updateStatus(updateLutTxName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
210
- }
211
- catch (e) {
212
- this.updateStatus(updateLutTxName, TransactionStatus.Failed, attemptNum);
213
- throw e;
214
- }
215
- }, 3, 150, this.errorsToThrow);
220
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => this.sendTransaction(updateLookupTable.updateLutTx, updateLutTxName, attemptNum, prioritySetting), 3, 150, this.errorsToThrow);
216
221
  }
217
222
  this.lookupTables.defaultLuts = client.defaultLookupTables();
218
223
  for (const item of items) {
@@ -309,23 +314,26 @@ class TransactionsManager {
309
314
  this.updateStatus(itemSet.name(), TransactionStatus.Skipped, attemptNum);
310
315
  }
311
316
  else {
312
- this.updateStatus(itemSet.name(), TransactionStatus.Processing, attemptNum);
313
317
  if (this.txHandler.localTest) {
314
318
  await this.debugAccounts(itemSet, tx);
315
319
  }
316
- try {
317
- const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting);
318
- this.updateStatus(itemSet.name(), TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
319
- }
320
- catch (e) {
321
- this.updateStatus(itemSet.name(), TransactionStatus.Failed, attemptNum);
322
- throw e;
323
- }
320
+ this.sendTransaction(tx, itemSet.name(), attemptNum, prioritySetting);
324
321
  }
325
322
  }, this.retries, this.retryDelay, this.errorsToThrow);
326
323
  }
327
324
  }
328
325
  return this.statuses;
329
326
  }
327
+ async sendTransaction(tx, txName, attemptNum, prioritySetting) {
328
+ this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
329
+ try {
330
+ const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting, () => this.updateStatus(txName, TransactionStatus.Processing, attemptNum, undefined, true));
331
+ this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
332
+ }
333
+ catch (e) {
334
+ this.updateStatus(txName, TransactionStatus.Failed, attemptNum);
335
+ throw e;
336
+ }
337
+ }
330
338
  }
331
339
  exports.TransactionsManager = TransactionsManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.155",
3
+ "version": "1.0.157",
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",
@@ -78,6 +78,9 @@ export abstract class SolautoClient extends TxHandler {
78
78
  public solautoPositionData!: SolautoPosition | null;
79
79
  public solautoPositionState!: PositionState | undefined;
80
80
 
81
+ public maxLtvBps?: number;
82
+ public liqThresholdBps?: number;
83
+
81
84
  public supplyMint!: PublicKey;
82
85
  public positionSupplyTa!: PublicKey;
83
86
  public signerSupplyTa!: PublicKey;
@@ -358,6 +361,13 @@ export abstract class SolautoClient extends TxHandler {
358
361
  );
359
362
  }
360
363
 
364
+ async maxLtvAndLiqThreshold(): Promise<[number, number] | undefined> {
365
+ if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
366
+ return [0, 0];
367
+ }
368
+ return undefined;
369
+ }
370
+
361
371
  openPosition(
362
372
  settingParams?: SolautoSettingsParametersInpArgs,
363
373
  dca?: DCASettingsInpArgs
@@ -212,6 +212,33 @@ export class SolautoMarginfiClient extends SolautoClient {
212
212
  ];
213
213
  }
214
214
 
215
+ async maxLtvAndLiqThreshold(): Promise<[number, number] | undefined> {
216
+ const result = super.maxLtvAndLiqThreshold();
217
+ if (result) {
218
+ return result;
219
+ } else {
220
+ if (
221
+ this.supplyMint.equals(PublicKey.default) ||
222
+ this.debtMint.equals(PublicKey.default)
223
+ ) {
224
+ return [0, 0];
225
+ } else {
226
+ const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
227
+ this.umi,
228
+ {
229
+ mint: this.supplyMint,
230
+ },
231
+ {
232
+ mint: this.debtMint,
233
+ }
234
+ );
235
+ this.maxLtvBps = maxLtv;
236
+ this.liqThresholdBps = liqThreshold;
237
+ return [this.maxLtvBps, this.liqThresholdBps];
238
+ }
239
+ }
240
+ }
241
+
215
242
  marginfiAccountInitialize(): TransactionBuilder {
216
243
  return marginfiAccountInitialize(this.umi, {
217
244
  marginfiAccount: this.marginfiAccount as Signer,
@@ -433,7 +460,7 @@ export class SolautoMarginfiClient extends SolautoClient {
433
460
  slippageBps: number,
434
461
  flashLoan?: FlashLoanDetails,
435
462
  targetLiqUtilizationRateBps?: number,
436
- limitGapBps?: number,
463
+ limitGapBps?: number
437
464
  ): TransactionBuilder {
438
465
  const inputIsSupply = swapDetails.inputMint.equals(this.supplyMint);
439
466
  const outputIsSupply = swapDetails.outputMint.equals(this.supplyMint);
@@ -452,7 +479,9 @@ export class SolautoMarginfiClient extends SolautoClient {
452
479
  ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
453
480
  solautoFeesSupplyTa:
454
481
  rebalanceStep === "B" ? publicKey(this.solautoFeesSupplyTa) : undefined,
455
- authorityReferralState: publicKey(this.referralStateManager.referralState),
482
+ authorityReferralState: publicKey(
483
+ this.referralStateManager.referralState
484
+ ),
456
485
  referredBySupplyTa: this.referredBySupplyTa
457
486
  ? publicKey(this.referredBySupplyTa)
458
487
  : undefined,
@@ -469,7 +498,9 @@ export class SolautoMarginfiClient extends SolautoClient {
469
498
  supplyBank: publicKey(this.marginfiSupplyAccounts.bank),
470
499
  supplyPriceOracle: publicKey(this.supplyPriceOracle),
471
500
  positionSupplyTa: publicKey(this.positionSupplyTa),
472
- authoritySupplyTa: publicKey(getTokenAccount(this.authority, this.supplyMint)),
501
+ authoritySupplyTa: publicKey(
502
+ getTokenAccount(this.authority, this.supplyMint)
503
+ ),
473
504
  vaultSupplyTa: needSupplyAccounts
474
505
  ? publicKey(this.marginfiSupplyAccounts.liquidityVault)
475
506
  : undefined,
@@ -479,7 +510,9 @@ export class SolautoMarginfiClient extends SolautoClient {
479
510
  debtBank: publicKey(this.marginfiDebtAccounts.bank),
480
511
  debtPriceOracle: publicKey(this.debtPriceOracle),
481
512
  positionDebtTa: publicKey(this.positionDebtTa),
482
- authorityDebtTa: publicKey(getTokenAccount(this.authority, this.debtMint)),
513
+ authorityDebtTa: publicKey(
514
+ getTokenAccount(this.authority, this.debtMint)
515
+ ),
483
516
  vaultDebtTa: needDebtAccounts
484
517
  ? publicKey(this.marginfiDebtAccounts.liquidityVault)
485
518
  : undefined,
@@ -488,9 +521,11 @@ export class SolautoMarginfiClient extends SolautoClient {
488
521
  : undefined,
489
522
  rebalanceType,
490
523
  targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
491
- targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
524
+ targetInAmountBaseUnit: targetLiqUtilizationRateBps
525
+ ? swapDetails.amount
526
+ : null,
492
527
  limitGapBps: limitGapBps ?? null,
493
- slippageBps: slippageBps ?? 0
528
+ slippageBps: slippageBps ?? 0,
494
529
  });
495
530
  }
496
531
 
@@ -626,8 +661,8 @@ export class SolautoMarginfiClient extends SolautoClient {
626
661
  const freshState = await getMarginfiAccountPositionState(
627
662
  this.umi,
628
663
  this.marginfiAccountPk,
629
- this.selfManaged ? undefined : this.supplyMint,
630
- this.selfManaged ? undefined : this.debtMint,
664
+ undefined,
665
+ undefined,
631
666
  this.livePositionUpdates
632
667
  );
633
668
 
@@ -639,8 +674,20 @@ export class SolautoMarginfiClient extends SolautoClient {
639
674
  this.log("Debt price: ", debtPrice);
640
675
  this.log("Liq threshold bps:", freshState.liqThresholdBps);
641
676
  this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
642
- this.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
643
- this.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
677
+ this.log(
678
+ "Supply USD:",
679
+ fromBaseUnit(
680
+ freshState.supply.amountUsed.baseUnit,
681
+ freshState.supply.decimals
682
+ ) * supplyPrice
683
+ );
684
+ this.log(
685
+ "Debt USD:",
686
+ fromBaseUnit(
687
+ freshState.debt.amountUsed.baseUnit,
688
+ freshState.debt.decimals
689
+ ) * debtPrice
690
+ );
644
691
  }
645
692
 
646
693
  return freshState;
@@ -180,6 +180,7 @@ export enum TransactionStatus {
180
180
  export type TransactionManagerStatuses = {
181
181
  name: string;
182
182
  status: TransactionStatus;
183
+ simulationSuccessful?: boolean;
183
184
  txSig?: string;
184
185
  attemptNum: number;
185
186
  }[];
@@ -243,14 +244,21 @@ export class TransactionsManager {
243
244
  return transactionSets;
244
245
  }
245
246
 
246
- updateStatus(
247
+ private updateStatus(
247
248
  name: string,
248
249
  status: TransactionStatus,
249
250
  attemptNum: number,
250
- txSig?: string
251
+ txSig?: string,
252
+ simulationSuccessful?: boolean
251
253
  ) {
252
254
  if (!this.statuses.filter((x) => x.name === name)) {
253
- this.statuses.push({ name, status, txSig, attemptNum });
255
+ this.statuses.push({
256
+ name,
257
+ status,
258
+ txSig,
259
+ attemptNum,
260
+ simulationSuccessful,
261
+ });
254
262
  } else {
255
263
  const idx = this.statuses.findIndex(
256
264
  (x) => x.name === name && x.attemptNum === attemptNum
@@ -258,8 +266,17 @@ export class TransactionsManager {
258
266
  if (idx !== -1) {
259
267
  this.statuses[idx].status = status;
260
268
  this.statuses[idx].txSig = txSig;
269
+ if (simulationSuccessful) {
270
+ this.statuses[idx].simulationSuccessful = simulationSuccessful;
271
+ }
261
272
  } else {
262
- this.statuses.push({ name, status, txSig, attemptNum });
273
+ this.statuses.push({
274
+ name,
275
+ status,
276
+ txSig,
277
+ attemptNum,
278
+ simulationSuccessful,
279
+ });
263
280
  }
264
281
  }
265
282
  this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
@@ -267,7 +284,7 @@ export class TransactionsManager {
267
284
  }
268
285
 
269
286
  // TODO remove me
270
- async debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder) {
287
+ private async debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder) {
271
288
  const lutInputs = await itemSet.lookupTables.getLutInputs([]);
272
289
  const lutAccounts = lutInputs.map((x) => x.addresses).flat();
273
290
  for (const ix of tx.getInstructions()) {
@@ -287,7 +304,7 @@ export class TransactionsManager {
287
304
  }
288
305
  }
289
306
 
290
- async clientSend(
307
+ public async clientSend(
291
308
  transactions: TransactionItem[],
292
309
  prioritySetting?: PriorityFeeSetting
293
310
  ): Promise<TransactionManagerStatuses> {
@@ -302,36 +319,13 @@ export class TransactionsManager {
302
319
  updateLookupTable?.needsToBeIsolated
303
320
  ) {
304
321
  await retryWithExponentialBackoff(
305
- async (attemptNum) => {
306
- this.updateStatus(
322
+ async (attemptNum) =>
323
+ this.sendTransaction(
324
+ updateLookupTable.updateLutTx,
307
325
  updateLutTxName,
308
- TransactionStatus.Processing,
309
- attemptNum
310
- );
311
- try {
312
- const txSig = await sendSingleOptimizedTransaction(
313
- this.txHandler.umi,
314
- this.txHandler.connection,
315
- updateLookupTable.updateLutTx,
316
- this.txType,
317
- attemptNum,
318
- prioritySetting
319
- );
320
- this.updateStatus(
321
- updateLutTxName,
322
- TransactionStatus.Successful,
323
- attemptNum,
324
- txSig ? bs58.encode(txSig) : undefined
325
- );
326
- } catch (e) {
327
- this.updateStatus(
328
- updateLutTxName,
329
- TransactionStatus.Failed,
330
- attemptNum
331
- );
332
- throw e;
333
- }
334
- },
326
+ attemptNum,
327
+ prioritySetting
328
+ ),
335
329
  3,
336
330
  150,
337
331
  this.errorsToThrow
@@ -386,7 +380,7 @@ export class TransactionsManager {
386
380
  return result;
387
381
  }
388
382
 
389
- async send(
383
+ public async send(
390
384
  items: TransactionItem[],
391
385
  prioritySetting?: PriorityFeeSetting,
392
386
  initialized?: boolean
@@ -475,39 +469,15 @@ export class TransactionsManager {
475
469
  attemptNum
476
470
  );
477
471
  } else {
478
- this.updateStatus(
479
- itemSet.name(),
480
- TransactionStatus.Processing,
481
- attemptNum
482
- );
483
-
484
472
  if (this.txHandler.localTest) {
485
473
  await this.debugAccounts(itemSet, tx);
486
474
  }
487
-
488
- try {
489
- const txSig = await sendSingleOptimizedTransaction(
490
- this.txHandler.umi,
491
- this.txHandler.connection,
492
- tx,
493
- this.txType,
494
- attemptNum,
495
- prioritySetting
496
- );
497
- this.updateStatus(
498
- itemSet.name(),
499
- TransactionStatus.Successful,
500
- attemptNum,
501
- txSig ? bs58.encode(txSig) : undefined
502
- );
503
- } catch (e) {
504
- this.updateStatus(
505
- itemSet.name(),
506
- TransactionStatus.Failed,
507
- attemptNum
508
- );
509
- throw e;
510
- }
475
+ this.sendTransaction(
476
+ tx,
477
+ itemSet.name(),
478
+ attemptNum,
479
+ prioritySetting
480
+ );
511
481
  }
512
482
  },
513
483
  this.retries,
@@ -519,4 +489,40 @@ export class TransactionsManager {
519
489
 
520
490
  return this.statuses;
521
491
  }
492
+
493
+ private async sendTransaction(
494
+ tx: TransactionBuilder,
495
+ txName: string,
496
+ attemptNum: number,
497
+ prioritySetting?: PriorityFeeSetting
498
+ ) {
499
+ this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
500
+ try {
501
+ const txSig = await sendSingleOptimizedTransaction(
502
+ this.txHandler.umi,
503
+ this.txHandler.connection,
504
+ tx,
505
+ this.txType,
506
+ attemptNum,
507
+ prioritySetting,
508
+ () =>
509
+ this.updateStatus(
510
+ txName,
511
+ TransactionStatus.Processing,
512
+ attemptNum,
513
+ undefined,
514
+ true
515
+ )
516
+ );
517
+ this.updateStatus(
518
+ txName,
519
+ TransactionStatus.Successful,
520
+ attemptNum,
521
+ txSig ? bs58.encode(txSig) : undefined
522
+ );
523
+ } catch (e) {
524
+ this.updateStatus(txName, TransactionStatus.Failed, attemptNum);
525
+ throw e;
526
+ }
527
+ }
522
528
  }