@haven-fi/solauto-sdk 1.0.566 → 1.0.568
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/solautoMarginfiClient.d.ts +1 -0
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +11 -0
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +27 -2
- package/src/utils/jupiterUtils.ts +0 -1
- package/tests/transactions/solautoMarginfi.ts +184 -13
@@ -43,6 +43,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
|
|
43
43
|
rebalance(rebalanceStep: "A" | "B", jupQuote: QuoteResponse, rebalanceType: SolautoRebalanceTypeArgs, rebalanceValues: RebalanceValues, flashLoan?: FlashLoanDetails, targetLiqUtilizationRateBps?: number): TransactionBuilder;
|
44
44
|
flashBorrow(rebalanceType: SolautoRebalanceType, flashLoanDetails: FlashLoanDetails, destinationTokenAccount: PublicKey): TransactionBuilder;
|
45
45
|
flashRepay(flashLoanDetails: FlashLoanDetails): TransactionBuilder;
|
46
|
+
closeBalance(marginfiAccount: PublicKey, bank: PublicKey): TransactionBuilder;
|
46
47
|
getFreshPositionState(): Promise<PositionState | undefined>;
|
47
48
|
supplyLiquidityAvailable(): bigint;
|
48
49
|
supplyLiquidityDepositable(): bigint;
|
@@ -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;AAM1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D,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAmDjE,wBAAwB,IAAI,MAAM;IAIlC,0BAA0B,IAAI,MAAM;IAIpC,sBAAsB,IAAI,MAAM;CAGjC"}
|
@@ -454,11 +454,22 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
454
454
|
signer: this.signer,
|
455
455
|
signerTokenAccount: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), flashLoanDetails.mint)),
|
456
456
|
}))
|
457
|
+
.add((this.intermediaryMarginfiAccount?.lendingAccount.balances ?? [])
|
458
|
+
.filter((x) => x.active && (0, numberUtils_1.bytesToI80F48)(x.liabilityShares.value) > 0)
|
459
|
+
.map((x) => this.closeBalance(this.intermediaryMarginfiAccountPk, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.bankPk))))
|
457
460
|
.add((0, marginfi_sdk_1.lendingAccountEndFlashloan)(this.umi, {
|
458
461
|
marginfiAccount: (0, umi_1.publicKey)(this.intermediaryMarginfiAccountPk),
|
459
462
|
signer: this.signer,
|
460
463
|
}).addRemainingAccounts(remainingAccounts));
|
461
464
|
}
|
465
|
+
closeBalance(marginfiAccount, bank) {
|
466
|
+
return (0, umi_1.transactionBuilder)().add((0, marginfi_sdk_1.lendingAccountCloseBalance)(this.umi, {
|
467
|
+
signer: this.signer,
|
468
|
+
marginfiAccount: (0, umi_1.publicKey)(marginfiAccount),
|
469
|
+
bank: (0, umi_1.publicKey)(bank),
|
470
|
+
marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
|
471
|
+
}));
|
472
|
+
}
|
462
473
|
async getFreshPositionState() {
|
463
474
|
const state = await super.getFreshPositionState();
|
464
475
|
if (state) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAA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B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA2F7B;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,SAAS,EAAE,EAClB,oBAAoB,CAAC,EAAE,OAAO;;GAwC/B"}
|
package/package.json
CHANGED
@@ -40,6 +40,7 @@ import {
|
|
40
40
|
MARGINFI_PROGRAM_ID,
|
41
41
|
MarginfiAccount,
|
42
42
|
lendingAccountBorrow,
|
43
|
+
lendingAccountCloseBalance,
|
43
44
|
lendingAccountDeposit,
|
44
45
|
lendingAccountEndFlashloan,
|
45
46
|
lendingAccountRepay,
|
@@ -61,7 +62,7 @@ import {
|
|
61
62
|
getMarginfiMaxLtvAndLiqThreshold,
|
62
63
|
marginfiAccountEmpty,
|
63
64
|
} from "../utils/marginfiUtils";
|
64
|
-
import { fromBaseUnit, toBps } from "../utils/numberUtils";
|
65
|
+
import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
|
65
66
|
import { QuoteResponse } from "@jup-ag/api";
|
66
67
|
import { consoleLog, safeGetPrice, splTokenTransferUmiIx } from "../utils";
|
67
68
|
|
@@ -584,7 +585,10 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
584
585
|
return transactionBuilder().add(
|
585
586
|
splTokenTransferUmiIx(
|
586
587
|
this.signer,
|
587
|
-
getTokenAccount(
|
588
|
+
getTokenAccount(
|
589
|
+
toWeb3JsPublicKey(this.signer.publicKey),
|
590
|
+
this.debtMint
|
591
|
+
),
|
588
592
|
destinationTokenAccount,
|
589
593
|
toWeb3JsPublicKey(this.signer.publicKey),
|
590
594
|
flashLoanDetails.baseUnitAmount
|
@@ -701,6 +705,16 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
701
705
|
),
|
702
706
|
})
|
703
707
|
)
|
708
|
+
.add(
|
709
|
+
(this.intermediaryMarginfiAccount?.lendingAccount.balances ?? [])
|
710
|
+
.filter((x) => x.active && bytesToI80F48(x.liabilityShares.value) > 0)
|
711
|
+
.map((x) =>
|
712
|
+
this.closeBalance(
|
713
|
+
this.intermediaryMarginfiAccountPk,
|
714
|
+
toWeb3JsPublicKey(x.bankPk)
|
715
|
+
)
|
716
|
+
)
|
717
|
+
)
|
704
718
|
.add(
|
705
719
|
lendingAccountEndFlashloan(this.umi, {
|
706
720
|
marginfiAccount: publicKey(this.intermediaryMarginfiAccountPk),
|
@@ -709,6 +723,17 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
709
723
|
);
|
710
724
|
}
|
711
725
|
|
726
|
+
closeBalance(marginfiAccount: PublicKey, bank: PublicKey) {
|
727
|
+
return transactionBuilder().add(
|
728
|
+
lendingAccountCloseBalance(this.umi, {
|
729
|
+
signer: this.signer,
|
730
|
+
marginfiAccount: publicKey(marginfiAccount),
|
731
|
+
bank: publicKey(bank),
|
732
|
+
marginfiGroup: publicKey(this.marginfiGroup),
|
733
|
+
})
|
734
|
+
);
|
735
|
+
}
|
736
|
+
|
712
737
|
async getFreshPositionState(): Promise<PositionState | undefined> {
|
713
738
|
const state = await super.getFreshPositionState();
|
714
739
|
if (state) {
|
@@ -1,9 +1,17 @@
|
|
1
1
|
import { describe, it } from "mocha";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
none,
|
4
|
+
publicKey,
|
5
|
+
some,
|
6
|
+
transactionBuilder,
|
7
|
+
Umi,
|
8
|
+
} from "@metaplex-foundation/umi";
|
3
9
|
import { setupTest } from "../shared";
|
4
10
|
import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
|
5
11
|
import {
|
12
|
+
fetchSolautoPosition,
|
6
13
|
PositionType,
|
14
|
+
safeFetchAllSolautoPosition,
|
7
15
|
safeFetchSolautoPosition,
|
8
16
|
solautoAction,
|
9
17
|
SolautoSettingsParametersInpArgs,
|
@@ -27,6 +35,8 @@ import { PublicKey } from "@solana/web3.js";
|
|
27
35
|
import {
|
28
36
|
DEFAULT_MARGINFI_GROUP,
|
29
37
|
MARGINFI_ACCOUNTS,
|
38
|
+
POPCAT,
|
39
|
+
RETARDIO,
|
30
40
|
SOLAUTO_PROD_PROGRAM,
|
31
41
|
SOLAUTO_TEST_PROGRAM,
|
32
42
|
USDC,
|
@@ -34,22 +44,120 @@ import {
|
|
34
44
|
} from "../../src/constants";
|
35
45
|
import {
|
36
46
|
buildHeliusApiUrl,
|
47
|
+
fetchTokenPrices,
|
37
48
|
getAllPositionsByAuthority,
|
49
|
+
getBankLiquidityAvailableBaseUnit,
|
38
50
|
getQnComputeUnitPriceEstimate,
|
39
51
|
getSolautoManagedPositions,
|
40
52
|
getSolautoPositionAccount,
|
41
53
|
retryWithExponentialBackoff,
|
54
|
+
safeGetPrice,
|
42
55
|
} from "../../src/utils";
|
43
56
|
import { PriorityFeeSetting } from "../../src/types";
|
44
|
-
import {
|
57
|
+
import {
|
58
|
+
buildIronforgeApiUrl,
|
59
|
+
fromBaseUnit,
|
60
|
+
tokenInfo,
|
61
|
+
USD_DECIMALS,
|
62
|
+
} from "../../dist";
|
63
|
+
import {
|
64
|
+
safeFetchBank,
|
65
|
+
safeFetchMarginfiAccount,
|
66
|
+
} from "../../src/marginfi-sdk";
|
67
|
+
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
68
|
+
|
69
|
+
async function test(
|
70
|
+
umi: Umi,
|
71
|
+
sp: PublicKey | undefined,
|
72
|
+
supplyMint: PublicKey,
|
73
|
+
sb: PublicKey,
|
74
|
+
supplyMintDecimals: number,
|
75
|
+
debtMint: PublicKey,
|
76
|
+
db: PublicKey,
|
77
|
+
debtMintDecimals: number
|
78
|
+
) {
|
79
|
+
const solautoPosition = sp
|
80
|
+
? await fetchSolautoPosition(umi, publicKey(sp))
|
81
|
+
: undefined;
|
82
|
+
|
83
|
+
const mfiAccount = solautoPosition
|
84
|
+
? await safeFetchMarginfiAccount(
|
85
|
+
umi,
|
86
|
+
solautoPosition.position.protocolUserAccount
|
87
|
+
)
|
88
|
+
: undefined;
|
89
|
+
|
90
|
+
const supplyBank = await safeFetchBank(umi, publicKey(sb));
|
91
|
+
const debtBank = await safeFetchBank(umi, publicKey(db));
|
92
|
+
|
93
|
+
await fetchTokenPrices([supplyMint, debtMint]);
|
94
|
+
|
95
|
+
console.log(supplyBank);
|
96
|
+
console.log(debtBank);
|
97
|
+
|
98
|
+
if (mfiAccount) {
|
99
|
+
console.log(mfiAccount.lendingAccount.balances);
|
100
|
+
console.log(
|
101
|
+
fromBaseUnit(
|
102
|
+
BigInt(
|
103
|
+
bytesToI80F48(
|
104
|
+
mfiAccount.lendingAccount.balances[0].assetShares.value
|
105
|
+
) * bytesToI80F48(supplyBank.assetShareValue.value)
|
106
|
+
),
|
107
|
+
supplyMintDecimals
|
108
|
+
) * safeGetPrice(supplyMint)
|
109
|
+
);
|
110
|
+
}
|
111
|
+
|
112
|
+
const imfiAccount = await safeFetchMarginfiAccount(
|
113
|
+
umi,
|
114
|
+
publicKey("E8oukAkTMW4YsAPymMzWQHWb8egmGq9yjDtmMi6gfY18")
|
115
|
+
);
|
116
|
+
|
117
|
+
console.log(
|
118
|
+
bytesToI80F48(
|
119
|
+
imfiAccount.lendingAccount.balances[0].liabilityShares.value
|
120
|
+
) *
|
121
|
+
bytesToI80F48(supplyBank.liabilityShareValue.value) *
|
122
|
+
safeGetPrice(supplyMint)
|
123
|
+
);
|
124
|
+
console.log(
|
125
|
+
bytesToI80F48(
|
126
|
+
imfiAccount.lendingAccount.balances[1].liabilityShares.value
|
127
|
+
) *
|
128
|
+
bytesToI80F48(debtBank.liabilityShareValue.value) *
|
129
|
+
safeGetPrice(debtMint)
|
130
|
+
);
|
131
|
+
|
132
|
+
console.log(
|
133
|
+
bytesToI80F48(supplyBank.totalAssetShares.value),
|
134
|
+
bytesToI80F48(supplyBank.totalLiabilityShares.value),
|
135
|
+
bytesToI80F48(supplyBank.totalAssetShares.value) -
|
136
|
+
bytesToI80F48(supplyBank.totalLiabilityShares.value),
|
137
|
+
fromBaseUnit(
|
138
|
+
getBankLiquidityAvailableBaseUnit(supplyBank, false),
|
139
|
+
supplyMintDecimals
|
140
|
+
) * safeGetPrice(supplyMint)
|
141
|
+
);
|
142
|
+
console.log(
|
143
|
+
bytesToI80F48(debtBank.totalAssetShares.value),
|
144
|
+
bytesToI80F48(debtBank.totalLiabilityShares.value),
|
145
|
+
bytesToI80F48(debtBank.totalAssetShares.value) -
|
146
|
+
bytesToI80F48(debtBank.totalLiabilityShares.value),
|
147
|
+
fromBaseUnit(
|
148
|
+
getBankLiquidityAvailableBaseUnit(debtBank, false),
|
149
|
+
debtMintDecimals
|
150
|
+
) * safeGetPrice(debtMint)
|
151
|
+
);
|
152
|
+
}
|
45
153
|
|
46
154
|
describe("Solauto Marginfi tests", async () => {
|
47
|
-
|
48
|
-
const signer = setupTest("solauto-manager");
|
155
|
+
const signer = setupTest();
|
156
|
+
// const signer = setupTest("solauto-manager");
|
49
157
|
|
50
158
|
const payForTransactions = true;
|
51
|
-
const testProgram =
|
52
|
-
const positionId =
|
159
|
+
const testProgram = true;
|
160
|
+
const positionId = 1;
|
53
161
|
|
54
162
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
55
163
|
const client = new SolautoMarginfiClient(
|
@@ -65,7 +173,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
65
173
|
await client.initialize({
|
66
174
|
signer,
|
67
175
|
positionId,
|
68
|
-
authority: new PublicKey("
|
176
|
+
// authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
|
69
177
|
// new: true,
|
70
178
|
// marginfiAccount: new PublicKey(
|
71
179
|
// ""
|
@@ -75,6 +183,41 @@ describe("Solauto Marginfi tests", async () => {
|
|
75
183
|
// debtMint: new PublicKey(USDC),
|
76
184
|
});
|
77
185
|
|
186
|
+
// await test(
|
187
|
+
// client.umi,
|
188
|
+
// undefined,
|
189
|
+
// new PublicKey(RETARDIO),
|
190
|
+
// new PublicKey("3J5rKmCi7JXG6qmiobFJyAidVTnnNAMGj4jomfBxKGRM"),
|
191
|
+
// 6,
|
192
|
+
// new PublicKey(USDC),
|
193
|
+
// new PublicKey("6cgYhBFWCc5sNHxkvSRhd5H9AdAHR41zKwuF37HmLry5"),
|
194
|
+
// 6
|
195
|
+
// );
|
196
|
+
// await test(
|
197
|
+
// client.umi,
|
198
|
+
// new PublicKey("EcdfYZCtaePaDWVy9Cz6eiS5QbLbhThau1fHLhQTEZqs"),
|
199
|
+
// new PublicKey(USDC),
|
200
|
+
// new PublicKey("EXrnNVfLagt3j4hCHSD9WqK75o6dkZBtjpnrSrSC78MA"),
|
201
|
+
// 6,
|
202
|
+
// new PublicKey(POPCAT),
|
203
|
+
// new PublicKey("845oEvt1oduoBj5zQxTr21cWWaUVnRjGerJuW3yMo2nn"),
|
204
|
+
// 9
|
205
|
+
// );
|
206
|
+
|
207
|
+
// const mfiAccount = await safeFetchMarginfiAccount(
|
208
|
+
// client.umi,
|
209
|
+
// publicKey("E8oukAkTMW4YsAPymMzWQHWb8egmGq9yjDtmMi6gfY18")
|
210
|
+
// );
|
211
|
+
// console.log(mfiAccount.lendingAccount.balances);
|
212
|
+
// console.log(
|
213
|
+
// mfiAccount.lendingAccount.balances.map((x) =>
|
214
|
+
// bytesToI80F48(x.liabilityShares.value)
|
215
|
+
// )
|
216
|
+
// );
|
217
|
+
// console.log(
|
218
|
+
// mfiAccount.lendingAccount.balances.map((x) => x.bankPk.toString())
|
219
|
+
// );
|
220
|
+
|
78
221
|
const transactionItems: TransactionItem[] = [];
|
79
222
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
80
223
|
// boostToBps: maxBoostToBps(
|
@@ -142,13 +285,41 @@ describe("Solauto Marginfi tests", async () => {
|
|
142
285
|
// )
|
143
286
|
// );
|
144
287
|
|
145
|
-
transactionItems.push(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
288
|
+
// transactionItems.push(
|
289
|
+
// new TransactionItem(
|
290
|
+
// async (attemptNum) =>
|
291
|
+
// await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
292
|
+
// "rebalance"
|
293
|
+
// )
|
294
|
+
// );
|
295
|
+
|
296
|
+
const imfiAccount = await safeFetchMarginfiAccount(
|
297
|
+
client.umi,
|
298
|
+
publicKey(client.intermediaryMarginfiAccountPk)
|
299
|
+
);
|
300
|
+
|
301
|
+
console.log(imfiAccount.lendingAccount.balances);
|
302
|
+
console.log(
|
303
|
+
imfiAccount.lendingAccount.balances.map((x) => x.bankPk.toString())
|
151
304
|
);
|
305
|
+
return;
|
306
|
+
|
307
|
+
// transactionItems.push(
|
308
|
+
// new TransactionItem(async () => ({
|
309
|
+
// tx: transactionBuilder().add(
|
310
|
+
// imfiAccount.lendingAccount.balances
|
311
|
+
// .filter(
|
312
|
+
// (x) => x.active && bytesToI80F48(x.liabilityShares.value) > 0
|
313
|
+
// )
|
314
|
+
// .map((x) =>
|
315
|
+
// client.closeBalance(
|
316
|
+
// client.intermediaryMarginfiAccountPk,
|
317
|
+
// toWeb3JsPublicKey(x.bankPk)
|
318
|
+
// )
|
319
|
+
// )
|
320
|
+
// ),
|
321
|
+
// }))
|
322
|
+
// );
|
152
323
|
|
153
324
|
// transactionItems.push(
|
154
325
|
// new TransactionItem(
|