@haven-fi/solauto-sdk 1.0.121 → 1.0.123
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/solautoMarginfiClient.d.ts +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +14 -2
- package/dist/generated/instructions/marginfiRebalance.d.ts +2 -0
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.js +1 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +8 -5
- package/dist/transactions/transactionsManager.d.ts +0 -1
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +2 -3
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +2 -1
- package/src/clients/solautoMarginfiClient.ts +17 -4
- package/src/generated/instructions/marginfiRebalance.ts +3 -0
- package/src/transactions/transactionUtils.ts +47 -35
- package/src/transactions/transactionsManager.ts +2 -13
- package/tests/transactions/solautoMarginfi.ts +42 -32
@@ -62,7 +62,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
62
62
|
protocolInteraction(args: SolautoActionArgs): TransactionBuilder;
|
63
63
|
abstract flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
64
64
|
abstract flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
65
|
-
abstract rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
65
|
+
abstract rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, slippageBps: number, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
66
66
|
getFreshPositionState(): Promise<PositionState | undefined>;
|
67
67
|
}
|
68
68
|
//# sourceMappingURL=solautoClient.d.ts.map
|
@@ -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,EAChC,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,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,8BAAsB,aAAc,SAAQ,SAAS;IAmC1C,SAAS,CAAC,EAAE,OAAO;IAlCrB,eAAe,EAAG,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,C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AE,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"}
|
@@ -37,7 +37,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
|
|
37
37
|
protocolInteraction(args: SolautoActionArgs): TransactionBuilder;
|
38
38
|
private marginfiProtocolInteractionIx;
|
39
39
|
private marginfiSolautoProtocolInteractionIx;
|
40
|
-
rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
40
|
+
rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, slippageBps: number, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
41
41
|
flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
42
42
|
flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
43
43
|
createIntermediaryMarginfiAccount(): TransactionBuilder;
|
@@ -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,E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4BlE"}
|
@@ -12,6 +12,7 @@ const generalUtils_1 = require("../utils/generalUtils");
|
|
12
12
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
13
13
|
const marginfiUtils_1 = require("../utils/marginfiUtils");
|
14
14
|
const numberUtils_1 = require("../utils/numberUtils");
|
15
|
+
const constants_1 = require("../constants");
|
15
16
|
const utils_1 = require("../utils");
|
16
17
|
class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
17
18
|
constructor() {
|
@@ -268,7 +269,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
268
269
|
solautoAction: args,
|
269
270
|
});
|
270
271
|
}
|
271
|
-
rebalance(rebalanceStep, swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps, limitGapBps) {
|
272
|
+
rebalance(rebalanceStep, swapDetails, rebalanceType, slippageBps, flashLoan, targetLiqUtilizationRateBps, limitGapBps) {
|
272
273
|
const inputIsSupply = swapDetails.inputMint.equals(this.supplyMint);
|
273
274
|
const outputIsSupply = swapDetails.outputMint.equals(this.supplyMint);
|
274
275
|
const needSupplyAccounts = (inputIsSupply && rebalanceStep === "A") ||
|
@@ -315,6 +316,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
315
316
|
rebalanceType,
|
316
317
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
317
318
|
limitGapBps: limitGapBps ?? null,
|
319
|
+
slippageBps: slippageBps ?? 0
|
318
320
|
});
|
319
321
|
}
|
320
322
|
flashBorrow(flashLoanDetails, destinationTokenAccount) {
|
@@ -414,7 +416,17 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
414
416
|
return state;
|
415
417
|
}
|
416
418
|
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
|
417
|
-
|
419
|
+
if (freshState) {
|
420
|
+
const supplyPrice = constants_1.PRICES[(freshState?.supply.mint ?? web3_js_1.PublicKey.default).toString()].price;
|
421
|
+
const debtPrice = constants_1.PRICES[(freshState?.debt.mint ?? web3_js_1.PublicKey.default).toString()].price;
|
422
|
+
console.log("Supply price: ", supplyPrice);
|
423
|
+
console.log("Debt price: ", supplyPrice);
|
424
|
+
console.log("Fresh state", freshState);
|
425
|
+
console.log("Liq threshold bps:", freshState.liqUtilizationRateBps);
|
426
|
+
console.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
|
427
|
+
console.log("Supply USD:", (0, numberUtils_1.fromBaseUnit)(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
|
428
|
+
console.log("Debt USD:", (0, numberUtils_1.fromBaseUnit)(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
|
429
|
+
}
|
418
430
|
return freshState;
|
419
431
|
}
|
420
432
|
}
|
@@ -36,11 +36,13 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
36
36
|
};
|
37
37
|
export type MarginfiRebalanceInstructionData = {
|
38
38
|
discriminator: number;
|
39
|
+
slippageBps: number;
|
39
40
|
rebalanceType: SolautoRebalanceType;
|
40
41
|
targetLiqUtilizationRateBps: Option<number>;
|
41
42
|
limitGapBps: Option<number>;
|
42
43
|
};
|
43
44
|
export type MarginfiRebalanceInstructionDataArgs = {
|
45
|
+
slippageBps: number;
|
44
46
|
rebalanceType: SolautoRebalanceTypeArgs;
|
45
47
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
46
48
|
limitGapBps: OptionOrNullable<number>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiRebalance.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/marginfiRebalance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU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tC,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,oBAAoB,CAAC;IACpC,2BAA2B,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,wBAAwB,CAAC;IACxC,2BAA2B,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtD,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,EACpC,gCAAgC,CACjC,
|
1
|
+
{"version":3,"file":"marginfiRebalance.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/marginfiRebalance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMX,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EAEzB,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;IAC3B,mBAAmB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACtC,sBAAsB,EAAE,SAAS,GAAG,GAAG,CAAC;IACxC,kBAAkB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACrC,eAAe,EAAE,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AAoC,EACpC,gCAAgC,CACjC,CAqBA;AAGD,MAAM,MAAM,gCAAgC,GAC1C,oCAAoC,CAAC;AAGvC,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,KAAK,EAAE,oCAAoC,GAAG,gCAAgC,GAC7E,kBAAkB,CA6KpB"}
|
@@ -16,6 +16,7 @@ const types_1 = require("../types");
|
|
16
16
|
function getMarginfiRebalanceInstructionDataSerializer() {
|
17
17
|
return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([
|
18
18
|
['discriminator', (0, serializers_1.u8)()],
|
19
|
+
['slippageBps', (0, serializers_1.u16)()],
|
19
20
|
['rebalanceType', (0, types_1.getSolautoRebalanceTypeSerializer)()],
|
20
21
|
['targetLiqUtilizationRateBps', (0, serializers_1.option)((0, serializers_1.u16)())],
|
21
22
|
['limitGapBps', (0, serializers_1.option)((0, serializers_1.u16)())],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA6MzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CA4HA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD"}
|
@@ -119,7 +119,9 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
119
119
|
if (rebalanceInstructions.length === 0) {
|
120
120
|
return (0, umi_1.transactionBuilder)();
|
121
121
|
}
|
122
|
-
const usesAccount = (key) => tx
|
122
|
+
const usesAccount = (key) => tx
|
123
|
+
.getInstructions()
|
124
|
+
.some((t) => t.keys.some((k) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(k.pubkey).equals(key)));
|
123
125
|
const checkReferralSupplyTa = client.referredBySupplyTa && usesAccount(client.referredBySupplyTa);
|
124
126
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
125
127
|
const checkIntermediaryMfiAccount = client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
|
@@ -182,6 +184,7 @@ function getRebalanceInstructions(tx) {
|
|
182
184
|
try {
|
183
185
|
const serializer = (0, generated_1.getMarginfiRebalanceInstructionDataSerializer)();
|
184
186
|
const discriminator = serializer.serialize({
|
187
|
+
slippageBps: 0,
|
185
188
|
limitGapBps: 0,
|
186
189
|
rebalanceType: generated_1.SolautoRebalanceType.None,
|
187
190
|
targetLiqUtilizationRateBps: 0,
|
@@ -346,11 +349,11 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
346
349
|
client.flashBorrow(flashLoan, (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), swapDetails.inputMint)),
|
347
350
|
...(addFirstRebalance
|
348
351
|
? [
|
349
|
-
client.rebalance("A", swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
352
|
+
client.rebalance("A", swapDetails, rebalanceType, jupQuote.slippageBps, flashLoan, targetLiqUtilizationRateBps),
|
350
353
|
]
|
351
354
|
: []),
|
352
355
|
swapIx,
|
353
|
-
client.rebalance("B", swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
356
|
+
client.rebalance("B", swapDetails, rebalanceType, jupQuote.slippageBps, flashLoan, targetLiqUtilizationRateBps),
|
354
357
|
client.flashRepay(flashLoan),
|
355
358
|
]);
|
356
359
|
}
|
@@ -359,9 +362,9 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
359
362
|
tx = tx.add([
|
360
363
|
setupInstructions,
|
361
364
|
tokenLedgerIx,
|
362
|
-
client.rebalance("A", swapDetails, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
365
|
+
client.rebalance("A", swapDetails, rebalanceType, jupQuote.slippageBps, undefined, targetLiqUtilizationRateBps),
|
363
366
|
swapIx,
|
364
|
-
client.rebalance("B", swapDetails, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
367
|
+
client.rebalance("B", swapDetails, rebalanceType, jupQuote.slippageBps, undefined, targetLiqUtilizationRateBps),
|
365
368
|
]);
|
366
369
|
}
|
367
370
|
if (client.solautoPositionState.liqUtilizationRateBps >
|
@@ -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;CAiBtC;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;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc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AAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,aAAa,CAAC;IARxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;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;YAQzB,uBAAuB;IAwCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAoB7D,UAAU,CACd,YAAY,EAAE,eAAe,EAAE,EAC/B,eAAe,CAAC,EAAE,kBAAkB;IA+EhC,IAAI,CACR,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO;CA0GxB"}
|
@@ -111,7 +111,6 @@ var TransactionStatus;
|
|
111
111
|
(function (TransactionStatus) {
|
112
112
|
TransactionStatus["Skipped"] = "Skipped";
|
113
113
|
TransactionStatus["Processing"] = "Processing";
|
114
|
-
TransactionStatus["AwaitingSignature"] = "Awaiting Signature";
|
115
114
|
TransactionStatus["Queued"] = "Queued";
|
116
115
|
TransactionStatus["Successful"] = "Successful";
|
117
116
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
@@ -198,7 +197,7 @@ class TransactionsManager {
|
|
198
197
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
199
198
|
updateLookupTable?.needsToBeIsolated) {
|
200
199
|
this.updateStatus(updateLutTxName, TransactionStatus.Processing);
|
201
|
-
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.txType, attemptNum, prioritySetting
|
200
|
+
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.txType, attemptNum, prioritySetting), 3, 150, this.errorsToThrow);
|
202
201
|
this.updateStatus(updateLutTxName, TransactionStatus.Successful);
|
203
202
|
}
|
204
203
|
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
@@ -296,7 +295,7 @@ class TransactionsManager {
|
|
296
295
|
if (this.txHandler.localTest) {
|
297
296
|
await this.debugAccounts(itemSet, tx);
|
298
297
|
}
|
299
|
-
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting
|
298
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting);
|
300
299
|
this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
|
301
300
|
}
|
302
301
|
}, 4, 150, this.errorsToThrow);
|
package/package.json
CHANGED
@@ -581,9 +581,10 @@ export abstract class SolautoClient extends TxHandler {
|
|
581
581
|
rebalanceStep: "A" | "B",
|
582
582
|
swapDetails: JupSwapDetails,
|
583
583
|
rebalanceType: SolautoRebalanceTypeArgs,
|
584
|
+
slippageBps: number,
|
584
585
|
flashLoan?: FlashLoanDetails,
|
585
586
|
targetLiqUtilizationRateBps?: number,
|
586
|
-
limitGapBps?: number
|
587
|
+
limitGapBps?: number,
|
587
588
|
): TransactionBuilder;
|
588
589
|
|
589
590
|
async getFreshPositionState(): Promise<PositionState | undefined> {
|
@@ -54,8 +54,8 @@ import {
|
|
54
54
|
getMarginfiAccountPositionState,
|
55
55
|
getMaxLtvAndLiqThreshold,
|
56
56
|
} from "../utils/marginfiUtils";
|
57
|
-
import { bytesToI80F48, toBps } from "../utils/numberUtils";
|
58
|
-
import { SOLAUTO_MANAGER } from "../constants";
|
57
|
+
import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
|
58
|
+
import { PRICES, SOLAUTO_MANAGER } from "../constants";
|
59
59
|
import { createFakePositionState } from "../utils";
|
60
60
|
|
61
61
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
@@ -427,9 +427,10 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
427
427
|
rebalanceStep: "A" | "B",
|
428
428
|
swapDetails: JupSwapDetails,
|
429
429
|
rebalanceType: SolautoRebalanceTypeArgs,
|
430
|
+
slippageBps: number,
|
430
431
|
flashLoan?: FlashLoanDetails,
|
431
432
|
targetLiqUtilizationRateBps?: number,
|
432
|
-
limitGapBps?: number
|
433
|
+
limitGapBps?: number,
|
433
434
|
): TransactionBuilder {
|
434
435
|
const inputIsSupply = swapDetails.inputMint.equals(this.supplyMint);
|
435
436
|
const outputIsSupply = swapDetails.outputMint.equals(this.supplyMint);
|
@@ -486,6 +487,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
486
487
|
rebalanceType,
|
487
488
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
488
489
|
limitGapBps: limitGapBps ?? null,
|
490
|
+
slippageBps: slippageBps ?? 0
|
489
491
|
});
|
490
492
|
}
|
491
493
|
|
@@ -625,7 +627,18 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
625
627
|
this.debtMint,
|
626
628
|
this.livePositionUpdates
|
627
629
|
);
|
628
|
-
|
630
|
+
|
631
|
+
if (freshState) {
|
632
|
+
const supplyPrice = PRICES[(freshState?.supply.mint ?? PublicKey.default).toString()].price;
|
633
|
+
const debtPrice = PRICES[(freshState?.debt.mint ?? PublicKey.default).toString()].price;
|
634
|
+
console.log("Supply price: ", supplyPrice);
|
635
|
+
console.log("Debt price: ", supplyPrice);
|
636
|
+
console.log("Fresh state", freshState);
|
637
|
+
console.log("Liq threshold bps:", freshState.liqUtilizationRateBps);
|
638
|
+
console.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
|
639
|
+
console.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
|
640
|
+
console.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
|
641
|
+
}
|
629
642
|
|
630
643
|
return freshState;
|
631
644
|
}
|
@@ -66,12 +66,14 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
66
66
|
// Data.
|
67
67
|
export type MarginfiRebalanceInstructionData = {
|
68
68
|
discriminator: number;
|
69
|
+
slippageBps: number;
|
69
70
|
rebalanceType: SolautoRebalanceType;
|
70
71
|
targetLiqUtilizationRateBps: Option<number>;
|
71
72
|
limitGapBps: Option<number>;
|
72
73
|
};
|
73
74
|
|
74
75
|
export type MarginfiRebalanceInstructionDataArgs = {
|
76
|
+
slippageBps: number;
|
75
77
|
rebalanceType: SolautoRebalanceTypeArgs;
|
76
78
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
77
79
|
limitGapBps: OptionOrNullable<number>;
|
@@ -89,6 +91,7 @@ export function getMarginfiRebalanceInstructionDataSerializer(): Serializer<
|
|
89
91
|
struct<MarginfiRebalanceInstructionData>(
|
90
92
|
[
|
91
93
|
['discriminator', u8()],
|
94
|
+
['slippageBps', u16()],
|
92
95
|
['rebalanceType', getSolautoRebalanceTypeSerializer()],
|
93
96
|
['targetLiqUtilizationRateBps', option(u16())],
|
94
97
|
['limitGapBps', option(u16())],
|
@@ -111,12 +111,18 @@ async function transactionChoresBefore(
|
|
111
111
|
client.referralStateManager.referralStateData === null ||
|
112
112
|
(client.referredByState !== undefined &&
|
113
113
|
client.referralStateManager.referralStateData?.referredByState ===
|
114
|
-
|
114
|
+
publicKey(PublicKey.default)) ||
|
115
115
|
(client.authorityLutAddress !== undefined &&
|
116
116
|
client.referralStateManager.referralStateData!.lookupTable ==
|
117
|
-
|
117
|
+
publicKey(PublicKey.default))
|
118
118
|
) {
|
119
|
-
chores = chores.add(
|
119
|
+
chores = chores.add(
|
120
|
+
client.referralStateManager.updateReferralStatesIx(
|
121
|
+
undefined,
|
122
|
+
client.referredByAuthority,
|
123
|
+
client.authorityLutAddress
|
124
|
+
)
|
125
|
+
);
|
120
126
|
}
|
121
127
|
|
122
128
|
if (client.selfManaged) {
|
@@ -233,10 +239,10 @@ export async function rebalanceChoresBefore(
|
|
233
239
|
}
|
234
240
|
|
235
241
|
const usesAccount = (key: PublicKey) =>
|
236
|
-
tx
|
237
|
-
|
238
|
-
|
239
|
-
|
242
|
+
tx
|
243
|
+
.getInstructions()
|
244
|
+
.some((t) => t.keys.some((k) => toWeb3JsPublicKey(k.pubkey).equals(key)));
|
245
|
+
|
240
246
|
const checkReferralSupplyTa =
|
241
247
|
client.referredBySupplyTa && usesAccount(client.referredBySupplyTa);
|
242
248
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
@@ -371,6 +377,7 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
|
371
377
|
try {
|
372
378
|
const serializer = getMarginfiRebalanceInstructionDataSerializer();
|
373
379
|
const discriminator = serializer.serialize({
|
380
|
+
slippageBps: 0,
|
374
381
|
limitGapBps: 0,
|
375
382
|
rebalanceType: SolautoRebalanceType.None,
|
376
383
|
targetLiqUtilizationRateBps: 0,
|
@@ -379,7 +386,7 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
|
379
386
|
if (data.discriminator === discriminator) {
|
380
387
|
return true;
|
381
388
|
}
|
382
|
-
} catch {
|
389
|
+
} catch {}
|
383
390
|
return false;
|
384
391
|
}
|
385
392
|
});
|
@@ -400,7 +407,7 @@ function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
|
400
407
|
if (data.discriminator === discriminator) {
|
401
408
|
solautoActions?.push(data.solautoAction);
|
402
409
|
}
|
403
|
-
} catch {
|
410
|
+
} catch {}
|
404
411
|
}
|
405
412
|
|
406
413
|
if (x.programId === MARGINFI_PROGRAM_ID) {
|
@@ -423,7 +430,7 @@ function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
|
423
430
|
fields: [data.amount],
|
424
431
|
});
|
425
432
|
}
|
426
|
-
} catch {
|
433
|
+
} catch {}
|
427
434
|
|
428
435
|
try {
|
429
436
|
const serializer = getLendingAccountBorrowInstructionDataSerializer();
|
@@ -444,7 +451,7 @@ function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
|
444
451
|
fields: [data.amount],
|
445
452
|
});
|
446
453
|
}
|
447
|
-
} catch {
|
454
|
+
} catch {}
|
448
455
|
|
449
456
|
try {
|
450
457
|
const serializer = getLendingAccountWithdrawInstructionDataSerializer();
|
@@ -466,16 +473,16 @@ function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
|
466
473
|
fields: [
|
467
474
|
data.withdrawAll
|
468
475
|
? {
|
469
|
-
|
470
|
-
|
476
|
+
__kind: "All",
|
477
|
+
}
|
471
478
|
: {
|
472
|
-
|
473
|
-
|
474
|
-
|
479
|
+
__kind: "Some",
|
480
|
+
fields: [data.amount],
|
481
|
+
},
|
475
482
|
],
|
476
483
|
});
|
477
484
|
}
|
478
|
-
} catch {
|
485
|
+
} catch {}
|
479
486
|
|
480
487
|
try {
|
481
488
|
const serializer = getLendingAccountRepayInstructionDataSerializer();
|
@@ -497,16 +504,16 @@ function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
|
497
504
|
fields: [
|
498
505
|
data.repayAll
|
499
506
|
? {
|
500
|
-
|
501
|
-
|
507
|
+
__kind: "All",
|
508
|
+
}
|
502
509
|
: {
|
503
|
-
|
504
|
-
|
505
|
-
|
510
|
+
__kind: "Some",
|
511
|
+
fields: [data.amount],
|
512
|
+
},
|
506
513
|
],
|
507
514
|
});
|
508
515
|
}
|
509
|
-
} catch {
|
516
|
+
} catch {}
|
510
517
|
}
|
511
518
|
|
512
519
|
// TODO support other platforms
|
@@ -552,10 +559,11 @@ export async function buildSolautoRebalanceTransaction(
|
|
552
559
|
client: SolautoClient,
|
553
560
|
targetLiqUtilizationRateBps?: number,
|
554
561
|
attemptNum?: number
|
555
|
-
): Promise<
|
556
|
-
|
557
|
-
|
558
|
-
|
562
|
+
): Promise<
|
563
|
+
| {
|
564
|
+
tx: TransactionBuilder;
|
565
|
+
lookupTableAddresses: string[];
|
566
|
+
}
|
559
567
|
| undefined
|
560
568
|
> {
|
561
569
|
client.solautoPositionState = await client.getFreshPositionState();
|
@@ -620,20 +628,22 @@ export async function buildSolautoRebalanceTransaction(
|
|
620
628
|
),
|
621
629
|
...(addFirstRebalance
|
622
630
|
? [
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
+
client.rebalance(
|
632
|
+
"A",
|
633
|
+
swapDetails,
|
634
|
+
rebalanceType,
|
635
|
+
jupQuote.slippageBps,
|
636
|
+
flashLoan,
|
637
|
+
targetLiqUtilizationRateBps
|
638
|
+
),
|
639
|
+
]
|
631
640
|
: []),
|
632
641
|
swapIx,
|
633
642
|
client.rebalance(
|
634
643
|
"B",
|
635
644
|
swapDetails,
|
636
645
|
rebalanceType,
|
646
|
+
jupQuote.slippageBps,
|
637
647
|
flashLoan,
|
638
648
|
targetLiqUtilizationRateBps
|
639
649
|
),
|
@@ -648,6 +658,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
648
658
|
"A",
|
649
659
|
swapDetails,
|
650
660
|
rebalanceType,
|
661
|
+
jupQuote.slippageBps,
|
651
662
|
undefined,
|
652
663
|
targetLiqUtilizationRateBps
|
653
664
|
),
|
@@ -656,6 +667,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
656
667
|
"B",
|
657
668
|
swapDetails,
|
658
669
|
rebalanceType,
|
670
|
+
jupQuote.slippageBps,
|
659
671
|
undefined,
|
660
672
|
targetLiqUtilizationRateBps
|
661
673
|
),
|
@@ -166,7 +166,6 @@ class TransactionSet {
|
|
166
166
|
export enum TransactionStatus {
|
167
167
|
Skipped = "Skipped",
|
168
168
|
Processing = "Processing",
|
169
|
-
AwaitingSignature = "Awaiting Signature",
|
170
169
|
Queued = "Queued",
|
171
170
|
Successful = "Successful",
|
172
171
|
}
|
@@ -294,12 +293,7 @@ export class TransactionsManager {
|
|
294
293
|
updateLookupTable.updateLutTx,
|
295
294
|
this.txType,
|
296
295
|
attemptNum,
|
297
|
-
prioritySetting
|
298
|
-
() =>
|
299
|
-
this.updateStatus(
|
300
|
-
updateLutTxName,
|
301
|
-
TransactionStatus.AwaitingSignature
|
302
|
-
)
|
296
|
+
prioritySetting
|
303
297
|
),
|
304
298
|
3,
|
305
299
|
150,
|
@@ -450,12 +444,7 @@ export class TransactionsManager {
|
|
450
444
|
tx,
|
451
445
|
this.txType,
|
452
446
|
attemptNum,
|
453
|
-
prioritySetting
|
454
|
-
() =>
|
455
|
-
this.updateStatus(
|
456
|
-
itemSet!.name(),
|
457
|
-
TransactionStatus.AwaitingSignature
|
458
|
-
)
|
447
|
+
prioritySetting
|
459
448
|
);
|
460
449
|
this.updateStatus(
|
461
450
|
itemSet.name(),
|
@@ -1,15 +1,20 @@
|
|
1
1
|
import { describe, it } from "mocha";
|
2
2
|
import { none, publicKey, some } from "@metaplex-foundation/umi";
|
3
3
|
import { setupTest } from "../shared";
|
4
|
-
import {
|
5
|
-
SolautoMarginfiClient,
|
6
|
-
} from "../../src/clients/solautoMarginfiClient";
|
4
|
+
import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
|
7
5
|
import {
|
8
6
|
solautoAction,
|
9
7
|
SolautoSettingsParametersInpArgs,
|
10
8
|
} from "../../src/generated";
|
11
9
|
import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
|
12
|
-
import {
|
10
|
+
import {
|
11
|
+
getDebtAdjustmentUsd,
|
12
|
+
getLiqUtilzationRateBps,
|
13
|
+
maxBoostToBps,
|
14
|
+
maxRepayFromBps,
|
15
|
+
maxRepayToBps,
|
16
|
+
toBaseUnit,
|
17
|
+
} from "../../src/utils/numberUtils";
|
13
18
|
import { NATIVE_MINT } from "@solana/spl-token";
|
14
19
|
import { getTokenPrices } from "../../src/utils/generalUtils";
|
15
20
|
import {
|
@@ -20,33 +25,30 @@ import { PublicKey } from "@solana/web3.js";
|
|
20
25
|
import { USDC_MINT } from "../../src/constants";
|
21
26
|
|
22
27
|
describe("Solauto Marginfi tests", async () => {
|
23
|
-
const signer = setupTest();
|
24
|
-
|
28
|
+
// const signer = setupTest();
|
29
|
+
const signer = setupTest("solauto-manager");
|
25
30
|
|
26
31
|
const payForTransactions = false;
|
27
32
|
const useJitoBundle = false;
|
28
33
|
const positionId = 1;
|
29
34
|
|
30
35
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
31
|
-
|
32
36
|
const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
|
33
37
|
|
34
38
|
const supply = NATIVE_MINT;
|
35
39
|
const supplyDecimals = 9;
|
36
40
|
const debtDecimals = 6;
|
37
41
|
|
38
|
-
await client.initialize(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
);
|
42
|
+
await client.initialize({
|
43
|
+
signer,
|
44
|
+
positionId,
|
45
|
+
authority: new PublicKey("E5BBsR1sUToPc3jXVwhrK5ttSiy6xhWJDMdQLvkgNppe")
|
46
|
+
// marginfiAccount: new PublicKey(
|
47
|
+
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
48
|
+
// ),
|
49
|
+
// supplyMint: NATIVE_MINT,
|
50
|
+
// debtMint: new PublicKey(USDC_MINT),
|
51
|
+
});
|
50
52
|
|
51
53
|
const transactionItems: TransactionItem[] = [];
|
52
54
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
@@ -120,13 +122,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
120
122
|
// }, "deposit")
|
121
123
|
// );
|
122
124
|
|
123
|
-
transactionItems.push(
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
);
|
125
|
+
// transactionItems.push(
|
126
|
+
// new TransactionItem(
|
127
|
+
// async (attemptNum) =>
|
128
|
+
// await buildSolautoRebalanceTransaction(client, 1500, attemptNum),
|
129
|
+
// "rebalance"
|
130
|
+
// )
|
131
|
+
// );
|
130
132
|
|
131
133
|
// transactionItems.push(
|
132
134
|
// new TransactionItem(
|
@@ -155,11 +157,19 @@ describe("Solauto Marginfi tests", async () => {
|
|
155
157
|
// )
|
156
158
|
// );
|
157
159
|
|
158
|
-
await new TransactionsManager(
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
).clientSend(transactionItems);
|
160
|
+
// await new TransactionsManager(
|
161
|
+
// client,
|
162
|
+
// undefined,
|
163
|
+
// !payForTransactions ? "only-simulate" : "normal",
|
164
|
+
// useJitoBundle
|
165
|
+
// ).clientSend(transactionItems);
|
166
|
+
|
167
|
+
// const debtAdjustment = getDebtAdjustmentUsd(8696, 366, 165, 7000);
|
168
|
+
// const newLiqUtilizationRate = getLiqUtilzationRateBps(366 + debtAdjustment, 165 + debtAdjustment, 8696);
|
169
|
+
// console.log(newLiqUtilizationRate);
|
170
|
+
|
171
|
+
console.log("CURRENT", Number(client.solautoPositionState?.supply.amountUsed.baseUnit));
|
172
|
+
const freshState = await client.getFreshPositionState();
|
173
|
+
console.log("FRESH", Number(freshState!.supply.amountUsed.baseUnit));
|
164
174
|
});
|
165
175
|
});
|