@haven-fi/solauto-sdk 1.0.170 → 1.0.171
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +1 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +3 -3
- package/dist/utils/solauto/rebalanceUtils.js +3 -3
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +1 -1
- package/src/clients/solautoMarginfiClient.ts +3 -3
- package/src/utils/solauto/rebalanceUtils.ts +3 -3
@@ -56,7 +56,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
56
56
|
} | undefined>;
|
57
57
|
solautoPositionSettings(): SolautoSettingsParameters | undefined;
|
58
58
|
solautoPositionActiveDca(): DCASettings | undefined;
|
59
|
-
|
59
|
+
maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined>;
|
60
60
|
openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
|
61
61
|
updatePositionIx(args: UpdatePositionDataArgs): TransactionBuilder;
|
62
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;AAO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,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,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,7 +189,7 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
189
189
|
return (this.livePositionUpdates.activeDca ??
|
190
190
|
this.solautoPositionData?.position.dca);
|
191
191
|
}
|
192
|
-
async
|
192
|
+
async maxLtvAndLiqThresholdBps() {
|
193
193
|
if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
|
194
194
|
return [this.maxLtvBps, this.liqThresholdBps];
|
195
195
|
}
|
@@ -30,7 +30,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
|
|
30
30
|
protocolAccount(): PublicKey;
|
31
31
|
defaultLookupTables(): string[];
|
32
32
|
lutAccountsToAdd(): PublicKey[];
|
33
|
-
|
33
|
+
maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined>;
|
34
34
|
marginfiAccountInitialize(): TransactionBuilder;
|
35
35
|
openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
|
36
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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0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAyBvE,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,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"}
|
@@ -53,7 +53,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
53
53
|
this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
|
54
54
|
this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
|
55
55
|
if (!this.solautoPositionState) {
|
56
|
-
const result = await this.
|
56
|
+
const result = await this.maxLtvAndLiqThresholdBps();
|
57
57
|
this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? result[0] : 0, result ? result[1] : 0);
|
58
58
|
}
|
59
59
|
if (!this.initialized) {
|
@@ -96,8 +96,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
96
96
|
: []),
|
97
97
|
];
|
98
98
|
}
|
99
|
-
async
|
100
|
-
const result = await super.
|
99
|
+
async maxLtvAndLiqThresholdBps() {
|
100
|
+
const result = await super.maxLtvAndLiqThresholdBps();
|
101
101
|
if (result) {
|
102
102
|
return result;
|
103
103
|
}
|
@@ -167,8 +167,8 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
167
167
|
(values.dcaTokenType === generated_1.TokenType.Debt ? values.amountUsdToDcaIn : 0);
|
168
168
|
const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(input.mint), input.decimals);
|
169
169
|
const outputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(output.mint), output.decimals);
|
170
|
-
const exactOut = values.repayingCloseToMaxLtv;
|
171
|
-
const exactIn = !exactOut
|
170
|
+
const exactOut = targetLiqUtilizationRateBps === 0 || values.repayingCloseToMaxLtv;
|
171
|
+
const exactIn = !exactOut;
|
172
172
|
return {
|
173
173
|
inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
|
174
174
|
outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
|
@@ -177,7 +177,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
177
177
|
amount: exactOut
|
178
178
|
? outputAmount +
|
179
179
|
(targetLiqUtilizationRateBps === 0
|
180
|
-
? BigInt(Math.round(Number(
|
180
|
+
? BigInt(Math.round(Number(outputAmount) *
|
181
181
|
// Add this small percentage to account for the APR on the debt between now and the transaction
|
182
182
|
0.0001))
|
183
183
|
: BigInt(0))
|
package/package.json
CHANGED
@@ -361,7 +361,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
361
361
|
);
|
362
362
|
}
|
363
363
|
|
364
|
-
async
|
364
|
+
async maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined> {
|
365
365
|
if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
|
366
366
|
return [this.maxLtvBps, this.liqThresholdBps];
|
367
367
|
}
|
@@ -133,7 +133,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
133
133
|
this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
|
134
134
|
|
135
135
|
if (!this.solautoPositionState) {
|
136
|
-
const result = await this.
|
136
|
+
const result = await this.maxLtvAndLiqThresholdBps()!;
|
137
137
|
this.solautoPositionState = createFakePositionState(
|
138
138
|
{ mint: this.supplyMint },
|
139
139
|
{ mint: this.debtMint },
|
@@ -208,8 +208,8 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
208
208
|
];
|
209
209
|
}
|
210
210
|
|
211
|
-
async
|
212
|
-
const result = await super.
|
211
|
+
async maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined> {
|
212
|
+
const result = await super.maxLtvAndLiqThresholdBps();
|
213
213
|
if (result) {
|
214
214
|
return result;
|
215
215
|
} else if (
|
@@ -346,8 +346,8 @@ export function getJupSwapRebalanceDetails(
|
|
346
346
|
output.decimals
|
347
347
|
);
|
348
348
|
|
349
|
-
const exactOut = values.repayingCloseToMaxLtv;
|
350
|
-
const exactIn = !exactOut
|
349
|
+
const exactOut = targetLiqUtilizationRateBps === 0 || values.repayingCloseToMaxLtv;
|
350
|
+
const exactIn = !exactOut;
|
351
351
|
|
352
352
|
return {
|
353
353
|
inputMint: toWeb3JsPublicKey(input.mint),
|
@@ -359,7 +359,7 @@ export function getJupSwapRebalanceDetails(
|
|
359
359
|
(targetLiqUtilizationRateBps === 0
|
360
360
|
? BigInt(
|
361
361
|
Math.round(
|
362
|
-
Number(
|
362
|
+
Number(outputAmount) *
|
363
363
|
// Add this small percentage to account for the APR on the debt between now and the transaction
|
364
364
|
0.0001
|
365
365
|
)
|