@kamino-finance/klend-sdk 5.11.14 → 5.11.16
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.d.ts +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +3 -3
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +3 -0
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/reserve.d.ts +7 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +145 -255
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types.d.ts +2 -0
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts +1 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +8 -2
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +24 -5
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +99 -89
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/utils/ata.d.ts +15 -2
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +68 -3
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -1
- package/dist/utils/constants.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/manager.ts +5 -6
- package/src/classes/market.ts +4 -0
- package/src/classes/reserve.ts +178 -319
- package/src/classes/types.ts +3 -0
- package/src/classes/utils.ts +9 -3
- package/src/classes/vault.ts +44 -12
- package/src/client_kamino_manager.ts +225 -92
- package/src/utils/ata.ts +102 -4
- package/src/utils/constants.ts +2 -0
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Chain,
|
|
17
17
|
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
18
18
|
encodeTokenName,
|
|
19
|
+
getMedianSlotDurationInMsFromLastEpochs,
|
|
19
20
|
initLookupTableIx,
|
|
20
21
|
KaminoManager,
|
|
21
22
|
KaminoMarket,
|
|
@@ -84,7 +85,12 @@ async function main() {
|
|
|
84
85
|
|
|
85
86
|
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
86
87
|
|
|
87
|
-
const kaminoManager = new KaminoManager(
|
|
88
|
+
const kaminoManager = new KaminoManager(
|
|
89
|
+
env.connection,
|
|
90
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
91
|
+
env.kLendProgramId,
|
|
92
|
+
env.kVaultProgramId
|
|
93
|
+
);
|
|
88
94
|
|
|
89
95
|
const { market: marketKp, ixns: createMarketIxns } = await kaminoManager.createMarketIxs({
|
|
90
96
|
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
@@ -118,7 +124,12 @@ async function main() {
|
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
121
|
-
const kaminoManager = new KaminoManager(
|
|
127
|
+
const kaminoManager = new KaminoManager(
|
|
128
|
+
env.connection,
|
|
129
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
130
|
+
env.kLendProgramId,
|
|
131
|
+
env.kVaultProgramId
|
|
132
|
+
);
|
|
122
133
|
|
|
123
134
|
const reserveConfigFromFile = JSON.parse(fs.readFileSync(reserveConfigPath, 'utf8'));
|
|
124
135
|
|
|
@@ -184,7 +195,12 @@ async function main() {
|
|
|
184
195
|
throw new Error('If using multisig mode, multisig is required');
|
|
185
196
|
}
|
|
186
197
|
|
|
187
|
-
const kaminoManager = new KaminoManager(
|
|
198
|
+
const kaminoManager = new KaminoManager(
|
|
199
|
+
env.connection,
|
|
200
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
201
|
+
env.kLendProgramId,
|
|
202
|
+
env.kVaultProgramId
|
|
203
|
+
);
|
|
188
204
|
|
|
189
205
|
const reserveConfigFromFile = JSON.parse(fs.readFileSync(reserveConfigPath, 'utf8'));
|
|
190
206
|
|
|
@@ -247,7 +263,12 @@ async function main() {
|
|
|
247
263
|
}
|
|
248
264
|
|
|
249
265
|
const multisigPk = multisig ? new PublicKey(multisig) : PublicKey.default;
|
|
250
|
-
const kaminoManager = new KaminoManager(
|
|
266
|
+
const kaminoManager = new KaminoManager(
|
|
267
|
+
env.connection,
|
|
268
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
269
|
+
env.kLendProgramId,
|
|
270
|
+
env.kVaultProgramId
|
|
271
|
+
);
|
|
251
272
|
|
|
252
273
|
const tokenProgramID = await getAccountOwner(env.connection, tokenMint);
|
|
253
274
|
const kaminoVaultConfig = new KaminoVaultConfig({
|
|
@@ -293,7 +314,12 @@ async function main() {
|
|
|
293
314
|
throw new Error('If using multisig mode, multisig is required');
|
|
294
315
|
}
|
|
295
316
|
|
|
296
|
-
const kaminoManager = new KaminoManager(
|
|
317
|
+
const kaminoManager = new KaminoManager(
|
|
318
|
+
env.connection,
|
|
319
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
320
|
+
env.kLendProgramId,
|
|
321
|
+
env.kVaultProgramId
|
|
322
|
+
);
|
|
297
323
|
|
|
298
324
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
299
325
|
const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, new PendingVaultAdmin(), newAdmin);
|
|
@@ -329,7 +355,12 @@ async function main() {
|
|
|
329
355
|
throw new Error('If using multisig mode, multisig is required');
|
|
330
356
|
}
|
|
331
357
|
|
|
332
|
-
const kaminoManager = new KaminoManager(
|
|
358
|
+
const kaminoManager = new KaminoManager(
|
|
359
|
+
env.connection,
|
|
360
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
361
|
+
env.kLendProgramId,
|
|
362
|
+
env.kVaultProgramId
|
|
363
|
+
);
|
|
333
364
|
|
|
334
365
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
335
366
|
const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, field, value);
|
|
@@ -364,7 +395,12 @@ async function main() {
|
|
|
364
395
|
throw new Error('If using multisig mode, multisig is required');
|
|
365
396
|
}
|
|
366
397
|
|
|
367
|
-
const kaminoManager = new KaminoManager(
|
|
398
|
+
const kaminoManager = new KaminoManager(
|
|
399
|
+
env.connection,
|
|
400
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
401
|
+
env.kLendProgramId,
|
|
402
|
+
env.kVaultProgramId
|
|
403
|
+
);
|
|
368
404
|
|
|
369
405
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
370
406
|
const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, new ManagementFeeBps(), feeBps);
|
|
@@ -401,7 +437,12 @@ async function main() {
|
|
|
401
437
|
throw new Error('If using multisig mode, multisig is required');
|
|
402
438
|
}
|
|
403
439
|
|
|
404
|
-
const kaminoManager = new KaminoManager(
|
|
440
|
+
const kaminoManager = new KaminoManager(
|
|
441
|
+
env.connection,
|
|
442
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
443
|
+
env.kLendProgramId,
|
|
444
|
+
env.kVaultProgramId
|
|
445
|
+
);
|
|
405
446
|
|
|
406
447
|
const instructions = await kaminoManager.insertIntoLUTIxs(env.payer.publicKey, lutAddress, addressesArr);
|
|
407
448
|
|
|
@@ -435,7 +476,12 @@ async function main() {
|
|
|
435
476
|
throw new Error('If using multisig mode, multisig is required');
|
|
436
477
|
}
|
|
437
478
|
|
|
438
|
-
const kaminoManager = new KaminoManager(
|
|
479
|
+
const kaminoManager = new KaminoManager(
|
|
480
|
+
env.connection,
|
|
481
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
482
|
+
env.kLendProgramId,
|
|
483
|
+
env.kVaultProgramId
|
|
484
|
+
);
|
|
439
485
|
|
|
440
486
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
441
487
|
const syncLUTIxs = await kaminoManager.syncVaultLUTIxs(kaminoVault);
|
|
@@ -471,7 +517,12 @@ async function main() {
|
|
|
471
517
|
throw new Error('If using multisig mode, multisig is required');
|
|
472
518
|
}
|
|
473
519
|
|
|
474
|
-
const kaminoManager = new KaminoManager(
|
|
520
|
+
const kaminoManager = new KaminoManager(
|
|
521
|
+
env.connection,
|
|
522
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
523
|
+
env.kLendProgramId,
|
|
524
|
+
env.kVaultProgramId
|
|
525
|
+
);
|
|
475
526
|
|
|
476
527
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
477
528
|
const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, new PerformanceFeeBps(), feeBps);
|
|
@@ -505,7 +556,12 @@ async function main() {
|
|
|
505
556
|
throw new Error('If using multisig mode, multisig is required');
|
|
506
557
|
}
|
|
507
558
|
|
|
508
|
-
const kaminoManager = new KaminoManager(
|
|
559
|
+
const kaminoManager = new KaminoManager(
|
|
560
|
+
env.connection,
|
|
561
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
562
|
+
env.kLendProgramId,
|
|
563
|
+
env.kVaultProgramId
|
|
564
|
+
);
|
|
509
565
|
|
|
510
566
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
511
567
|
const instructions = await kaminoManager.acceptVaultOwnershipIxs(kaminoVault);
|
|
@@ -540,7 +596,12 @@ async function main() {
|
|
|
540
596
|
throw new Error('If using multisig mode, multisig is required');
|
|
541
597
|
}
|
|
542
598
|
|
|
543
|
-
const kaminoManager = new KaminoManager(
|
|
599
|
+
const kaminoManager = new KaminoManager(
|
|
600
|
+
env.connection,
|
|
601
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
602
|
+
env.kLendProgramId,
|
|
603
|
+
env.kVaultProgramId
|
|
604
|
+
);
|
|
544
605
|
|
|
545
606
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
546
607
|
const instruction = await kaminoManager.giveUpPendingFeesIx(kaminoVault, new Decimal(maxAmountToGiveUp));
|
|
@@ -567,7 +628,12 @@ async function main() {
|
|
|
567
628
|
throw new Error('If using multisig mode, multisig is required');
|
|
568
629
|
}
|
|
569
630
|
|
|
570
|
-
const kaminoManager = new KaminoManager(
|
|
631
|
+
const kaminoManager = new KaminoManager(
|
|
632
|
+
env.connection,
|
|
633
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
634
|
+
env.kLendProgramId,
|
|
635
|
+
env.kVaultProgramId
|
|
636
|
+
);
|
|
571
637
|
|
|
572
638
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
573
639
|
const instructions = await kaminoManager.withdrawPendingFeesIxs(
|
|
@@ -595,10 +661,12 @@ async function main() {
|
|
|
595
661
|
|
|
596
662
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
597
663
|
|
|
598
|
-
const stakeIxs = await new KaminoManager(
|
|
599
|
-
env.
|
|
600
|
-
|
|
601
|
-
|
|
664
|
+
const stakeIxs = await new KaminoManager(
|
|
665
|
+
env.connection,
|
|
666
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
667
|
+
env.kLendProgramId,
|
|
668
|
+
env.kVaultProgramId
|
|
669
|
+
).stakeSharesIxs(env.payer.publicKey, kaminoVault);
|
|
602
670
|
|
|
603
671
|
if (mode === 'multisig' && !multisig) {
|
|
604
672
|
throw new Error('If using multisig mode, multisig is required');
|
|
@@ -631,7 +699,12 @@ async function main() {
|
|
|
631
699
|
throw new Error('If using multisig mode, multisig is required');
|
|
632
700
|
}
|
|
633
701
|
|
|
634
|
-
const kaminoManager = new KaminoManager(
|
|
702
|
+
const kaminoManager = new KaminoManager(
|
|
703
|
+
env.connection,
|
|
704
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
705
|
+
env.kLendProgramId,
|
|
706
|
+
env.kVaultProgramId
|
|
707
|
+
);
|
|
635
708
|
const reserveState = await Reserve.fetch(env.connection, reserveAddress, env.kLendProgramId);
|
|
636
709
|
if (!reserveState) {
|
|
637
710
|
throw new Error('Reserve not found');
|
|
@@ -682,7 +755,12 @@ async function main() {
|
|
|
682
755
|
throw new Error('If using multisig mode, multisig is required');
|
|
683
756
|
}
|
|
684
757
|
|
|
685
|
-
const kaminoManager = new KaminoManager(
|
|
758
|
+
const kaminoManager = new KaminoManager(
|
|
759
|
+
env.connection,
|
|
760
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
761
|
+
env.kLendProgramId,
|
|
762
|
+
env.kVaultProgramId
|
|
763
|
+
);
|
|
686
764
|
|
|
687
765
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
688
766
|
const depositInstructions = await kaminoManager.depositToVaultIxs(env.payer.publicKey, kaminoVault, amount);
|
|
@@ -711,7 +789,12 @@ async function main() {
|
|
|
711
789
|
throw new Error('If using multisig mode, multisig is required');
|
|
712
790
|
}
|
|
713
791
|
|
|
714
|
-
const kaminoManager = new KaminoManager(
|
|
792
|
+
const kaminoManager = new KaminoManager(
|
|
793
|
+
env.connection,
|
|
794
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
795
|
+
env.kLendProgramId,
|
|
796
|
+
env.kVaultProgramId
|
|
797
|
+
);
|
|
715
798
|
|
|
716
799
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
717
800
|
const withdrawIxs = await kaminoManager.withdrawFromVaultIxs(
|
|
@@ -751,7 +834,12 @@ async function main() {
|
|
|
751
834
|
throw new Error('If using multisig mode, multisig is required');
|
|
752
835
|
}
|
|
753
836
|
|
|
754
|
-
const kaminoManager = new KaminoManager(
|
|
837
|
+
const kaminoManager = new KaminoManager(
|
|
838
|
+
env.connection,
|
|
839
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
840
|
+
env.kLendProgramId,
|
|
841
|
+
env.kVaultProgramId
|
|
842
|
+
);
|
|
755
843
|
|
|
756
844
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
757
845
|
const instructions = await kaminoManager.investAllReservesIxs(env.payer.publicKey, kaminoVault);
|
|
@@ -783,7 +871,12 @@ async function main() {
|
|
|
783
871
|
throw new Error('If using multisig mode, multisig is required');
|
|
784
872
|
}
|
|
785
873
|
|
|
786
|
-
const kaminoManager = new KaminoManager(
|
|
874
|
+
const kaminoManager = new KaminoManager(
|
|
875
|
+
env.connection,
|
|
876
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
877
|
+
env.kLendProgramId,
|
|
878
|
+
env.kVaultProgramId
|
|
879
|
+
);
|
|
787
880
|
|
|
788
881
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
789
882
|
const reserveState = await Reserve.fetch(env.connection, new PublicKey(reserve), env.kLendProgramId);
|
|
@@ -828,8 +921,9 @@ async function main() {
|
|
|
828
921
|
.requiredOption('--vault <string>', 'Vault address')
|
|
829
922
|
.action(async ({ vault }) => {
|
|
830
923
|
const env = initializeClient(false, false);
|
|
924
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
831
925
|
|
|
832
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
926
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
833
927
|
|
|
834
928
|
const vaultAddress = new PublicKey(vault);
|
|
835
929
|
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
@@ -850,8 +944,9 @@ async function main() {
|
|
|
850
944
|
.requiredOption('--vault <string>', 'Vault address')
|
|
851
945
|
.action(async ({ vault }) => {
|
|
852
946
|
const env = initializeClient(false, false);
|
|
947
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
853
948
|
|
|
854
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
949
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
855
950
|
|
|
856
951
|
const vaultAddress = new PublicKey(vault);
|
|
857
952
|
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
@@ -869,8 +964,9 @@ async function main() {
|
|
|
869
964
|
.requiredOption('--vault <string>', 'Vault address')
|
|
870
965
|
.action(async ({ vault }) => {
|
|
871
966
|
const env = initializeClient(false, false);
|
|
967
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
872
968
|
|
|
873
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
969
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
874
970
|
|
|
875
971
|
const vaultAddress = new PublicKey(vault);
|
|
876
972
|
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
@@ -888,8 +984,9 @@ async function main() {
|
|
|
888
984
|
.requiredOption('--wallet <string>', 'User wailt address')
|
|
889
985
|
.action(async ({ vault, wallet }) => {
|
|
890
986
|
const env = initializeClient(false, false);
|
|
987
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
891
988
|
|
|
892
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
989
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
893
990
|
|
|
894
991
|
const vaultAddress = new PublicKey(vault);
|
|
895
992
|
const walletAddress = new PublicKey(wallet);
|
|
@@ -903,8 +1000,9 @@ async function main() {
|
|
|
903
1000
|
.requiredOption('--wallet <string>', 'User wailt address')
|
|
904
1001
|
.action(async ({ wallet }) => {
|
|
905
1002
|
const env = initializeClient(false, false);
|
|
1003
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
906
1004
|
|
|
907
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1005
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
908
1006
|
|
|
909
1007
|
const walletAddress = new PublicKey(wallet);
|
|
910
1008
|
const userShares = await kaminoManager.getUserSharesBalanceAllVaults(walletAddress);
|
|
@@ -918,8 +1016,9 @@ async function main() {
|
|
|
918
1016
|
.requiredOption('--vault <string>', 'Vault address')
|
|
919
1017
|
.action(async ({ vault }) => {
|
|
920
1018
|
const env = initializeClient(false, false);
|
|
1019
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
921
1020
|
|
|
922
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1021
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
923
1022
|
|
|
924
1023
|
const vaultAddress = new PublicKey(vault);
|
|
925
1024
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
@@ -935,8 +1034,9 @@ async function main() {
|
|
|
935
1034
|
.requiredOption('--vault <string>', 'Vault address')
|
|
936
1035
|
.action(async ({ vault }) => {
|
|
937
1036
|
const env = initializeClient(false, false);
|
|
1037
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
938
1038
|
|
|
939
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1039
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
940
1040
|
|
|
941
1041
|
const vaultAddress = new PublicKey(vault);
|
|
942
1042
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
@@ -961,7 +1061,12 @@ async function main() {
|
|
|
961
1061
|
|
|
962
1062
|
commands.command('get-oracle-mappings').action(async () => {
|
|
963
1063
|
const env = initializeClient(false, false);
|
|
964
|
-
const kaminoManager = new KaminoManager(
|
|
1064
|
+
const kaminoManager = new KaminoManager(
|
|
1065
|
+
env.connection,
|
|
1066
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1067
|
+
env.kLendProgramId,
|
|
1068
|
+
env.kVaultProgramId
|
|
1069
|
+
);
|
|
965
1070
|
|
|
966
1071
|
console.log('Getting oracle mappings');
|
|
967
1072
|
const oracleConfigs = await kaminoManager.getScopeOracleConfigs();
|
|
@@ -970,15 +1075,21 @@ async function main() {
|
|
|
970
1075
|
|
|
971
1076
|
commands.command('get-all-vaults').action(async () => {
|
|
972
1077
|
const env = initializeClient(false, false);
|
|
973
|
-
const
|
|
1078
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
974
1079
|
|
|
1080
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
975
1081
|
const allVaults = await kaminoManager.getAllVaults();
|
|
976
1082
|
console.log('all vaults', allVaults);
|
|
977
1083
|
});
|
|
978
1084
|
|
|
979
1085
|
commands.command('get-all-vaults-pks').action(async () => {
|
|
980
1086
|
const env = initializeClient(false, false);
|
|
981
|
-
const kaminoManager = new KaminoManager(
|
|
1087
|
+
const kaminoManager = new KaminoManager(
|
|
1088
|
+
env.connection,
|
|
1089
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1090
|
+
env.kLendProgramId,
|
|
1091
|
+
env.kVaultProgramId
|
|
1092
|
+
);
|
|
982
1093
|
|
|
983
1094
|
const allVaults = await kaminoManager.getAllVaults();
|
|
984
1095
|
console.log(
|
|
@@ -994,8 +1105,9 @@ async function main() {
|
|
|
994
1105
|
const env = initializeClient(false, false);
|
|
995
1106
|
|
|
996
1107
|
const vaultAddress = new PublicKey(vault);
|
|
1108
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
997
1109
|
|
|
998
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1110
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
999
1111
|
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
1000
1112
|
|
|
1001
1113
|
const simulatedHoldings = await kaminoManager.calculateSimulatedHoldingsWithInterest(vaultState);
|
|
@@ -1036,8 +1148,9 @@ async function main() {
|
|
|
1036
1148
|
const env = initializeClient(false, false);
|
|
1037
1149
|
|
|
1038
1150
|
const vaultAddress = new PublicKey(vault);
|
|
1151
|
+
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
1039
1152
|
|
|
1040
|
-
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1153
|
+
const kaminoManager = new KaminoManager(env.connection, slotDuration, env.kLendProgramId, env.kVaultProgramId);
|
|
1041
1154
|
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
1042
1155
|
|
|
1043
1156
|
const computedAllocation = await kaminoManager.getVaultComputedReservesAllocation(vaultState);
|
|
@@ -1117,7 +1230,12 @@ async function main() {
|
|
|
1117
1230
|
throw new Error('If using multisig mode, multisig is required');
|
|
1118
1231
|
}
|
|
1119
1232
|
|
|
1120
|
-
const kaminoManager = new KaminoManager(
|
|
1233
|
+
const kaminoManager = new KaminoManager(
|
|
1234
|
+
env.connection,
|
|
1235
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1236
|
+
env.kLendProgramId,
|
|
1237
|
+
env.kVaultProgramId
|
|
1238
|
+
);
|
|
1121
1239
|
|
|
1122
1240
|
const newLendingMarket = LendingMarket.fromJSON(JSON.parse(fs.readFileSync(lendingMarketConfigPath, 'utf8')));
|
|
1123
1241
|
|
|
@@ -1157,7 +1275,12 @@ async function main() {
|
|
|
1157
1275
|
throw new Error('If using multisig mode, multisig is required');
|
|
1158
1276
|
}
|
|
1159
1277
|
|
|
1160
|
-
const kaminoManager = new KaminoManager(
|
|
1278
|
+
const kaminoManager = new KaminoManager(
|
|
1279
|
+
env.connection,
|
|
1280
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1281
|
+
env.kLendProgramId,
|
|
1282
|
+
env.kVaultProgramId
|
|
1283
|
+
);
|
|
1161
1284
|
|
|
1162
1285
|
const ixn = kaminoManager.updateLendingMarketOwnerIxs(marketWithAddress);
|
|
1163
1286
|
|
|
@@ -1195,7 +1318,12 @@ async function main() {
|
|
|
1195
1318
|
throw new Error('If using multisig mode, multisig is required');
|
|
1196
1319
|
}
|
|
1197
1320
|
|
|
1198
|
-
const kaminoManager = new KaminoManager(
|
|
1321
|
+
const kaminoManager = new KaminoManager(
|
|
1322
|
+
env.connection,
|
|
1323
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1324
|
+
env.kLendProgramId,
|
|
1325
|
+
env.kVaultProgramId
|
|
1326
|
+
);
|
|
1199
1327
|
|
|
1200
1328
|
const currentName = parseZeroPaddedUtf8(lendingMarketState.name);
|
|
1201
1329
|
const newNameEncoded = encodeTokenName(newName);
|
|
@@ -1251,7 +1379,12 @@ async function main() {
|
|
|
1251
1379
|
throw new Error('If using multisig mode, multisig is required');
|
|
1252
1380
|
}
|
|
1253
1381
|
|
|
1254
|
-
const kaminoManager = new KaminoManager(
|
|
1382
|
+
const kaminoManager = new KaminoManager(
|
|
1383
|
+
env.connection,
|
|
1384
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
1385
|
+
env.kLendProgramId,
|
|
1386
|
+
env.kVaultProgramId
|
|
1387
|
+
);
|
|
1255
1388
|
|
|
1256
1389
|
const newReserveConfigFields: ReserveConfigFields = {
|
|
1257
1390
|
...reserveState.config,
|
|
@@ -1427,64 +1560,64 @@ function createAddExtraComputeUnitFeeTransaction(units: number, microLamports: n
|
|
|
1427
1560
|
return ixns;
|
|
1428
1561
|
}
|
|
1429
1562
|
|
|
1430
|
-
function parseReserveConfigFromFile(
|
|
1563
|
+
function parseReserveConfigFromFile(reserveConfigFromFile: any): ReserveConfig {
|
|
1431
1564
|
const reserveConfigFields: ReserveConfigFields = {
|
|
1432
|
-
status:
|
|
1433
|
-
loanToValuePct:
|
|
1434
|
-
liquidationThresholdPct:
|
|
1435
|
-
minLiquidationBonusBps:
|
|
1436
|
-
protocolLiquidationFeePct:
|
|
1437
|
-
protocolTakeRatePct:
|
|
1438
|
-
assetTier:
|
|
1439
|
-
maxLiquidationBonusBps:
|
|
1440
|
-
badDebtLiquidationBonusBps:
|
|
1565
|
+
status: reserveConfigFromFile.status,
|
|
1566
|
+
loanToValuePct: reserveConfigFromFile.loanToValuePct,
|
|
1567
|
+
liquidationThresholdPct: reserveConfigFromFile.liquidationThresholdPct,
|
|
1568
|
+
minLiquidationBonusBps: reserveConfigFromFile.minLiquidationBonusBps,
|
|
1569
|
+
protocolLiquidationFeePct: reserveConfigFromFile.protocolLiquidationFeePct,
|
|
1570
|
+
protocolTakeRatePct: reserveConfigFromFile.protocolLiquidationFeePct,
|
|
1571
|
+
assetTier: reserveConfigFromFile.assetTier,
|
|
1572
|
+
maxLiquidationBonusBps: reserveConfigFromFile.maxLiquidationBonusBps,
|
|
1573
|
+
badDebtLiquidationBonusBps: reserveConfigFromFile.badDebtLiquidationBonusBps,
|
|
1441
1574
|
fees: {
|
|
1442
|
-
borrowFeeSf: Fraction.fromDecimal(new Decimal(
|
|
1443
|
-
flashLoanFeeSf: Fraction.fromDecimal(new Decimal(
|
|
1575
|
+
borrowFeeSf: Fraction.fromDecimal(new Decimal(reserveConfigFromFile.fees.borrowFee)).valueSf,
|
|
1576
|
+
flashLoanFeeSf: Fraction.fromDecimal(new Decimal(reserveConfigFromFile.fees.flashLoanFee)).valueSf,
|
|
1444
1577
|
padding: Array(8).fill(0),
|
|
1445
1578
|
},
|
|
1446
|
-
depositLimit: new BN(
|
|
1447
|
-
borrowLimit: new BN(
|
|
1579
|
+
depositLimit: new BN(reserveConfigFromFile.depositLimit),
|
|
1580
|
+
borrowLimit: new BN(reserveConfigFromFile.borrowLimit),
|
|
1448
1581
|
tokenInfo: {
|
|
1449
|
-
name: encodeTokenName(
|
|
1582
|
+
name: encodeTokenName(reserveConfigFromFile.tokenInfo.name),
|
|
1450
1583
|
heuristic: new PriceHeuristic({
|
|
1451
|
-
lower: new BN(
|
|
1452
|
-
upper: new BN(
|
|
1453
|
-
exp: new BN(
|
|
1584
|
+
lower: new BN(reserveConfigFromFile.tokenInfo.heuristic.lower),
|
|
1585
|
+
upper: new BN(reserveConfigFromFile.tokenInfo.heuristic.upper),
|
|
1586
|
+
exp: new BN(reserveConfigFromFile.tokenInfo.heuristic.exp),
|
|
1454
1587
|
}),
|
|
1455
|
-
maxTwapDivergenceBps: new BN(
|
|
1456
|
-
maxAgePriceSeconds: new BN(
|
|
1457
|
-
maxAgeTwapSeconds: new BN(
|
|
1458
|
-
...parseOracleConfiguration(
|
|
1459
|
-
blockPriceUsage:
|
|
1588
|
+
maxTwapDivergenceBps: new BN(reserveConfigFromFile.tokenInfo.maxTwapDivergenceBps),
|
|
1589
|
+
maxAgePriceSeconds: new BN(reserveConfigFromFile.tokenInfo.maxAgePriceSeconds),
|
|
1590
|
+
maxAgeTwapSeconds: new BN(reserveConfigFromFile.tokenInfo.maxAgeTwapSeconds),
|
|
1591
|
+
...parseOracleConfiguration(reserveConfigFromFile),
|
|
1592
|
+
blockPriceUsage: reserveConfigFromFile.tokenInfo.blockPriceUsage,
|
|
1460
1593
|
reserved: Array(7).fill(0),
|
|
1461
1594
|
padding: Array(19).fill(new BN(0)),
|
|
1462
1595
|
} as TokenInfo,
|
|
1463
|
-
borrowRateCurve: parseBorrowRateCurve(
|
|
1596
|
+
borrowRateCurve: parseBorrowRateCurve(reserveConfigFromFile),
|
|
1464
1597
|
depositWithdrawalCap: new WithdrawalCaps({
|
|
1465
|
-
configCapacity: new BN(
|
|
1598
|
+
configCapacity: new BN(reserveConfigFromFile.depositWithdrawalCap.configCapacity),
|
|
1466
1599
|
currentTotal: new BN(0),
|
|
1467
1600
|
lastIntervalStartTimestamp: new BN(0),
|
|
1468
|
-
configIntervalLengthSeconds: new BN(
|
|
1601
|
+
configIntervalLengthSeconds: new BN(reserveConfigFromFile.depositWithdrawalCap.configIntervalLengthSeconds),
|
|
1469
1602
|
}),
|
|
1470
1603
|
debtWithdrawalCap: new WithdrawalCaps({
|
|
1471
|
-
configCapacity: new BN(
|
|
1604
|
+
configCapacity: new BN(reserveConfigFromFile.debtWithdrawalCap.configCapacity),
|
|
1472
1605
|
currentTotal: new BN(0),
|
|
1473
1606
|
lastIntervalStartTimestamp: new BN(0),
|
|
1474
|
-
configIntervalLengthSeconds: new BN(
|
|
1607
|
+
configIntervalLengthSeconds: new BN(reserveConfigFromFile.debtWithdrawalCap.configIntervalLengthSeconds),
|
|
1475
1608
|
}),
|
|
1476
|
-
deleveragingMarginCallPeriodSecs: new BN(
|
|
1477
|
-
borrowFactorPct: new BN(
|
|
1478
|
-
elevationGroups:
|
|
1479
|
-
deleveragingThresholdDecreaseBpsPerDay: new BN(
|
|
1480
|
-
disableUsageAsCollOutsideEmode:
|
|
1481
|
-
utilizationLimitBlockBorrowingAbovePct:
|
|
1482
|
-
hostFixedInterestRateBps:
|
|
1483
|
-
autodeleverageEnabled:
|
|
1484
|
-
borrowLimitOutsideElevationGroup: new BN(
|
|
1485
|
-
borrowLimitAgainstThisCollateralInElevationGroup: parseReserveBorrowLimitAgainstCollInEmode(
|
|
1486
|
-
deleveragingBonusIncreaseBpsPerDay: new BN(
|
|
1487
|
-
reserved1: Array(
|
|
1609
|
+
deleveragingMarginCallPeriodSecs: new BN(reserveConfigFromFile.deleveragingMarginCallPeriodSecs),
|
|
1610
|
+
borrowFactorPct: new BN(reserveConfigFromFile.borrowFactorPct),
|
|
1611
|
+
elevationGroups: reserveConfigFromFile.elevationGroups,
|
|
1612
|
+
deleveragingThresholdDecreaseBpsPerDay: new BN(reserveConfigFromFile.deleveragingThresholdDecreaseBpsPerDay),
|
|
1613
|
+
disableUsageAsCollOutsideEmode: reserveConfigFromFile.disableUsageAsCollOutsideEmode,
|
|
1614
|
+
utilizationLimitBlockBorrowingAbovePct: reserveConfigFromFile.utilizationLimitBlockBorrowingAbovePct,
|
|
1615
|
+
hostFixedInterestRateBps: reserveConfigFromFile.hostFixedInterestRateBps,
|
|
1616
|
+
autodeleverageEnabled: reserveConfigFromFile.autodeleverageEnabled,
|
|
1617
|
+
borrowLimitOutsideElevationGroup: new BN(reserveConfigFromFile.borrowLimitOutsideElevationGroup),
|
|
1618
|
+
borrowLimitAgainstThisCollateralInElevationGroup: parseReserveBorrowLimitAgainstCollInEmode(reserveConfigFromFile),
|
|
1619
|
+
deleveragingBonusIncreaseBpsPerDay: new BN(reserveConfigFromFile.deleveragingBonusIncreaseBpsPerDay),
|
|
1620
|
+
reserved1: Array(1).fill(0),
|
|
1488
1621
|
reserved2: Array(2).fill(0),
|
|
1489
1622
|
reserved3: Array(8).fill(0),
|
|
1490
1623
|
};
|
|
@@ -1492,29 +1625,29 @@ function parseReserveConfigFromFile(farmConfigFromFile: any): ReserveConfig {
|
|
|
1492
1625
|
return new ReserveConfig(reserveConfigFields);
|
|
1493
1626
|
}
|
|
1494
1627
|
|
|
1495
|
-
function parseOracleConfiguration(
|
|
1628
|
+
function parseOracleConfiguration(reserveConfigFromFile: any): {
|
|
1496
1629
|
pythConfiguration: PythConfiguration;
|
|
1497
1630
|
switchboardConfiguration: SwitchboardConfiguration;
|
|
1498
1631
|
scopeConfiguration: ScopeConfiguration;
|
|
1499
1632
|
} {
|
|
1500
1633
|
const pythConfiguration = new PythConfiguration({
|
|
1501
|
-
price: new PublicKey(
|
|
1634
|
+
price: new PublicKey(reserveConfigFromFile.tokenInfo.pythConfiguration.price),
|
|
1502
1635
|
});
|
|
1503
1636
|
const switchboardConfiguration = new SwitchboardConfiguration({
|
|
1504
|
-
priceAggregator: new PublicKey(
|
|
1505
|
-
twapAggregator: new PublicKey(
|
|
1637
|
+
priceAggregator: new PublicKey(reserveConfigFromFile.tokenInfo.switchboardConfiguration.priceAggregator),
|
|
1638
|
+
twapAggregator: new PublicKey(reserveConfigFromFile.tokenInfo.switchboardConfiguration.twapAggregator),
|
|
1506
1639
|
});
|
|
1507
1640
|
const priceChain = [65535, 65535, 65535, 65535];
|
|
1508
1641
|
const twapChain = [65535, 65535, 65535, 65535];
|
|
1509
1642
|
|
|
1510
|
-
const priceChainFromFile: number[] =
|
|
1511
|
-
const twapChainFromFile: number[] =
|
|
1643
|
+
const priceChainFromFile: number[] = reserveConfigFromFile.tokenInfo.scopeConfiguration.priceChain;
|
|
1644
|
+
const twapChainFromFile: number[] = reserveConfigFromFile.tokenInfo.scopeConfiguration.twapChain;
|
|
1512
1645
|
|
|
1513
1646
|
priceChainFromFile.forEach((value, index) => (priceChain[index] = value));
|
|
1514
1647
|
twapChainFromFile.forEach((value, index) => (twapChain[index] = value));
|
|
1515
1648
|
|
|
1516
1649
|
const scopeConfiguration = new ScopeConfiguration({
|
|
1517
|
-
priceFeed: new PublicKey(
|
|
1650
|
+
priceFeed: new PublicKey(reserveConfigFromFile.tokenInfo.scopeConfiguration.priceFeed),
|
|
1518
1651
|
priceChain: priceChain,
|
|
1519
1652
|
twapChain: twapChain,
|
|
1520
1653
|
});
|
|
@@ -1526,29 +1659,29 @@ function parseOracleConfiguration(farmConfigFromFile: any): {
|
|
|
1526
1659
|
};
|
|
1527
1660
|
}
|
|
1528
1661
|
|
|
1529
|
-
function parseBorrowRateCurve(
|
|
1662
|
+
function parseBorrowRateCurve(reserveConfigFromFile: any): BorrowRateCurve {
|
|
1530
1663
|
const curvePoints: CurvePointFields[] = [];
|
|
1531
1664
|
|
|
1532
|
-
|
|
1665
|
+
reserveConfigFromFile.borrowRateCurve.points.forEach((curvePoint: { utilizationRateBps: any; borrowRateBps: any }) =>
|
|
1533
1666
|
curvePoints.push({
|
|
1534
1667
|
utilizationRateBps: curvePoint.utilizationRateBps,
|
|
1535
1668
|
borrowRateBps: curvePoint.borrowRateBps,
|
|
1536
1669
|
})
|
|
1537
1670
|
);
|
|
1538
1671
|
|
|
1539
|
-
const
|
|
1672
|
+
const finalCurvePoints: CurvePointFields[] = Array(11).fill(curvePoints[curvePoints.length - 1]);
|
|
1540
1673
|
|
|
1541
|
-
curvePoints.forEach((curvePoint, index) => (
|
|
1674
|
+
curvePoints.forEach((curvePoint, index) => (finalCurvePoints[index] = curvePoint));
|
|
1542
1675
|
|
|
1543
|
-
const borrowRateCurve = new BorrowRateCurve({ points:
|
|
1676
|
+
const borrowRateCurve = new BorrowRateCurve({ points: finalCurvePoints });
|
|
1544
1677
|
|
|
1545
1678
|
return borrowRateCurve;
|
|
1546
1679
|
}
|
|
1547
1680
|
|
|
1548
|
-
function parseReserveBorrowLimitAgainstCollInEmode(
|
|
1681
|
+
function parseReserveBorrowLimitAgainstCollInEmode(reserveConfigFromFile: any): BN[] {
|
|
1549
1682
|
const reserveBorrowLimitAgainstCollInEmode: BN[] = Array(32).fill(new BN(0));
|
|
1550
1683
|
|
|
1551
|
-
|
|
1684
|
+
reserveConfigFromFile.borrowLimitAgainstThisCollateralInElevationGroup.forEach(
|
|
1552
1685
|
(limit: any, index: number) => (reserveBorrowLimitAgainstCollInEmode[index] = new BN(limit))
|
|
1553
1686
|
);
|
|
1554
1687
|
|