@haven-fi/solauto-sdk 1.0.156 → 1.0.157
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +3 -0
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +6 -0
- package/dist/clients/solautoMarginfiClient.d.ts +1 -0
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +26 -2
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +10 -0
- package/src/clients/solautoMarginfiClient.ts +55 -8
@@ -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,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Q,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,0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S,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,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
|
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) {
|
package/package.json
CHANGED
@@ -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(
|
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(
|
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(
|
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
|
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
|
|
@@ -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(
|
643
|
-
|
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;
|