@kamino-finance/klend-sdk 5.12.7-beta.0 → 5.12.8
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/classes/manager.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -0
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +16 -0
- package/dist/classes/vault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +2 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js +2 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +4 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +12 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts +2 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js +2 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +26 -11
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +15 -10
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +1 -1
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.js +4 -4
- package/dist/leverage/operations.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +3 -2
- package/dist/utils/instruction.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/manager.ts +2 -2
- package/src/classes/vault.ts +16 -1
- package/src/idl_codegen_kamino_vault/instructions/deposit.ts +4 -0
- package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +16 -0
- package/src/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.ts +4 -0
- package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +31 -16
- package/src/idl_kamino_vault.json +120 -10
- package/src/lending_operations/repay_with_collateral_operations.ts +2 -2
- package/src/lending_operations/swap_collateral_operations.ts +2 -2
- package/src/leverage/operations.ts +5 -5
- package/src/utils/instruction.ts +2 -1
package/src/classes/vault.ts
CHANGED
|
@@ -109,7 +109,7 @@ const TOKEN_VAULT_SEED = 'token_vault';
|
|
|
109
109
|
const CTOKEN_VAULT_SEED = 'ctoken_vault';
|
|
110
110
|
const BASE_VAULT_AUTHORITY_SEED = 'authority';
|
|
111
111
|
const SHARES_SEED = 'shares';
|
|
112
|
-
|
|
112
|
+
const EVENT_AUTHORITY_SEED = '__event_authority';
|
|
113
113
|
export const INITIAL_DEPOSIT_LAMPORTS = 1000;
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -794,6 +794,7 @@ export class KaminoVaultClient {
|
|
|
794
794
|
]);
|
|
795
795
|
createAtasIxns.push(createSharesAtaIxns);
|
|
796
796
|
|
|
797
|
+
const eventAuthority = getEventAuthorityPda(this._kaminoVaultProgramId);
|
|
797
798
|
const depoistAccounts: DepositAccounts = {
|
|
798
799
|
user: user,
|
|
799
800
|
vaultState: vault.address,
|
|
@@ -806,6 +807,8 @@ export class KaminoVaultClient {
|
|
|
806
807
|
tokenProgram: tokenProgramID,
|
|
807
808
|
klendProgram: this._kaminoLendProgramId,
|
|
808
809
|
sharesTokenProgram: TOKEN_PROGRAM_ID,
|
|
810
|
+
eventAuthority: eventAuthority,
|
|
811
|
+
program: this._kaminoVaultProgramId,
|
|
809
812
|
};
|
|
810
813
|
|
|
811
814
|
const depositArgs: DepositArgs = {
|
|
@@ -1276,6 +1279,7 @@ export class KaminoVaultClient {
|
|
|
1276
1279
|
): TransactionInstruction {
|
|
1277
1280
|
const lendingMarketAuth = lendingMarketAuthPda(marketAddress, this._kaminoLendProgramId)[0];
|
|
1278
1281
|
|
|
1282
|
+
const eventAuthority = getEventAuthorityPda(this._kaminoVaultProgramId);
|
|
1279
1283
|
const withdrawAccounts: WithdrawAccounts = {
|
|
1280
1284
|
withdrawFromAvailable: {
|
|
1281
1285
|
user,
|
|
@@ -1289,6 +1293,8 @@ export class KaminoVaultClient {
|
|
|
1289
1293
|
tokenProgram: vaultState.tokenProgram,
|
|
1290
1294
|
sharesTokenProgram: TOKEN_PROGRAM_ID,
|
|
1291
1295
|
klendProgram: this._kaminoLendProgramId,
|
|
1296
|
+
eventAuthority: eventAuthority,
|
|
1297
|
+
program: this._kaminoVaultProgramId,
|
|
1292
1298
|
},
|
|
1293
1299
|
withdrawFromReserveAccounts: {
|
|
1294
1300
|
vaultState: vault.address,
|
|
@@ -1301,6 +1307,8 @@ export class KaminoVaultClient {
|
|
|
1301
1307
|
reserveCollateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
1302
1308
|
instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1303
1309
|
},
|
|
1310
|
+
eventAuthority: eventAuthority,
|
|
1311
|
+
program: this._kaminoVaultProgramId,
|
|
1304
1312
|
};
|
|
1305
1313
|
|
|
1306
1314
|
const withdrawArgs: WithdrawArgs = {
|
|
@@ -1341,6 +1349,7 @@ export class KaminoVaultClient {
|
|
|
1341
1349
|
userTokenAta: PublicKey,
|
|
1342
1350
|
shareAmountLamports: Decimal
|
|
1343
1351
|
): Promise<TransactionInstruction> {
|
|
1352
|
+
const eventAuthority = getEventAuthorityPda(this._kaminoVaultProgramId);
|
|
1344
1353
|
const withdrawFromAvailableAccounts: WithdrawFromAvailableAccounts = {
|
|
1345
1354
|
user,
|
|
1346
1355
|
vaultState: vault.address,
|
|
@@ -1353,6 +1362,8 @@ export class KaminoVaultClient {
|
|
|
1353
1362
|
tokenProgram: vaultState.tokenProgram,
|
|
1354
1363
|
sharesTokenProgram: TOKEN_PROGRAM_ID,
|
|
1355
1364
|
klendProgram: this._kaminoLendProgramId,
|
|
1365
|
+
eventAuthority: eventAuthority,
|
|
1366
|
+
program: this._kaminoVaultProgramId,
|
|
1356
1367
|
};
|
|
1357
1368
|
|
|
1358
1369
|
const withdrawFromAvailableArgs: WithdrawFromAvailableArgs = {
|
|
@@ -2688,6 +2699,10 @@ export function getCTokenVaultPda(vaultAddress: PublicKey, reserveAddress: Publi
|
|
|
2688
2699
|
)[0];
|
|
2689
2700
|
}
|
|
2690
2701
|
|
|
2702
|
+
export function getEventAuthorityPda(kaminoVaultProgramId: PublicKey) {
|
|
2703
|
+
return PublicKey.findProgramAddressSync([Buffer.from(EVENT_AUTHORITY_SEED)], kaminoVaultProgramId)[0];
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2691
2706
|
export type VaultHolder = {
|
|
2692
2707
|
holderPubkey: PublicKey;
|
|
2693
2708
|
amount: Decimal;
|
|
@@ -20,6 +20,8 @@ export interface DepositAccounts {
|
|
|
20
20
|
klendProgram: PublicKey
|
|
21
21
|
tokenProgram: PublicKey
|
|
22
22
|
sharesTokenProgram: PublicKey
|
|
23
|
+
eventAuthority: PublicKey
|
|
24
|
+
program: PublicKey
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const layout = borsh.struct([borsh.u64("maxAmount")])
|
|
@@ -41,6 +43,8 @@ export function deposit(
|
|
|
41
43
|
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
42
44
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
43
45
|
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
46
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
47
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
44
48
|
]
|
|
45
49
|
const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182])
|
|
46
50
|
const buffer = Buffer.alloc(1000)
|
|
@@ -21,6 +21,8 @@ export interface WithdrawAccounts {
|
|
|
21
21
|
tokenProgram: PublicKey
|
|
22
22
|
sharesTokenProgram: PublicKey
|
|
23
23
|
klendProgram: PublicKey
|
|
24
|
+
eventAuthority: PublicKey
|
|
25
|
+
program: PublicKey
|
|
24
26
|
}
|
|
25
27
|
withdrawFromReserveAccounts: {
|
|
26
28
|
vaultState: PublicKey
|
|
@@ -33,6 +35,8 @@ export interface WithdrawAccounts {
|
|
|
33
35
|
reserveCollateralTokenProgram: PublicKey
|
|
34
36
|
instructionSysvarAccount: PublicKey
|
|
35
37
|
}
|
|
38
|
+
eventAuthority: PublicKey
|
|
39
|
+
program: PublicKey
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
export const layout = borsh.struct([borsh.u64("sharesAmount")])
|
|
@@ -98,6 +102,16 @@ export function withdraw(
|
|
|
98
102
|
isSigner: false,
|
|
99
103
|
isWritable: false,
|
|
100
104
|
},
|
|
105
|
+
{
|
|
106
|
+
pubkey: accounts.withdrawFromAvailable.eventAuthority,
|
|
107
|
+
isSigner: false,
|
|
108
|
+
isWritable: false,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
pubkey: accounts.withdrawFromAvailable.program,
|
|
112
|
+
isSigner: false,
|
|
113
|
+
isWritable: false,
|
|
114
|
+
},
|
|
101
115
|
{
|
|
102
116
|
pubkey: accounts.withdrawFromReserveAccounts.vaultState,
|
|
103
117
|
isSigner: false,
|
|
@@ -144,6 +158,8 @@ export function withdraw(
|
|
|
144
158
|
isSigner: false,
|
|
145
159
|
isWritable: false,
|
|
146
160
|
},
|
|
161
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
162
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
147
163
|
]
|
|
148
164
|
const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34])
|
|
149
165
|
const buffer = Buffer.alloc(1000)
|
|
@@ -20,6 +20,8 @@ export interface WithdrawFromAvailableAccounts {
|
|
|
20
20
|
tokenProgram: PublicKey
|
|
21
21
|
sharesTokenProgram: PublicKey
|
|
22
22
|
klendProgram: PublicKey
|
|
23
|
+
eventAuthority: PublicKey
|
|
24
|
+
program: PublicKey
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const layout = borsh.struct([borsh.u64("sharesAmount")])
|
|
@@ -41,6 +43,8 @@ export function withdrawFromAvailable(
|
|
|
41
43
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
42
44
|
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
43
45
|
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
46
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
47
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
44
48
|
]
|
|
45
49
|
const identifier = Buffer.from([19, 131, 112, 155, 170, 220, 34, 57])
|
|
46
50
|
const buffer = Buffer.alloc(1000)
|
|
@@ -10,10 +10,15 @@ export interface ReserveConfigFields {
|
|
|
10
10
|
assetTier: number
|
|
11
11
|
/** Flat rate that goes to the host */
|
|
12
12
|
hostFixedInterestRateBps: number
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* [DEPRECATED] Space that used to hold 2 fields:
|
|
15
|
+
* - Boost for side (debt or collateral)
|
|
16
|
+
* - Reward points multiplier per obligation type
|
|
17
|
+
* Can be re-used after making sure all underlying production account data is zeroed.
|
|
18
|
+
*/
|
|
14
19
|
reserved2: Array<number>
|
|
15
|
-
/**
|
|
16
|
-
|
|
20
|
+
/** Cut of the order execution bonus that the protocol receives, as a percentage */
|
|
21
|
+
protocolOrderExecutionFeePct: number
|
|
17
22
|
/** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
|
|
18
23
|
protocolTakeRatePct: number
|
|
19
24
|
/** Cut of the liquidation bonus that the protocol receives, as a percentage */
|
|
@@ -98,10 +103,15 @@ export interface ReserveConfigJSON {
|
|
|
98
103
|
assetTier: number
|
|
99
104
|
/** Flat rate that goes to the host */
|
|
100
105
|
hostFixedInterestRateBps: number
|
|
101
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* [DEPRECATED] Space that used to hold 2 fields:
|
|
108
|
+
* - Boost for side (debt or collateral)
|
|
109
|
+
* - Reward points multiplier per obligation type
|
|
110
|
+
* Can be re-used after making sure all underlying production account data is zeroed.
|
|
111
|
+
*/
|
|
102
112
|
reserved2: Array<number>
|
|
103
|
-
/**
|
|
104
|
-
|
|
113
|
+
/** Cut of the order execution bonus that the protocol receives, as a percentage */
|
|
114
|
+
protocolOrderExecutionFeePct: number
|
|
105
115
|
/** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
|
|
106
116
|
protocolTakeRatePct: number
|
|
107
117
|
/** Cut of the liquidation bonus that the protocol receives, as a percentage */
|
|
@@ -187,10 +197,15 @@ export class ReserveConfig {
|
|
|
187
197
|
readonly assetTier: number
|
|
188
198
|
/** Flat rate that goes to the host */
|
|
189
199
|
readonly hostFixedInterestRateBps: number
|
|
190
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* [DEPRECATED] Space that used to hold 2 fields:
|
|
202
|
+
* - Boost for side (debt or collateral)
|
|
203
|
+
* - Reward points multiplier per obligation type
|
|
204
|
+
* Can be re-used after making sure all underlying production account data is zeroed.
|
|
205
|
+
*/
|
|
191
206
|
readonly reserved2: Array<number>
|
|
192
|
-
/**
|
|
193
|
-
readonly
|
|
207
|
+
/** Cut of the order execution bonus that the protocol receives, as a percentage */
|
|
208
|
+
readonly protocolOrderExecutionFeePct: number
|
|
194
209
|
/** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
|
|
195
210
|
readonly protocolTakeRatePct: number
|
|
196
211
|
/** Cut of the liquidation bonus that the protocol receives, as a percentage */
|
|
@@ -272,7 +287,7 @@ export class ReserveConfig {
|
|
|
272
287
|
this.assetTier = fields.assetTier
|
|
273
288
|
this.hostFixedInterestRateBps = fields.hostFixedInterestRateBps
|
|
274
289
|
this.reserved2 = fields.reserved2
|
|
275
|
-
this.
|
|
290
|
+
this.protocolOrderExecutionFeePct = fields.protocolOrderExecutionFeePct
|
|
276
291
|
this.protocolTakeRatePct = fields.protocolTakeRatePct
|
|
277
292
|
this.protocolLiquidationFeePct = fields.protocolLiquidationFeePct
|
|
278
293
|
this.loanToValuePct = fields.loanToValuePct
|
|
@@ -318,8 +333,8 @@ export class ReserveConfig {
|
|
|
318
333
|
borsh.u8("status"),
|
|
319
334
|
borsh.u8("assetTier"),
|
|
320
335
|
borsh.u16("hostFixedInterestRateBps"),
|
|
321
|
-
borsh.array(borsh.u8(),
|
|
322
|
-
borsh.
|
|
336
|
+
borsh.array(borsh.u8(), 9, "reserved2"),
|
|
337
|
+
borsh.u8("protocolOrderExecutionFeePct"),
|
|
323
338
|
borsh.u8("protocolTakeRatePct"),
|
|
324
339
|
borsh.u8("protocolLiquidationFeePct"),
|
|
325
340
|
borsh.u8("loanToValuePct"),
|
|
@@ -361,7 +376,7 @@ export class ReserveConfig {
|
|
|
361
376
|
assetTier: obj.assetTier,
|
|
362
377
|
hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
|
|
363
378
|
reserved2: obj.reserved2,
|
|
364
|
-
|
|
379
|
+
protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
|
|
365
380
|
protocolTakeRatePct: obj.protocolTakeRatePct,
|
|
366
381
|
protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
|
|
367
382
|
loanToValuePct: obj.loanToValuePct,
|
|
@@ -404,7 +419,7 @@ export class ReserveConfig {
|
|
|
404
419
|
assetTier: fields.assetTier,
|
|
405
420
|
hostFixedInterestRateBps: fields.hostFixedInterestRateBps,
|
|
406
421
|
reserved2: fields.reserved2,
|
|
407
|
-
|
|
422
|
+
protocolOrderExecutionFeePct: fields.protocolOrderExecutionFeePct,
|
|
408
423
|
protocolTakeRatePct: fields.protocolTakeRatePct,
|
|
409
424
|
protocolLiquidationFeePct: fields.protocolLiquidationFeePct,
|
|
410
425
|
loanToValuePct: fields.loanToValuePct,
|
|
@@ -449,7 +464,7 @@ export class ReserveConfig {
|
|
|
449
464
|
assetTier: this.assetTier,
|
|
450
465
|
hostFixedInterestRateBps: this.hostFixedInterestRateBps,
|
|
451
466
|
reserved2: this.reserved2,
|
|
452
|
-
|
|
467
|
+
protocolOrderExecutionFeePct: this.protocolOrderExecutionFeePct,
|
|
453
468
|
protocolTakeRatePct: this.protocolTakeRatePct,
|
|
454
469
|
protocolLiquidationFeePct: this.protocolLiquidationFeePct,
|
|
455
470
|
loanToValuePct: this.loanToValuePct,
|
|
@@ -492,7 +507,7 @@ export class ReserveConfig {
|
|
|
492
507
|
assetTier: obj.assetTier,
|
|
493
508
|
hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
|
|
494
509
|
reserved2: obj.reserved2,
|
|
495
|
-
|
|
510
|
+
protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
|
|
496
511
|
protocolTakeRatePct: obj.protocolTakeRatePct,
|
|
497
512
|
protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
|
|
498
513
|
loanToValuePct: obj.loanToValuePct,
|
|
@@ -180,6 +180,16 @@
|
|
|
180
180
|
"name": "sharesTokenProgram",
|
|
181
181
|
"isMut": false,
|
|
182
182
|
"isSigner": false
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "eventAuthority",
|
|
186
|
+
"isMut": false,
|
|
187
|
+
"isSigner": false
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "program",
|
|
191
|
+
"isMut": false,
|
|
192
|
+
"isSigner": false
|
|
183
193
|
}
|
|
184
194
|
],
|
|
185
195
|
"args": [
|
|
@@ -249,6 +259,16 @@
|
|
|
249
259
|
"name": "klendProgram",
|
|
250
260
|
"isMut": false,
|
|
251
261
|
"isSigner": false
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "eventAuthority",
|
|
265
|
+
"isMut": false,
|
|
266
|
+
"isSigner": false
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"name": "program",
|
|
270
|
+
"isMut": false,
|
|
271
|
+
"isSigner": false
|
|
252
272
|
}
|
|
253
273
|
]
|
|
254
274
|
},
|
|
@@ -301,6 +321,16 @@
|
|
|
301
321
|
"isSigner": false
|
|
302
322
|
}
|
|
303
323
|
]
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"name": "eventAuthority",
|
|
327
|
+
"isMut": false,
|
|
328
|
+
"isSigner": false
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "program",
|
|
332
|
+
"isMut": false,
|
|
333
|
+
"isSigner": false
|
|
304
334
|
}
|
|
305
335
|
],
|
|
306
336
|
"args": [
|
|
@@ -722,6 +752,16 @@
|
|
|
722
752
|
"name": "klendProgram",
|
|
723
753
|
"isMut": false,
|
|
724
754
|
"isSigner": false
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
"name": "eventAuthority",
|
|
758
|
+
"isMut": false,
|
|
759
|
+
"isSigner": false
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"name": "program",
|
|
763
|
+
"isMut": false,
|
|
764
|
+
"isSigner": false
|
|
725
765
|
}
|
|
726
766
|
],
|
|
727
767
|
"args": [
|
|
@@ -1198,26 +1238,24 @@
|
|
|
1198
1238
|
{
|
|
1199
1239
|
"name": "reserved2",
|
|
1200
1240
|
"docs": [
|
|
1201
|
-
"[DEPRECATED]
|
|
1241
|
+
"[DEPRECATED] Space that used to hold 2 fields:",
|
|
1242
|
+
"- Boost for side (debt or collateral)",
|
|
1243
|
+
"- Reward points multiplier per obligation type",
|
|
1244
|
+
"Can be re-used after making sure all underlying production account data is zeroed."
|
|
1202
1245
|
],
|
|
1203
1246
|
"type": {
|
|
1204
1247
|
"array": [
|
|
1205
1248
|
"u8",
|
|
1206
|
-
|
|
1249
|
+
9
|
|
1207
1250
|
]
|
|
1208
1251
|
}
|
|
1209
1252
|
},
|
|
1210
1253
|
{
|
|
1211
|
-
"name": "
|
|
1254
|
+
"name": "protocolOrderExecutionFeePct",
|
|
1212
1255
|
"docs": [
|
|
1213
|
-
"
|
|
1256
|
+
"Cut of the order execution bonus that the protocol receives, as a percentage"
|
|
1214
1257
|
],
|
|
1215
|
-
"type":
|
|
1216
|
-
"array": [
|
|
1217
|
-
"u8",
|
|
1218
|
-
8
|
|
1219
|
-
]
|
|
1220
|
-
}
|
|
1258
|
+
"type": "u8"
|
|
1221
1259
|
},
|
|
1222
1260
|
{
|
|
1223
1261
|
"name": "protocolTakeRatePct",
|
|
@@ -1982,6 +2020,78 @@
|
|
|
1982
2020
|
}
|
|
1983
2021
|
}
|
|
1984
2022
|
],
|
|
2023
|
+
"events": [
|
|
2024
|
+
{
|
|
2025
|
+
"name": "DepositResultEvent",
|
|
2026
|
+
"fields": [
|
|
2027
|
+
{
|
|
2028
|
+
"name": "sharesToMint",
|
|
2029
|
+
"type": "u64",
|
|
2030
|
+
"index": false
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
"name": "tokenToDeposit",
|
|
2034
|
+
"type": "u64",
|
|
2035
|
+
"index": false
|
|
2036
|
+
},
|
|
2037
|
+
{
|
|
2038
|
+
"name": "crankFundsToDeposit",
|
|
2039
|
+
"type": "u64",
|
|
2040
|
+
"index": false
|
|
2041
|
+
}
|
|
2042
|
+
]
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
"name": "DepositUserAtaBalanceEvent",
|
|
2046
|
+
"fields": [
|
|
2047
|
+
{
|
|
2048
|
+
"name": "userAtaBalance",
|
|
2049
|
+
"type": "u64",
|
|
2050
|
+
"index": false
|
|
2051
|
+
}
|
|
2052
|
+
]
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
"name": "SharesToWithdrawEvent",
|
|
2056
|
+
"fields": [
|
|
2057
|
+
{
|
|
2058
|
+
"name": "sharesAmount",
|
|
2059
|
+
"type": "u64",
|
|
2060
|
+
"index": false
|
|
2061
|
+
},
|
|
2062
|
+
{
|
|
2063
|
+
"name": "userSharesBefore",
|
|
2064
|
+
"type": "u64",
|
|
2065
|
+
"index": false
|
|
2066
|
+
}
|
|
2067
|
+
]
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
"name": "WithdrawResultEvent",
|
|
2071
|
+
"fields": [
|
|
2072
|
+
{
|
|
2073
|
+
"name": "sharesToBurn",
|
|
2074
|
+
"type": "u64",
|
|
2075
|
+
"index": false
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
"name": "availableToSendToUser",
|
|
2079
|
+
"type": "u64",
|
|
2080
|
+
"index": false
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
"name": "investedToDisinvestCtokens",
|
|
2084
|
+
"type": "u64",
|
|
2085
|
+
"index": false
|
|
2086
|
+
},
|
|
2087
|
+
{
|
|
2088
|
+
"name": "investedLiquidityToSendToUser",
|
|
2089
|
+
"type": "u64",
|
|
2090
|
+
"index": false
|
|
2091
|
+
}
|
|
2092
|
+
]
|
|
2093
|
+
}
|
|
2094
|
+
],
|
|
1985
2095
|
"errors": [
|
|
1986
2096
|
{
|
|
1987
2097
|
"code": 7000,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
removeBudgetAndAtaIxns,
|
|
17
17
|
ScopePriceRefreshConfig,
|
|
18
18
|
U64_MAX,
|
|
19
|
-
|
|
19
|
+
uniqueAccountsWithProgramIds,
|
|
20
20
|
} from '../utils';
|
|
21
21
|
import { AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
22
22
|
import Decimal from 'decimal.js';
|
|
@@ -147,7 +147,7 @@ export async function getRepayWithCollSwapInputs<QuoteResponse>({
|
|
|
147
147
|
inputAmountLamports,
|
|
148
148
|
useV2Ixs
|
|
149
149
|
);
|
|
150
|
-
const uniqueKlendAccounts =
|
|
150
|
+
const uniqueKlendAccounts = uniqueAccountsWithProgramIds(klendIxs.instructions);
|
|
151
151
|
|
|
152
152
|
const swapQuoteInputs: SwapInputs = {
|
|
153
153
|
inputAmountLamports,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
PublicKeySet,
|
|
22
22
|
ScopePriceRefreshConfig,
|
|
23
23
|
U64_MAX,
|
|
24
|
-
|
|
24
|
+
uniqueAccountsWithProgramIds,
|
|
25
25
|
} from '../utils';
|
|
26
26
|
import { AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
27
27
|
import Decimal from 'decimal.js';
|
|
@@ -162,7 +162,7 @@ export async function getSwapCollIxns<QuoteResponse>(
|
|
|
162
162
|
|
|
163
163
|
// Construct the Klend's own ixns with a fake swap-out (only to learn the klend accounts used):
|
|
164
164
|
const fakeKlendIxns = await getKlendIxns(args, FAKE_TARGET_COLL_SWAP_OUT_AMOUNT, context);
|
|
165
|
-
const klendAccounts =
|
|
165
|
+
const klendAccounts = uniqueAccountsWithProgramIds(listIxns(fakeKlendIxns));
|
|
166
166
|
|
|
167
167
|
// Construct the external swap ixns (and learn the actual swap-out amount):
|
|
168
168
|
const externalSwapIxns = await getExternalSwapIxns(args, klendAccounts, context);
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
getTransferWsolIxns,
|
|
28
28
|
getLookupTableAccount,
|
|
29
29
|
removeBudgetAndAtaIxns,
|
|
30
|
-
|
|
30
|
+
uniqueAccountsWithProgramIds,
|
|
31
31
|
} from '../utils';
|
|
32
32
|
import {
|
|
33
33
|
adjustDepositLeverageCalcs,
|
|
@@ -163,7 +163,7 @@ export async function getDepositWithLeverageSwapInputs<QuoteResponse>({
|
|
|
163
163
|
elevationGroupOverride
|
|
164
164
|
);
|
|
165
165
|
|
|
166
|
-
const uniqueKlendAccounts =
|
|
166
|
+
const uniqueKlendAccounts = uniqueAccountsWithProgramIds(klendIxs.instructions);
|
|
167
167
|
|
|
168
168
|
const swapInputAmount = toLamports(
|
|
169
169
|
!collIsKtoken ? calcs.swapDebtTokenIn : calcs.singleSidedDepositKtokenOnly,
|
|
@@ -677,7 +677,7 @@ export async function getWithdrawWithLeverageSwapInputs<QuoteResponse>({
|
|
|
677
677
|
useV2Ixs
|
|
678
678
|
);
|
|
679
679
|
|
|
680
|
-
const uniqueKlendAccounts =
|
|
680
|
+
const uniqueKlendAccounts = uniqueAccountsWithProgramIds(klendIxs.instructions);
|
|
681
681
|
|
|
682
682
|
const swapInputAmount = toLamports(
|
|
683
683
|
calcs.collTokenSwapIn,
|
|
@@ -1104,7 +1104,7 @@ export async function getAdjustLeverageSwapInputs<QuoteResponse>({
|
|
|
1104
1104
|
useV2Ixs
|
|
1105
1105
|
);
|
|
1106
1106
|
|
|
1107
|
-
const uniqueKlendAccounts =
|
|
1107
|
+
const uniqueKlendAccounts = uniqueAccountsWithProgramIds(klendIxs.instructions);
|
|
1108
1108
|
|
|
1109
1109
|
const swapInputAmount = toLamports(
|
|
1110
1110
|
!collIsKtoken ? calcs.borrowAmount : calcs.amountToFlashBorrowDebt,
|
|
@@ -1209,7 +1209,7 @@ export async function getAdjustLeverageSwapInputs<QuoteResponse>({
|
|
|
1209
1209
|
useV2Ixs
|
|
1210
1210
|
);
|
|
1211
1211
|
|
|
1212
|
-
const uniqueKlendAccounts =
|
|
1212
|
+
const uniqueKlendAccounts = uniqueAccountsWithProgramIds(klendIxs.instructions);
|
|
1213
1213
|
|
|
1214
1214
|
const swapInputAmount = toLamports(
|
|
1215
1215
|
calcs.withdrawAmountWithSlippageAndFlashLoanFee,
|
package/src/utils/instruction.ts
CHANGED
|
@@ -260,7 +260,7 @@ export function notEmpty<TValue>(value: TValue | null | undefined): value is TVa
|
|
|
260
260
|
return true;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
export function
|
|
263
|
+
export function uniqueAccountsWithProgramIds(
|
|
264
264
|
ixs: TransactionInstruction[],
|
|
265
265
|
addressLookupTables: PublicKey[] | AddressLookupTableAccount[] = []
|
|
266
266
|
): Array<PublicKey> {
|
|
@@ -273,6 +273,7 @@ export function uniqueAccounts(
|
|
|
273
273
|
|
|
274
274
|
const uniqueAccounts = new PublicKeySet<PublicKey>(luts);
|
|
275
275
|
ixs.forEach((ixn) => {
|
|
276
|
+
uniqueAccounts.add(ixn.programId);
|
|
276
277
|
ixn.keys.forEach((key) => {
|
|
277
278
|
uniqueAccounts.add(key.pubkey);
|
|
278
279
|
});
|