@exponent-labs/kamino-sy-sdk 0.0.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/CHANGELOG.md +16 -0
- package/build/index.d.ts +63 -0
- package/build/index.js +299 -0
- package/build/index.js.map +1 -0
- package/build/tryit.d.ts +1 -0
- package/build/tryit.js +23 -0
- package/build/tryit.js.map +1 -0
- package/package.json +23 -0
- package/src/index.ts +368 -0
- package/src/tryit.ts +24 -0
- package/tsconfig.json +24 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.0.3](https://github.com/exponent-finance/exponent-core/compare/@exponent-labs/kamino-sy-sdk@0.0.2...@exponent-labs/kamino-sy-sdk@0.0.3) (2025-03-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @exponent-labs/kamino-sy-sdk
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.0.2](https://github.com/exponent-finance/exponent-core/compare/@exponent-labs/kamino-sy-sdk@0.0.1...@exponent-labs/kamino-sy-sdk@0.0.2) (2025-03-03)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @exponent-labs/kamino-sy-sdk
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Wallet, web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import { KaminoSyPda } from "@exponent-labs/kamino-sy-pda";
|
|
3
|
+
import { KaminoPda } from "@exponent-labs/kamino-pda";
|
|
4
|
+
import { KaminoSyState, KaminoSyMetaAccount } from "@exponent-labs/exponent-types";
|
|
5
|
+
export declare class MyWallet implements Wallet {
|
|
6
|
+
readonly payer: web3.Keypair;
|
|
7
|
+
constructor(payer: web3.Keypair);
|
|
8
|
+
signTransaction<T extends web3.Transaction | web3.VersionedTransaction>(tx: T): Promise<T>;
|
|
9
|
+
signAllTransactions<T extends web3.Transaction | web3.VersionedTransaction>(txs: T[]): Promise<T[]>;
|
|
10
|
+
get publicKey(): web3.PublicKey;
|
|
11
|
+
}
|
|
12
|
+
export declare class KlendSySdk {
|
|
13
|
+
state: KaminoSyState;
|
|
14
|
+
/** Private program for building instructions */
|
|
15
|
+
private program;
|
|
16
|
+
syPda: KaminoSyPda;
|
|
17
|
+
klendPda: KaminoPda;
|
|
18
|
+
constructor(state: KaminoSyState);
|
|
19
|
+
/** Load an instance of SyMeta */
|
|
20
|
+
static load({ cnx, klendReserve, klendMarketId, klendSyProgramId, klendProgramId, }: {
|
|
21
|
+
cnx: web3.Connection;
|
|
22
|
+
klendReserve: web3.PublicKey;
|
|
23
|
+
klendMarketId: web3.PublicKey;
|
|
24
|
+
klendSyProgramId: web3.PublicKey;
|
|
25
|
+
klendProgramId?: web3.PublicKey;
|
|
26
|
+
}): Promise<KlendSySdk>;
|
|
27
|
+
/** Reload the state of the account */
|
|
28
|
+
reload(cnx: web3.Connection): Promise<void>;
|
|
29
|
+
get account(): KaminoSyMetaAccount;
|
|
30
|
+
get mintSy(): web3.PublicKey;
|
|
31
|
+
get maxSySupply(): string;
|
|
32
|
+
get minMintSize(): string;
|
|
33
|
+
get minRedeemSize(): string;
|
|
34
|
+
get mintBase(): web3.PublicKey;
|
|
35
|
+
get selfAddress(): web3.PublicKey;
|
|
36
|
+
get tokenProgramBase(): web3.PublicKey;
|
|
37
|
+
get tokenBaseAccountAuthority(): web3.PublicKey;
|
|
38
|
+
get klendReserve(): web3.PublicKey;
|
|
39
|
+
get klendFarm(): web3.PublicKey;
|
|
40
|
+
get klendObligation(): web3.PublicKey;
|
|
41
|
+
get klendUserMetadata(): web3.PublicKey;
|
|
42
|
+
get tokenSyEscrow(): web3.PublicKey;
|
|
43
|
+
get klendSyProgramId(): web3.PublicKey;
|
|
44
|
+
get klendProgramId(): web3.PublicKey;
|
|
45
|
+
get klendMarket(): web3.PublicKey;
|
|
46
|
+
get reserveDestinationDepositCollateral(): web3.PublicKey;
|
|
47
|
+
get reserveCollateralMint(): web3.PublicKey;
|
|
48
|
+
get reserveLiquiditySupply(): web3.PublicKey;
|
|
49
|
+
get lendingMarketAuthority(): web3.PublicKey;
|
|
50
|
+
ixMintSy({ depositor, amountBase, baseSrc, syDst, }: {
|
|
51
|
+
depositor: web3.PublicKey;
|
|
52
|
+
amountBase: string;
|
|
53
|
+
baseSrc?: web3.PublicKey;
|
|
54
|
+
syDst?: web3.PublicKey;
|
|
55
|
+
}): Promise<web3.TransactionInstruction>;
|
|
56
|
+
ixRedeemSy({ redeemer, amountSy, baseDst, sySrc, }: {
|
|
57
|
+
redeemer: web3.PublicKey;
|
|
58
|
+
amountSy: string;
|
|
59
|
+
baseDst?: web3.PublicKey;
|
|
60
|
+
sySrc?: web3.PublicKey;
|
|
61
|
+
}): Promise<web3.TransactionInstruction>;
|
|
62
|
+
ixRefreshObligationAndFarms(crank: web3.PublicKey): web3.TransactionInstruction[];
|
|
63
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KlendSySdk = exports.MyWallet = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const kamino_sy_idl_1 = require("@exponent-labs/kamino-sy-idl");
|
|
6
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
7
|
+
const kamino_sy_pda_1 = require("@exponent-labs/kamino-sy-pda");
|
|
8
|
+
const kamino_pda_1 = require("@exponent-labs/kamino-pda");
|
|
9
|
+
const exponent_fetcher_1 = require("@exponent-labs/exponent-fetcher");
|
|
10
|
+
const kamino_lend_standard_1 = require("@exponent-labs/kamino-lend-standard");
|
|
11
|
+
function transformSyMetaAccountRaw(s) {
|
|
12
|
+
return {
|
|
13
|
+
kaminoReserve: s.kamino_reserve,
|
|
14
|
+
kaminoObligation: s.kamino_obligation,
|
|
15
|
+
kaminoFarm: s.kamino_farm,
|
|
16
|
+
kaminoUserMetadata: s.kamino_user_metadata,
|
|
17
|
+
mintSy: s.mint_sy,
|
|
18
|
+
tokenSyEscrow: s.token_sy_escrow,
|
|
19
|
+
maxSySupply: s.max_sy_supply.toString(),
|
|
20
|
+
minMintSize: s.min_mint_size.toString(),
|
|
21
|
+
minRedeemSize: s.min_redeem_size.toString(),
|
|
22
|
+
userState: s.user_state,
|
|
23
|
+
emissions: s.emissions.map((e) => ({
|
|
24
|
+
mint: e.mint,
|
|
25
|
+
tokenProgram: e.tokenProgram,
|
|
26
|
+
escrowAccount: e.escrowAccount,
|
|
27
|
+
index: e.index,
|
|
28
|
+
lastSeenIndex: e.lastSeenIndex,
|
|
29
|
+
lastSeenTotalAccruedEmissions: e.lastSeenTotalAccruedEmissions,
|
|
30
|
+
totalClaimedEmissions: e.totalClaimedEmissions,
|
|
31
|
+
treasuryEmission: e.treasuryEmission,
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async function loadAccountState(cnx, klendReserve, klendSyProgramId) {
|
|
36
|
+
const pda = new kamino_sy_pda_1.KaminoSyPda(klendSyProgramId);
|
|
37
|
+
const syMetaAddress = pda.syMeta({ kaminoReserve: klendReserve });
|
|
38
|
+
const coder = new anchor_1.BorshCoder(kamino_sy_idl_1.IDL);
|
|
39
|
+
const ai = await cnx.getAccountInfo(syMetaAddress);
|
|
40
|
+
const a = coder.accounts.decode("SyMeta", ai.data);
|
|
41
|
+
return transformSyMetaAccountRaw(a);
|
|
42
|
+
}
|
|
43
|
+
const KAMINO_LEND_PROGRAM_ID = new anchor_1.web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
44
|
+
class MyWallet {
|
|
45
|
+
payer;
|
|
46
|
+
constructor(payer) {
|
|
47
|
+
this.payer = payer;
|
|
48
|
+
this.payer = payer;
|
|
49
|
+
}
|
|
50
|
+
async signTransaction(tx) {
|
|
51
|
+
if (tx instanceof anchor_1.web3.Transaction) {
|
|
52
|
+
tx.partialSign(this.payer);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
tx.sign([this.payer]);
|
|
56
|
+
}
|
|
57
|
+
return tx;
|
|
58
|
+
}
|
|
59
|
+
async signAllTransactions(txs) {
|
|
60
|
+
return txs.map((t) => {
|
|
61
|
+
if (t instanceof anchor_1.web3.Transaction) {
|
|
62
|
+
t.partialSign(this.payer);
|
|
63
|
+
}
|
|
64
|
+
else if (t instanceof anchor_1.web3.VersionedTransaction) {
|
|
65
|
+
t.sign([this.payer]);
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
get publicKey() {
|
|
71
|
+
return this.payer.publicKey;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.MyWallet = MyWallet;
|
|
75
|
+
class KlendSySdk {
|
|
76
|
+
state;
|
|
77
|
+
/** Private program for building instructions */
|
|
78
|
+
program;
|
|
79
|
+
syPda;
|
|
80
|
+
klendPda;
|
|
81
|
+
constructor(state) {
|
|
82
|
+
this.state = state;
|
|
83
|
+
// create a fake AnchorProvider -- which is unused
|
|
84
|
+
this.program = new anchor_1.Program(kamino_sy_idl_1.IDL, new anchor_1.AnchorProvider(new anchor_1.web3.Connection("https://api.devnet.solana.com"), new MyWallet(anchor_1.web3.Keypair.generate())));
|
|
85
|
+
this.syPda = new kamino_sy_pda_1.KaminoSyPda(state.klendSyProgramId);
|
|
86
|
+
this.klendPda = new kamino_pda_1.KaminoPda(state.klendProgramId);
|
|
87
|
+
}
|
|
88
|
+
/** Load an instance of SyMeta */
|
|
89
|
+
static async load({ cnx, klendReserve, klendMarketId, klendSyProgramId, klendProgramId, }) {
|
|
90
|
+
const account = await loadAccountState(cnx, klendReserve, klendSyProgramId);
|
|
91
|
+
const b = await (0, exponent_fetcher_1.fetchKaminoReserve)(klendReserve, cnx);
|
|
92
|
+
const baseMintAi = await cnx.getAccountInfo(b.baseMint);
|
|
93
|
+
const tokenProgramBase = baseMintAi.owner;
|
|
94
|
+
const selfAddress = new kamino_sy_pda_1.KaminoSyPda(klendSyProgramId).syMeta({ kaminoReserve: klendReserve });
|
|
95
|
+
const state = {
|
|
96
|
+
selfAddress,
|
|
97
|
+
account,
|
|
98
|
+
klendSyProgramId,
|
|
99
|
+
syRate: b.assetShareValue.toString(),
|
|
100
|
+
mintBase: b.baseMint,
|
|
101
|
+
tokenProgramBase,
|
|
102
|
+
klendProgramId: klendProgramId || KAMINO_LEND_PROGRAM_ID,
|
|
103
|
+
klendMarketId,
|
|
104
|
+
};
|
|
105
|
+
return new KlendSySdk(state);
|
|
106
|
+
}
|
|
107
|
+
/** Reload the state of the account */
|
|
108
|
+
async reload(cnx) {
|
|
109
|
+
const b = await (0, exponent_fetcher_1.fetchKaminoReserve)(this.klendReserve, cnx);
|
|
110
|
+
const account = await loadAccountState(cnx, this.state.account.kaminoReserve, this.state.klendSyProgramId);
|
|
111
|
+
this.state.account = account;
|
|
112
|
+
this.state.syRate = b.assetShareValue.toString();
|
|
113
|
+
}
|
|
114
|
+
get account() {
|
|
115
|
+
return this.state.account;
|
|
116
|
+
}
|
|
117
|
+
get mintSy() {
|
|
118
|
+
return this.account.mintSy;
|
|
119
|
+
}
|
|
120
|
+
get maxSySupply() {
|
|
121
|
+
return this.account.maxSySupply;
|
|
122
|
+
}
|
|
123
|
+
get minMintSize() {
|
|
124
|
+
return this.account.minMintSize;
|
|
125
|
+
}
|
|
126
|
+
get minRedeemSize() {
|
|
127
|
+
return this.account.minRedeemSize;
|
|
128
|
+
}
|
|
129
|
+
get mintBase() {
|
|
130
|
+
return this.state.mintBase;
|
|
131
|
+
}
|
|
132
|
+
get selfAddress() {
|
|
133
|
+
return this.state.selfAddress;
|
|
134
|
+
}
|
|
135
|
+
get tokenProgramBase() {
|
|
136
|
+
return this.state.tokenProgramBase;
|
|
137
|
+
}
|
|
138
|
+
get tokenBaseAccountAuthority() {
|
|
139
|
+
return this.syPda.accountAuthorityToken({ reserve: this.klendReserve });
|
|
140
|
+
}
|
|
141
|
+
get klendReserve() {
|
|
142
|
+
return this.state.account.kaminoReserve;
|
|
143
|
+
}
|
|
144
|
+
get klendFarm() {
|
|
145
|
+
return this.state.account.kaminoFarm;
|
|
146
|
+
}
|
|
147
|
+
get klendObligation() {
|
|
148
|
+
return this.state.account.kaminoObligation;
|
|
149
|
+
}
|
|
150
|
+
get klendUserMetadata() {
|
|
151
|
+
return this.state.account.kaminoUserMetadata;
|
|
152
|
+
}
|
|
153
|
+
get tokenSyEscrow() {
|
|
154
|
+
return this.state.account.tokenSyEscrow;
|
|
155
|
+
}
|
|
156
|
+
get klendSyProgramId() {
|
|
157
|
+
return this.state.klendSyProgramId;
|
|
158
|
+
}
|
|
159
|
+
get klendProgramId() {
|
|
160
|
+
return this.state.klendProgramId;
|
|
161
|
+
}
|
|
162
|
+
get klendMarket() {
|
|
163
|
+
return this.state.klendMarketId;
|
|
164
|
+
}
|
|
165
|
+
get reserveDestinationDepositCollateral() {
|
|
166
|
+
return this.klendPda.getKaminoReserveCollateralSupply({
|
|
167
|
+
lendingMarket: this.klendMarket,
|
|
168
|
+
reserveLiquidityMint: this.mintBase,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
get reserveCollateralMint() {
|
|
172
|
+
return this.klendPda.getKaminoReserveCollateralMint({
|
|
173
|
+
lendingMarket: this.klendMarket,
|
|
174
|
+
reserveLiquidityMint: this.mintBase,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
get reserveLiquiditySupply() {
|
|
178
|
+
return this.klendPda.getKaminoReserveLiquiditySupply({
|
|
179
|
+
lendingMarket: this.klendMarket,
|
|
180
|
+
reserveLiquidityMint: this.mintBase,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
get lendingMarketAuthority() {
|
|
184
|
+
return this.klendPda.getKaminoLendingMarketAuthority({ lendingMarket: this.klendMarket });
|
|
185
|
+
}
|
|
186
|
+
ixMintSy({ depositor, amountBase, baseSrc, syDst, }) {
|
|
187
|
+
baseSrc = baseSrc || (0, spl_token_1.getAssociatedTokenAddressSync)(this.mintBase, depositor, true, this.state.tokenProgramBase);
|
|
188
|
+
syDst = syDst || (0, spl_token_1.getAssociatedTokenAddressSync)(this.mintSy, depositor, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
189
|
+
console.log();
|
|
190
|
+
return this.program.methods
|
|
191
|
+
.mint(new anchor_1.BN(amountBase))
|
|
192
|
+
.accountsStrict({
|
|
193
|
+
meta: this.selfAddress,
|
|
194
|
+
kaminoReserve: this.klendReserve,
|
|
195
|
+
mintBase: this.mintBase,
|
|
196
|
+
tokenBaseSigner: baseSrc,
|
|
197
|
+
mintSy: this.mintSy,
|
|
198
|
+
tokenSySigner: syDst,
|
|
199
|
+
tokenProgramBase: this.tokenProgramBase,
|
|
200
|
+
token22Program: spl_token_1.TOKEN_PROGRAM_ID,
|
|
201
|
+
kaminoLendProgram: this.klendProgramId,
|
|
202
|
+
kaminoObligation: this.klendObligation,
|
|
203
|
+
reserveDestinationDepositCollateral: this.reserveDestinationDepositCollateral,
|
|
204
|
+
kaminoCollateralTokenProgram: this.tokenProgramBase,
|
|
205
|
+
lendingMarket: this.klendMarket,
|
|
206
|
+
reserveCollateralMint: this.reserveCollateralMint,
|
|
207
|
+
reserveLiquiditySupply: this.reserveLiquiditySupply,
|
|
208
|
+
signer: depositor,
|
|
209
|
+
lendingMarketAuthority: this.lendingMarketAuthority,
|
|
210
|
+
tokenBaseAccountAuthority: this.tokenBaseAccountAuthority,
|
|
211
|
+
instruction: anchor_1.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
212
|
+
})
|
|
213
|
+
.instruction();
|
|
214
|
+
}
|
|
215
|
+
ixRedeemSy({ redeemer, amountSy, baseDst, sySrc, }) {
|
|
216
|
+
baseDst = baseDst || (0, spl_token_1.getAssociatedTokenAddressSync)(this.mintBase, redeemer, true, this.tokenProgramBase);
|
|
217
|
+
sySrc = sySrc || (0, spl_token_1.getAssociatedTokenAddressSync)(this.mintSy, redeemer, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
218
|
+
return this.program.methods
|
|
219
|
+
.redeem(new anchor_1.BN(amountSy))
|
|
220
|
+
.accountsStrict({
|
|
221
|
+
meta: this.selfAddress,
|
|
222
|
+
kaminoReserve: this.klendReserve,
|
|
223
|
+
mintBase: this.mintBase,
|
|
224
|
+
tokenBaseSigner: baseDst,
|
|
225
|
+
mintSy: this.mintSy,
|
|
226
|
+
tokenSySigner: sySrc,
|
|
227
|
+
tokenProgramBase: this.tokenProgramBase,
|
|
228
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
229
|
+
kaminoLendProgram: this.klendProgramId,
|
|
230
|
+
kaminoObligation: this.klendObligation,
|
|
231
|
+
reserveSourceCollateral: this.reserveDestinationDepositCollateral,
|
|
232
|
+
systemProgram: anchor_1.web3.SystemProgram.programId,
|
|
233
|
+
lendingMarket: this.klendMarket,
|
|
234
|
+
reserveCollateralMint: this.reserveCollateralMint,
|
|
235
|
+
reserveLiquiditySupply: this.reserveLiquiditySupply,
|
|
236
|
+
signer: redeemer,
|
|
237
|
+
lendingMarketAuthority: this.lendingMarketAuthority,
|
|
238
|
+
tokenBaseAccountAuthority: this.tokenBaseAccountAuthority,
|
|
239
|
+
instruction: anchor_1.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
240
|
+
})
|
|
241
|
+
.instruction();
|
|
242
|
+
}
|
|
243
|
+
ixRefreshObligationAndFarms(crank) {
|
|
244
|
+
console.log("klend program id", this.klendProgramId);
|
|
245
|
+
const refreshReserveIx = new anchor_1.web3.TransactionInstruction({
|
|
246
|
+
keys: [
|
|
247
|
+
{ pubkey: this.klendReserve, isWritable: true, isSigner: false },
|
|
248
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
249
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
250
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
251
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
252
|
+
// scope prices
|
|
253
|
+
{
|
|
254
|
+
pubkey: new anchor_1.web3.PublicKey("3NJYftD5sjVfxSnUdZ1wVML8f3aC6mp1CXCL6L7TnU8C"),
|
|
255
|
+
isWritable: false,
|
|
256
|
+
isSigner: false,
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
programId: this.klendProgramId,
|
|
260
|
+
data: Buffer.from([2, 218, 138, 235, 79, 201, 25, 102]),
|
|
261
|
+
});
|
|
262
|
+
const refreshObligationIx = new anchor_1.web3.TransactionInstruction({
|
|
263
|
+
keys: [
|
|
264
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
265
|
+
{ pubkey: this.klendObligation, isWritable: true, isSigner: false },
|
|
266
|
+
{ pubkey: this.klendReserve, isWritable: false, isSigner: false },
|
|
267
|
+
],
|
|
268
|
+
programId: this.klendProgramId,
|
|
269
|
+
data: Buffer.from([33, 132, 147, 228, 151, 192, 72, 89]),
|
|
270
|
+
});
|
|
271
|
+
const refreshObligationFarmsForReserveIx = new anchor_1.web3.TransactionInstruction({
|
|
272
|
+
keys: [
|
|
273
|
+
{ pubkey: crank, isWritable: true, isSigner: true },
|
|
274
|
+
{ pubkey: this.klendObligation, isWritable: true, isSigner: false },
|
|
275
|
+
{ pubkey: this.lendingMarketAuthority, isWritable: true, isSigner: false },
|
|
276
|
+
{ pubkey: this.klendReserve, isWritable: true, isSigner: false },
|
|
277
|
+
{ pubkey: this.klendFarm, isWritable: true, isSigner: false },
|
|
278
|
+
{
|
|
279
|
+
pubkey: this.klendPda.getKaminoFarmsObligationFarm({
|
|
280
|
+
obligation: this.klendObligation,
|
|
281
|
+
reserveFarmState: this.klendFarm,
|
|
282
|
+
farmsProgramId: kamino_lend_standard_1.KAMINO_FARMS_PROGRAM_ID,
|
|
283
|
+
}),
|
|
284
|
+
isWritable: true,
|
|
285
|
+
isSigner: false,
|
|
286
|
+
},
|
|
287
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
288
|
+
{ pubkey: kamino_lend_standard_1.KAMINO_FARMS_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
289
|
+
{ pubkey: anchor_1.web3.SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
|
|
290
|
+
{ pubkey: anchor_1.web3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
291
|
+
],
|
|
292
|
+
programId: this.klendProgramId,
|
|
293
|
+
data: Buffer.from([140, 144, 253, 21, 10, 74, 248, 3, 0]),
|
|
294
|
+
});
|
|
295
|
+
return [refreshReserveIx, refreshObligationIx, refreshObligationFarmsForReserveIx];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.KlendSySdk = KlendSySdk;
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAAyF;AACzF,gEAAsE;AACtE,iDAAmF;AACnF,gEAA0D;AAC1D,0DAAqD;AACrD,sEAAoE;AACpE,8EAA6E;AAG7E,SAAS,yBAAyB,CAAC,CAAyB;IAC1D,OAAO;QACL,aAAa,EAAE,CAAC,CAAC,cAAc;QAC/B,gBAAgB,EAAE,CAAC,CAAC,iBAAiB;QACrC,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,kBAAkB,EAAE,CAAC,CAAC,oBAAoB;QAC1C,MAAM,EAAE,CAAC,CAAC,OAAO;QACjB,aAAa,EAAE,CAAC,CAAC,eAAe;QAChC,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE;QACvC,WAAW,EAAE,CAAC,CAAC,aAAa,C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,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;gBACvE,EAAE,MAAM,EAAE,aAAI,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;aAC7E;YACD,SAAS,EAAE,IAAI,CAAC,cAAc;YAC9B,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;SAC1D,CAAC,CAAA;QAEF,OAAO,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,kCAAkC,CAAC,CAAA;IACpF,CAAC;CACF;AApSD,gCAoSC"}
|
package/build/tryit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/tryit.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
async function main() {
|
|
6
|
+
const cnx = new anchor_1.web3.Connection("https://api.mainnet-beta.solana.com");
|
|
7
|
+
const klendMarket = new anchor_1.web3.PublicKey("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF");
|
|
8
|
+
const klendReserve = new anchor_1.web3.PublicKey("D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59");
|
|
9
|
+
const klendSyProgramId = new anchor_1.web3.PublicKey("XPK1ndTK1xrgRg99ifvdPP1exrx8D1mRXTuxBkkroCx");
|
|
10
|
+
const klendProgramId = new anchor_1.web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
11
|
+
const sdk = await _1.KlendSySdk.load({
|
|
12
|
+
cnx,
|
|
13
|
+
klendMarketId: klendMarket,
|
|
14
|
+
klendReserve,
|
|
15
|
+
klendSyProgramId,
|
|
16
|
+
klendProgramId,
|
|
17
|
+
});
|
|
18
|
+
console.log(sdk);
|
|
19
|
+
}
|
|
20
|
+
main()
|
|
21
|
+
.then(() => console.log("done"))
|
|
22
|
+
.catch((err) => console.error(err));
|
|
23
|
+
//# sourceMappingURL=tryit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryit.js","sourceRoot":"","sources":["../src/tryit.ts"],"names":[],"mappings":";;AAAA,8CAAwC;AACxC,wBAA8B;AAE9B,KAAK,UAAU,IAAI;IACjB,MAAM,GAAG,GAAG,IAAI,aAAI,CAAC,UAAU,CAAC,qCAAqC,CAAC,CAAA;IACtE,MAAM,WAAW,GAAG,IAAI,aAAI,CAAC,SAAS,CAAC,8CAA8C,CAAC,CAAA;IACtF,MAAM,YAAY,GAAG,IAAI,aAAI,CAAC,SAAS,CAAC,8CAA8C,CAAC,CAAA;IACvF,MAAM,gBAAgB,GAAG,IAAI,aAAI,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAA;IAC1F,MAAM,cAAc,GAAG,IAAI,aAAI,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAA;IAExF,MAAM,GAAG,GAAG,MAAM,aAAU,CAAC,IAAI,CAAC;QAChC,GAAG;QACH,aAAa,EAAE,WAAW;QAC1B,YAAY;QACZ,gBAAgB;QAChB,cAAc;KACf,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAC/B,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exponent-labs/kamino-sy-sdk",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
|
+
"license": "AGPL-3.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --build",
|
|
9
|
+
"tryit": "ts-node src/tryit.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@coral-xyz/anchor": "^0.30.1",
|
|
13
|
+
"@exponent-labs/exponent-fetcher": "^0.0.3",
|
|
14
|
+
"@exponent-labs/kamino-pda": "^0.0.3",
|
|
15
|
+
"@exponent-labs/kamino-sy-idl": "^0.0.3",
|
|
16
|
+
"@exponent-labs/kamino-sy-pda": "^0.0.3",
|
|
17
|
+
"@solana/spl-token": "^0.4.6"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.4.5"
|
|
21
|
+
},
|
|
22
|
+
"gitHead": "209b8847e9a0fadb5b5ec96b9b47f0ace4a3bf9d"
|
|
23
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { AnchorProvider, BN, BorshCoder, Program, Wallet, web3 } from "@coral-xyz/anchor"
|
|
2
|
+
import { IDL, KaminoLendStandard } from "@exponent-labs/kamino-sy-idl"
|
|
3
|
+
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token"
|
|
4
|
+
import { KaminoSyPda } from "@exponent-labs/kamino-sy-pda"
|
|
5
|
+
import { KaminoPda } from "@exponent-labs/kamino-pda"
|
|
6
|
+
import { fetchKaminoReserve } from "@exponent-labs/exponent-fetcher"
|
|
7
|
+
import { KAMINO_FARMS_PROGRAM_ID } from "@exponent-labs/kamino-lend-standard"
|
|
8
|
+
import { KaminoSyState, KaminoSyMetaAccount, KaminoSyMetaAccountRaw } from "@exponent-labs/exponent-types"
|
|
9
|
+
|
|
10
|
+
function transformSyMetaAccountRaw(s: KaminoSyMetaAccountRaw): KaminoSyMetaAccount {
|
|
11
|
+
return {
|
|
12
|
+
kaminoReserve: s.kamino_reserve,
|
|
13
|
+
kaminoObligation: s.kamino_obligation,
|
|
14
|
+
kaminoFarm: s.kamino_farm,
|
|
15
|
+
kaminoUserMetadata: s.kamino_user_metadata,
|
|
16
|
+
mintSy: s.mint_sy,
|
|
17
|
+
tokenSyEscrow: s.token_sy_escrow,
|
|
18
|
+
maxSySupply: s.max_sy_supply.toString(),
|
|
19
|
+
minMintSize: s.min_mint_size.toString(),
|
|
20
|
+
minRedeemSize: s.min_redeem_size.toString(),
|
|
21
|
+
userState: s.user_state,
|
|
22
|
+
emissions: s.emissions.map((e) => ({
|
|
23
|
+
mint: e.mint,
|
|
24
|
+
tokenProgram: e.tokenProgram,
|
|
25
|
+
escrowAccount: e.escrowAccount,
|
|
26
|
+
index: e.index,
|
|
27
|
+
lastSeenIndex: e.lastSeenIndex,
|
|
28
|
+
lastSeenTotalAccruedEmissions: e.lastSeenTotalAccruedEmissions,
|
|
29
|
+
totalClaimedEmissions: e.totalClaimedEmissions,
|
|
30
|
+
treasuryEmission: e.treasuryEmission,
|
|
31
|
+
})),
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function loadAccountState(cnx: web3.Connection, klendReserve: web3.PublicKey, klendSyProgramId: web3.PublicKey) {
|
|
36
|
+
const pda = new KaminoSyPda(klendSyProgramId)
|
|
37
|
+
const syMetaAddress = pda.syMeta({ kaminoReserve: klendReserve })
|
|
38
|
+
const coder = new BorshCoder(IDL as KaminoLendStandard)
|
|
39
|
+
const ai = await cnx.getAccountInfo(syMetaAddress)
|
|
40
|
+
const a = coder.accounts.decode("SyMeta", ai.data)
|
|
41
|
+
return transformSyMetaAccountRaw(a)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const KAMINO_LEND_PROGRAM_ID = new web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD")
|
|
45
|
+
|
|
46
|
+
export class MyWallet implements Wallet {
|
|
47
|
+
constructor(readonly payer: web3.Keypair) {
|
|
48
|
+
this.payer = payer
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async signTransaction<T extends web3.Transaction | web3.VersionedTransaction>(tx: T): Promise<T> {
|
|
52
|
+
if (tx instanceof web3.Transaction) {
|
|
53
|
+
tx.partialSign(this.payer)
|
|
54
|
+
} else {
|
|
55
|
+
tx.sign([this.payer])
|
|
56
|
+
}
|
|
57
|
+
return tx
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async signAllTransactions<T extends web3.Transaction | web3.VersionedTransaction>(txs: T[]): Promise<T[]> {
|
|
61
|
+
return txs.map((t) => {
|
|
62
|
+
if (t instanceof web3.Transaction) {
|
|
63
|
+
t.partialSign(this.payer)
|
|
64
|
+
} else if (t instanceof web3.VersionedTransaction) {
|
|
65
|
+
t.sign([this.payer])
|
|
66
|
+
}
|
|
67
|
+
return t
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get publicKey(): web3.PublicKey {
|
|
72
|
+
return this.payer.publicKey
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class KlendSySdk {
|
|
77
|
+
/** Private program for building instructions */
|
|
78
|
+
private program: Program<KaminoLendStandard>
|
|
79
|
+
|
|
80
|
+
syPda: KaminoSyPda
|
|
81
|
+
klendPda: KaminoPda
|
|
82
|
+
|
|
83
|
+
constructor(public state: KaminoSyState) {
|
|
84
|
+
// create a fake AnchorProvider -- which is unused
|
|
85
|
+
this.program = new Program<KaminoLendStandard>(
|
|
86
|
+
IDL as KaminoLendStandard,
|
|
87
|
+
new AnchorProvider(new web3.Connection("https://api.devnet.solana.com"), new MyWallet(web3.Keypair.generate())),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
this.syPda = new KaminoSyPda(state.klendSyProgramId)
|
|
91
|
+
this.klendPda = new KaminoPda(state.klendProgramId)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Load an instance of SyMeta */
|
|
95
|
+
static async load({
|
|
96
|
+
cnx,
|
|
97
|
+
klendReserve,
|
|
98
|
+
klendMarketId,
|
|
99
|
+
klendSyProgramId,
|
|
100
|
+
klendProgramId,
|
|
101
|
+
}: {
|
|
102
|
+
cnx: web3.Connection
|
|
103
|
+
klendReserve: web3.PublicKey
|
|
104
|
+
klendMarketId: web3.PublicKey
|
|
105
|
+
klendSyProgramId: web3.PublicKey
|
|
106
|
+
klendProgramId?: web3.PublicKey
|
|
107
|
+
}) {
|
|
108
|
+
const account = await loadAccountState(cnx, klendReserve, klendSyProgramId)
|
|
109
|
+
const b = await fetchKaminoReserve(klendReserve, cnx)
|
|
110
|
+
const baseMintAi = await cnx.getAccountInfo(b.baseMint)
|
|
111
|
+
const tokenProgramBase = baseMintAi.owner
|
|
112
|
+
const selfAddress = new KaminoSyPda(klendSyProgramId).syMeta({ kaminoReserve: klendReserve })
|
|
113
|
+
|
|
114
|
+
const state = {
|
|
115
|
+
selfAddress,
|
|
116
|
+
account,
|
|
117
|
+
klendSyProgramId,
|
|
118
|
+
syRate: b.assetShareValue.toString(),
|
|
119
|
+
mintBase: b.baseMint,
|
|
120
|
+
tokenProgramBase,
|
|
121
|
+
klendProgramId: klendProgramId || KAMINO_LEND_PROGRAM_ID,
|
|
122
|
+
klendMarketId,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return new KlendSySdk(state)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Reload the state of the account */
|
|
129
|
+
async reload(cnx: web3.Connection) {
|
|
130
|
+
const b = await fetchKaminoReserve(this.klendReserve, cnx)
|
|
131
|
+
const account = await loadAccountState(cnx, this.state.account.kaminoReserve, this.state.klendSyProgramId)
|
|
132
|
+
this.state.account = account
|
|
133
|
+
this.state.syRate = b.assetShareValue.toString()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get account() {
|
|
137
|
+
return this.state.account
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get mintSy() {
|
|
141
|
+
return this.account.mintSy
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get maxSySupply() {
|
|
145
|
+
return this.account.maxSySupply
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get minMintSize() {
|
|
149
|
+
return this.account.minMintSize
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get minRedeemSize() {
|
|
153
|
+
return this.account.minRedeemSize
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get mintBase() {
|
|
157
|
+
return this.state.mintBase
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get selfAddress() {
|
|
161
|
+
return this.state.selfAddress
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get tokenProgramBase() {
|
|
165
|
+
return this.state.tokenProgramBase
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
get tokenBaseAccountAuthority() {
|
|
169
|
+
return this.syPda.accountAuthorityToken({ reserve: this.klendReserve })
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get klendReserve() {
|
|
173
|
+
return this.state.account.kaminoReserve
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
get klendFarm() {
|
|
177
|
+
return this.state.account.kaminoFarm
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get klendObligation() {
|
|
181
|
+
return this.state.account.kaminoObligation
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get klendUserMetadata() {
|
|
185
|
+
return this.state.account.kaminoUserMetadata
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get tokenSyEscrow() {
|
|
189
|
+
return this.state.account.tokenSyEscrow
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
get klendSyProgramId() {
|
|
193
|
+
return this.state.klendSyProgramId
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
get klendProgramId() {
|
|
197
|
+
return this.state.klendProgramId
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
get klendMarket() {
|
|
201
|
+
return this.state.klendMarketId
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
get reserveDestinationDepositCollateral() {
|
|
205
|
+
return this.klendPda.getKaminoReserveCollateralSupply({
|
|
206
|
+
lendingMarket: this.klendMarket,
|
|
207
|
+
reserveLiquidityMint: this.mintBase,
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get reserveCollateralMint() {
|
|
212
|
+
return this.klendPda.getKaminoReserveCollateralMint({
|
|
213
|
+
lendingMarket: this.klendMarket,
|
|
214
|
+
reserveLiquidityMint: this.mintBase,
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
get reserveLiquiditySupply() {
|
|
219
|
+
return this.klendPda.getKaminoReserveLiquiditySupply({
|
|
220
|
+
lendingMarket: this.klendMarket,
|
|
221
|
+
reserveLiquidityMint: this.mintBase,
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
get lendingMarketAuthority() {
|
|
226
|
+
return this.klendPda.getKaminoLendingMarketAuthority({ lendingMarket: this.klendMarket })
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
ixMintSy({
|
|
230
|
+
depositor,
|
|
231
|
+
amountBase,
|
|
232
|
+
baseSrc,
|
|
233
|
+
syDst,
|
|
234
|
+
}: {
|
|
235
|
+
depositor: web3.PublicKey
|
|
236
|
+
amountBase: string
|
|
237
|
+
baseSrc?: web3.PublicKey
|
|
238
|
+
syDst?: web3.PublicKey
|
|
239
|
+
}) {
|
|
240
|
+
baseSrc = baseSrc || getAssociatedTokenAddressSync(this.mintBase, depositor, true, this.state.tokenProgramBase)
|
|
241
|
+
syDst = syDst || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
|
|
242
|
+
|
|
243
|
+
console.log()
|
|
244
|
+
|
|
245
|
+
return this.program.methods
|
|
246
|
+
.mint(new BN(amountBase))
|
|
247
|
+
.accountsStrict({
|
|
248
|
+
meta: this.selfAddress,
|
|
249
|
+
kaminoReserve: this.klendReserve,
|
|
250
|
+
mintBase: this.mintBase,
|
|
251
|
+
tokenBaseSigner: baseSrc,
|
|
252
|
+
mintSy: this.mintSy,
|
|
253
|
+
tokenSySigner: syDst,
|
|
254
|
+
tokenProgramBase: this.tokenProgramBase,
|
|
255
|
+
token22Program: TOKEN_PROGRAM_ID,
|
|
256
|
+
kaminoLendProgram: this.klendProgramId,
|
|
257
|
+
kaminoObligation: this.klendObligation,
|
|
258
|
+
reserveDestinationDepositCollateral: this.reserveDestinationDepositCollateral,
|
|
259
|
+
kaminoCollateralTokenProgram: this.tokenProgramBase,
|
|
260
|
+
lendingMarket: this.klendMarket,
|
|
261
|
+
reserveCollateralMint: this.reserveCollateralMint,
|
|
262
|
+
reserveLiquiditySupply: this.reserveLiquiditySupply,
|
|
263
|
+
signer: depositor,
|
|
264
|
+
lendingMarketAuthority: this.lendingMarketAuthority,
|
|
265
|
+
tokenBaseAccountAuthority: this.tokenBaseAccountAuthority,
|
|
266
|
+
instruction: web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
267
|
+
})
|
|
268
|
+
.instruction()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
ixRedeemSy({
|
|
272
|
+
redeemer,
|
|
273
|
+
amountSy,
|
|
274
|
+
baseDst,
|
|
275
|
+
sySrc,
|
|
276
|
+
}: {
|
|
277
|
+
redeemer: web3.PublicKey
|
|
278
|
+
amountSy: string
|
|
279
|
+
baseDst?: web3.PublicKey
|
|
280
|
+
sySrc?: web3.PublicKey
|
|
281
|
+
}) {
|
|
282
|
+
baseDst = baseDst || getAssociatedTokenAddressSync(this.mintBase, redeemer, true, this.tokenProgramBase)
|
|
283
|
+
sySrc = sySrc || getAssociatedTokenAddressSync(this.mintSy, redeemer, true, TOKEN_PROGRAM_ID)
|
|
284
|
+
|
|
285
|
+
return this.program.methods
|
|
286
|
+
.redeem(new BN(amountSy))
|
|
287
|
+
.accountsStrict({
|
|
288
|
+
meta: this.selfAddress,
|
|
289
|
+
kaminoReserve: this.klendReserve,
|
|
290
|
+
mintBase: this.mintBase,
|
|
291
|
+
tokenBaseSigner: baseDst,
|
|
292
|
+
mintSy: this.mintSy,
|
|
293
|
+
tokenSySigner: sySrc,
|
|
294
|
+
tokenProgramBase: this.tokenProgramBase,
|
|
295
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
296
|
+
kaminoLendProgram: this.klendProgramId,
|
|
297
|
+
kaminoObligation: this.klendObligation,
|
|
298
|
+
reserveSourceCollateral: this.reserveDestinationDepositCollateral,
|
|
299
|
+
systemProgram: web3.SystemProgram.programId,
|
|
300
|
+
lendingMarket: this.klendMarket,
|
|
301
|
+
reserveCollateralMint: this.reserveCollateralMint,
|
|
302
|
+
reserveLiquiditySupply: this.reserveLiquiditySupply,
|
|
303
|
+
signer: redeemer,
|
|
304
|
+
lendingMarketAuthority: this.lendingMarketAuthority,
|
|
305
|
+
tokenBaseAccountAuthority: this.tokenBaseAccountAuthority,
|
|
306
|
+
instruction: web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
307
|
+
})
|
|
308
|
+
.instruction()
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
ixRefreshObligationAndFarms(crank: web3.PublicKey) {
|
|
312
|
+
console.log("klend program id", this.klendProgramId)
|
|
313
|
+
const refreshReserveIx = new web3.TransactionInstruction({
|
|
314
|
+
keys: [
|
|
315
|
+
{ pubkey: this.klendReserve, isWritable: true, isSigner: false },
|
|
316
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
317
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
318
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
319
|
+
{ pubkey: this.klendProgramId, isWritable: false, isSigner: false },
|
|
320
|
+
// scope prices
|
|
321
|
+
{
|
|
322
|
+
pubkey: new web3.PublicKey("3NJYftD5sjVfxSnUdZ1wVML8f3aC6mp1CXCL6L7TnU8C"),
|
|
323
|
+
isWritable: false,
|
|
324
|
+
isSigner: false,
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
programId: this.klendProgramId,
|
|
328
|
+
data: Buffer.from([2, 218, 138, 235, 79, 201, 25, 102]),
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
const refreshObligationIx = new web3.TransactionInstruction({
|
|
332
|
+
keys: [
|
|
333
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
334
|
+
{ pubkey: this.klendObligation, isWritable: true, isSigner: false },
|
|
335
|
+
{ pubkey: this.klendReserve, isWritable: false, isSigner: false },
|
|
336
|
+
],
|
|
337
|
+
programId: this.klendProgramId,
|
|
338
|
+
data: Buffer.from([33, 132, 147, 228, 151, 192, 72, 89]),
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
const refreshObligationFarmsForReserveIx = new web3.TransactionInstruction({
|
|
342
|
+
keys: [
|
|
343
|
+
{ pubkey: crank, isWritable: true, isSigner: true },
|
|
344
|
+
{ pubkey: this.klendObligation, isWritable: true, isSigner: false },
|
|
345
|
+
{ pubkey: this.lendingMarketAuthority, isWritable: true, isSigner: false },
|
|
346
|
+
{ pubkey: this.klendReserve, isWritable: true, isSigner: false },
|
|
347
|
+
{ pubkey: this.klendFarm, isWritable: true, isSigner: false },
|
|
348
|
+
{
|
|
349
|
+
pubkey: this.klendPda.getKaminoFarmsObligationFarm({
|
|
350
|
+
obligation: this.klendObligation,
|
|
351
|
+
reserveFarmState: this.klendFarm,
|
|
352
|
+
farmsProgramId: KAMINO_FARMS_PROGRAM_ID,
|
|
353
|
+
}),
|
|
354
|
+
isWritable: true,
|
|
355
|
+
isSigner: false,
|
|
356
|
+
},
|
|
357
|
+
{ pubkey: this.klendMarket, isWritable: false, isSigner: false },
|
|
358
|
+
{ pubkey: KAMINO_FARMS_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
359
|
+
{ pubkey: web3.SYSVAR_RENT_PUBKEY, isWritable: false, isSigner: false },
|
|
360
|
+
{ pubkey: web3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
361
|
+
],
|
|
362
|
+
programId: this.klendProgramId,
|
|
363
|
+
data: Buffer.from([140, 144, 253, 21, 10, 74, 248, 3, 0]),
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
return [refreshReserveIx, refreshObligationIx, refreshObligationFarmsForReserveIx]
|
|
367
|
+
}
|
|
368
|
+
}
|
package/src/tryit.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor"
|
|
2
|
+
import { KlendSySdk } from "."
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
const cnx = new web3.Connection("https://api.mainnet-beta.solana.com")
|
|
6
|
+
const klendMarket = new web3.PublicKey("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF")
|
|
7
|
+
const klendReserve = new web3.PublicKey("D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59")
|
|
8
|
+
const klendSyProgramId = new web3.PublicKey("XPK1ndTK1xrgRg99ifvdPP1exrx8D1mRXTuxBkkroCx")
|
|
9
|
+
const klendProgramId = new web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD")
|
|
10
|
+
|
|
11
|
+
const sdk = await KlendSySdk.load({
|
|
12
|
+
cnx,
|
|
13
|
+
klendMarketId: klendMarket,
|
|
14
|
+
klendReserve,
|
|
15
|
+
klendSyProgramId,
|
|
16
|
+
klendProgramId,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
console.log(sdk)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then(() => console.log("done"))
|
|
24
|
+
.catch((err) => console.error(err))
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
|
|
6
|
+
"composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
|
|
7
|
+
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
8
|
+
"module": "CommonJS" /* Specify what module code is generated. */,
|
|
9
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
10
|
+
"outDir": "./build" /* Specify an output folder for all emitted files. */,
|
|
11
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
12
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
13
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts", "src/**/*.json"],
|
|
17
|
+
"exclude": ["node_modules", "build"],
|
|
18
|
+
"references": [
|
|
19
|
+
{ "path": "../kamino-sy-idl" },
|
|
20
|
+
{ "path": "../kamino-sy-pda" },
|
|
21
|
+
{ "path": "../kamino-pda" },
|
|
22
|
+
{ "path": "../exponent-fetcher" }
|
|
23
|
+
]
|
|
24
|
+
}
|