@haven-fi/solauto-sdk 1.0.151 → 1.0.153
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +2 -0
- package/dist/generated/instructions/marginfiRebalance.d.ts +3 -0
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.js +22 -16
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +1 -0
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +0 -1
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +3 -1
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +2 -0
- package/src/generated/instructions/marginfiRebalance.ts +26 -16
- package/src/transactions/transactionUtils.ts +1 -0
- package/src/utils/generalUtils.ts +0 -1
- package/src/utils/solauto/rebalanceUtils.ts +3 -1
@@ -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;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAW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AAS,CAAC;IAG5B,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAmE1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAU/B,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA4DrB,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;CA4BlE"}
|
@@ -287,6 +287,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
287
287
|
referredBySupplyTa: this.referredBySupplyTa
|
288
288
|
? (0, umi_1.publicKey)(this.referredBySupplyTa)
|
289
289
|
: undefined,
|
290
|
+
positionAuthority: (0, umi_1.publicKey)(this.authority),
|
290
291
|
solautoPosition: (0, umi_1.publicKey)(this.solautoPosition),
|
291
292
|
marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
|
292
293
|
marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
|
@@ -313,6 +314,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
313
314
|
: undefined,
|
314
315
|
rebalanceType,
|
315
316
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
317
|
+
targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
|
316
318
|
limitGapBps: limitGapBps ?? null,
|
317
319
|
slippageBps: slippageBps ?? 0
|
318
320
|
});
|
@@ -17,6 +17,7 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
17
17
|
solautoFeesSupplyTa?: PublicKey | Pda;
|
18
18
|
authorityReferralState: PublicKey | Pda;
|
19
19
|
referredBySupplyTa?: PublicKey | Pda;
|
20
|
+
positionAuthority: PublicKey | Pda;
|
20
21
|
solautoPosition: PublicKey | Pda;
|
21
22
|
marginfiGroup: PublicKey | Pda;
|
22
23
|
marginfiAccount: PublicKey | Pda;
|
@@ -39,12 +40,14 @@ export type MarginfiRebalanceInstructionData = {
|
|
39
40
|
slippageBps: number;
|
40
41
|
rebalanceType: SolautoRebalanceType;
|
41
42
|
targetLiqUtilizationRateBps: Option<number>;
|
43
|
+
targetInAmountBaseUnit: Option<bigint>;
|
42
44
|
limitGapBps: Option<number>;
|
43
45
|
};
|
44
46
|
export type MarginfiRebalanceInstructionDataArgs = {
|
45
47
|
slippageBps: number;
|
46
48
|
rebalanceType: SolautoRebalanceTypeArgs;
|
47
49
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
50
|
+
targetInAmountBaseUnit: OptionOrNullable<number | bigint>;
|
48
51
|
limitGapBps: OptionOrNullable<number>;
|
49
52
|
};
|
50
53
|
export declare function getMarginfiRebalanceInstructionDataSerializer(): Serializer<MarginfiRebalanceInstructionDataArgs, MarginfiRebalanceInstructionData>;
|
@@ -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,
|
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,c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CAAoC,EACpC,gCAAgC,CACjC,CAsBA;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"}
|
@@ -19,6 +19,7 @@ function getMarginfiRebalanceInstructionDataSerializer() {
|
|
19
19
|
['slippageBps', (0, serializers_1.u16)()],
|
20
20
|
['rebalanceType', (0, types_1.getSolautoRebalanceTypeSerializer)()],
|
21
21
|
['targetLiqUtilizationRateBps', (0, serializers_1.option)((0, serializers_1.u16)())],
|
22
|
+
['targetInAmountBaseUnit', (0, serializers_1.option)((0, serializers_1.u64)())],
|
22
23
|
['limitGapBps', (0, serializers_1.option)((0, serializers_1.u16)())],
|
23
24
|
], { description: 'MarginfiRebalanceInstructionData' }), (value) => ({ ...value, discriminator: 9 }));
|
24
25
|
}
|
@@ -68,83 +69,88 @@ function marginfiRebalance(context, input) {
|
|
68
69
|
isWritable: true,
|
69
70
|
value: input.referredBySupplyTa ?? null,
|
70
71
|
},
|
71
|
-
|
72
|
+
positionAuthority: {
|
72
73
|
index: 8,
|
73
74
|
isWritable: true,
|
75
|
+
value: input.positionAuthority ?? null,
|
76
|
+
},
|
77
|
+
solautoPosition: {
|
78
|
+
index: 9,
|
79
|
+
isWritable: true,
|
74
80
|
value: input.solautoPosition ?? null,
|
75
81
|
},
|
76
82
|
marginfiGroup: {
|
77
|
-
index:
|
83
|
+
index: 10,
|
78
84
|
isWritable: false,
|
79
85
|
value: input.marginfiGroup ?? null,
|
80
86
|
},
|
81
87
|
marginfiAccount: {
|
82
|
-
index:
|
88
|
+
index: 11,
|
83
89
|
isWritable: true,
|
84
90
|
value: input.marginfiAccount ?? null,
|
85
91
|
},
|
86
92
|
intermediaryTa: {
|
87
|
-
index:
|
93
|
+
index: 12,
|
88
94
|
isWritable: true,
|
89
95
|
value: input.intermediaryTa ?? null,
|
90
96
|
},
|
91
97
|
supplyBank: {
|
92
|
-
index:
|
98
|
+
index: 13,
|
93
99
|
isWritable: true,
|
94
100
|
value: input.supplyBank ?? null,
|
95
101
|
},
|
96
102
|
supplyPriceOracle: {
|
97
|
-
index:
|
103
|
+
index: 14,
|
98
104
|
isWritable: false,
|
99
105
|
value: input.supplyPriceOracle ?? null,
|
100
106
|
},
|
101
107
|
positionSupplyTa: {
|
102
|
-
index:
|
108
|
+
index: 15,
|
103
109
|
isWritable: true,
|
104
110
|
value: input.positionSupplyTa ?? null,
|
105
111
|
},
|
106
112
|
authoritySupplyTa: {
|
107
|
-
index:
|
113
|
+
index: 16,
|
108
114
|
isWritable: true,
|
109
115
|
value: input.authoritySupplyTa ?? null,
|
110
116
|
},
|
111
117
|
vaultSupplyTa: {
|
112
|
-
index:
|
118
|
+
index: 17,
|
113
119
|
isWritable: true,
|
114
120
|
value: input.vaultSupplyTa ?? null,
|
115
121
|
},
|
116
122
|
supplyVaultAuthority: {
|
117
|
-
index:
|
123
|
+
index: 18,
|
118
124
|
isWritable: true,
|
119
125
|
value: input.supplyVaultAuthority ?? null,
|
120
126
|
},
|
121
127
|
debtBank: {
|
122
|
-
index:
|
128
|
+
index: 19,
|
123
129
|
isWritable: true,
|
124
130
|
value: input.debtBank ?? null,
|
125
131
|
},
|
126
132
|
debtPriceOracle: {
|
127
|
-
index:
|
133
|
+
index: 20,
|
128
134
|
isWritable: false,
|
129
135
|
value: input.debtPriceOracle ?? null,
|
130
136
|
},
|
131
137
|
positionDebtTa: {
|
132
|
-
index:
|
138
|
+
index: 21,
|
133
139
|
isWritable: true,
|
134
140
|
value: input.positionDebtTa ?? null,
|
135
141
|
},
|
136
142
|
authorityDebtTa: {
|
137
|
-
index:
|
143
|
+
index: 22,
|
138
144
|
isWritable: true,
|
139
145
|
value: input.authorityDebtTa ?? null,
|
140
146
|
},
|
141
147
|
vaultDebtTa: {
|
142
|
-
index:
|
148
|
+
index: 23,
|
143
149
|
isWritable: true,
|
144
150
|
value: input.vaultDebtTa ?? null,
|
145
151
|
},
|
146
152
|
debtVaultAuthority: {
|
147
|
-
index:
|
153
|
+
index: 24,
|
148
154
|
isWritable: true,
|
149
155
|
value: input.debtVaultAuthority ?? null,
|
150
156
|
},
|
@@ -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;AAoLD,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,CA6HA;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"}
|
@@ -187,6 +187,7 @@ function getRebalanceInstructions(tx) {
|
|
187
187
|
const discriminator = serializer.serialize({
|
188
188
|
slippageBps: 0,
|
189
189
|
limitGapBps: 0,
|
190
|
+
targetInAmountBaseUnit: 0,
|
190
191
|
rebalanceType: generated_1.SolautoRebalanceType.None,
|
191
192
|
targetLiqUtilizationRateBps: 0,
|
192
193
|
})[0];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKtG,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC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E9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAqChB"}
|
@@ -167,6 +167,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
167
167
|
: (0, generalUtils_2.safeGetPrice)(client.supplyMint);
|
168
168
|
const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / inputPrice, input.decimals);
|
169
169
|
const exactOut = targetLiqUtilizationRateBps === 0;
|
170
|
+
const exactIn = !exactOut && targetLiqUtilizationRateBps !== undefined;
|
170
171
|
return {
|
171
172
|
inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
|
172
173
|
outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
|
@@ -177,7 +178,8 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
177
178
|
BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
|
178
179
|
// Add this small percentage to account for the APR on the debt between now and the transaction
|
179
180
|
0.0001))
|
180
|
-
:
|
181
|
+
: inputAmount,
|
182
|
+
exactIn: exactIn,
|
181
183
|
exactOut: exactOut,
|
182
184
|
};
|
183
185
|
}
|
package/package.json
CHANGED
@@ -457,6 +457,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
457
457
|
referredBySupplyTa: this.referredBySupplyTa
|
458
458
|
? publicKey(this.referredBySupplyTa)
|
459
459
|
: undefined,
|
460
|
+
positionAuthority: publicKey(this.authority),
|
460
461
|
solautoPosition: publicKey(this.solautoPosition),
|
461
462
|
marginfiGroup: publicKey(this.marginfiGroup),
|
462
463
|
marginfiAccount: publicKey(this.marginfiAccountPk),
|
@@ -488,6 +489,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
488
489
|
: undefined,
|
489
490
|
rebalanceType,
|
490
491
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
492
|
+
targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
|
491
493
|
limitGapBps: limitGapBps ?? null,
|
492
494
|
slippageBps: slippageBps ?? 0
|
493
495
|
});
|
@@ -22,6 +22,7 @@ import {
|
|
22
22
|
option,
|
23
23
|
struct,
|
24
24
|
u16,
|
25
|
+
u64,
|
25
26
|
u8,
|
26
27
|
} from '@metaplex-foundation/umi/serializers';
|
27
28
|
import {
|
@@ -45,6 +46,7 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
45
46
|
solautoFeesSupplyTa?: PublicKey | Pda;
|
46
47
|
authorityReferralState: PublicKey | Pda;
|
47
48
|
referredBySupplyTa?: PublicKey | Pda;
|
49
|
+
positionAuthority: PublicKey | Pda;
|
48
50
|
solautoPosition: PublicKey | Pda;
|
49
51
|
marginfiGroup: PublicKey | Pda;
|
50
52
|
marginfiAccount: PublicKey | Pda;
|
@@ -69,6 +71,7 @@ export type MarginfiRebalanceInstructionData = {
|
|
69
71
|
slippageBps: number;
|
70
72
|
rebalanceType: SolautoRebalanceType;
|
71
73
|
targetLiqUtilizationRateBps: Option<number>;
|
74
|
+
targetInAmountBaseUnit: Option<bigint>;
|
72
75
|
limitGapBps: Option<number>;
|
73
76
|
};
|
74
77
|
|
@@ -76,6 +79,7 @@ export type MarginfiRebalanceInstructionDataArgs = {
|
|
76
79
|
slippageBps: number;
|
77
80
|
rebalanceType: SolautoRebalanceTypeArgs;
|
78
81
|
targetLiqUtilizationRateBps: OptionOrNullable<number>;
|
82
|
+
targetInAmountBaseUnit: OptionOrNullable<number | bigint>;
|
79
83
|
limitGapBps: OptionOrNullable<number>;
|
80
84
|
};
|
81
85
|
|
@@ -94,6 +98,7 @@ export function getMarginfiRebalanceInstructionDataSerializer(): Serializer<
|
|
94
98
|
['slippageBps', u16()],
|
95
99
|
['rebalanceType', getSolautoRebalanceTypeSerializer()],
|
96
100
|
['targetLiqUtilizationRateBps', option(u16())],
|
101
|
+
['targetInAmountBaseUnit', option(u64())],
|
97
102
|
['limitGapBps', option(u16())],
|
98
103
|
],
|
99
104
|
{ description: 'MarginfiRebalanceInstructionData' }
|
@@ -162,83 +167,88 @@ export function marginfiRebalance(
|
|
162
167
|
isWritable: true as boolean,
|
163
168
|
value: input.referredBySupplyTa ?? null,
|
164
169
|
},
|
165
|
-
|
170
|
+
positionAuthority: {
|
166
171
|
index: 8,
|
167
172
|
isWritable: true as boolean,
|
173
|
+
value: input.positionAuthority ?? null,
|
174
|
+
},
|
175
|
+
solautoPosition: {
|
176
|
+
index: 9,
|
177
|
+
isWritable: true as boolean,
|
168
178
|
value: input.solautoPosition ?? null,
|
169
179
|
},
|
170
180
|
marginfiGroup: {
|
171
|
-
index:
|
181
|
+
index: 10,
|
172
182
|
isWritable: false as boolean,
|
173
183
|
value: input.marginfiGroup ?? null,
|
174
184
|
},
|
175
185
|
marginfiAccount: {
|
176
|
-
index:
|
186
|
+
index: 11,
|
177
187
|
isWritable: true as boolean,
|
178
188
|
value: input.marginfiAccount ?? null,
|
179
189
|
},
|
180
190
|
intermediaryTa: {
|
181
|
-
index:
|
191
|
+
index: 12,
|
182
192
|
isWritable: true as boolean,
|
183
193
|
value: input.intermediaryTa ?? null,
|
184
194
|
},
|
185
195
|
supplyBank: {
|
186
|
-
index:
|
196
|
+
index: 13,
|
187
197
|
isWritable: true as boolean,
|
188
198
|
value: input.supplyBank ?? null,
|
189
199
|
},
|
190
200
|
supplyPriceOracle: {
|
191
|
-
index:
|
201
|
+
index: 14,
|
192
202
|
isWritable: false as boolean,
|
193
203
|
value: input.supplyPriceOracle ?? null,
|
194
204
|
},
|
195
205
|
positionSupplyTa: {
|
196
|
-
index:
|
206
|
+
index: 15,
|
197
207
|
isWritable: true as boolean,
|
198
208
|
value: input.positionSupplyTa ?? null,
|
199
209
|
},
|
200
210
|
authoritySupplyTa: {
|
201
|
-
index:
|
211
|
+
index: 16,
|
202
212
|
isWritable: true as boolean,
|
203
213
|
value: input.authoritySupplyTa ?? null,
|
204
214
|
},
|
205
215
|
vaultSupplyTa: {
|
206
|
-
index:
|
216
|
+
index: 17,
|
207
217
|
isWritable: true as boolean,
|
208
218
|
value: input.vaultSupplyTa ?? null,
|
209
219
|
},
|
210
220
|
supplyVaultAuthority: {
|
211
|
-
index:
|
221
|
+
index: 18,
|
212
222
|
isWritable: true as boolean,
|
213
223
|
value: input.supplyVaultAuthority ?? null,
|
214
224
|
},
|
215
225
|
debtBank: {
|
216
|
-
index:
|
226
|
+
index: 19,
|
217
227
|
isWritable: true as boolean,
|
218
228
|
value: input.debtBank ?? null,
|
219
229
|
},
|
220
230
|
debtPriceOracle: {
|
221
|
-
index:
|
231
|
+
index: 20,
|
222
232
|
isWritable: false as boolean,
|
223
233
|
value: input.debtPriceOracle ?? null,
|
224
234
|
},
|
225
235
|
positionDebtTa: {
|
226
|
-
index:
|
236
|
+
index: 21,
|
227
237
|
isWritable: true as boolean,
|
228
238
|
value: input.positionDebtTa ?? null,
|
229
239
|
},
|
230
240
|
authorityDebtTa: {
|
231
|
-
index:
|
241
|
+
index: 22,
|
232
242
|
isWritable: true as boolean,
|
233
243
|
value: input.authorityDebtTa ?? null,
|
234
244
|
},
|
235
245
|
vaultDebtTa: {
|
236
|
-
index:
|
246
|
+
index: 23,
|
237
247
|
isWritable: true as boolean,
|
238
248
|
value: input.vaultDebtTa ?? null,
|
239
249
|
},
|
240
250
|
debtVaultAuthority: {
|
241
|
-
index:
|
251
|
+
index: 24,
|
242
252
|
isWritable: true as boolean,
|
243
253
|
value: input.debtVaultAuthority ?? null,
|
244
254
|
},
|
@@ -392,6 +392,7 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
|
392
392
|
const discriminator = serializer.serialize({
|
393
393
|
slippageBps: 0,
|
394
394
|
limitGapBps: 0,
|
395
|
+
targetInAmountBaseUnit: 0,
|
395
396
|
rebalanceType: SolautoRebalanceType.None,
|
396
397
|
targetLiqUtilizationRateBps: 0,
|
397
398
|
})[0];
|
@@ -75,7 +75,6 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
75
75
|
|
76
76
|
const json = await resp.json();
|
77
77
|
const prices = json.parsed.map((x: any) => {
|
78
|
-
console.log(x);
|
79
78
|
if (x.price.expo > 0) {
|
80
79
|
return Number(toBaseUnit(Number(x.price.price), x.price.expo));
|
81
80
|
} else if (x.price.expo < 0) {
|
@@ -343,6 +343,7 @@ export function getJupSwapRebalanceDetails(
|
|
343
343
|
const inputAmount = toBaseUnit(usdToSwap / inputPrice!, input.decimals);
|
344
344
|
|
345
345
|
const exactOut = targetLiqUtilizationRateBps === 0;
|
346
|
+
const exactIn = !exactOut && targetLiqUtilizationRateBps !== undefined;
|
346
347
|
|
347
348
|
return {
|
348
349
|
inputMint: toWeb3JsPublicKey(input.mint),
|
@@ -358,7 +359,8 @@ export function getJupSwapRebalanceDetails(
|
|
358
359
|
0.0001
|
359
360
|
)
|
360
361
|
)
|
361
|
-
:
|
362
|
+
: inputAmount,
|
363
|
+
exactIn: exactIn,
|
362
364
|
exactOut: exactOut,
|
363
365
|
};
|
364
366
|
}
|