@exponent-labs/kamino-lend-standard 0.9.3
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/build/anchor/idl.json +2889 -0
- package/build/anchor/type.d.ts +2895 -0
- package/build/anchor/type.js +3 -0
- package/build/anchor/type.js.map +1 -0
- package/build/constants.d.ts +44 -0
- package/build/constants.js +144 -0
- package/build/constants.js.map +1 -0
- package/build/index.d.ts +103 -0
- package/build/index.js +318 -0
- package/build/index.js.map +1 -0
- package/build/instructions/addEmission.d.ts +11 -0
- package/build/instructions/addEmission.js +58 -0
- package/build/instructions/addEmission.js.map +1 -0
- package/build/instructions/createStandardToken.d.ts +0 -0
- package/build/instructions/createStandardToken.js +56 -0
- package/build/instructions/createStandardToken.js.map +1 -0
- package/build/instructions/depositInstruction.d.ts +17 -0
- package/build/instructions/depositInstruction.js +119 -0
- package/build/instructions/depositInstruction.js.map +1 -0
- package/build/instructions/getPositionInstruction.d.ts +15 -0
- package/build/instructions/getPositionInstruction.js +114 -0
- package/build/instructions/getPositionInstruction.js.map +1 -0
- package/build/instructions/index.d.ts +2 -0
- package/build/instructions/index.js +19 -0
- package/build/instructions/index.js.map +1 -0
- package/build/instructions/initializeKaminoLendAccount.d.ts +18 -0
- package/build/instructions/initializeKaminoLendAccount.js +85 -0
- package/build/instructions/initializeKaminoLendAccount.js.map +1 -0
- package/build/instructions/initializePositionInstruction.d.ts +8 -0
- package/build/instructions/initializePositionInstruction.js +55 -0
- package/build/instructions/initializePositionInstruction.js.map +1 -0
- package/build/instructions/mintInstruction.d.ts +19 -0
- package/build/instructions/mintInstruction.js +132 -0
- package/build/instructions/mintInstruction.js.map +1 -0
- package/build/instructions/redeemInstruction.d.ts +21 -0
- package/build/instructions/redeemInstruction.js +129 -0
- package/build/instructions/redeemInstruction.js.map +1 -0
- package/build/instructions/withdrawInstruction.d.ts +17 -0
- package/build/instructions/withdrawInstruction.js +122 -0
- package/build/instructions/withdrawInstruction.js.map +1 -0
- package/package.json +22 -0
- package/src/anchor/idl.json +2889 -0
- package/src/anchor/type.ts +2895 -0
- package/src/constants.d.ts +44 -0
- package/src/constants.js +133 -0
- package/src/constants.ts +205 -0
- package/src/index.ts +500 -0
- package/src/instructions/addEmission.ts +39 -0
- package/src/instructions/createStandardToken.ts +57 -0
- package/src/instructions/depositInstruction.ts +130 -0
- package/src/instructions/getPositionInstruction.ts +117 -0
- package/src/instructions/index.ts +2 -0
- package/src/instructions/initializeKaminoLendAccount.ts +101 -0
- package/src/instructions/initializePositionInstruction.ts +31 -0
- package/src/instructions/mintInstruction.ts +149 -0
- package/src/instructions/redeemInstruction.ts +140 -0
- package/src/instructions/withdrawInstruction.ts +137 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { KaminoLendStandard } from "../anchor/type";
|
|
3
|
+
export declare const mintInstruction: ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, lendingMarketAuthority, reserve, reserveFarmState, signer, feePayer, remainingAccounts, baseMint, signerBaseTokenAccount, signerReceiptTokenAccount, tokenProgramBase, }: {
|
|
4
|
+
kaminoLendStandardProgram: anchor.Program<KaminoLendStandard>;
|
|
5
|
+
kaminoFarmsProgramId: anchor.web3.PublicKey;
|
|
6
|
+
kaminoLendProgramId: anchor.web3.PublicKey;
|
|
7
|
+
amount: anchor.BN;
|
|
8
|
+
lendingMarket: anchor.web3.PublicKey;
|
|
9
|
+
lendingMarketAuthority: anchor.web3.PublicKey;
|
|
10
|
+
reserve: anchor.web3.PublicKey;
|
|
11
|
+
reserveFarmState: anchor.web3.PublicKey;
|
|
12
|
+
signer: anchor.web3.PublicKey;
|
|
13
|
+
feePayer: anchor.web3.PublicKey;
|
|
14
|
+
remainingAccounts: anchor.web3.AccountMeta[];
|
|
15
|
+
baseMint: anchor.web3.PublicKey;
|
|
16
|
+
signerBaseTokenAccount: anchor.web3.PublicKey;
|
|
17
|
+
signerReceiptTokenAccount: anchor.web3.PublicKey;
|
|
18
|
+
tokenProgramBase: anchor.web3.PublicKey;
|
|
19
|
+
}) => Promise<any[]>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.mintInstruction = void 0;
|
|
37
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
38
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
39
|
+
const constants_1 = require("../constants");
|
|
40
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
41
|
+
const mintInstruction = async ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, lendingMarketAuthority, reserve, reserveFarmState, signer, feePayer, remainingAccounts, baseMint, signerBaseTokenAccount, signerReceiptTokenAccount, tokenProgramBase, }) => {
|
|
42
|
+
const meta = (0, constants_1.getMeta)(reserve, kaminoLendStandardProgram.programId);
|
|
43
|
+
const userMetadata = (0, constants_1.getKaminoUserMetadata)(meta, kaminoLendProgramId);
|
|
44
|
+
const obligation = (0, constants_1.getKaminoLendObligation)(meta, lendingMarket, kaminoLendProgramId);
|
|
45
|
+
const obligationFarm = (0, constants_1.getKaminoFarmsObligationFarm)(obligation, reserveFarmState, kaminoFarmsProgramId);
|
|
46
|
+
const standardTokenMint = (0, constants_1.getStandardTokenMint)(reserve, kaminoLendStandardProgram.programId);
|
|
47
|
+
const accountAuthorityBaseToken = (0, constants_1.getAccountAuthorityBaseTokenAccount)(reserve, kaminoLendStandardProgram.programId);
|
|
48
|
+
const reserveLiquiditySupply = (0, constants_1.getKaminoReserveLiquiditySupply)(lendingMarket, baseMint, kaminoLendProgramId);
|
|
49
|
+
const reserveCollateralMint = (0, constants_1.getKaminoReserveCollateralMint)(lendingMarket, baseMint, kaminoLendProgramId);
|
|
50
|
+
console.log("reserveCollateralMint", reserveCollateralMint.toBase58());
|
|
51
|
+
const reserveDestinationDepositCollateral = (0, constants_1.getKaminoReserveCollateralSupply)(lendingMarket, baseMint, kaminoLendProgramId);
|
|
52
|
+
const refreshReserveInstruction = new web3_js_1.TransactionInstruction({
|
|
53
|
+
keys: [
|
|
54
|
+
{
|
|
55
|
+
pubkey: reserve,
|
|
56
|
+
isWritable: true,
|
|
57
|
+
isSigner: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
pubkey: lendingMarket,
|
|
61
|
+
isWritable: false,
|
|
62
|
+
isSigner: false,
|
|
63
|
+
},
|
|
64
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
65
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
66
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
67
|
+
remainingAccounts[1],
|
|
68
|
+
],
|
|
69
|
+
programId: kaminoLendProgramId,
|
|
70
|
+
data: Buffer.from([2, 218, 138, 235, 79, 201, 25, 102]),
|
|
71
|
+
});
|
|
72
|
+
const refreshObligationInstruction = new web3_js_1.TransactionInstruction({
|
|
73
|
+
keys: [
|
|
74
|
+
{ pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
75
|
+
{ pubkey: obligation, isWritable: true, isSigner: false },
|
|
76
|
+
],
|
|
77
|
+
programId: kaminoLendProgramId,
|
|
78
|
+
data: Buffer.from([33, 132, 147, 228, 151, 192, 72, 89]),
|
|
79
|
+
});
|
|
80
|
+
const refreshObligationFarmsForReserveInstruction = new web3_js_1.TransactionInstruction({
|
|
81
|
+
keys: [
|
|
82
|
+
{ pubkey: signer, isWritable: true, isSigner: false },
|
|
83
|
+
{ pubkey: obligation, isWritable: true, isSigner: false },
|
|
84
|
+
{ pubkey: lendingMarketAuthority, isWritable: true, isSigner: false },
|
|
85
|
+
{ pubkey: reserve, isWritable: true, isSigner: false },
|
|
86
|
+
{ pubkey: reserveFarmState, isWritable: true, isSigner: false },
|
|
87
|
+
{ pubkey: obligationFarm, isWritable: true, isSigner: false },
|
|
88
|
+
{ pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
89
|
+
{ pubkey: kaminoFarmsProgramId, isWritable: false, isSigner: false },
|
|
90
|
+
{ pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
|
|
91
|
+
// { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
92
|
+
{ pubkey: anchor.web3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
93
|
+
],
|
|
94
|
+
programId: kaminoLendProgramId,
|
|
95
|
+
// 8 byte discriminator + 0 byte for "collateral" mode
|
|
96
|
+
data: Buffer.from([140, 144, 253, 21, 10, 74, 248, 3, 0]),
|
|
97
|
+
});
|
|
98
|
+
const instruction = await kaminoLendStandardProgram.methods
|
|
99
|
+
.mint(amount)
|
|
100
|
+
.accountsStrict({
|
|
101
|
+
lendingMarket,
|
|
102
|
+
kaminoReserve: reserve,
|
|
103
|
+
meta,
|
|
104
|
+
lendingMarketAuthority,
|
|
105
|
+
signer,
|
|
106
|
+
kaminoObligation: obligation,
|
|
107
|
+
mintBase: baseMint,
|
|
108
|
+
tokenBaseAccountAuthority: accountAuthorityBaseToken,
|
|
109
|
+
instruction: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
110
|
+
mintSy: standardTokenMint,
|
|
111
|
+
tokenBaseSigner: signerBaseTokenAccount,
|
|
112
|
+
tokenSySigner: signerReceiptTokenAccount,
|
|
113
|
+
reserveLiquiditySupply,
|
|
114
|
+
reserveCollateralMint,
|
|
115
|
+
tokenProgramBase,
|
|
116
|
+
token22Program: spl_token_1.TOKEN_PROGRAM_ID,
|
|
117
|
+
kaminoLendProgram: kaminoLendProgramId,
|
|
118
|
+
reserveDestinationDepositCollateral,
|
|
119
|
+
kaminoCollateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
120
|
+
})
|
|
121
|
+
.remainingAccounts(remainingAccounts)
|
|
122
|
+
.instruction();
|
|
123
|
+
return [
|
|
124
|
+
refreshReserveInstruction,
|
|
125
|
+
refreshObligationInstruction,
|
|
126
|
+
refreshObligationFarmsForReserveInstruction,
|
|
127
|
+
instruction,
|
|
128
|
+
refreshObligationFarmsForReserveInstruction,
|
|
129
|
+
];
|
|
130
|
+
};
|
|
131
|
+
exports.mintInstruction = mintInstruction;
|
|
132
|
+
//# sourceMappingURL=mintInstruction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mintInstruction.js","sourceRoot":"","sources":["../../src/instructions/mintInstruction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA2C;AAE3C,iDAAoD;AACpD,4CAYqB;AACrB,6CAAwD;AAEjD,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,OAAO,EACP,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,GAiBjB,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAClE,MAAM,YAAY,GAAG,IAAA,iCAAqB,EAAC,IAAI,EAAE,mBAAmB,CAAC,CAAA;IACrE,MAAM,UAAU,GAAG,IAAA,mCAAuB,EAAC,IAAI,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAA;IACpF,MAAM,cAAc,GAAG,IAAA,wCAA4B,EAAC,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IACvG,MAAM,iBAAiB,GAAG,IAAA,gCAAoB,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAC5F,MAAM,yBAAyB,GAAG,IAAA,+CAAmC,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IACnH,MAAM,sBAAsB,GAAG,IAAA,2CAA+B,EAAC,aAAa,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAA;IAC5G,MAAM,qBAAqB,GAAG,IAAA,0CA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QACtD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KAC1D,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAC,OAAO;SACxD,IAAI,CAAC,MAAM,CAAC;SACZ,cAAc,CAAC;QACd,aAAa;QACb,aAAa,EAAE,OAAO;QACtB,IAAI;QACJ,sBAAsB;QACtB,MAAM;QACN,gBAAgB,EAAE,UAAU;QAC5B,QAAQ,EAAE,QAAQ;QAClB,yBAAyB,EAAE,yBAAyB;QACpD,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,0BAA0B;QACnD,MAAM,EAAE,iBAAiB;QACzB,eAAe,EAAE,sBAAsB;QACvC,aAAa,EAAE,yBAAyB;QACxC,sBAAsB;QACtB,qBAAqB;QACrB,gBAAgB;QAChB,cAAc,EAAE,4BAAgB;QAChC,iBAAiB,EAAE,mBAAmB;QACtC,mCAAmC;QACnC,4BAA4B,EAAE,4BAAgB;KAC/C,CAAC;SACD,iBAAiB,CAAC,iBAAiB,CAAC;SACpC,WAAW,EAAE,CAAA;IAEhB,OAAO;QACL,yBAAyB;QACzB,4BAA4B;QAC5B,2CAA2C;QAC3C,WAAW;QACX,2CAA2C;KAC5C,CAAA;AACH,CAAC,CAAA;AAlIY,QAAA,eAAe,mBAkI3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { KaminoLendStandard } from "../anchor/type";
|
|
3
|
+
export declare const redeemInstruction: ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, lendingMarketAuthority, reserve, reserveFarmState, signer, remainingAccounts, baseMint, signerBaseTokenAccount, signerReceiptTokenAccount, reserveLiquiditySupply, reserveCollateralMint, reserveSourceCollateral, }: {
|
|
4
|
+
kaminoLendStandardProgram: anchor.Program<KaminoLendStandard>;
|
|
5
|
+
kaminoFarmsProgramId: anchor.web3.PublicKey;
|
|
6
|
+
kaminoLendProgramId: anchor.web3.PublicKey;
|
|
7
|
+
amount: anchor.BN;
|
|
8
|
+
lendingMarket: anchor.web3.PublicKey;
|
|
9
|
+
lendingMarketAuthority: anchor.web3.PublicKey;
|
|
10
|
+
reserve: anchor.web3.PublicKey;
|
|
11
|
+
reserveFarmState: anchor.web3.PublicKey;
|
|
12
|
+
signer: anchor.web3.PublicKey;
|
|
13
|
+
feePayer: anchor.web3.PublicKey;
|
|
14
|
+
remainingAccounts: anchor.web3.AccountMeta[];
|
|
15
|
+
baseMint: anchor.web3.PublicKey;
|
|
16
|
+
signerBaseTokenAccount: anchor.web3.PublicKey;
|
|
17
|
+
signerReceiptTokenAccount: anchor.web3.PublicKey;
|
|
18
|
+
reserveLiquiditySupply: anchor.web3.PublicKey;
|
|
19
|
+
reserveCollateralMint: anchor.web3.PublicKey;
|
|
20
|
+
reserveSourceCollateral: anchor.web3.PublicKey;
|
|
21
|
+
}) => Promise<any[]>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.redeemInstruction = void 0;
|
|
37
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
38
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
39
|
+
const constants_1 = require("../constants");
|
|
40
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
41
|
+
const redeemInstruction = async ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, lendingMarketAuthority, reserve, reserveFarmState, signer, remainingAccounts, baseMint, signerBaseTokenAccount, signerReceiptTokenAccount, reserveLiquiditySupply, reserveCollateralMint, reserveSourceCollateral, }) => {
|
|
42
|
+
const meta = (0, constants_1.getMeta)(reserve, kaminoLendStandardProgram.programId);
|
|
43
|
+
const obligation = (0, constants_1.getKaminoLendObligation)(meta, lendingMarket, kaminoLendProgramId);
|
|
44
|
+
const obligationFarm = (0, constants_1.getKaminoFarmsObligationFarm)(obligation, reserveFarmState, kaminoFarmsProgramId);
|
|
45
|
+
const standardTokenMint = (0, constants_1.getStandardTokenMint)(reserve, kaminoLendStandardProgram.programId);
|
|
46
|
+
const accountAuthorityBaseToken = (0, constants_1.getAccountAuthorityBaseTokenAccount)(reserve, kaminoLendStandardProgram.programId);
|
|
47
|
+
const refreshReserveInstruction = new web3_js_1.TransactionInstruction({
|
|
48
|
+
keys: [
|
|
49
|
+
{
|
|
50
|
+
pubkey: reserve,
|
|
51
|
+
isWritable: true,
|
|
52
|
+
isSigner: false,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
pubkey: lendingMarket,
|
|
56
|
+
isWritable: false,
|
|
57
|
+
isSigner: false,
|
|
58
|
+
},
|
|
59
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
60
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
61
|
+
{ pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
62
|
+
remainingAccounts[1],
|
|
63
|
+
],
|
|
64
|
+
programId: kaminoLendProgramId,
|
|
65
|
+
data: Buffer.from([2, 218, 138, 235, 79, 201, 25, 102]),
|
|
66
|
+
});
|
|
67
|
+
const refreshObligationInstruction = new web3_js_1.TransactionInstruction({
|
|
68
|
+
keys: [
|
|
69
|
+
{ pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
70
|
+
{ pubkey: obligation, isWritable: true, isSigner: false },
|
|
71
|
+
{ pubkey: reserve, isWritable: false, isSigner: false },
|
|
72
|
+
],
|
|
73
|
+
programId: kaminoLendProgramId,
|
|
74
|
+
data: Buffer.from([33, 132, 147, 228, 151, 192, 72, 89]),
|
|
75
|
+
});
|
|
76
|
+
const refreshObligationFarmsForReserveInstruction = new web3_js_1.TransactionInstruction({
|
|
77
|
+
keys: [
|
|
78
|
+
{ pubkey: signer, isWritable: true, isSigner: false },
|
|
79
|
+
{ pubkey: obligation, isWritable: true, isSigner: false },
|
|
80
|
+
{ pubkey: lendingMarketAuthority, isWritable: true, isSigner: false },
|
|
81
|
+
{ pubkey: reserve, isWritable: true, isSigner: false },
|
|
82
|
+
{ pubkey: reserveFarmState, isWritable: true, isSigner: false },
|
|
83
|
+
{ pubkey: obligationFarm, isWritable: true, isSigner: false },
|
|
84
|
+
{ pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
85
|
+
{ pubkey: kaminoFarmsProgramId, isWritable: false, isSigner: false },
|
|
86
|
+
{ pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
|
|
87
|
+
// { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
88
|
+
{ pubkey: anchor.web3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
89
|
+
],
|
|
90
|
+
programId: kaminoLendProgramId,
|
|
91
|
+
// 8 byte discriminator + 0 byte for "collateral" mode
|
|
92
|
+
data: Buffer.from([140, 144, 253, 21, 10, 74, 248, 3, 0]),
|
|
93
|
+
});
|
|
94
|
+
const instruction = await kaminoLendStandardProgram.methods
|
|
95
|
+
.redeem(amount)
|
|
96
|
+
.accountsStrict({
|
|
97
|
+
lendingMarket,
|
|
98
|
+
kaminoReserve: reserve,
|
|
99
|
+
meta,
|
|
100
|
+
lendingMarketAuthority,
|
|
101
|
+
signer,
|
|
102
|
+
kaminoObligation: obligation,
|
|
103
|
+
mintBase: baseMint,
|
|
104
|
+
tokenBaseAccountAuthority: accountAuthorityBaseToken,
|
|
105
|
+
instruction: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
106
|
+
mintSy: standardTokenMint,
|
|
107
|
+
tokenBaseSigner: signerBaseTokenAccount,
|
|
108
|
+
tokenSySigner: signerReceiptTokenAccount,
|
|
109
|
+
reserveLiquiditySupply,
|
|
110
|
+
reserveCollateralMint,
|
|
111
|
+
// TODO - this token program is not known
|
|
112
|
+
tokenProgramBase: spl_token_1.TOKEN_PROGRAM_ID,
|
|
113
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
114
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
115
|
+
kaminoLendProgram: kaminoLendProgramId,
|
|
116
|
+
reserveSourceCollateral,
|
|
117
|
+
})
|
|
118
|
+
.remainingAccounts(remainingAccounts)
|
|
119
|
+
.instruction();
|
|
120
|
+
return [
|
|
121
|
+
refreshReserveInstruction,
|
|
122
|
+
refreshObligationInstruction,
|
|
123
|
+
refreshObligationFarmsForReserveInstruction,
|
|
124
|
+
instruction,
|
|
125
|
+
refreshObligationFarmsForReserveInstruction,
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
exports.redeemInstruction = redeemInstruction;
|
|
129
|
+
//# sourceMappingURL=redeemInstruction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redeemInstruction.js","sourceRoot":"","sources":["../../src/instructions/redeemInstruction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA2C;AAE3C,iDAAoD;AACpD,4CAOqB;AACrB,6CAAwD;AAEjD,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,OAAO,EACP,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GAmBxB,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAClE,MAAM,UAAU,GAAG,IAAA,mCAAuB,EAAC,IAAI,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAA;IACpF,MAAM,cAAc,GAAG,IAAA,wCAA4B,EAAC,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IACvG,MAAM,iBAAiB,GAAG,IAAA,gCAAoB,EAAC,OAAO,EAAE,yBAAy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C,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KAC1D,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAC,OAAO;SACxD,MAAM,CAAC,MAAM,CAAC;SACd,cAAc,CAAC;QACd,aAAa;QACb,aAAa,EAAE,OAAO;QACtB,IAAI;QACJ,sBAAsB;QACtB,MAAM;QACN,gBAAgB,EAAE,UAAU;QAC5B,QAAQ,EAAE,QAAQ;QAClB,yBAAyB,EAAE,yBAAyB;QACpD,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,0BAA0B;QACnD,MAAM,EAAE,iBAAiB;QACzB,eAAe,EAAE,sBAAsB;QACvC,aAAa,EAAE,yBAAyB;QACxC,sBAAsB;QACtB,qBAAqB;QACrB,yCAAyC;QACzC,gBAAgB,EAAE,4BAAgB;QAClC,YAAY,EAAE,4BAAgB;QAC9B,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS;QAClD,iBAAiB,EAAE,mBAAmB;QACtC,uBAAuB;KACxB,CAAC;SACD,iBAAiB,CAAC,iBAAiB,CAAC;SACpC,WAAW,EAAE,CAAA;IAEhB,OAAO;QACL,yBAAyB;QACzB,4BAA4B;QAC5B,2CAA2C;QAC3C,WAAW;QACX,2CAA2C;KAC5C,CAAA;AACH,CAAC,CAAA;AA9HY,QAAA,iBAAiB,qBA8H7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { KaminoLendStandard } from "../anchor/type";
|
|
3
|
+
export declare const withdrawInstruction: ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, reserve, reserveFarmState, signer, feePayer, remainingAccounts, signerReceiptTokenAccount, kaminoFarm, kaminoGlobalConfig, }: {
|
|
4
|
+
kaminoLendStandardProgram: anchor.Program<KaminoLendStandard>;
|
|
5
|
+
kaminoFarmsProgramId: anchor.web3.PublicKey;
|
|
6
|
+
kaminoLendProgramId: anchor.web3.PublicKey;
|
|
7
|
+
amount: anchor.BN;
|
|
8
|
+
lendingMarket: anchor.web3.PublicKey;
|
|
9
|
+
reserve: anchor.web3.PublicKey;
|
|
10
|
+
reserveFarmState: anchor.web3.PublicKey;
|
|
11
|
+
signer: anchor.web3.PublicKey;
|
|
12
|
+
feePayer: anchor.web3.PublicKey;
|
|
13
|
+
remainingAccounts: anchor.web3.AccountMeta[];
|
|
14
|
+
signerReceiptTokenAccount: anchor.web3.PublicKey;
|
|
15
|
+
kaminoFarm: anchor.web3.PublicKey;
|
|
16
|
+
kaminoGlobalConfig: anchor.web3.PublicKey;
|
|
17
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.withdrawInstruction = void 0;
|
|
37
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
38
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
39
|
+
const constants_1 = require("../constants");
|
|
40
|
+
const withdrawInstruction = async ({ kaminoLendStandardProgram, kaminoFarmsProgramId, kaminoLendProgramId, amount, lendingMarket, reserve, reserveFarmState, signer, feePayer, remainingAccounts, signerReceiptTokenAccount, kaminoFarm, kaminoGlobalConfig, }) => {
|
|
41
|
+
const meta = (0, constants_1.getMeta)(reserve, kaminoLendStandardProgram.programId);
|
|
42
|
+
const obligation = (0, constants_1.getKaminoLendObligation)(meta, lendingMarket, kaminoLendProgramId);
|
|
43
|
+
const userState = (0, constants_1.getKaminoFarmsObligationFarm)(obligation, reserveFarmState, kaminoFarmsProgramId);
|
|
44
|
+
const obligationFarm = (0, constants_1.getKaminoFarmsObligationFarm)(obligation, reserveFarmState, kaminoFarmsProgramId);
|
|
45
|
+
const standardTokenMint = (0, constants_1.getStandardTokenMint)(reserve, kaminoLendStandardProgram.programId);
|
|
46
|
+
const accountAuthorityBaseToken = (0, constants_1.getAccountAuthorityBaseTokenAccount)(reserve, kaminoLendStandardProgram.programId);
|
|
47
|
+
// const refreshReserveInstruction = new TransactionInstruction({
|
|
48
|
+
// keys: [
|
|
49
|
+
// {
|
|
50
|
+
// pubkey: reserve,
|
|
51
|
+
// isWritable: true,
|
|
52
|
+
// isSigner: false,
|
|
53
|
+
// },
|
|
54
|
+
// {
|
|
55
|
+
// pubkey: lendingMarket,
|
|
56
|
+
// isWritable: false,
|
|
57
|
+
// isSigner: false,
|
|
58
|
+
// },
|
|
59
|
+
// remainingAccounts[0],
|
|
60
|
+
// { pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
61
|
+
// { pubkey: kaminoLendProgramId, isWritable: false, isSigner: false },
|
|
62
|
+
// remainingAccounts[1],
|
|
63
|
+
// ],
|
|
64
|
+
// programId: kaminoLendProgramId,
|
|
65
|
+
// data: Buffer.from([2, 218, 138, 235, 79, 201, 25, 102]),
|
|
66
|
+
// })
|
|
67
|
+
// const refreshObligationInstruction = new TransactionInstruction({
|
|
68
|
+
// keys: [
|
|
69
|
+
// { pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
70
|
+
// { pubkey: obligation, isWritable: true, isSigner: false },
|
|
71
|
+
// ],
|
|
72
|
+
// programId: kaminoLendProgramId,
|
|
73
|
+
// data: Buffer.from([33, 132, 147, 228, 151, 192, 72, 89]),
|
|
74
|
+
// })
|
|
75
|
+
// const refreshObligationFarmsForReserveInstruction = new TransactionInstruction({
|
|
76
|
+
// keys: [
|
|
77
|
+
// { pubkey: signer, isWritable: true, isSigner: false },
|
|
78
|
+
// { pubkey: obligation, isWritable: true, isSigner: false },
|
|
79
|
+
// { pubkey: lendingMarketAuthority, isWritable: true, isSigner: false },
|
|
80
|
+
// { pubkey: reserve, isWritable: true, isSigner: false },
|
|
81
|
+
// { pubkey: reserveFarmState, isWritable: true, isSigner: false },
|
|
82
|
+
// { pubkey: obligationFarm, isWritable: true, isSigner: false },
|
|
83
|
+
// { pubkey: lendingMarket, isWritable: false, isSigner: false },
|
|
84
|
+
// { pubkey: kaminoFarmsProgramId, isWritable: false, isSigner: false },
|
|
85
|
+
// { pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
|
|
86
|
+
// // { pubkey: TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
87
|
+
// { pubkey: anchor.web3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
88
|
+
// ],
|
|
89
|
+
// programId: kaminoLendProgramId,
|
|
90
|
+
// // 8 byte discriminator + 0 byte for "collateral" mode
|
|
91
|
+
// data: Buffer.from([140, 144, 253, 21, 10, 74, 248, 3, 0]),
|
|
92
|
+
// })
|
|
93
|
+
const emissionTracker = (0, constants_1.getEmissionTracker)(reserve, kaminoLendStandardProgram.programId);
|
|
94
|
+
const position = (0, constants_1.getPosition)(reserve, signer, kaminoLendStandardProgram.programId);
|
|
95
|
+
const kaminoFarmVaultsAuthority = (0, constants_1.getKaminoFarmsVaultAuthority)(kaminoFarm, kaminoFarmsProgramId);
|
|
96
|
+
const instruction = await kaminoLendStandardProgram.methods
|
|
97
|
+
.withdraw(amount)
|
|
98
|
+
.accountsStrict({
|
|
99
|
+
feePayer,
|
|
100
|
+
meta,
|
|
101
|
+
kaminoReserve: reserve,
|
|
102
|
+
owner: signer,
|
|
103
|
+
position,
|
|
104
|
+
tokenSyEscrow: (0, constants_1.getStakedReceiptPool)(reserve, kaminoLendStandardProgram.programId),
|
|
105
|
+
mintSy: standardTokenMint,
|
|
106
|
+
tokenSySigner: signerReceiptTokenAccount,
|
|
107
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
108
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
109
|
+
kaminoFarmsProgram: kaminoFarmsProgramId,
|
|
110
|
+
kaminoFarm,
|
|
111
|
+
kaminoFarmVaultsAuthority,
|
|
112
|
+
kaminoGlobalConfig,
|
|
113
|
+
// farms program id because scope prices is optional
|
|
114
|
+
kaminoScopePrices: kaminoFarmsProgramId,
|
|
115
|
+
userState,
|
|
116
|
+
})
|
|
117
|
+
.remainingAccounts(remainingAccounts)
|
|
118
|
+
.instruction();
|
|
119
|
+
return instruction;
|
|
120
|
+
};
|
|
121
|
+
exports.withdrawInstruction = withdrawInstruction;
|
|
122
|
+
//# sourceMappingURL=withdrawInstruction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawInstruction.js","sourceRoot":"","sources":["../../src/instructions/withdrawInstruction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA2C;AAE3C,iDAAiF;AAEjF,4CAcqB;AAGd,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,GAenB,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAElE,MAAM,UAAU,GAAG,IAAA,mCAAuB,EAAC,IAAI,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAA;IACpF,MAAM,SAAS,GAAG,IAAA,wCAA4B,EAAC,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IAClG,MAAM,cAAc,GAAG,IAAA,wCAA4B,EAAC,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IACvG,MAAM,iBAAiB,GAAG,IAAA,gCAAoB,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAC5F,MAAM,yBAAyB,GAAG,IAAA,+CAAmC,EAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAA;IAEnH,mEAAmE;IACnE,cAAc;IACd,UAAU;IACV,2BAA2B;IAC3B,4BAA4B;IAC5B,2BAA2B;IAC3B,WAAW;IACX,UAAU;IACV,iCAAiC;IAC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V,yBAAyB;QACzB,kBAAkB;QAClB,oDAAoD;QACpD,iBAAiB,EAAE,oBAAoB;QACvC,SAAS;KACV,CAAC;SACD,iBAAiB,CAAC,iBAAiB,CAAC;SACpC,WAAW,EAAE,CAAA;IAEhB,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAnHY,QAAA,mBAAmB,uBAmH/B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exponent-labs/kamino-lend-standard",
|
|
3
|
+
"version": "0.9.3",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
|
+
"license": "AGPL-3.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --build"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@coral-xyz/anchor": "^0.31.0",
|
|
12
|
+
"@exponent-labs/exponent-admin-pda": "0.9.3",
|
|
13
|
+
"@exponent-labs/marginfi-sy-pda": "0.9.3",
|
|
14
|
+
"@solana/spl-token": "^0.4.8",
|
|
15
|
+
"@solana/web3.js": "1.95.8",
|
|
16
|
+
"anchor-bankrun": "0.5.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.12.12",
|
|
20
|
+
"typescript": "^5.4.5"
|
|
21
|
+
}
|
|
22
|
+
}
|