@haven-fi/solauto-sdk 1.0.162 → 1.0.163
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 +1 -2
- package/dist/generated/instructions/marginfiRebalance.d.ts +0 -2
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.js +0 -1
- package/dist/generated/types/rebalanceData.d.ts +0 -2
- package/dist/generated/types/rebalanceData.d.ts.map +1 -1
- package/dist/generated/types/rebalanceData.js +1 -2
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +5 -6
- package/dist/utils/jupiterUtils.js +1 -1
- package/dist/utils/solauto/rebalanceUtils.d.ts +1 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +13 -13
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +0 -1
- package/src/clients/solautoMarginfiClient.ts +0 -2
- package/src/generated/instructions/marginfiRebalance.ts +0 -3
- package/src/generated/types/rebalanceData.ts +1 -4
- package/src/transactions/transactionUtils.ts +1 -6
- package/src/utils/jupiterUtils.ts +1 -1
- package/src/utils/solauto/rebalanceUtils.ts +25 -19
- package/tests/transactions/solautoMarginfi.ts +4 -4
@@ -65,7 +65,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
65
65
|
protocolInteraction(args: SolautoActionArgs): TransactionBuilder;
|
66
66
|
abstract flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
67
67
|
abstract flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
68
|
-
abstract rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs,
|
68
|
+
abstract rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
69
69
|
getFreshPositionState(): Promise<PositionState | undefined>;
|
70
70
|
}
|
71
71
|
//# 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,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,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,SA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G,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,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"}
|
@@ -38,7 +38,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
|
|
38
38
|
protocolInteraction(args: SolautoActionArgs): TransactionBuilder;
|
39
39
|
private marginfiProtocolInteractionIx;
|
40
40
|
private marginfiSolautoProtocolInteractionIx;
|
41
|
-
rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs,
|
41
|
+
rebalance(rebalanceStep: "A" | "B", swapDetails: JupSwapDetails, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number, limitGapBps?: number): TransactionBuilder;
|
42
42
|
flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
43
43
|
flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
44
44
|
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,EAA8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W,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"}
|
@@ -291,7 +291,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
291
291
|
solautoAction: args,
|
292
292
|
});
|
293
293
|
}
|
294
|
-
rebalance(rebalanceStep, swapDetails, rebalanceType,
|
294
|
+
rebalance(rebalanceStep, swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps, limitGapBps) {
|
295
295
|
const inputIsSupply = swapDetails.inputMint.equals(this.supplyMint);
|
296
296
|
const outputIsSupply = swapDetails.outputMint.equals(this.supplyMint);
|
297
297
|
const needSupplyAccounts = (inputIsSupply && rebalanceStep === "A") ||
|
@@ -340,7 +340,6 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
340
340
|
? swapDetails.amount
|
341
341
|
: null,
|
342
342
|
limitGapBps: limitGapBps ?? null,
|
343
|
-
slippageBps: slippageBps ?? 0,
|
344
343
|
});
|
345
344
|
}
|
346
345
|
flashBorrow(flashLoanDetails, destinationTokenAccount) {
|
@@ -37,14 +37,12 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
37
37
|
};
|
38
38
|
export type MarginfiRebalanceInstructionData = {
|
39
39
|
discriminator: number;
|
40
|
-
slippageBps: number;
|
41
40
|
rebalanceType: SolautoRebalanceType;
|
42
41
|
targetLiqUtilizationRateBps: Option<number>;
|
43
42
|
targetInAmountBaseUnit: Option<bigint>;
|
44
43
|
limitGapBps: Option<number>;
|
45
44
|
};
|
46
45
|
export type MarginfiRebalanceInstructionDataArgs = {
|
47
|
-
slippageBps: number;
|
48
46
|
rebalanceType: SolautoRebalanceTypeArgs;
|
49
47
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
50
48
|
targetInAmountBaseUnit: OptionOrNullable<number | bigint>;
|
@@ -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,EAOX,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,iBAAiB,EAAE,SAAS,GAAG,GAAG,CAAC;IACnC,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,aAAa,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,cAAc,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,UAAU,EAAE,SAAS,GAAG,GAAG,CAAC;IAC5B,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,gBAAgB,EAAE,SAAS,GAAG,GAAG,CAAC;IAClC,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,oBAAoB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACvC,QAAQ,EAAE,SAAS,GAAG,GAAG,CAAC;IAC1B,eAAe,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAClC,cAAc,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,eAAe,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC9B,kBAAkB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;CACtC,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,
|
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,EAOX,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,iBAAiB,EAAE,SAAS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,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,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,CAkLpB"}
|
@@ -16,7 +16,6 @@ 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)()],
|
20
19
|
['rebalanceType', (0, types_1.getSolautoRebalanceTypeSerializer)()],
|
21
20
|
['targetLiqUtilizationRateBps', (0, serializers_1.option)((0, serializers_1.u16)())],
|
22
21
|
['targetInAmountBaseUnit', (0, serializers_1.option)((0, serializers_1.u64)())],
|
@@ -10,7 +10,6 @@ import { SolautoRebalanceType, SolautoRebalanceTypeArgs } from '.';
|
|
10
10
|
export type RebalanceData = {
|
11
11
|
rebalanceType: SolautoRebalanceType;
|
12
12
|
padding1: Array<number>;
|
13
|
-
priceSlippageBps: number;
|
14
13
|
targetLiqUtilizationRateBps: number;
|
15
14
|
padding2: Array<number>;
|
16
15
|
flashLoanAmount: bigint;
|
@@ -19,7 +18,6 @@ export type RebalanceData = {
|
|
19
18
|
export type RebalanceDataArgs = {
|
20
19
|
rebalanceType: SolautoRebalanceTypeArgs;
|
21
20
|
padding1: Array<number>;
|
22
|
-
priceSlippageBps: number;
|
23
21
|
targetLiqUtilizationRateBps: number;
|
24
22
|
padding2: Array<number>;
|
25
23
|
flashLoanAmount: number | bigint;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceData.d.ts","sourceRoot":"","sources":["../../../src/generated/types/rebalanceData.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EAOX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EAEzB,MAAM,GAAG,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,
|
1
|
+
{"version":3,"file":"rebalanceData.d.ts","sourceRoot":"","sources":["../../../src/generated/types/rebalanceData.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EAOX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EAEzB,MAAM,GAAG,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,2BAA2B,EAAE,MAAM,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,wBAAwB,CAAC;IACxC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,2BAA2B,EAAE,MAAM,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,UAAU,CACtD,iBAAiB,EACjB,aAAa,CACd,CAYA"}
|
@@ -14,9 +14,8 @@ function getRebalanceDataSerializer() {
|
|
14
14
|
return (0, serializers_1.struct)([
|
15
15
|
['rebalanceType', (0, _1.getSolautoRebalanceTypeSerializer)()],
|
16
16
|
['padding1', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
|
17
|
-
['priceSlippageBps', (0, serializers_1.u16)()],
|
18
17
|
['targetLiqUtilizationRateBps', (0, serializers_1.u16)()],
|
19
|
-
['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size:
|
18
|
+
['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 6 })],
|
20
19
|
['flashLoanAmount', (0, serializers_1.u64)()],
|
21
20
|
['padding', (0, serializers_1.bytes)({ size: 32 })],
|
22
21
|
], { description: 'RebalanceData' });
|
@@ -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,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;
|
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,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,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,CA0BnD;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,CA+HA;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"}
|
@@ -185,7 +185,6 @@ function getRebalanceInstructions(tx) {
|
|
185
185
|
try {
|
186
186
|
const serializer = (0, generated_1.getMarginfiRebalanceInstructionDataSerializer)();
|
187
187
|
const discriminator = serializer.serialize({
|
188
|
-
slippageBps: 0,
|
189
188
|
limitGapBps: 0,
|
190
189
|
targetInAmountBaseUnit: 0,
|
191
190
|
rebalanceType: generated_1.SolautoRebalanceType.None,
|
@@ -350,11 +349,11 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
350
349
|
client.flashBorrow(flashLoan, (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), swapDetails.inputMint)),
|
351
350
|
...(addFirstRebalance
|
352
351
|
? [
|
353
|
-
client.rebalance("A", swapDetails, rebalanceType,
|
352
|
+
client.rebalance("A", swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
354
353
|
]
|
355
354
|
: []),
|
356
355
|
swapIx,
|
357
|
-
client.rebalance("B", swapDetails, rebalanceType,
|
356
|
+
client.rebalance("B", swapDetails, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
358
357
|
client.flashRepay(flashLoan),
|
359
358
|
]);
|
360
359
|
}
|
@@ -363,9 +362,9 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
363
362
|
tx = tx.add([
|
364
363
|
setupInstructions,
|
365
364
|
tokenLedgerIx,
|
366
|
-
client.rebalance("A", swapDetails, rebalanceType,
|
365
|
+
client.rebalance("A", swapDetails, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
367
366
|
swapIx,
|
368
|
-
client.rebalance("B", swapDetails, rebalanceType,
|
367
|
+
client.rebalance("B", swapDetails, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
369
368
|
]);
|
370
369
|
}
|
371
370
|
if (client.solautoPositionState.liqUtilizationRateBps >
|
@@ -388,7 +387,7 @@ async function convertReferralFeesToDestination(umi, referralState, tokenAccount
|
|
388
387
|
inputMint: tokenAccountData.mint,
|
389
388
|
outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.destFeesMint),
|
390
389
|
exactIn: true,
|
391
|
-
slippageIncFactor: 0.
|
390
|
+
slippageIncFactor: 0.25,
|
392
391
|
});
|
393
392
|
let tx = (0, umi_1.transactionBuilder)()
|
394
393
|
.add(setupInstructions)
|
@@ -31,7 +31,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
31
31
|
: swapDetails.exactIn
|
32
32
|
? "ExactIn"
|
33
33
|
: undefined,
|
34
|
-
slippageBps:
|
34
|
+
slippageBps: 50,
|
35
35
|
maxAccounts: !swapDetails.exactOut ? 60 : undefined,
|
36
36
|
}), 3);
|
37
37
|
const priceImpactBps = (Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+IjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CAmEjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,MAAM,GACrB,gBAAgB,GAAG,SAAS,CAgE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CA4ChB"}
|
@@ -106,9 +106,11 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
106
106
|
limitGap;
|
107
107
|
debtAdjustmentUsd = maxUsageUsd - maxUsageUsd * limitGap;
|
108
108
|
}
|
109
|
+
const maxRepayTo = (0, numberUtils_1.maxRepayToBps)(state.maxLtvBps, state.liqThresholdBps);
|
109
110
|
return {
|
110
111
|
increasingLeverage,
|
111
112
|
debtAdjustmentUsd,
|
113
|
+
repayingCloseToMaxLtv: state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
|
112
114
|
amountToDcaIn: amountToDcaIn ?? 0,
|
113
115
|
amountUsdToDcaIn,
|
114
116
|
dcaTokenType: dca?.tokenType,
|
@@ -142,15 +144,13 @@ function getFlashLoanDetails(client, values, jupQuote, priceImpactBps) {
|
|
142
144
|
flashLoanToken = client.solautoPositionState.supply;
|
143
145
|
flashLoanTokenPrice = (0, generalUtils_2.safeGetPrice)(client.supplyMint);
|
144
146
|
}
|
145
|
-
const exactAmountBaseUnit = jupQuote
|
146
|
-
(jupQuote.swapMode === "ExactOut" || jupQuote.swapMode === "ExactIn")
|
147
|
+
const exactAmountBaseUnit = jupQuote.swapMode === "ExactOut" || jupQuote.swapMode === "ExactIn"
|
147
148
|
? BigInt(parseInt(jupQuote.inAmount))
|
148
149
|
: undefined;
|
149
150
|
return requiresFlashLoan
|
150
151
|
? {
|
151
152
|
baseUnitAmount: exactAmountBaseUnit
|
152
|
-
? exactAmountBaseUnit
|
153
|
-
BigInt(Math.round(Number(exactAmountBaseUnit) * (0, numberUtils_1.fromBps)(priceImpactBps)))
|
153
|
+
? exactAmountBaseUnit
|
154
154
|
: (0, numberUtils_1.toBaseUnit)(debtAdjustmentWithSlippage / flashLoanTokenPrice, flashLoanToken.decimals),
|
155
155
|
mint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(flashLoanToken.mint),
|
156
156
|
}
|
@@ -165,11 +165,9 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
165
165
|
: client.solautoPositionState.debt;
|
166
166
|
const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
|
167
167
|
(values.dcaTokenType === generated_1.TokenType.Debt ? values.amountUsdToDcaIn : 0);
|
168
|
-
const
|
169
|
-
|
170
|
-
|
171
|
-
const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / inputPrice, input.decimals);
|
172
|
-
const exactOut = targetLiqUtilizationRateBps === 0;
|
168
|
+
const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(input.mint), input.decimals);
|
169
|
+
const outputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(output.mint), output.decimals);
|
170
|
+
const exactOut = values.repayingCloseToMaxLtv;
|
173
171
|
const exactIn = !exactOut && targetLiqUtilizationRateBps !== undefined;
|
174
172
|
return {
|
175
173
|
inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
|
@@ -177,10 +175,12 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
177
175
|
destinationWallet: client.solautoPosition,
|
178
176
|
slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
|
179
177
|
amount: exactOut
|
180
|
-
?
|
181
|
-
|
182
|
-
|
183
|
-
|
178
|
+
? outputAmount +
|
179
|
+
(targetLiqUtilizationRateBps === 0
|
180
|
+
? BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
|
181
|
+
// Add this small percentage to account for the APR on the debt between now and the transaction
|
182
|
+
0.0001))
|
183
|
+
: BigInt(0))
|
184
184
|
: inputAmount,
|
185
185
|
exactIn: exactIn,
|
186
186
|
exactOut: exactOut,
|
package/package.json
CHANGED
@@ -597,7 +597,6 @@ export abstract class SolautoClient extends TxHandler {
|
|
597
597
|
rebalanceStep: "A" | "B",
|
598
598
|
swapDetails: JupSwapDetails,
|
599
599
|
rebalanceType: SolautoRebalanceTypeArgs,
|
600
|
-
slippageBps: number,
|
601
600
|
flashLoan?: FlashLoanDetails,
|
602
601
|
targetLiqUtilizationRateBps?: number,
|
603
602
|
limitGapBps?: number,
|
@@ -453,7 +453,6 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
453
453
|
rebalanceStep: "A" | "B",
|
454
454
|
swapDetails: JupSwapDetails,
|
455
455
|
rebalanceType: SolautoRebalanceTypeArgs,
|
456
|
-
slippageBps: number,
|
457
456
|
flashLoan?: FlashLoanDetails,
|
458
457
|
targetLiqUtilizationRateBps?: number,
|
459
458
|
limitGapBps?: number
|
@@ -521,7 +520,6 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
521
520
|
? swapDetails.amount
|
522
521
|
: null,
|
523
522
|
limitGapBps: limitGapBps ?? null,
|
524
|
-
slippageBps: slippageBps ?? 0,
|
525
523
|
});
|
526
524
|
}
|
527
525
|
|
@@ -68,7 +68,6 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
68
68
|
// Data.
|
69
69
|
export type MarginfiRebalanceInstructionData = {
|
70
70
|
discriminator: number;
|
71
|
-
slippageBps: number;
|
72
71
|
rebalanceType: SolautoRebalanceType;
|
73
72
|
targetLiqUtilizationRateBps: Option<number>;
|
74
73
|
targetInAmountBaseUnit: Option<bigint>;
|
@@ -76,7 +75,6 @@ export type MarginfiRebalanceInstructionData = {
|
|
76
75
|
};
|
77
76
|
|
78
77
|
export type MarginfiRebalanceInstructionDataArgs = {
|
79
|
-
slippageBps: number;
|
80
78
|
rebalanceType: SolautoRebalanceTypeArgs;
|
81
79
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
82
80
|
targetInAmountBaseUnit: OptionOrNullable<number | bigint>;
|
@@ -95,7 +93,6 @@ export function getMarginfiRebalanceInstructionDataSerializer(): Serializer<
|
|
95
93
|
struct<MarginfiRebalanceInstructionData>(
|
96
94
|
[
|
97
95
|
['discriminator', u8()],
|
98
|
-
['slippageBps', u16()],
|
99
96
|
['rebalanceType', getSolautoRebalanceTypeSerializer()],
|
100
97
|
['targetLiqUtilizationRateBps', option(u16())],
|
101
98
|
['targetInAmountBaseUnit', option(u64())],
|
@@ -24,7 +24,6 @@ import {
|
|
24
24
|
export type RebalanceData = {
|
25
25
|
rebalanceType: SolautoRebalanceType;
|
26
26
|
padding1: Array<number>;
|
27
|
-
priceSlippageBps: number;
|
28
27
|
targetLiqUtilizationRateBps: number;
|
29
28
|
padding2: Array<number>;
|
30
29
|
flashLoanAmount: bigint;
|
@@ -34,7 +33,6 @@ export type RebalanceData = {
|
|
34
33
|
export type RebalanceDataArgs = {
|
35
34
|
rebalanceType: SolautoRebalanceTypeArgs;
|
36
35
|
padding1: Array<number>;
|
37
|
-
priceSlippageBps: number;
|
38
36
|
targetLiqUtilizationRateBps: number;
|
39
37
|
padding2: Array<number>;
|
40
38
|
flashLoanAmount: number | bigint;
|
@@ -49,9 +47,8 @@ export function getRebalanceDataSerializer(): Serializer<
|
|
49
47
|
[
|
50
48
|
['rebalanceType', getSolautoRebalanceTypeSerializer()],
|
51
49
|
['padding1', array(u8(), { size: 7 })],
|
52
|
-
['priceSlippageBps', u16()],
|
53
50
|
['targetLiqUtilizationRateBps', u16()],
|
54
|
-
['padding2', array(u8(), { size:
|
51
|
+
['padding2', array(u8(), { size: 6 })],
|
55
52
|
['flashLoanAmount', u64()],
|
56
53
|
['padding', bytes({ size: 32 })],
|
57
54
|
],
|
@@ -390,7 +390,6 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
|
390
390
|
try {
|
391
391
|
const serializer = getMarginfiRebalanceInstructionDataSerializer();
|
392
392
|
const discriminator = serializer.serialize({
|
393
|
-
slippageBps: 0,
|
394
393
|
limitGapBps: 0,
|
395
394
|
targetInAmountBaseUnit: 0,
|
396
395
|
rebalanceType: SolautoRebalanceType.None,
|
@@ -651,7 +650,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
651
650
|
"A",
|
652
651
|
swapDetails,
|
653
652
|
rebalanceType,
|
654
|
-
priceImpactBps,
|
655
653
|
flashLoan,
|
656
654
|
targetLiqUtilizationRateBps
|
657
655
|
),
|
@@ -662,7 +660,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
662
660
|
"B",
|
663
661
|
swapDetails,
|
664
662
|
rebalanceType,
|
665
|
-
priceImpactBps,
|
666
663
|
flashLoan,
|
667
664
|
targetLiqUtilizationRateBps
|
668
665
|
),
|
@@ -677,7 +674,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
677
674
|
"A",
|
678
675
|
swapDetails,
|
679
676
|
rebalanceType,
|
680
|
-
priceImpactBps,
|
681
677
|
undefined,
|
682
678
|
targetLiqUtilizationRateBps
|
683
679
|
),
|
@@ -686,7 +682,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
686
682
|
"B",
|
687
683
|
swapDetails,
|
688
684
|
rebalanceType,
|
689
|
-
priceImpactBps,
|
690
685
|
undefined,
|
691
686
|
targetLiqUtilizationRateBps
|
692
687
|
),
|
@@ -727,7 +722,7 @@ export async function convertReferralFeesToDestination(
|
|
727
722
|
inputMint: tokenAccountData.mint,
|
728
723
|
outputMint: toWeb3JsPublicKey(referralState.destFeesMint),
|
729
724
|
exactIn: true,
|
730
|
-
slippageIncFactor: 0.
|
725
|
+
slippageIncFactor: 0.25,
|
731
726
|
});
|
732
727
|
|
733
728
|
let tx = transactionBuilder()
|
@@ -23,6 +23,7 @@ import {
|
|
23
23
|
getLiqUtilzationRateBps,
|
24
24
|
getMaxLiqUtilizationRateBps,
|
25
25
|
getSolautoFeesBps,
|
26
|
+
maxRepayToBps,
|
26
27
|
toBaseUnit,
|
27
28
|
} from "../numberUtils";
|
28
29
|
import { USD_DECIMALS } from "../../constants/generalAccounts";
|
@@ -159,6 +160,7 @@ function getTargetRateAndDcaAmount(
|
|
159
160
|
export interface RebalanceValues {
|
160
161
|
increasingLeverage: boolean;
|
161
162
|
debtAdjustmentUsd: number;
|
163
|
+
repayingCloseToMaxLtv: boolean;
|
162
164
|
amountToDcaIn: number;
|
163
165
|
amountUsdToDcaIn: number;
|
164
166
|
dcaTokenType?: TokenType;
|
@@ -231,9 +233,11 @@ export function getRebalanceValues(
|
|
231
233
|
debtAdjustmentUsd = maxUsageUsd - maxUsageUsd * limitGap;
|
232
234
|
}
|
233
235
|
|
236
|
+
const maxRepayTo = maxRepayToBps(state.maxLtvBps, state.liqThresholdBps);
|
234
237
|
return {
|
235
238
|
increasingLeverage,
|
236
239
|
debtAdjustmentUsd,
|
240
|
+
repayingCloseToMaxLtv: state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
|
237
241
|
amountToDcaIn: amountToDcaIn ?? 0,
|
238
242
|
amountUsdToDcaIn,
|
239
243
|
dcaTokenType: dca?.tokenType,
|
@@ -299,18 +303,14 @@ export function getFlashLoanDetails(
|
|
299
303
|
}
|
300
304
|
|
301
305
|
const exactAmountBaseUnit =
|
302
|
-
jupQuote
|
303
|
-
(jupQuote.swapMode === "ExactOut" || jupQuote.swapMode === "ExactIn")
|
306
|
+
jupQuote.swapMode === "ExactOut" || jupQuote.swapMode === "ExactIn"
|
304
307
|
? BigInt(parseInt(jupQuote.inAmount))
|
305
308
|
: undefined;
|
306
309
|
|
307
310
|
return requiresFlashLoan
|
308
311
|
? {
|
309
312
|
baseUnitAmount: exactAmountBaseUnit
|
310
|
-
? exactAmountBaseUnit
|
311
|
-
BigInt(
|
312
|
-
Math.round(Number(exactAmountBaseUnit) * fromBps(priceImpactBps))
|
313
|
-
)
|
313
|
+
? exactAmountBaseUnit
|
314
314
|
: toBaseUnit(
|
315
315
|
debtAdjustmentWithSlippage / flashLoanTokenPrice,
|
316
316
|
flashLoanToken.decimals
|
@@ -337,12 +337,16 @@ export function getJupSwapRebalanceDetails(
|
|
337
337
|
Math.abs(values.debtAdjustmentUsd) +
|
338
338
|
(values.dcaTokenType === TokenType.Debt ? values.amountUsdToDcaIn : 0);
|
339
339
|
|
340
|
-
const
|
341
|
-
|
342
|
-
|
343
|
-
|
340
|
+
const inputAmount = toBaseUnit(
|
341
|
+
usdToSwap / safeGetPrice(input.mint)!,
|
342
|
+
input.decimals
|
343
|
+
);
|
344
|
+
const outputAmount = toBaseUnit(
|
345
|
+
usdToSwap / safeGetPrice(output.mint)!,
|
346
|
+
output.decimals
|
347
|
+
);
|
344
348
|
|
345
|
-
const exactOut =
|
349
|
+
const exactOut = values.repayingCloseToMaxLtv;
|
346
350
|
const exactIn = !exactOut && targetLiqUtilizationRateBps !== undefined;
|
347
351
|
|
348
352
|
return {
|
@@ -351,14 +355,16 @@ export function getJupSwapRebalanceDetails(
|
|
351
355
|
destinationWallet: client.solautoPosition,
|
352
356
|
slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
|
353
357
|
amount: exactOut
|
354
|
-
?
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
358
|
+
? outputAmount +
|
359
|
+
(targetLiqUtilizationRateBps === 0
|
360
|
+
? BigInt(
|
361
|
+
Math.round(
|
362
|
+
Number(client.solautoPositionState!.debt.amountUsed.baseUnit) *
|
363
|
+
// Add this small percentage to account for the APR on the debt between now and the transaction
|
364
|
+
0.0001
|
365
|
+
)
|
366
|
+
)
|
367
|
+
: BigInt(0))
|
362
368
|
: inputAmount,
|
363
369
|
exactIn: exactIn,
|
364
370
|
exactOut: exactOut,
|
@@ -21,10 +21,10 @@ import { USDC_MINT } from "../../src/constants";
|
|
21
21
|
import { buildHeliusApiUrl } from "../../src/utils";
|
22
22
|
|
23
23
|
describe("Solauto Marginfi tests", async () => {
|
24
|
-
|
25
|
-
const signer = setupTest("solauto-manager");
|
24
|
+
const signer = setupTest();
|
25
|
+
// const signer = setupTest("solauto-manager");
|
26
26
|
|
27
|
-
const payForTransactions =
|
27
|
+
const payForTransactions = true;
|
28
28
|
const useJitoBundle = false;
|
29
29
|
const positionId = 1;
|
30
30
|
|
@@ -124,7 +124,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
124
124
|
transactionItems.push(
|
125
125
|
new TransactionItem(
|
126
126
|
async (attemptNum) =>
|
127
|
-
await buildSolautoRebalanceTransaction(client,
|
127
|
+
await buildSolautoRebalanceTransaction(client, 7200, attemptNum),
|
128
128
|
"rebalance"
|
129
129
|
)
|
130
130
|
);
|