@carrot-protocol/clend-rpc 0.1.20 → 0.1.21-mfi-fl-dev-179454d
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.
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { web3, BN } from "@coral-xyz/anchor";
|
|
2
|
+
export declare function createMarginfiStartFlashLoanIx(clendAccount: web3.PublicKey, signer: web3.PublicKey, endIndex: BN): web3.TransactionInstruction;
|
|
3
|
+
export declare function createMarginfiEndFlashLoanIx(clendAccount: web3.PublicKey, signer: web3.PublicKey): web3.TransactionInstruction;
|
|
4
|
+
export declare function createMarginfiDepositIx(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, signer: web3.PublicKey, bank: web3.PublicKey, signerTokenAccount: web3.PublicKey, bankLiquidityVault: web3.PublicKey, amount: BN): web3.TransactionInstruction;
|
|
5
|
+
export declare function createMarginfiWithdrawIx(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, signer: web3.PublicKey, bank: web3.PublicKey, destinationTokenAccount: web3.PublicKey, bankLiquidityVaultAuthority: web3.PublicKey, bankLiquidityVault: web3.PublicKey, amount: BN, withdrawAll?: boolean): web3.TransactionInstruction;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMarginfiStartFlashLoanIx = createMarginfiStartFlashLoanIx;
|
|
4
|
+
exports.createMarginfiEndFlashLoanIx = createMarginfiEndFlashLoanIx;
|
|
5
|
+
exports.createMarginfiDepositIx = createMarginfiDepositIx;
|
|
6
|
+
exports.createMarginfiWithdrawIx = createMarginfiWithdrawIx;
|
|
7
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
9
|
+
// Flash loan functions
|
|
10
|
+
function createMarginfiStartFlashLoanIx(clendAccount, signer, endIndex) {
|
|
11
|
+
return new anchor_1.web3.TransactionInstruction({
|
|
12
|
+
programId: marginfiProgramId,
|
|
13
|
+
keys: [
|
|
14
|
+
{ pubkey: clendAccount, isSigner: false, isWritable: true },
|
|
15
|
+
{ pubkey: signer, isSigner: true, isWritable: false },
|
|
16
|
+
{
|
|
17
|
+
pubkey: anchor_1.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
18
|
+
isSigner: false,
|
|
19
|
+
isWritable: false,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
data: Buffer.from([
|
|
23
|
+
...new anchor_1.BN(0).toArray("le", 8), // instruction index for startFlashLoan
|
|
24
|
+
...endIndex.toArray("le", 8),
|
|
25
|
+
]),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function createMarginfiEndFlashLoanIx(clendAccount, signer) {
|
|
29
|
+
return new anchor_1.web3.TransactionInstruction({
|
|
30
|
+
programId: marginfiProgramId,
|
|
31
|
+
keys: [
|
|
32
|
+
{ pubkey: clendAccount, isSigner: false, isWritable: true },
|
|
33
|
+
{ pubkey: signer, isSigner: true, isWritable: false },
|
|
34
|
+
],
|
|
35
|
+
data: Buffer.from([
|
|
36
|
+
...new anchor_1.BN(1).toArray("le", 8), // instruction index for endFlashLoan
|
|
37
|
+
]),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Deposit function
|
|
41
|
+
function createMarginfiDepositIx(clendGroup, clendAccount, signer, bank, signerTokenAccount, bankLiquidityVault, amount) {
|
|
42
|
+
return new anchor_1.web3.TransactionInstruction({
|
|
43
|
+
programId: marginfiProgramId,
|
|
44
|
+
keys: [
|
|
45
|
+
{ pubkey: clendGroup, isSigner: false, isWritable: false },
|
|
46
|
+
{ pubkey: clendAccount, isSigner: false, isWritable: true },
|
|
47
|
+
{ pubkey: signer, isSigner: true, isWritable: false },
|
|
48
|
+
{ pubkey: bank, isSigner: false, isWritable: true },
|
|
49
|
+
{ pubkey: signerTokenAccount, isSigner: false, isWritable: true },
|
|
50
|
+
{ pubkey: bankLiquidityVault, isSigner: false, isWritable: true },
|
|
51
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
52
|
+
],
|
|
53
|
+
data: Buffer.from([
|
|
54
|
+
...new anchor_1.BN(2).toArray("le", 8), // instruction index for deposit
|
|
55
|
+
...amount.toArray("le", 8),
|
|
56
|
+
]),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Withdraw function
|
|
60
|
+
function createMarginfiWithdrawIx(clendGroup, clendAccount, signer, bank, destinationTokenAccount, bankLiquidityVaultAuthority, bankLiquidityVault, amount, withdrawAll) {
|
|
61
|
+
const data = Buffer.from([
|
|
62
|
+
...new anchor_1.BN(3).toArray("le", 8), // instruction index for withdraw
|
|
63
|
+
...amount.toArray("le", 8),
|
|
64
|
+
]);
|
|
65
|
+
// Add withdrawAll flag if provided
|
|
66
|
+
if (withdrawAll !== undefined) {
|
|
67
|
+
data.writeUInt8(withdrawAll ? 1 : 0, data.length);
|
|
68
|
+
}
|
|
69
|
+
return new anchor_1.web3.TransactionInstruction({
|
|
70
|
+
programId: marginfiProgramId,
|
|
71
|
+
keys: [
|
|
72
|
+
{ pubkey: clendGroup, isSigner: false, isWritable: false },
|
|
73
|
+
{ pubkey: clendAccount, isSigner: false, isWritable: true },
|
|
74
|
+
{ pubkey: signer, isSigner: true, isWritable: false },
|
|
75
|
+
{ pubkey: bank, isSigner: false, isWritable: true },
|
|
76
|
+
{ pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
|
|
77
|
+
{
|
|
78
|
+
pubkey: bankLiquidityVaultAuthority,
|
|
79
|
+
isSigner: false,
|
|
80
|
+
isWritable: true,
|
|
81
|
+
},
|
|
82
|
+
{ pubkey: bankLiquidityVault, isSigner: false, isWritable: true },
|
|
83
|
+
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
84
|
+
],
|
|
85
|
+
data,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const marginfiProgramId = new anchor_1.web3.PublicKey("MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA");
|
|
89
|
+
//# sourceMappingURL=marginfi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marginfi.js","sourceRoot":"","sources":["../../src/integrations/marginfi.ts"],"names":[],"mappings":";;AAIA,wEAqBC;AAED,oEAcC;AAGD,0DAyBC;AAGD,4DAuCC;AA/GD,8CAA6C;AAC7C,iDAAqD;AAErD,uBAAuB;AACvB,SAAgB,8BAA8B,CAC5C,YAA4B,EAC5B,MAAsB,EACtB,QAAY;IAEZ,OAAO,IAAI,aAAI,CAAC,sBAAsB,CAAC;QACrC,SAAS,EAAE,iBAAiB;QAC5B,IAAI,EAAE;YACJ,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;YAC3D,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;YACrD;gBACE,MAAM,EAAE,aAAI,CAAC,0BAA0B;gBACvC,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,KAAK;aAClB;SACF;QACD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;YAChB,GAAG,IAAI,WAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,uCAAuC;YACtE,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7B,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,4BAA4B,CAC1C,YAA4B,EAC5B,MAAsB;IAEtB,OAAO,IAAI,aAAI,CAAC,sBAAsB,CAAC;QACrC,SAAS,EAAE,iBAAiB;QAC5B,IAAI,EAAE;YACJ,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;YAC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