@haven-fi/solauto-sdk 1.0.216 → 1.0.218
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +2 -2
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts +2 -2
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +10 -4
- package/dist/generated/instructions/marginfiRebalance.d.ts +1 -1
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/types/index.d.ts +1 -0
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +1 -0
- package/dist/generated/types/rebalanceData.d.ts +3 -3
- package/dist/generated/types/rebalanceData.d.ts.map +1 -1
- package/dist/generated/types/rebalanceData.js +2 -2
- package/dist/generated/types/rebalanceDirection.d.ts +15 -0
- package/dist/generated/types/rebalanceDirection.d.ts.map +1 -0
- package/dist/generated/types/rebalanceDirection.js +22 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +4 -4
- package/dist/utils/numberUtils.d.ts +1 -1
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/numberUtils.js +2 -2
- package/dist/utils/solauto/rebalanceUtils.d.ts +2 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +2 -4
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +2 -1
- package/src/clients/solautoMarginfiClient.ts +21 -12
- package/src/generated/instructions/marginfiRebalance.ts +1 -1
- package/src/generated/types/index.ts +1 -0
- package/src/generated/types/rebalanceData.ts +7 -5
- package/src/generated/types/rebalanceDirection.ts +25 -0
- package/src/transactions/transactionUtils.ts +4 -0
- package/src/utils/numberUtils.ts +3 -2
- package/src/utils/solauto/rebalanceUtils.ts +10 -8
- package/tests/unit/rebalanceCalculations.ts +4 -2
@@ -2,7 +2,7 @@ import "rpc-websockets/dist/lib/client";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
3
3
|
import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
|
4
4
|
import { DCASettings, DCASettingsInpArgs, LendingPlatform, PositionState, SolautoActionArgs, SolautoPosition, SolautoRebalanceTypeArgs, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, UpdatePositionDataArgs } from "../generated";
|
5
|
-
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
5
|
+
import { FlashLoanDetails, RebalanceValues } from "../utils/solauto/rebalanceUtils";
|
6
6
|
import { LivePositionUpdates } from "../utils/solauto/generalUtils";
|
7
7
|
import { ReferralStateManager, ReferralStateManagerArgs } from "./referralStateManager";
|
8
8
|
import { QuoteResponse } from "@jup-ag/api";
|
@@ -55,7 +55,7 @@ export declare abstract class SolautoClient extends ReferralStateManager {
|
|
55
55
|
protocolInteraction(args: SolautoActionArgs): TransactionBuilder;
|
56
56
|
abstract flashBorrow(flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
57
57
|
abstract flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
58
|
-
abstract rebalance(rebalanceStep: "A" | "B", jupQuote: QuoteResponse, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number): TransactionBuilder;
|
58
|
+
abstract rebalance(rebalanceStep: "A" | "B", jupQuote: QuoteResponse, rebalanceType: SolautoRebalanceTypeArgs, rebalanceValues: RebalanceValues, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number): TransactionBuilder;
|
59
59
|
getFreshPositionState(): Promise<PositionState | undefined>;
|
60
60
|
}
|
61
61
|
//# 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,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
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,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,8BAAsB,aAAc,SAAQ,oBAAoB;IACvD,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,C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,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,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -4,7 +4,7 @@ import { SolautoClient, SolautoClientArgs } from "./solautoClient";
|
|
4
4
|
import { MarginfiAssetAccounts } from "../types/accounts";
|
5
5
|
import { DCASettingsInpArgs, PositionState, SolautoActionArgs, SolautoRebalanceTypeArgs, SolautoSettingsParametersInpArgs } from "../generated";
|
6
6
|
import { MarginfiAccount } from "../marginfi-sdk";
|
7
|
-
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
7
|
+
import { FlashLoanDetails, RebalanceValues } from "../utils/solauto/rebalanceUtils";
|
8
8
|
import { QuoteResponse } from "@jup-ag/api";
|
9
9
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
10
10
|
marginfiAccount?: PublicKey | Signer;
|
@@ -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", jupQuote: QuoteResponse, rebalanceType: SolautoRebalanceTypeArgs, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number): TransactionBuilder;
|
41
|
+
rebalance(rebalanceStep: "A" | "B", jupQuote: QuoteResponse, rebalanceType: SolautoRebalanceTypeArgs, rebalanceValues: RebalanceValues, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: 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,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;
|
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,OAA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MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IA0BvE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA6C9B,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,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAsErB,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;CA6ClE"}
|
@@ -286,7 +286,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
286
286
|
solautoAction: args,
|
287
287
|
});
|
288
288
|
}
|
289
|
-
rebalance(rebalanceStep, jupQuote, rebalanceType, flashLoan, targetLiqUtilizationRateBps) {
|
289
|
+
rebalance(rebalanceStep, jupQuote, rebalanceType, rebalanceValues, flashLoan, targetLiqUtilizationRateBps) {
|
290
290
|
const inputIsSupply = new web3_js_1.PublicKey(jupQuote.inputMint).equals(this.supplyMint);
|
291
291
|
const outputIsSupply = new web3_js_1.PublicKey(jupQuote.outputMint).equals(this.supplyMint);
|
292
292
|
const needSupplyAccounts = (inputIsSupply && rebalanceStep === "A") ||
|
@@ -304,7 +304,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
304
304
|
referredBySupplyTa: this.referredBySupplyTa()
|
305
305
|
? (0, umi_1.publicKey)(this.referredBySupplyTa())
|
306
306
|
: undefined,
|
307
|
-
positionAuthority:
|
307
|
+
positionAuthority: rebalanceValues.rebalanceAction === "dca"
|
308
|
+
? (0, umi_1.publicKey)(this.authority)
|
309
|
+
: undefined,
|
308
310
|
solautoPosition: (0, umi_1.publicKey)(this.solautoPosition),
|
309
311
|
marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
|
310
312
|
marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
|
@@ -312,7 +314,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
312
314
|
supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyAccounts.bank),
|
313
315
|
supplyPriceOracle: (0, umi_1.publicKey)(this.supplyPriceOracle),
|
314
316
|
positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
|
315
|
-
authoritySupplyTa:
|
317
|
+
authoritySupplyTa: this.selfManaged
|
318
|
+
? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.supplyMint))
|
319
|
+
: undefined,
|
316
320
|
vaultSupplyTa: needSupplyAccounts
|
317
321
|
? (0, umi_1.publicKey)(this.marginfiSupplyAccounts.liquidityVault)
|
318
322
|
: undefined,
|
@@ -322,7 +326,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
322
326
|
debtBank: (0, umi_1.publicKey)(this.marginfiDebtAccounts.bank),
|
323
327
|
debtPriceOracle: (0, umi_1.publicKey)(this.debtPriceOracle),
|
324
328
|
positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
|
325
|
-
authorityDebtTa:
|
329
|
+
authorityDebtTa: this.selfManaged
|
330
|
+
? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.debtMint))
|
331
|
+
: undefined,
|
326
332
|
vaultDebtTa: needDebtAccounts
|
327
333
|
? (0, umi_1.publicKey)(this.marginfiDebtAccounts.liquidityVault)
|
328
334
|
: undefined,
|
@@ -17,7 +17,7 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
17
17
|
solautoFeesSupplyTa?: PublicKey | Pda;
|
18
18
|
authorityReferralState: PublicKey | Pda;
|
19
19
|
referredBySupplyTa?: PublicKey | Pda;
|
20
|
-
positionAuthority
|
20
|
+
positionAuthority?: PublicKey | Pda;
|
21
21
|
solautoPosition: PublicKey | Pda;
|
22
22
|
marginfiGroup: PublicKey | Pda;
|
23
23
|
marginfiAccount: PublicKey | Pda;
|
@@ -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;
|
1
|
+
{"version":3,"file":"marginfiRebalance.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AAQ,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,aAAa,EAAE,oBAAoB,CAAC;IACpC,2BAA2B,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,wBAAwB,CAAC;IACxC,2BAA2B,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtD,sBAAsB,EAAE,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAC3D,CAAC;AAEF,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,EACpC,gCAAgC,CACjC,CAoBA;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,6 +16,7 @@ export * from './positionState';
|
|
16
16
|
export * from './positionTokenUsage';
|
17
17
|
export * from './positionType';
|
18
18
|
export * from './rebalanceData';
|
19
|
+
export * from './rebalanceDirection';
|
19
20
|
export * from './solautoAction';
|
20
21
|
export * from './solautoRebalanceType';
|
21
22
|
export * from './solautoSettingsParameters';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
@@ -32,6 +32,7 @@ __exportStar(require("./positionState"), exports);
|
|
32
32
|
__exportStar(require("./positionTokenUsage"), exports);
|
33
33
|
__exportStar(require("./positionType"), exports);
|
34
34
|
__exportStar(require("./rebalanceData"), exports);
|
35
|
+
__exportStar(require("./rebalanceDirection"), exports);
|
35
36
|
__exportStar(require("./solautoAction"), exports);
|
36
37
|
__exportStar(require("./solautoRebalanceType"), exports);
|
37
38
|
__exportStar(require("./solautoSettingsParameters"), exports);
|
@@ -6,11 +6,11 @@
|
|
6
6
|
* @see https://github.com/metaplex-foundation/kinobi
|
7
7
|
*/
|
8
8
|
import { Serializer } from '@metaplex-foundation/umi/serializers';
|
9
|
-
import { SolautoRebalanceType, SolautoRebalanceTypeArgs } from '.';
|
9
|
+
import { RebalanceDirection, RebalanceDirectionArgs, SolautoRebalanceType, SolautoRebalanceTypeArgs } from '.';
|
10
10
|
export type RebalanceData = {
|
11
11
|
rebalanceType: SolautoRebalanceType;
|
12
12
|
padding1: Array<number>;
|
13
|
-
|
13
|
+
rebalanceDirection: RebalanceDirection;
|
14
14
|
padding2: Array<number>;
|
15
15
|
flashLoanAmount: bigint;
|
16
16
|
padding: Uint8Array;
|
@@ -18,7 +18,7 @@ export type RebalanceData = {
|
|
18
18
|
export type RebalanceDataArgs = {
|
19
19
|
rebalanceType: SolautoRebalanceTypeArgs;
|
20
20
|
padding1: Array<number>;
|
21
|
-
|
21
|
+
rebalanceDirection: RebalanceDirectionArgs;
|
22
22
|
padding2: Array<number>;
|
23
23
|
flashLoanAmount: number | bigint;
|
24
24
|
padding: Uint8Array;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceData.d.ts","sourceRoot":"","sources":["../../../src/generated/types/rebalanceData.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,
|
1
|
+
{"version":3,"file":"rebalanceData.d.ts","sourceRoot":"","sources":["../../../src/generated/types/rebalanceData.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EAMX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EAGzB,MAAM,GAAG,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,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,kBAAkB,EAAE,sBAAsB,CAAC;IAC3C,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,8 +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
|
-
['
|
18
|
-
['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size:
|
17
|
+
['rebalanceDirection', (0, _1.getRebalanceDirectionSerializer)()],
|
18
|
+
['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
|
19
19
|
['flashLoanAmount', (0, serializers_1.u64)()],
|
20
20
|
['padding', (0, serializers_1.bytes)({ size: 32 })],
|
21
21
|
], { description: 'RebalanceData' });
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* This code was AUTOGENERATED using the kinobi library.
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
4
|
+
* to add features, then rerun kinobi to update it.
|
5
|
+
*
|
6
|
+
* @see https://github.com/metaplex-foundation/kinobi
|
7
|
+
*/
|
8
|
+
import { Serializer } from '@metaplex-foundation/umi/serializers';
|
9
|
+
export declare enum RebalanceDirection {
|
10
|
+
Boost = 0,
|
11
|
+
Repay = 1
|
12
|
+
}
|
13
|
+
export type RebalanceDirectionArgs = RebalanceDirection;
|
14
|
+
export declare function getRebalanceDirectionSerializer(): Serializer<RebalanceDirectionArgs, RebalanceDirection>;
|
15
|
+
//# sourceMappingURL=rebalanceDirection.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"rebalanceDirection.d.ts","sourceRoot":"","sources":["../../../src/generated/types/rebalanceDirection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,kBAAkB;IAC5B,KAAK,IAAA;IACL,KAAK,IAAA;CACN;AAED,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,wBAAgB,+BAA+B,IAAI,UAAU,CAC3D,sBAAsB,EACtB,kBAAkB,CACnB,CAIA"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* This code was AUTOGENERATED using the kinobi library.
|
4
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
5
|
+
* to add features, then rerun kinobi to update it.
|
6
|
+
*
|
7
|
+
* @see https://github.com/metaplex-foundation/kinobi
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.RebalanceDirection = void 0;
|
11
|
+
exports.getRebalanceDirectionSerializer = getRebalanceDirectionSerializer;
|
12
|
+
const serializers_1 = require("@metaplex-foundation/umi/serializers");
|
13
|
+
var RebalanceDirection;
|
14
|
+
(function (RebalanceDirection) {
|
15
|
+
RebalanceDirection[RebalanceDirection["Boost"] = 0] = "Boost";
|
16
|
+
RebalanceDirection[RebalanceDirection["Repay"] = 1] = "Repay";
|
17
|
+
})(RebalanceDirection || (exports.RebalanceDirection = RebalanceDirection = {}));
|
18
|
+
function getRebalanceDirectionSerializer() {
|
19
|
+
return (0, serializers_1.scalarEnum)(RebalanceDirection, {
|
20
|
+
description: 'RebalanceDirection',
|
21
|
+
});
|
22
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAiH7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAiH7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
|
@@ -381,11 +381,11 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
381
381
|
client.flashBorrow(flashLoan, (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), swapDetails.inputMint)),
|
382
382
|
...(addFirstRebalance
|
383
383
|
? [
|
384
|
-
client.rebalance("A", jupQuote, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
384
|
+
client.rebalance("A", jupQuote, rebalanceType, values, flashLoan, targetLiqUtilizationRateBps),
|
385
385
|
]
|
386
386
|
: []),
|
387
387
|
swapIx,
|
388
|
-
client.rebalance("B", jupQuote, rebalanceType, flashLoan, targetLiqUtilizationRateBps),
|
388
|
+
client.rebalance("B", jupQuote, rebalanceType, values, flashLoan, targetLiqUtilizationRateBps),
|
389
389
|
client.flashRepay(flashLoan),
|
390
390
|
]);
|
391
391
|
}
|
@@ -394,9 +394,9 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
394
394
|
tx = tx.add([
|
395
395
|
setupInstructions,
|
396
396
|
tokenLedgerIx,
|
397
|
-
client.rebalance("A", jupQuote, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
397
|
+
client.rebalance("A", jupQuote, rebalanceType, values, undefined, targetLiqUtilizationRateBps),
|
398
398
|
swapIx,
|
399
|
-
client.rebalance("B", jupQuote, rebalanceType, undefined, targetLiqUtilizationRateBps),
|
399
|
+
client.rebalance("B", jupQuote, rebalanceType, values, undefined, targetLiqUtilizationRateBps),
|
400
400
|
]);
|
401
401
|
}
|
402
402
|
return {
|
@@ -6,7 +6,7 @@ export declare function toBps(value: number): number;
|
|
6
6
|
export declare function bytesToI80F48(bytes: number[]): number;
|
7
7
|
export declare function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint;
|
8
8
|
export declare function getDebtAdjustmentUsd(liqThresholdBps: number, supplyUsd: number, debtUsd: number, targetLiqUtilizationRateBps: number, adjustmentFeeBps?: number): number;
|
9
|
-
export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number): {
|
9
|
+
export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number, rebalanceDirection: "boost" | "repay"): {
|
10
10
|
solauto: number;
|
11
11
|
referrer: number;
|
12
12
|
total: number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAA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Rate * (1 - adjustmentFee) * liqThreshold);
|
67
67
|
return debtAdjustmentUsd;
|
68
68
|
}
|
69
|
-
function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetWorthUsd) {
|
69
|
+
function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetWorthUsd, rebalanceDirection) {
|
70
70
|
const minSize = 10000; // Minimum position size
|
71
71
|
const maxSize = 500000; // Maximum position size
|
72
72
|
const maxFeeBps = 200; // Fee in basis points for minSize (2%)
|
73
73
|
const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
|
74
74
|
const k = 1.5;
|
75
75
|
let feeBps = 0;
|
76
|
-
if (targetLiqUtilizationRateBps !== undefined) {
|
76
|
+
if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
|
77
77
|
feeBps = 25;
|
78
78
|
}
|
79
79
|
else if (positionNetWorthUsd <= minSize) {
|
@@ -3,6 +3,7 @@ import { SolautoClient } from "../../clients/solautoClient";
|
|
3
3
|
import { DCASettings, PositionState, SolautoSettingsParameters, TokenType } from "../../generated";
|
4
4
|
import { QuoteResponse } from "@jup-ag/api";
|
5
5
|
import { JupSwapDetails } from "../jupiterUtils";
|
6
|
+
import { RebalanceAction } from "../../types";
|
6
7
|
export interface RebalanceValues {
|
7
8
|
increasingLeverage: boolean;
|
8
9
|
debtAdjustmentUsd: number;
|
@@ -10,6 +11,7 @@ export interface RebalanceValues {
|
|
10
11
|
amountToDcaIn: number;
|
11
12
|
amountUsdToDcaIn: number;
|
12
13
|
dcaTokenType?: TokenType;
|
14
|
+
rebalanceAction: RebalanceAction;
|
13
15
|
}
|
14
16
|
export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
|
15
17
|
export interface FlashLoanDetails {
|
@@ -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;AAajD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkI9C,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;IACzB,eAAe,EAAE,eAAe,CAAC;CAClC;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,GACnC,eAAe,CAiDjB;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,GACtB,gBAAgB,GAAG,SAAS,CA0D9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
|
@@ -84,10 +84,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
84
84
|
const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
85
85
|
(dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
|
86
86
|
const increasingLeverage = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
|
87
|
-
|
88
|
-
if (increasingLeverage) {
|
89
|
-
adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS)).total;
|
90
|
-
}
|
87
|
+
const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), increasingLeverage ? "boost" : "repay").total;
|
91
88
|
const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
|
92
89
|
amountUsdToDcaIn;
|
93
90
|
const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
|
@@ -100,6 +97,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
100
97
|
amountToDcaIn: amountToDcaIn ?? 0,
|
101
98
|
amountUsdToDcaIn,
|
102
99
|
dcaTokenType: dca?.tokenType,
|
100
|
+
rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
|
103
101
|
};
|
104
102
|
}
|
105
103
|
function getFlashLoanDetails(client, values, jupQuote) {
|
package/package.json
CHANGED
@@ -36,7 +36,7 @@ import {
|
|
36
36
|
getWrappedInstruction,
|
37
37
|
splTokenTransferUmiIx,
|
38
38
|
} from "../utils/solanaUtils";
|
39
|
-
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
39
|
+
import { FlashLoanDetails, RebalanceValues } from "../utils/solauto/rebalanceUtils";
|
40
40
|
import {
|
41
41
|
MIN_POSITION_STATE_FRESHNESS_SECS,
|
42
42
|
SOLAUTO_LUT,
|
@@ -537,6 +537,7 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
537
537
|
rebalanceStep: "A" | "B",
|
538
538
|
jupQuote: QuoteResponse,
|
539
539
|
rebalanceType: SolautoRebalanceTypeArgs,
|
540
|
+
rebalanceValues: RebalanceValues,
|
540
541
|
flashLoan?: FlashLoanDetails,
|
541
542
|
targetLiqUtilizationRateBps?: number
|
542
543
|
): TransactionBuilder;
|
@@ -32,7 +32,11 @@ import {
|
|
32
32
|
marginfiRebalance,
|
33
33
|
marginfiRefreshData,
|
34
34
|
} from "../generated";
|
35
|
-
import {
|
35
|
+
import {
|
36
|
+
getMarginfiAccountPDA,
|
37
|
+
getReferralState,
|
38
|
+
getTokenAccount,
|
39
|
+
} from "../utils/accountUtils";
|
36
40
|
import { generateRandomU64, safeGetPrice } from "../utils/generalUtils";
|
37
41
|
import {
|
38
42
|
MARGINFI_PROGRAM_ID,
|
@@ -47,7 +51,10 @@ import {
|
|
47
51
|
safeFetchAllMarginfiAccount,
|
48
52
|
safeFetchMarginfiAccount,
|
49
53
|
} from "../marginfi-sdk";
|
50
|
-
import {
|
54
|
+
import {
|
55
|
+
FlashLoanDetails,
|
56
|
+
RebalanceValues,
|
57
|
+
} from "../utils/solauto/rebalanceUtils";
|
51
58
|
import {
|
52
59
|
findMarginfiAccounts,
|
53
60
|
getAllMarginfiAccountsByAuthority,
|
@@ -449,6 +456,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
449
456
|
rebalanceStep: "A" | "B",
|
450
457
|
jupQuote: QuoteResponse,
|
451
458
|
rebalanceType: SolautoRebalanceTypeArgs,
|
459
|
+
rebalanceValues: RebalanceValues,
|
452
460
|
flashLoan?: FlashLoanDetails,
|
453
461
|
targetLiqUtilizationRateBps?: number
|
454
462
|
): TransactionBuilder {
|
@@ -473,13 +481,14 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
473
481
|
ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
|
474
482
|
solautoFeesSupplyTa:
|
475
483
|
rebalanceStep === "B" ? publicKey(this.solautoFeesSupplyTa) : undefined,
|
476
|
-
authorityReferralState: publicKey(
|
477
|
-
this.referralState
|
478
|
-
),
|
484
|
+
authorityReferralState: publicKey(this.referralState),
|
479
485
|
referredBySupplyTa: this.referredBySupplyTa()
|
480
486
|
? publicKey(this.referredBySupplyTa()!)
|
481
487
|
: undefined,
|
482
|
-
positionAuthority:
|
488
|
+
positionAuthority:
|
489
|
+
rebalanceValues.rebalanceAction === "dca"
|
490
|
+
? publicKey(this.authority)
|
491
|
+
: undefined,
|
483
492
|
solautoPosition: publicKey(this.solautoPosition),
|
484
493
|
marginfiGroup: publicKey(this.marginfiGroup),
|
485
494
|
marginfiAccount: publicKey(this.marginfiAccountPk),
|
@@ -492,9 +501,9 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
492
501
|
supplyBank: publicKey(this.marginfiSupplyAccounts.bank),
|
493
502
|
supplyPriceOracle: publicKey(this.supplyPriceOracle),
|
494
503
|
positionSupplyTa: publicKey(this.positionSupplyTa),
|
495
|
-
authoritySupplyTa:
|
496
|
-
getTokenAccount(this.authority, this.supplyMint)
|
497
|
-
|
504
|
+
authoritySupplyTa: this.selfManaged
|
505
|
+
? publicKey(getTokenAccount(this.authority, this.supplyMint))
|
506
|
+
: undefined,
|
498
507
|
vaultSupplyTa: needSupplyAccounts
|
499
508
|
? publicKey(this.marginfiSupplyAccounts.liquidityVault)
|
500
509
|
: undefined,
|
@@ -504,9 +513,9 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
504
513
|
debtBank: publicKey(this.marginfiDebtAccounts.bank),
|
505
514
|
debtPriceOracle: publicKey(this.debtPriceOracle),
|
506
515
|
positionDebtTa: publicKey(this.positionDebtTa),
|
507
|
-
authorityDebtTa:
|
508
|
-
getTokenAccount(this.authority, this.debtMint)
|
509
|
-
|
516
|
+
authorityDebtTa: this.selfManaged
|
517
|
+
? publicKey(getTokenAccount(this.authority, this.debtMint))
|
518
|
+
: undefined,
|
510
519
|
vaultDebtTa: needDebtAccounts
|
511
520
|
? publicKey(this.marginfiDebtAccounts.liquidityVault)
|
512
521
|
: undefined,
|
@@ -46,7 +46,7 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
46
46
|
solautoFeesSupplyTa?: PublicKey | Pda;
|
47
47
|
authorityReferralState: PublicKey | Pda;
|
48
48
|
referredBySupplyTa?: PublicKey | Pda;
|
49
|
-
positionAuthority
|
49
|
+
positionAuthority?: PublicKey | Pda;
|
50
50
|
solautoPosition: PublicKey | Pda;
|
51
51
|
marginfiGroup: PublicKey | Pda;
|
52
52
|
marginfiAccount: PublicKey | Pda;
|
@@ -17,6 +17,7 @@ export * from './positionState';
|
|
17
17
|
export * from './positionTokenUsage';
|
18
18
|
export * from './positionType';
|
19
19
|
export * from './rebalanceData';
|
20
|
+
export * from './rebalanceDirection';
|
20
21
|
export * from './solautoAction';
|
21
22
|
export * from './solautoRebalanceType';
|
22
23
|
export * from './solautoSettingsParameters';
|
@@ -11,20 +11,22 @@ import {
|
|
11
11
|
array,
|
12
12
|
bytes,
|
13
13
|
struct,
|
14
|
-
u16,
|
15
14
|
u64,
|
16
15
|
u8,
|
17
16
|
} from '@metaplex-foundation/umi/serializers';
|
18
17
|
import {
|
18
|
+
RebalanceDirection,
|
19
|
+
RebalanceDirectionArgs,
|
19
20
|
SolautoRebalanceType,
|
20
21
|
SolautoRebalanceTypeArgs,
|
22
|
+
getRebalanceDirectionSerializer,
|
21
23
|
getSolautoRebalanceTypeSerializer,
|
22
24
|
} from '.';
|
23
25
|
|
24
26
|
export type RebalanceData = {
|
25
27
|
rebalanceType: SolautoRebalanceType;
|
26
28
|
padding1: Array<number>;
|
27
|
-
|
29
|
+
rebalanceDirection: RebalanceDirection;
|
28
30
|
padding2: Array<number>;
|
29
31
|
flashLoanAmount: bigint;
|
30
32
|
padding: Uint8Array;
|
@@ -33,7 +35,7 @@ export type RebalanceData = {
|
|
33
35
|
export type RebalanceDataArgs = {
|
34
36
|
rebalanceType: SolautoRebalanceTypeArgs;
|
35
37
|
padding1: Array<number>;
|
36
|
-
|
38
|
+
rebalanceDirection: RebalanceDirectionArgs;
|
37
39
|
padding2: Array<number>;
|
38
40
|
flashLoanAmount: number | bigint;
|
39
41
|
padding: Uint8Array;
|
@@ -47,8 +49,8 @@ export function getRebalanceDataSerializer(): Serializer<
|
|
47
49
|
[
|
48
50
|
['rebalanceType', getSolautoRebalanceTypeSerializer()],
|
49
51
|
['padding1', array(u8(), { size: 7 })],
|
50
|
-
['
|
51
|
-
['padding2', array(u8(), { size:
|
52
|
+
['rebalanceDirection', getRebalanceDirectionSerializer()],
|
53
|
+
['padding2', array(u8(), { size: 7 })],
|
52
54
|
['flashLoanAmount', u64()],
|
53
55
|
['padding', bytes({ size: 32 })],
|
54
56
|
],
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* This code was AUTOGENERATED using the kinobi library.
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
4
|
+
* to add features, then rerun kinobi to update it.
|
5
|
+
*
|
6
|
+
* @see https://github.com/metaplex-foundation/kinobi
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers';
|
10
|
+
|
11
|
+
export enum RebalanceDirection {
|
12
|
+
Boost,
|
13
|
+
Repay,
|
14
|
+
}
|
15
|
+
|
16
|
+
export type RebalanceDirectionArgs = RebalanceDirection;
|
17
|
+
|
18
|
+
export function getRebalanceDirectionSerializer(): Serializer<
|
19
|
+
RebalanceDirectionArgs,
|
20
|
+
RebalanceDirection
|
21
|
+
> {
|
22
|
+
return scalarEnum<RebalanceDirection>(RebalanceDirection, {
|
23
|
+
description: 'RebalanceDirection',
|
24
|
+
}) as Serializer<RebalanceDirectionArgs, RebalanceDirection>;
|
25
|
+
}
|
@@ -706,6 +706,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
706
706
|
"A",
|
707
707
|
jupQuote,
|
708
708
|
rebalanceType,
|
709
|
+
values,
|
709
710
|
flashLoan,
|
710
711
|
targetLiqUtilizationRateBps
|
711
712
|
),
|
@@ -716,6 +717,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
716
717
|
"B",
|
717
718
|
jupQuote,
|
718
719
|
rebalanceType,
|
720
|
+
values,
|
719
721
|
flashLoan,
|
720
722
|
targetLiqUtilizationRateBps
|
721
723
|
),
|
@@ -730,6 +732,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
730
732
|
"A",
|
731
733
|
jupQuote,
|
732
734
|
rebalanceType,
|
735
|
+
values,
|
733
736
|
undefined,
|
734
737
|
targetLiqUtilizationRateBps
|
735
738
|
),
|
@@ -738,6 +741,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
738
741
|
"B",
|
739
742
|
jupQuote,
|
740
743
|
rebalanceType,
|
744
|
+
values,
|
741
745
|
undefined,
|
742
746
|
targetLiqUtilizationRateBps
|
743
747
|
),
|
package/src/utils/numberUtils.ts
CHANGED
@@ -89,7 +89,8 @@ export function getDebtAdjustmentUsd(
|
|
89
89
|
export function getSolautoFeesBps(
|
90
90
|
isReferred: boolean,
|
91
91
|
targetLiqUtilizationRateBps: number | undefined,
|
92
|
-
positionNetWorthUsd: number
|
92
|
+
positionNetWorthUsd: number,
|
93
|
+
rebalanceDirection: "boost" | "repay"
|
93
94
|
): {
|
94
95
|
solauto: number;
|
95
96
|
referrer: number;
|
@@ -103,7 +104,7 @@ export function getSolautoFeesBps(
|
|
103
104
|
|
104
105
|
let feeBps: number = 0;
|
105
106
|
|
106
|
-
if (targetLiqUtilizationRateBps !== undefined) {
|
107
|
+
if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
|
107
108
|
feeBps = 25;
|
108
109
|
} else if (positionNetWorthUsd <= minSize) {
|
109
110
|
feeBps = maxFeeBps;
|
@@ -27,6 +27,7 @@ import {
|
|
27
27
|
toBaseUnit,
|
28
28
|
} from "../numberUtils";
|
29
29
|
import { USD_DECIMALS } from "../../constants/generalAccounts";
|
30
|
+
import { RebalanceAction } from "../../types";
|
30
31
|
|
31
32
|
function getAdditionalAmountToDcaIn(dca: DCASettings): number {
|
32
33
|
if (dca.dcaInBaseUnit === BigInt(0)) {
|
@@ -163,6 +164,7 @@ export interface RebalanceValues {
|
|
163
164
|
amountToDcaIn: number;
|
164
165
|
amountUsdToDcaIn: number;
|
165
166
|
dcaTokenType?: TokenType;
|
167
|
+
rebalanceAction: RebalanceAction;
|
166
168
|
}
|
167
169
|
|
168
170
|
export function getRebalanceValues(
|
@@ -188,14 +190,12 @@ export function getRebalanceValues(
|
|
188
190
|
|
189
191
|
const increasingLeverage =
|
190
192
|
amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
).total;
|
198
|
-
}
|
193
|
+
const adjustmentFeeBps = getSolautoFeesBps(
|
194
|
+
false,
|
195
|
+
targetLiqUtilizationRateBps,
|
196
|
+
fromBaseUnit(state.netWorth.baseAmountUsdValue, USD_DECIMALS),
|
197
|
+
increasingLeverage ? "boost" : "repay"
|
198
|
+
).total;
|
199
199
|
|
200
200
|
const supplyUsd =
|
201
201
|
fromBaseUnit(state.supply.amountUsed.baseAmountUsdValue, USD_DECIMALS) +
|
@@ -221,6 +221,8 @@ export function getRebalanceValues(
|
|
221
221
|
amountToDcaIn: amountToDcaIn ?? 0,
|
222
222
|
amountUsdToDcaIn,
|
223
223
|
dcaTokenType: dca?.tokenType,
|
224
|
+
rebalanceAction:
|
225
|
+
(amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
|
224
226
|
};
|
225
227
|
}
|
226
228
|
|
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
DCASettings,
|
12
12
|
LendingPlatform,
|
13
13
|
PositionType,
|
14
|
+
RebalanceDirection,
|
14
15
|
SolautoRebalanceType,
|
15
16
|
SolautoSettingsParameters,
|
16
17
|
TokenType,
|
@@ -64,7 +65,8 @@ function assertAccurateRebalance(
|
|
64
65
|
fromBaseUnit(
|
65
66
|
client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
66
67
|
USD_DECIMALS
|
67
|
-
)
|
68
|
+
),
|
69
|
+
increasingLeverage ? "boost" : "repay"
|
68
70
|
).total;
|
69
71
|
}
|
70
72
|
|
@@ -174,7 +176,7 @@ async function getFakePosition(
|
|
174
176
|
state: client.solautoPositionState!,
|
175
177
|
rebalance: {
|
176
178
|
rebalanceType: SolautoRebalanceType.Regular,
|
177
|
-
|
179
|
+
rebalanceDirection: RebalanceDirection.Boost,
|
178
180
|
flashLoanAmount: BigInt(0),
|
179
181
|
padding1: [],
|
180
182
|
padding2: [],
|