@keel-fi/svm-alm-controller 1.0.0-rc.1 → 1.0.2-rc.1
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/generated/accounts/oracle.d.ts +2 -2
- package/dist/generated/accounts/oracle.d.ts.map +1 -1
- package/dist/generated/instructions/atomicSwapBorrow.d.ts +2 -2
- package/dist/generated/instructions/atomicSwapRepay.d.ts +1 -1
- package/dist/generated/instructions/claimRent.d.ts +45 -0
- package/dist/generated/instructions/claimRent.d.ts.map +1 -0
- package/dist/generated/instructions/index.d.ts +1 -0
- package/dist/generated/instructions/index.d.ts.map +1 -1
- package/dist/generated/instructions/initializeController.d.ts +1 -1
- package/dist/generated/instructions/initializeIntegration.d.ts +1 -1
- package/dist/generated/instructions/initializeReserve.d.ts +1 -1
- package/dist/generated/instructions/manageController.d.ts +1 -1
- package/dist/generated/instructions/manageIntegration.d.ts +1 -1
- package/dist/generated/instructions/managePermission.d.ts +1 -1
- package/dist/generated/instructions/manageReserve.d.ts +1 -1
- package/dist/generated/instructions/pull.d.ts +6 -9
- package/dist/generated/instructions/pull.d.ts.map +1 -1
- package/dist/generated/instructions/push.d.ts +6 -9
- package/dist/generated/instructions/push.d.ts.map +1 -1
- package/dist/generated/instructions/sync.d.ts +13 -7
- package/dist/generated/instructions/sync.d.ts.map +1 -1
- package/dist/generated/instructions/updateOracle.d.ts +5 -5
- package/dist/generated/instructions/updateOracle.d.ts.map +1 -1
- package/dist/generated/programs/svmAlmController.d.ts +8 -5
- package/dist/generated/programs/svmAlmController.d.ts.map +1 -1
- package/dist/generated/types/controllerStatus.d.ts +2 -1
- package/dist/generated/types/controllerStatus.d.ts.map +1 -1
- package/dist/generated/types/controllerUpdateEvent.d.ts +1 -1
- package/dist/generated/types/controllerUpdateEvent.d.ts.map +1 -1
- package/dist/generated/types/driftConfig.d.ts +12 -0
- package/dist/generated/types/driftConfig.d.ts.map +1 -0
- package/dist/generated/types/feed.d.ts +3 -2
- package/dist/generated/types/feed.d.ts.map +1 -1
- package/dist/generated/types/index.d.ts +4 -7
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/initializeArgs.d.ts +16 -5
- package/dist/generated/types/initializeArgs.d.ts.map +1 -1
- package/dist/generated/types/integrationConfig.d.ts +15 -8
- package/dist/generated/types/integrationConfig.d.ts.map +1 -1
- package/dist/generated/types/integrationState.d.ts +15 -8
- package/dist/generated/types/integrationState.d.ts.map +1 -1
- package/dist/generated/types/integrationType.d.ts +5 -4
- package/dist/generated/types/integrationType.d.ts.map +1 -1
- package/dist/generated/types/integrationUpdateEvent.d.ts +1 -1
- package/dist/generated/types/integrationUpdateEvent.d.ts.map +1 -1
- package/dist/generated/types/kaminoConfig.d.ts +14 -0
- package/dist/generated/types/kaminoConfig.d.ts.map +1 -0
- package/dist/generated/types/lendingState.d.ts +13 -0
- package/dist/generated/types/lendingState.d.ts.map +1 -0
- package/dist/generated/types/oracleUpdateEvent.d.ts +1 -1
- package/dist/generated/types/oracleUpdateEvent.d.ts.map +1 -1
- package/dist/generated/types/permissionUpdateEvent.d.ts +1 -1
- package/dist/generated/types/permissionUpdateEvent.d.ts.map +1 -1
- package/dist/generated/types/pullArgs.d.ts +16 -13
- package/dist/generated/types/pullArgs.d.ts.map +1 -1
- package/dist/generated/types/pushArgs.d.ts +16 -13
- package/dist/generated/types/pushArgs.d.ts.map +1 -1
- package/dist/generated/types/reserveUpdateEvent.d.ts +1 -1
- package/dist/generated/types/reserveUpdateEvent.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +751 -505
- package/dist/index.js +766 -521
- package/dist/integrations/drift/index.d.ts +2 -0
- package/dist/integrations/drift/index.d.ts.map +1 -0
- package/dist/integrations/drift/pdas.d.ts +10 -0
- package/dist/integrations/drift/pdas.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +3 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/kamino/index.d.ts +2 -0
- package/dist/integrations/kamino/index.d.ts.map +1 -0
- package/dist/integrations/kamino/pdas.d.ts +27 -0
- package/dist/integrations/kamino/pdas.d.ts.map +1 -0
- package/dist/pdas.d.ts +0 -1
- package/dist/pdas.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/generated/types/depositForBurnArgs.d.ts +0 -15
- package/dist/generated/types/depositForBurnArgs.d.ts.map +0 -1
- package/dist/generated/types/depositSingleTokenTypeExactAmountInArgs.d.ts +0 -13
- package/dist/generated/types/depositSingleTokenTypeExactAmountInArgs.d.ts.map +0 -1
- package/dist/generated/types/splTokenSwapConfig.d.ts +0 -15
- package/dist/generated/types/splTokenSwapConfig.d.ts.map +0 -1
- package/dist/generated/types/splTokenSwapState.d.ts +0 -17
- package/dist/generated/types/splTokenSwapState.d.ts.map +0 -1
- package/dist/generated/types/swapV1Subset.d.ts +0 -17
- package/dist/generated/types/swapV1Subset.d.ts.map +0 -1
- package/dist/generated/types/withdrawSingleTokenTypeExactAmountOutArgs.d.ts +0 -13
- package/dist/generated/types/withdrawSingleTokenTypeExactAmountOutArgs.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -177,6 +177,7 @@ exports.ControllerStatus = void 0;
|
|
|
177
177
|
ControllerStatus[ControllerStatus["Frozen"] = 0] = "Frozen";
|
|
178
178
|
ControllerStatus[ControllerStatus["Active"] = 1] = "Active";
|
|
179
179
|
ControllerStatus[ControllerStatus["PushPullFrozen"] = 2] = "PushPullFrozen";
|
|
180
|
+
ControllerStatus[ControllerStatus["AtomicSwapLock"] = 3] = "AtomicSwapLock";
|
|
180
181
|
})(exports.ControllerStatus || (exports.ControllerStatus = {}));
|
|
181
182
|
function getControllerStatusEncoder() {
|
|
182
183
|
return kit.getEnumEncoder(exports.ControllerStatus);
|
|
@@ -208,38 +209,24 @@ function getControllerUpdateEventCodec() {
|
|
|
208
209
|
return kit.combineCodec(getControllerUpdateEventEncoder(), getControllerUpdateEventDecoder());
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
function
|
|
212
|
+
function getDriftConfigEncoder() {
|
|
212
213
|
return kit.getStructEncoder([
|
|
213
|
-
['
|
|
214
|
-
['
|
|
215
|
-
['
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
function getDepositForBurnArgsDecoder() {
|
|
219
|
-
return kit.getStructDecoder([
|
|
220
|
-
['amount', kit.getU64Decoder()],
|
|
221
|
-
['destinationDomain', kit.getU32Decoder()],
|
|
222
|
-
['mintRecipient', kit.getAddressDecoder()],
|
|
223
|
-
]);
|
|
224
|
-
}
|
|
225
|
-
function getDepositForBurnArgsCodec() {
|
|
226
|
-
return kit.combineCodec(getDepositForBurnArgsEncoder(), getDepositForBurnArgsDecoder());
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function getDepositSingleTokenTypeExactAmountInArgsEncoder() {
|
|
230
|
-
return kit.getStructEncoder([
|
|
231
|
-
['sourceTokenAmount', kit.getU64Encoder()],
|
|
232
|
-
['minimumPoolTokenAmount', kit.getU64Encoder()],
|
|
214
|
+
['subAccountId', kit.getU16Encoder()],
|
|
215
|
+
['spotMarketIndex', kit.getU16Encoder()],
|
|
216
|
+
['poolId', kit.getU8Encoder()],
|
|
217
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 219)],
|
|
233
218
|
]);
|
|
234
219
|
}
|
|
235
|
-
function
|
|
220
|
+
function getDriftConfigDecoder() {
|
|
236
221
|
return kit.getStructDecoder([
|
|
237
|
-
['
|
|
238
|
-
['
|
|
222
|
+
['subAccountId', kit.getU16Decoder()],
|
|
223
|
+
['spotMarketIndex', kit.getU16Decoder()],
|
|
224
|
+
['poolId', kit.getU8Decoder()],
|
|
225
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 219)],
|
|
239
226
|
]);
|
|
240
227
|
}
|
|
241
|
-
function
|
|
242
|
-
return kit.combineCodec(
|
|
228
|
+
function getDriftConfigCodec() {
|
|
229
|
+
return kit.combineCodec(getDriftConfigEncoder(), getDriftConfigDecoder());
|
|
243
230
|
}
|
|
244
231
|
|
|
245
232
|
function getFeedEncoder() {
|
|
@@ -273,7 +260,6 @@ function getFeedArgsCodec() {
|
|
|
273
260
|
function getInitializeArgsEncoder() {
|
|
274
261
|
return kit.getDiscriminatedUnionEncoder([
|
|
275
262
|
['SplTokenExternal', kit.getUnitEncoder()],
|
|
276
|
-
['SplTokenSwap', kit.getUnitEncoder()],
|
|
277
263
|
[
|
|
278
264
|
'CctpBridge',
|
|
279
265
|
kit.getStructEncoder([
|
|
@@ -297,12 +283,19 @@ function getInitializeArgsEncoder() {
|
|
|
297
283
|
['oraclePriceInverted', kit.getBooleanEncoder()],
|
|
298
284
|
]),
|
|
299
285
|
],
|
|
286
|
+
[
|
|
287
|
+
'Drift',
|
|
288
|
+
kit.getStructEncoder([
|
|
289
|
+
['subAccountId', kit.getU16Encoder()],
|
|
290
|
+
['spotMarketIndex', kit.getU16Encoder()],
|
|
291
|
+
]),
|
|
292
|
+
],
|
|
293
|
+
['KaminoIntegration', kit.getStructEncoder([['obligationId', kit.getU8Encoder()]])],
|
|
300
294
|
]);
|
|
301
295
|
}
|
|
302
296
|
function getInitializeArgsDecoder() {
|
|
303
297
|
return kit.getDiscriminatedUnionDecoder([
|
|
304
298
|
['SplTokenExternal', kit.getUnitDecoder()],
|
|
305
|
-
['SplTokenSwap', kit.getUnitDecoder()],
|
|
306
299
|
[
|
|
307
300
|
'CctpBridge',
|
|
308
301
|
kit.getStructDecoder([
|
|
@@ -326,6 +319,14 @@ function getInitializeArgsDecoder() {
|
|
|
326
319
|
['oraclePriceInverted', kit.getBooleanDecoder()],
|
|
327
320
|
]),
|
|
328
321
|
],
|
|
322
|
+
[
|
|
323
|
+
'Drift',
|
|
324
|
+
kit.getStructDecoder([
|
|
325
|
+
['subAccountId', kit.getU16Decoder()],
|
|
326
|
+
['spotMarketIndex', kit.getU16Decoder()],
|
|
327
|
+
]),
|
|
328
|
+
],
|
|
329
|
+
['KaminoIntegration', kit.getStructDecoder([['obligationId', kit.getU8Decoder()]])],
|
|
329
330
|
]);
|
|
330
331
|
}
|
|
331
332
|
function getInitializeArgsCodec() {
|
|
@@ -352,12 +353,6 @@ function getIntegrationConfigEncoder() {
|
|
|
352
353
|
['fields', kit.getTupleEncoder([getSplTokenExternalConfigEncoder()])],
|
|
353
354
|
]),
|
|
354
355
|
],
|
|
355
|
-
[
|
|
356
|
-
'SplTokenSwap',
|
|
357
|
-
kit.getStructEncoder([
|
|
358
|
-
['fields', kit.getTupleEncoder([getSplTokenSwapConfigEncoder()])],
|
|
359
|
-
]),
|
|
360
|
-
],
|
|
361
356
|
[
|
|
362
357
|
'CctpBridge',
|
|
363
358
|
kit.getStructEncoder([
|
|
@@ -376,6 +371,18 @@ function getIntegrationConfigEncoder() {
|
|
|
376
371
|
['fields', kit.getTupleEncoder([getAtomicSwapConfigEncoder()])],
|
|
377
372
|
]),
|
|
378
373
|
],
|
|
374
|
+
[
|
|
375
|
+
'Drift',
|
|
376
|
+
kit.getStructEncoder([
|
|
377
|
+
['fields', kit.getTupleEncoder([getDriftConfigEncoder()])],
|
|
378
|
+
]),
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
'Kamino',
|
|
382
|
+
kit.getStructEncoder([
|
|
383
|
+
['fields', kit.getTupleEncoder([getKaminoConfigEncoder()])],
|
|
384
|
+
]),
|
|
385
|
+
],
|
|
379
386
|
]);
|
|
380
387
|
}
|
|
381
388
|
function getIntegrationConfigDecoder() {
|
|
@@ -390,12 +397,6 @@ function getIntegrationConfigDecoder() {
|
|
|
390
397
|
['fields', kit.getTupleDecoder([getSplTokenExternalConfigDecoder()])],
|
|
391
398
|
]),
|
|
392
399
|
],
|
|
393
|
-
[
|
|
394
|
-
'SplTokenSwap',
|
|
395
|
-
kit.getStructDecoder([
|
|
396
|
-
['fields', kit.getTupleDecoder([getSplTokenSwapConfigDecoder()])],
|
|
397
|
-
]),
|
|
398
|
-
],
|
|
399
400
|
[
|
|
400
401
|
'CctpBridge',
|
|
401
402
|
kit.getStructDecoder([
|
|
@@ -414,6 +415,18 @@ function getIntegrationConfigDecoder() {
|
|
|
414
415
|
['fields', kit.getTupleDecoder([getAtomicSwapConfigDecoder()])],
|
|
415
416
|
]),
|
|
416
417
|
],
|
|
418
|
+
[
|
|
419
|
+
'Drift',
|
|
420
|
+
kit.getStructDecoder([
|
|
421
|
+
['fields', kit.getTupleDecoder([getDriftConfigDecoder()])],
|
|
422
|
+
]),
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
'Kamino',
|
|
426
|
+
kit.getStructDecoder([
|
|
427
|
+
['fields', kit.getTupleDecoder([getKaminoConfigDecoder()])],
|
|
428
|
+
]),
|
|
429
|
+
],
|
|
417
430
|
]);
|
|
418
431
|
}
|
|
419
432
|
function getIntegrationConfigCodec() {
|
|
@@ -440,12 +453,6 @@ function getIntegrationStateEncoder() {
|
|
|
440
453
|
['fields', kit.getTupleEncoder([getSplTokenExternalStateEncoder()])],
|
|
441
454
|
]),
|
|
442
455
|
],
|
|
443
|
-
[
|
|
444
|
-
'SplTokenSwap',
|
|
445
|
-
kit.getStructEncoder([
|
|
446
|
-
['fields', kit.getTupleEncoder([getSplTokenSwapStateEncoder()])],
|
|
447
|
-
]),
|
|
448
|
-
],
|
|
449
456
|
[
|
|
450
457
|
'CctpBridge',
|
|
451
458
|
kit.getStructEncoder([
|
|
@@ -464,6 +471,18 @@ function getIntegrationStateEncoder() {
|
|
|
464
471
|
['fields', kit.getTupleEncoder([getAtomicSwapStateEncoder()])],
|
|
465
472
|
]),
|
|
466
473
|
],
|
|
474
|
+
[
|
|
475
|
+
'Drift',
|
|
476
|
+
kit.getStructEncoder([
|
|
477
|
+
['fields', kit.getTupleEncoder([getLendingStateEncoder()])],
|
|
478
|
+
]),
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
'Kamino',
|
|
482
|
+
kit.getStructEncoder([
|
|
483
|
+
['fields', kit.getTupleEncoder([getLendingStateEncoder()])],
|
|
484
|
+
]),
|
|
485
|
+
],
|
|
467
486
|
]);
|
|
468
487
|
}
|
|
469
488
|
function getIntegrationStateDecoder() {
|
|
@@ -478,12 +497,6 @@ function getIntegrationStateDecoder() {
|
|
|
478
497
|
['fields', kit.getTupleDecoder([getSplTokenExternalStateDecoder()])],
|
|
479
498
|
]),
|
|
480
499
|
],
|
|
481
|
-
[
|
|
482
|
-
'SplTokenSwap',
|
|
483
|
-
kit.getStructDecoder([
|
|
484
|
-
['fields', kit.getTupleDecoder([getSplTokenSwapStateDecoder()])],
|
|
485
|
-
]),
|
|
486
|
-
],
|
|
487
500
|
[
|
|
488
501
|
'CctpBridge',
|
|
489
502
|
kit.getStructDecoder([
|
|
@@ -502,6 +515,18 @@ function getIntegrationStateDecoder() {
|
|
|
502
515
|
['fields', kit.getTupleDecoder([getAtomicSwapStateDecoder()])],
|
|
503
516
|
]),
|
|
504
517
|
],
|
|
518
|
+
[
|
|
519
|
+
'Drift',
|
|
520
|
+
kit.getStructDecoder([
|
|
521
|
+
['fields', kit.getTupleDecoder([getLendingStateDecoder()])],
|
|
522
|
+
]),
|
|
523
|
+
],
|
|
524
|
+
[
|
|
525
|
+
'Kamino',
|
|
526
|
+
kit.getStructDecoder([
|
|
527
|
+
['fields', kit.getTupleDecoder([getLendingStateDecoder()])],
|
|
528
|
+
]),
|
|
529
|
+
],
|
|
505
530
|
]);
|
|
506
531
|
}
|
|
507
532
|
function getIntegrationStateCodec() {
|
|
@@ -534,10 +559,11 @@ function getIntegrationStatusCodec() {
|
|
|
534
559
|
exports.IntegrationType = void 0;
|
|
535
560
|
(function (IntegrationType) {
|
|
536
561
|
IntegrationType[IntegrationType["SplTokenExternal"] = 0] = "SplTokenExternal";
|
|
537
|
-
IntegrationType[IntegrationType["
|
|
538
|
-
IntegrationType[IntegrationType["
|
|
539
|
-
IntegrationType[IntegrationType["
|
|
540
|
-
IntegrationType[IntegrationType["
|
|
562
|
+
IntegrationType[IntegrationType["CctpBridge"] = 1] = "CctpBridge";
|
|
563
|
+
IntegrationType[IntegrationType["LzBridge"] = 2] = "LzBridge";
|
|
564
|
+
IntegrationType[IntegrationType["AtomicSwap"] = 3] = "AtomicSwap";
|
|
565
|
+
IntegrationType[IntegrationType["Drift"] = 4] = "Drift";
|
|
566
|
+
IntegrationType[IntegrationType["Kamino"] = 5] = "Kamino";
|
|
541
567
|
})(exports.IntegrationType || (exports.IntegrationType = {}));
|
|
542
568
|
function getIntegrationTypeEncoder() {
|
|
543
569
|
return kit.getEnumEncoder(exports.IntegrationType);
|
|
@@ -549,6 +575,70 @@ function getIntegrationTypeCodec() {
|
|
|
549
575
|
return kit.combineCodec(getIntegrationTypeEncoder(), getIntegrationTypeDecoder());
|
|
550
576
|
}
|
|
551
577
|
|
|
578
|
+
function getIntegrationEncoder() {
|
|
579
|
+
return kit.getStructEncoder([
|
|
580
|
+
['controller', kit.getAddressEncoder()],
|
|
581
|
+
['description', kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
582
|
+
['hash', kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
583
|
+
['status', getIntegrationStatusEncoder()],
|
|
584
|
+
['rateLimitSlope', kit.getU64Encoder()],
|
|
585
|
+
['rateLimitMaxOutflow', kit.getU64Encoder()],
|
|
586
|
+
['rateLimitOutflowAmountAvailable', kit.getU64Encoder()],
|
|
587
|
+
['rateLimitRemainder', kit.getU64Encoder()],
|
|
588
|
+
['lastRefreshTimestamp', kit.getI64Encoder()],
|
|
589
|
+
['lastRefreshSlot', kit.getU64Encoder()],
|
|
590
|
+
['config', getIntegrationConfigEncoder()],
|
|
591
|
+
['state', getIntegrationStateEncoder()],
|
|
592
|
+
['permitLiquidation', kit.getBooleanEncoder()],
|
|
593
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 87)],
|
|
594
|
+
]);
|
|
595
|
+
}
|
|
596
|
+
function getIntegrationDecoder() {
|
|
597
|
+
return kit.getStructDecoder([
|
|
598
|
+
['controller', kit.getAddressDecoder()],
|
|
599
|
+
['description', kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
600
|
+
['hash', kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
601
|
+
['status', getIntegrationStatusDecoder()],
|
|
602
|
+
['rateLimitSlope', kit.getU64Decoder()],
|
|
603
|
+
['rateLimitMaxOutflow', kit.getU64Decoder()],
|
|
604
|
+
['rateLimitOutflowAmountAvailable', kit.getU64Decoder()],
|
|
605
|
+
['rateLimitRemainder', kit.getU64Decoder()],
|
|
606
|
+
['lastRefreshTimestamp', kit.getI64Decoder()],
|
|
607
|
+
['lastRefreshSlot', kit.getU64Decoder()],
|
|
608
|
+
['config', getIntegrationConfigDecoder()],
|
|
609
|
+
['state', getIntegrationStateDecoder()],
|
|
610
|
+
['permitLiquidation', kit.getBooleanDecoder()],
|
|
611
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 87)],
|
|
612
|
+
]);
|
|
613
|
+
}
|
|
614
|
+
function getIntegrationCodec() {
|
|
615
|
+
return kit.combineCodec(getIntegrationEncoder(), getIntegrationDecoder());
|
|
616
|
+
}
|
|
617
|
+
function decodeIntegration(encodedAccount) {
|
|
618
|
+
return kit.decodeAccount(encodedAccount, getIntegrationDecoder());
|
|
619
|
+
}
|
|
620
|
+
async function fetchIntegration(rpc, address, config) {
|
|
621
|
+
const maybeAccount = await fetchMaybeIntegration(rpc, address, config);
|
|
622
|
+
kit.assertAccountExists(maybeAccount);
|
|
623
|
+
return maybeAccount;
|
|
624
|
+
}
|
|
625
|
+
async function fetchMaybeIntegration(rpc, address, config) {
|
|
626
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
627
|
+
return decodeIntegration(maybeAccount);
|
|
628
|
+
}
|
|
629
|
+
async function fetchAllIntegration(rpc, addresses, config) {
|
|
630
|
+
const maybeAccounts = await fetchAllMaybeIntegration(rpc, addresses, config);
|
|
631
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
632
|
+
return maybeAccounts;
|
|
633
|
+
}
|
|
634
|
+
async function fetchAllMaybeIntegration(rpc, addresses, config) {
|
|
635
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
636
|
+
return maybeAccounts.map((maybeAccount) => decodeIntegration(maybeAccount));
|
|
637
|
+
}
|
|
638
|
+
function getIntegrationSize() {
|
|
639
|
+
return 507;
|
|
640
|
+
}
|
|
641
|
+
|
|
552
642
|
function getIntegrationUpdateEventEncoder() {
|
|
553
643
|
return kit.getStructEncoder([
|
|
554
644
|
['authority', kit.getAddressEncoder()],
|
|
@@ -571,6 +661,46 @@ function getIntegrationUpdateEventCodec() {
|
|
|
571
661
|
return kit.combineCodec(getIntegrationUpdateEventEncoder(), getIntegrationUpdateEventDecoder());
|
|
572
662
|
}
|
|
573
663
|
|
|
664
|
+
function getKaminoConfigEncoder() {
|
|
665
|
+
return kit.getStructEncoder([
|
|
666
|
+
['market', kit.getAddressEncoder()],
|
|
667
|
+
['reserve', kit.getAddressEncoder()],
|
|
668
|
+
['reserveLiquidityMint', kit.getAddressEncoder()],
|
|
669
|
+
['obligation', kit.getAddressEncoder()],
|
|
670
|
+
['obligationId', kit.getU8Encoder()],
|
|
671
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 95)],
|
|
672
|
+
]);
|
|
673
|
+
}
|
|
674
|
+
function getKaminoConfigDecoder() {
|
|
675
|
+
return kit.getStructDecoder([
|
|
676
|
+
['market', kit.getAddressDecoder()],
|
|
677
|
+
['reserve', kit.getAddressDecoder()],
|
|
678
|
+
['reserveLiquidityMint', kit.getAddressDecoder()],
|
|
679
|
+
['obligation', kit.getAddressDecoder()],
|
|
680
|
+
['obligationId', kit.getU8Decoder()],
|
|
681
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 95)],
|
|
682
|
+
]);
|
|
683
|
+
}
|
|
684
|
+
function getKaminoConfigCodec() {
|
|
685
|
+
return kit.combineCodec(getKaminoConfigEncoder(), getKaminoConfigDecoder());
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function getLendingStateEncoder() {
|
|
689
|
+
return kit.getStructEncoder([
|
|
690
|
+
['balance', kit.getU64Encoder()],
|
|
691
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 40)],
|
|
692
|
+
]);
|
|
693
|
+
}
|
|
694
|
+
function getLendingStateDecoder() {
|
|
695
|
+
return kit.getStructDecoder([
|
|
696
|
+
['balance', kit.getU64Decoder()],
|
|
697
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 40)],
|
|
698
|
+
]);
|
|
699
|
+
}
|
|
700
|
+
function getLendingStateCodec() {
|
|
701
|
+
return kit.combineCodec(getLendingStateEncoder(), getLendingStateDecoder());
|
|
702
|
+
}
|
|
703
|
+
|
|
574
704
|
function getLocalTokenEncoder() {
|
|
575
705
|
return kit.getStructEncoder([
|
|
576
706
|
['custody', kit.getAddressEncoder()],
|
|
@@ -695,6 +825,64 @@ function getOFTStoreCodec() {
|
|
|
695
825
|
return kit.combineCodec(getOFTStoreEncoder(), getOFTStoreDecoder());
|
|
696
826
|
}
|
|
697
827
|
|
|
828
|
+
function getOracleEncoder() {
|
|
829
|
+
return kit.getStructEncoder([
|
|
830
|
+
['version', kit.getU8Encoder()],
|
|
831
|
+
['authority', kit.getAddressEncoder()],
|
|
832
|
+
['nonce', kit.getAddressEncoder()],
|
|
833
|
+
['value', kit.getI128Encoder()],
|
|
834
|
+
['precision', kit.getU32Encoder()],
|
|
835
|
+
['lastUpdateSlot', kit.getU64Encoder()],
|
|
836
|
+
['controller', kit.getAddressEncoder()],
|
|
837
|
+
['baseMint', kit.getAddressEncoder()],
|
|
838
|
+
['quoteMint', kit.getAddressEncoder()],
|
|
839
|
+
['reserved', kit.fixEncoderSize(kit.getBytesEncoder(), 64)],
|
|
840
|
+
['feeds', kit.getArrayEncoder(getFeedEncoder(), { size: 1 })],
|
|
841
|
+
]);
|
|
842
|
+
}
|
|
843
|
+
function getOracleDecoder() {
|
|
844
|
+
return kit.getStructDecoder([
|
|
845
|
+
['version', kit.getU8Decoder()],
|
|
846
|
+
['authority', kit.getAddressDecoder()],
|
|
847
|
+
['nonce', kit.getAddressDecoder()],
|
|
848
|
+
['value', kit.getI128Decoder()],
|
|
849
|
+
['precision', kit.getU32Decoder()],
|
|
850
|
+
['lastUpdateSlot', kit.getU64Decoder()],
|
|
851
|
+
['controller', kit.getAddressDecoder()],
|
|
852
|
+
['baseMint', kit.getAddressDecoder()],
|
|
853
|
+
['quoteMint', kit.getAddressDecoder()],
|
|
854
|
+
['reserved', kit.fixDecoderSize(kit.getBytesDecoder(), 64)],
|
|
855
|
+
['feeds', kit.getArrayDecoder(getFeedDecoder(), { size: 1 })],
|
|
856
|
+
]);
|
|
857
|
+
}
|
|
858
|
+
function getOracleCodec() {
|
|
859
|
+
return kit.combineCodec(getOracleEncoder(), getOracleDecoder());
|
|
860
|
+
}
|
|
861
|
+
function decodeOracle(encodedAccount) {
|
|
862
|
+
return kit.decodeAccount(encodedAccount, getOracleDecoder());
|
|
863
|
+
}
|
|
864
|
+
async function fetchOracle(rpc, address, config) {
|
|
865
|
+
const maybeAccount = await fetchMaybeOracle(rpc, address, config);
|
|
866
|
+
kit.assertAccountExists(maybeAccount);
|
|
867
|
+
return maybeAccount;
|
|
868
|
+
}
|
|
869
|
+
async function fetchMaybeOracle(rpc, address, config) {
|
|
870
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
871
|
+
return decodeOracle(maybeAccount);
|
|
872
|
+
}
|
|
873
|
+
async function fetchAllOracle(rpc, addresses, config) {
|
|
874
|
+
const maybeAccounts = await fetchAllMaybeOracle(rpc, addresses, config);
|
|
875
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
876
|
+
return maybeAccounts;
|
|
877
|
+
}
|
|
878
|
+
async function fetchAllMaybeOracle(rpc, addresses, config) {
|
|
879
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
880
|
+
return maybeAccounts.map((maybeAccount) => decodeOracle(maybeAccount));
|
|
881
|
+
}
|
|
882
|
+
function getOracleSize() {
|
|
883
|
+
return 349;
|
|
884
|
+
}
|
|
885
|
+
|
|
698
886
|
function getOracleUpdateEventEncoder() {
|
|
699
887
|
return kit.getStructEncoder([
|
|
700
888
|
['authority', kit.getAddressEncoder()],
|
|
@@ -746,58 +934,118 @@ function getPermissionStatusCodec() {
|
|
|
746
934
|
return kit.combineCodec(getPermissionStatusEncoder(), getPermissionStatusDecoder());
|
|
747
935
|
}
|
|
748
936
|
|
|
749
|
-
function
|
|
937
|
+
function getPermissionEncoder() {
|
|
750
938
|
return kit.getStructEncoder([
|
|
751
|
-
['authority', kit.getAddressEncoder()],
|
|
752
939
|
['controller', kit.getAddressEncoder()],
|
|
753
|
-
['
|
|
754
|
-
['
|
|
755
|
-
['
|
|
940
|
+
['authority', kit.getAddressEncoder()],
|
|
941
|
+
['status', getPermissionStatusEncoder()],
|
|
942
|
+
['canManagePermissions', kit.getBooleanEncoder()],
|
|
943
|
+
['canInvokeExternalTransfer', kit.getBooleanEncoder()],
|
|
944
|
+
['canExecuteSwap', kit.getBooleanEncoder()],
|
|
945
|
+
['canReallocate', kit.getBooleanEncoder()],
|
|
946
|
+
['canFreezeController', kit.getBooleanEncoder()],
|
|
947
|
+
['canUnfreezeController', kit.getBooleanEncoder()],
|
|
948
|
+
['canManageReservesAndIntegrations', kit.getBooleanEncoder()],
|
|
949
|
+
['canSuspendPermissions', kit.getBooleanEncoder()],
|
|
950
|
+
['canLiquidate', kit.getBooleanEncoder()],
|
|
951
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 30)],
|
|
756
952
|
]);
|
|
757
953
|
}
|
|
758
|
-
function
|
|
954
|
+
function getPermissionDecoder() {
|
|
759
955
|
return kit.getStructDecoder([
|
|
760
|
-
['authority', kit.getAddressDecoder()],
|
|
761
956
|
['controller', kit.getAddressDecoder()],
|
|
762
|
-
['
|
|
763
|
-
['
|
|
764
|
-
['
|
|
957
|
+
['authority', kit.getAddressDecoder()],
|
|
958
|
+
['status', getPermissionStatusDecoder()],
|
|
959
|
+
['canManagePermissions', kit.getBooleanDecoder()],
|
|
960
|
+
['canInvokeExternalTransfer', kit.getBooleanDecoder()],
|
|
961
|
+
['canExecuteSwap', kit.getBooleanDecoder()],
|
|
962
|
+
['canReallocate', kit.getBooleanDecoder()],
|
|
963
|
+
['canFreezeController', kit.getBooleanDecoder()],
|
|
964
|
+
['canUnfreezeController', kit.getBooleanDecoder()],
|
|
965
|
+
['canManageReservesAndIntegrations', kit.getBooleanDecoder()],
|
|
966
|
+
['canSuspendPermissions', kit.getBooleanDecoder()],
|
|
967
|
+
['canLiquidate', kit.getBooleanDecoder()],
|
|
968
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 30)],
|
|
765
969
|
]);
|
|
766
970
|
}
|
|
767
|
-
function
|
|
768
|
-
return kit.combineCodec(
|
|
971
|
+
function getPermissionCodec() {
|
|
972
|
+
return kit.combineCodec(getPermissionEncoder(), getPermissionDecoder());
|
|
769
973
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
974
|
+
function decodePermission(encodedAccount) {
|
|
975
|
+
return kit.decodeAccount(encodedAccount, getPermissionDecoder());
|
|
976
|
+
}
|
|
977
|
+
async function fetchPermission(rpc, address, config) {
|
|
978
|
+
const maybeAccount = await fetchMaybePermission(rpc, address, config);
|
|
979
|
+
kit.assertAccountExists(maybeAccount);
|
|
980
|
+
return maybeAccount;
|
|
981
|
+
}
|
|
982
|
+
async function fetchMaybePermission(rpc, address, config) {
|
|
983
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
984
|
+
return decodePermission(maybeAccount);
|
|
985
|
+
}
|
|
986
|
+
async function fetchAllPermission(rpc, addresses, config) {
|
|
987
|
+
const maybeAccounts = await fetchAllMaybePermission(rpc, addresses, config);
|
|
988
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
989
|
+
return maybeAccounts;
|
|
990
|
+
}
|
|
991
|
+
async function fetchAllMaybePermission(rpc, addresses, config) {
|
|
992
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
993
|
+
return maybeAccounts.map((maybeAccount) => decodePermission(maybeAccount));
|
|
994
|
+
}
|
|
995
|
+
function getPermissionSize() {
|
|
996
|
+
return 104;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function getPermissionUpdateEventEncoder() {
|
|
1000
|
+
return kit.getStructEncoder([
|
|
1001
|
+
['authority', kit.getAddressEncoder()],
|
|
1002
|
+
['controller', kit.getAddressEncoder()],
|
|
1003
|
+
['permission', kit.getAddressEncoder()],
|
|
1004
|
+
['oldState', kit.getOptionEncoder(getPermissionEncoder())],
|
|
1005
|
+
['newState', kit.getOptionEncoder(getPermissionEncoder())],
|
|
1006
|
+
]);
|
|
1007
|
+
}
|
|
1008
|
+
function getPermissionUpdateEventDecoder() {
|
|
1009
|
+
return kit.getStructDecoder([
|
|
1010
|
+
['authority', kit.getAddressDecoder()],
|
|
1011
|
+
['controller', kit.getAddressDecoder()],
|
|
1012
|
+
['permission', kit.getAddressDecoder()],
|
|
1013
|
+
['oldState', kit.getOptionDecoder(getPermissionDecoder())],
|
|
1014
|
+
['newState', kit.getOptionDecoder(getPermissionDecoder())],
|
|
1015
|
+
]);
|
|
1016
|
+
}
|
|
1017
|
+
function getPermissionUpdateEventCodec() {
|
|
1018
|
+
return kit.combineCodec(getPermissionUpdateEventEncoder(), getPermissionUpdateEventDecoder());
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function getPullArgsEncoder() {
|
|
1022
|
+
return kit.getDiscriminatedUnionEncoder([
|
|
1023
|
+
['SplTokenExternal', kit.getUnitEncoder()],
|
|
783
1024
|
['CctpBridge', kit.getUnitEncoder()],
|
|
784
1025
|
['LzBridge', kit.getUnitEncoder()],
|
|
1026
|
+
['Kamino', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
1027
|
+
[
|
|
1028
|
+
'Drift',
|
|
1029
|
+
kit.getStructEncoder([
|
|
1030
|
+
['spotMarketIndex', kit.getU16Encoder()],
|
|
1031
|
+
['amount', kit.getU64Encoder()],
|
|
1032
|
+
]),
|
|
1033
|
+
],
|
|
785
1034
|
]);
|
|
786
1035
|
}
|
|
787
1036
|
function getPullArgsDecoder() {
|
|
788
1037
|
return kit.getDiscriminatedUnionDecoder([
|
|
789
1038
|
['SplTokenExternal', kit.getUnitDecoder()],
|
|
1039
|
+
['CctpBridge', kit.getUnitDecoder()],
|
|
1040
|
+
['LzBridge', kit.getUnitDecoder()],
|
|
1041
|
+
['Kamino', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
790
1042
|
[
|
|
791
|
-
'
|
|
1043
|
+
'Drift',
|
|
792
1044
|
kit.getStructDecoder([
|
|
793
|
-
['
|
|
794
|
-
['
|
|
795
|
-
['maximumPoolTokenAmountA', kit.getU64Decoder()],
|
|
796
|
-
['maximumPoolTokenAmountB', kit.getU64Decoder()],
|
|
1045
|
+
['spotMarketIndex', kit.getU16Decoder()],
|
|
1046
|
+
['amount', kit.getU64Decoder()],
|
|
797
1047
|
]),
|
|
798
1048
|
],
|
|
799
|
-
['CctpBridge', kit.getUnitDecoder()],
|
|
800
|
-
['LzBridge', kit.getUnitDecoder()],
|
|
801
1049
|
]);
|
|
802
1050
|
}
|
|
803
1051
|
function getPullArgsCodec() {
|
|
@@ -815,33 +1063,31 @@ function isPullArgs(kind, value) {
|
|
|
815
1063
|
function getPushArgsEncoder() {
|
|
816
1064
|
return kit.getDiscriminatedUnionEncoder([
|
|
817
1065
|
['SplTokenExternal', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
1066
|
+
['CctpBridge', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
1067
|
+
['LzBridge', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
818
1068
|
[
|
|
819
|
-
'
|
|
1069
|
+
'Drift',
|
|
820
1070
|
kit.getStructEncoder([
|
|
821
|
-
['
|
|
822
|
-
['
|
|
823
|
-
['minimumPoolTokenAmountA', kit.getU64Encoder()],
|
|
824
|
-
['minimumPoolTokenAmountB', kit.getU64Encoder()],
|
|
1071
|
+
['spotMarketIndex', kit.getU16Encoder()],
|
|
1072
|
+
['amount', kit.getU64Encoder()],
|
|
825
1073
|
]),
|
|
826
1074
|
],
|
|
827
|
-
['
|
|
828
|
-
['LzBridge', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
1075
|
+
['Kamino', kit.getStructEncoder([['amount', kit.getU64Encoder()]])],
|
|
829
1076
|
]);
|
|
830
1077
|
}
|
|
831
1078
|
function getPushArgsDecoder() {
|
|
832
1079
|
return kit.getDiscriminatedUnionDecoder([
|
|
833
1080
|
['SplTokenExternal', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
1081
|
+
['CctpBridge', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
1082
|
+
['LzBridge', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
834
1083
|
[
|
|
835
|
-
'
|
|
1084
|
+
'Drift',
|
|
836
1085
|
kit.getStructDecoder([
|
|
837
|
-
['
|
|
838
|
-
['
|
|
839
|
-
['minimumPoolTokenAmountA', kit.getU64Decoder()],
|
|
840
|
-
['minimumPoolTokenAmountB', kit.getU64Decoder()],
|
|
1086
|
+
['spotMarketIndex', kit.getU16Decoder()],
|
|
1087
|
+
['amount', kit.getU64Decoder()],
|
|
841
1088
|
]),
|
|
842
1089
|
],
|
|
843
|
-
['
|
|
844
|
-
['LzBridge', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
1090
|
+
['Kamino', kit.getStructDecoder([['amount', kit.getU64Decoder()]])],
|
|
845
1091
|
]);
|
|
846
1092
|
}
|
|
847
1093
|
function getPushArgsCodec() {
|
|
@@ -887,6 +1133,66 @@ function getReserveStatusCodec() {
|
|
|
887
1133
|
return kit.combineCodec(getReserveStatusEncoder(), getReserveStatusDecoder());
|
|
888
1134
|
}
|
|
889
1135
|
|
|
1136
|
+
function getReserveEncoder() {
|
|
1137
|
+
return kit.getStructEncoder([
|
|
1138
|
+
['controller', kit.getAddressEncoder()],
|
|
1139
|
+
['mint', kit.getAddressEncoder()],
|
|
1140
|
+
['vault', kit.getAddressEncoder()],
|
|
1141
|
+
['status', getReserveStatusEncoder()],
|
|
1142
|
+
['rateLimitSlope', kit.getU64Encoder()],
|
|
1143
|
+
['rateLimitMaxOutflow', kit.getU64Encoder()],
|
|
1144
|
+
['rateLimitOutflowAmountAvailable', kit.getU64Encoder()],
|
|
1145
|
+
['rateLimitRemainder', kit.getU64Encoder()],
|
|
1146
|
+
['lastBalance', kit.getU64Encoder()],
|
|
1147
|
+
['lastRefreshTimestamp', kit.getI64Encoder()],
|
|
1148
|
+
['lastRefreshSlot', kit.getU64Encoder()],
|
|
1149
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 120)],
|
|
1150
|
+
]);
|
|
1151
|
+
}
|
|
1152
|
+
function getReserveDecoder() {
|
|
1153
|
+
return kit.getStructDecoder([
|
|
1154
|
+
['controller', kit.getAddressDecoder()],
|
|
1155
|
+
['mint', kit.getAddressDecoder()],
|
|
1156
|
+
['vault', kit.getAddressDecoder()],
|
|
1157
|
+
['status', getReserveStatusDecoder()],
|
|
1158
|
+
['rateLimitSlope', kit.getU64Decoder()],
|
|
1159
|
+
['rateLimitMaxOutflow', kit.getU64Decoder()],
|
|
1160
|
+
['rateLimitOutflowAmountAvailable', kit.getU64Decoder()],
|
|
1161
|
+
['rateLimitRemainder', kit.getU64Decoder()],
|
|
1162
|
+
['lastBalance', kit.getU64Decoder()],
|
|
1163
|
+
['lastRefreshTimestamp', kit.getI64Decoder()],
|
|
1164
|
+
['lastRefreshSlot', kit.getU64Decoder()],
|
|
1165
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 120)],
|
|
1166
|
+
]);
|
|
1167
|
+
}
|
|
1168
|
+
function getReserveCodec() {
|
|
1169
|
+
return kit.combineCodec(getReserveEncoder(), getReserveDecoder());
|
|
1170
|
+
}
|
|
1171
|
+
function decodeReserve(encodedAccount) {
|
|
1172
|
+
return kit.decodeAccount(encodedAccount, getReserveDecoder());
|
|
1173
|
+
}
|
|
1174
|
+
async function fetchReserve(rpc, address, config) {
|
|
1175
|
+
const maybeAccount = await fetchMaybeReserve(rpc, address, config);
|
|
1176
|
+
kit.assertAccountExists(maybeAccount);
|
|
1177
|
+
return maybeAccount;
|
|
1178
|
+
}
|
|
1179
|
+
async function fetchMaybeReserve(rpc, address, config) {
|
|
1180
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1181
|
+
return decodeReserve(maybeAccount);
|
|
1182
|
+
}
|
|
1183
|
+
async function fetchAllReserve(rpc, addresses, config) {
|
|
1184
|
+
const maybeAccounts = await fetchAllMaybeReserve(rpc, addresses, config);
|
|
1185
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
1186
|
+
return maybeAccounts;
|
|
1187
|
+
}
|
|
1188
|
+
async function fetchAllMaybeReserve(rpc, addresses, config) {
|
|
1189
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
1190
|
+
return maybeAccounts.map((maybeAccount) => decodeReserve(maybeAccount));
|
|
1191
|
+
}
|
|
1192
|
+
function getReserveSize() {
|
|
1193
|
+
return 273;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
890
1196
|
function getReserveUpdateEventEncoder() {
|
|
891
1197
|
return kit.getStructEncoder([
|
|
892
1198
|
['authority', kit.getAddressEncoder()],
|
|
@@ -941,52 +1247,6 @@ function getSplTokenExternalStateCodec() {
|
|
|
941
1247
|
return kit.combineCodec(getSplTokenExternalStateEncoder(), getSplTokenExternalStateDecoder());
|
|
942
1248
|
}
|
|
943
1249
|
|
|
944
|
-
function getSplTokenSwapConfigEncoder() {
|
|
945
|
-
return kit.getStructEncoder([
|
|
946
|
-
['program', kit.getAddressEncoder()],
|
|
947
|
-
['swap', kit.getAddressEncoder()],
|
|
948
|
-
['mintA', kit.getAddressEncoder()],
|
|
949
|
-
['mintB', kit.getAddressEncoder()],
|
|
950
|
-
['lpMint', kit.getAddressEncoder()],
|
|
951
|
-
['lpTokenAccount', kit.getAddressEncoder()],
|
|
952
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
953
|
-
]);
|
|
954
|
-
}
|
|
955
|
-
function getSplTokenSwapConfigDecoder() {
|
|
956
|
-
return kit.getStructDecoder([
|
|
957
|
-
['program', kit.getAddressDecoder()],
|
|
958
|
-
['swap', kit.getAddressDecoder()],
|
|
959
|
-
['mintA', kit.getAddressDecoder()],
|
|
960
|
-
['mintB', kit.getAddressDecoder()],
|
|
961
|
-
['lpMint', kit.getAddressDecoder()],
|
|
962
|
-
['lpTokenAccount', kit.getAddressDecoder()],
|
|
963
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
964
|
-
]);
|
|
965
|
-
}
|
|
966
|
-
function getSplTokenSwapConfigCodec() {
|
|
967
|
-
return kit.combineCodec(getSplTokenSwapConfigEncoder(), getSplTokenSwapConfigDecoder());
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
function getSplTokenSwapStateEncoder() {
|
|
971
|
-
return kit.getStructEncoder([
|
|
972
|
-
['lastBalanceA', kit.getU64Encoder()],
|
|
973
|
-
['lastBalanceB', kit.getU64Encoder()],
|
|
974
|
-
['lastBalanceLp', kit.getU64Encoder()],
|
|
975
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 24)],
|
|
976
|
-
]);
|
|
977
|
-
}
|
|
978
|
-
function getSplTokenSwapStateDecoder() {
|
|
979
|
-
return kit.getStructDecoder([
|
|
980
|
-
['lastBalanceA', kit.getU64Decoder()],
|
|
981
|
-
['lastBalanceB', kit.getU64Decoder()],
|
|
982
|
-
['lastBalanceLp', kit.getU64Decoder()],
|
|
983
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 24)],
|
|
984
|
-
]);
|
|
985
|
-
}
|
|
986
|
-
function getSplTokenSwapStateCodec() {
|
|
987
|
-
return kit.combineCodec(getSplTokenSwapStateEncoder(), getSplTokenSwapStateDecoder());
|
|
988
|
-
}
|
|
989
|
-
|
|
990
1250
|
function getSvmAlmControllerEventEncoder() {
|
|
991
1251
|
return kit.getDiscriminatedUnionEncoder([
|
|
992
1252
|
[
|
|
@@ -1061,363 +1321,73 @@ function getSvmAlmControllerEventDecoder() {
|
|
|
1061
1321
|
],
|
|
1062
1322
|
[
|
|
1063
1323
|
'OracleUpdate',
|
|
1064
|
-
kit.getStructDecoder([
|
|
1065
|
-
['fields', kit.getTupleDecoder([getOracleUpdateEventDecoder()])],
|
|
1066
|
-
]),
|
|
1067
|
-
],
|
|
1068
|
-
]);
|
|
1069
|
-
}
|
|
1070
|
-
function getSvmAlmControllerEventCodec() {
|
|
1071
|
-
return kit.combineCodec(getSvmAlmControllerEventEncoder(), getSvmAlmControllerEventDecoder());
|
|
1072
|
-
}
|
|
1073
|
-
function svmAlmControllerEvent(kind, data) {
|
|
1074
|
-
return Array.isArray(data)
|
|
1075
|
-
? { __kind: kind, fields: data }
|
|
1076
|
-
: { __kind: kind, ...(data ?? {}) };
|
|
1077
|
-
}
|
|
1078
|
-
function isSvmAlmControllerEvent(kind, value) {
|
|
1079
|
-
return value.__kind === kind;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
function getSwapV1SubsetEncoder() {
|
|
1083
|
-
return kit.getStructEncoder([
|
|
1084
|
-
['isInitialized', kit.getBooleanEncoder()],
|
|
1085
|
-
['bumpSeed', kit.getU8Encoder()],
|
|
1086
|
-
['tokenProgramId', kit.getAddressEncoder()],
|
|
1087
|
-
['tokenA', kit.getAddressEncoder()],
|
|
1088
|
-
['tokenB', kit.getAddressEncoder()],
|
|
1089
|
-
['poolMint', kit.getAddressEncoder()],
|
|
1090
|
-
['tokenAMint', kit.getAddressEncoder()],
|
|
1091
|
-
['tokenBMint', kit.getAddressEncoder()],
|
|
1092
|
-
['poolFeeAccount', kit.getAddressEncoder()],
|
|
1093
|
-
]);
|
|
1094
|
-
}
|
|
1095
|
-
function getSwapV1SubsetDecoder() {
|
|
1096
|
-
return kit.getStructDecoder([
|
|
1097
|
-
['isInitialized', kit.getBooleanDecoder()],
|
|
1098
|
-
['bumpSeed', kit.getU8Decoder()],
|
|
1099
|
-
['tokenProgramId', kit.getAddressDecoder()],
|
|
1100
|
-
['tokenA', kit.getAddressDecoder()],
|
|
1101
|
-
['tokenB', kit.getAddressDecoder()],
|
|
1102
|
-
['poolMint', kit.getAddressDecoder()],
|
|
1103
|
-
['tokenAMint', kit.getAddressDecoder()],
|
|
1104
|
-
['tokenBMint', kit.getAddressDecoder()],
|
|
1105
|
-
['poolFeeAccount', kit.getAddressDecoder()],
|
|
1106
|
-
]);
|
|
1107
|
-
}
|
|
1108
|
-
function getSwapV1SubsetCodec() {
|
|
1109
|
-
return kit.combineCodec(getSwapV1SubsetEncoder(), getSwapV1SubsetDecoder());
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
function getWithdrawSingleTokenTypeExactAmountOutArgsEncoder() {
|
|
1113
|
-
return kit.getStructEncoder([
|
|
1114
|
-
['destinationTokenAmount', kit.getU64Encoder()],
|
|
1115
|
-
['maximumPoolTokenAmount', kit.getU64Encoder()],
|
|
1116
|
-
]);
|
|
1117
|
-
}
|
|
1118
|
-
function getWithdrawSingleTokenTypeExactAmountOutArgsDecoder() {
|
|
1119
|
-
return kit.getStructDecoder([
|
|
1120
|
-
['destinationTokenAmount', kit.getU64Decoder()],
|
|
1121
|
-
['maximumPoolTokenAmount', kit.getU64Decoder()],
|
|
1122
|
-
]);
|
|
1123
|
-
}
|
|
1124
|
-
function getWithdrawSingleTokenTypeExactAmountOutArgsCodec() {
|
|
1125
|
-
return kit.combineCodec(getWithdrawSingleTokenTypeExactAmountOutArgsEncoder(), getWithdrawSingleTokenTypeExactAmountOutArgsDecoder());
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
function getControllerEncoder() {
|
|
1129
|
-
return kit.getStructEncoder([
|
|
1130
|
-
['id', kit.getU16Encoder()],
|
|
1131
|
-
['bump', kit.getU8Encoder()],
|
|
1132
|
-
['status', getControllerStatusEncoder()],
|
|
1133
|
-
['authority', kit.getAddressEncoder()],
|
|
1134
|
-
['authorityBump', kit.getU8Encoder()],
|
|
1135
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 128)],
|
|
1136
|
-
]);
|
|
1137
|
-
}
|
|
1138
|
-
function getControllerDecoder() {
|
|
1139
|
-
return kit.getStructDecoder([
|
|
1140
|
-
['id', kit.getU16Decoder()],
|
|
1141
|
-
['bump', kit.getU8Decoder()],
|
|
1142
|
-
['status', getControllerStatusDecoder()],
|
|
1143
|
-
['authority', kit.getAddressDecoder()],
|
|
1144
|
-
['authorityBump', kit.getU8Decoder()],
|
|
1145
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 128)],
|
|
1146
|
-
]);
|
|
1147
|
-
}
|
|
1148
|
-
function getControllerCodec() {
|
|
1149
|
-
return kit.combineCodec(getControllerEncoder(), getControllerDecoder());
|
|
1150
|
-
}
|
|
1151
|
-
function decodeController(encodedAccount) {
|
|
1152
|
-
return kit.decodeAccount(encodedAccount, getControllerDecoder());
|
|
1153
|
-
}
|
|
1154
|
-
async function fetchController(rpc, address, config) {
|
|
1155
|
-
const maybeAccount = await fetchMaybeController(rpc, address, config);
|
|
1156
|
-
kit.assertAccountExists(maybeAccount);
|
|
1157
|
-
return maybeAccount;
|
|
1158
|
-
}
|
|
1159
|
-
async function fetchMaybeController(rpc, address, config) {
|
|
1160
|
-
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1161
|
-
return decodeController(maybeAccount);
|
|
1162
|
-
}
|
|
1163
|
-
async function fetchAllController(rpc, addresses, config) {
|
|
1164
|
-
const maybeAccounts = await fetchAllMaybeController(rpc, addresses, config);
|
|
1165
|
-
kit.assertAccountsExist(maybeAccounts);
|
|
1166
|
-
return maybeAccounts;
|
|
1167
|
-
}
|
|
1168
|
-
async function fetchAllMaybeController(rpc, addresses, config) {
|
|
1169
|
-
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
1170
|
-
return maybeAccounts.map((maybeAccount) => decodeController(maybeAccount));
|
|
1171
|
-
}
|
|
1172
|
-
function getControllerSize() {
|
|
1173
|
-
return 165;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function getIntegrationEncoder() {
|
|
1177
|
-
return kit.getStructEncoder([
|
|
1178
|
-
['controller', kit.getAddressEncoder()],
|
|
1179
|
-
['description', kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
1180
|
-
['hash', kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
1181
|
-
['status', getIntegrationStatusEncoder()],
|
|
1182
|
-
['rateLimitSlope', kit.getU64Encoder()],
|
|
1183
|
-
['rateLimitMaxOutflow', kit.getU64Encoder()],
|
|
1184
|
-
['rateLimitOutflowAmountAvailable', kit.getU64Encoder()],
|
|
1185
|
-
['rateLimitRemainder', kit.getU64Encoder()],
|
|
1186
|
-
['lastRefreshTimestamp', kit.getI64Encoder()],
|
|
1187
|
-
['lastRefreshSlot', kit.getU64Encoder()],
|
|
1188
|
-
['config', getIntegrationConfigEncoder()],
|
|
1189
|
-
['state', getIntegrationStateEncoder()],
|
|
1190
|
-
['permitLiquidation', kit.getBooleanEncoder()],
|
|
1191
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 87)],
|
|
1192
|
-
]);
|
|
1193
|
-
}
|
|
1194
|
-
function getIntegrationDecoder() {
|
|
1195
|
-
return kit.getStructDecoder([
|
|
1196
|
-
['controller', kit.getAddressDecoder()],
|
|
1197
|
-
['description', kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
1198
|
-
['hash', kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
1199
|
-
['status', getIntegrationStatusDecoder()],
|
|
1200
|
-
['rateLimitSlope', kit.getU64Decoder()],
|
|
1201
|
-
['rateLimitMaxOutflow', kit.getU64Decoder()],
|
|
1202
|
-
['rateLimitOutflowAmountAvailable', kit.getU64Decoder()],
|
|
1203
|
-
['rateLimitRemainder', kit.getU64Decoder()],
|
|
1204
|
-
['lastRefreshTimestamp', kit.getI64Decoder()],
|
|
1205
|
-
['lastRefreshSlot', kit.getU64Decoder()],
|
|
1206
|
-
['config', getIntegrationConfigDecoder()],
|
|
1207
|
-
['state', getIntegrationStateDecoder()],
|
|
1208
|
-
['permitLiquidation', kit.getBooleanDecoder()],
|
|
1209
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 87)],
|
|
1210
|
-
]);
|
|
1211
|
-
}
|
|
1212
|
-
function getIntegrationCodec() {
|
|
1213
|
-
return kit.combineCodec(getIntegrationEncoder(), getIntegrationDecoder());
|
|
1214
|
-
}
|
|
1215
|
-
function decodeIntegration(encodedAccount) {
|
|
1216
|
-
return kit.decodeAccount(encodedAccount, getIntegrationDecoder());
|
|
1217
|
-
}
|
|
1218
|
-
async function fetchIntegration(rpc, address, config) {
|
|
1219
|
-
const maybeAccount = await fetchMaybeIntegration(rpc, address, config);
|
|
1220
|
-
kit.assertAccountExists(maybeAccount);
|
|
1221
|
-
return maybeAccount;
|
|
1222
|
-
}
|
|
1223
|
-
async function fetchMaybeIntegration(rpc, address, config) {
|
|
1224
|
-
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1225
|
-
return decodeIntegration(maybeAccount);
|
|
1226
|
-
}
|
|
1227
|
-
async function fetchAllIntegration(rpc, addresses, config) {
|
|
1228
|
-
const maybeAccounts = await fetchAllMaybeIntegration(rpc, addresses, config);
|
|
1229
|
-
kit.assertAccountsExist(maybeAccounts);
|
|
1230
|
-
return maybeAccounts;
|
|
1231
|
-
}
|
|
1232
|
-
async function fetchAllMaybeIntegration(rpc, addresses, config) {
|
|
1233
|
-
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
1234
|
-
return maybeAccounts.map((maybeAccount) => decodeIntegration(maybeAccount));
|
|
1235
|
-
}
|
|
1236
|
-
function getIntegrationSize() {
|
|
1237
|
-
return 507;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
function getOracleEncoder() {
|
|
1241
|
-
return kit.getStructEncoder([
|
|
1242
|
-
['version', kit.getU8Encoder()],
|
|
1243
|
-
['authority', kit.getAddressEncoder()],
|
|
1244
|
-
['nonce', kit.getAddressEncoder()],
|
|
1245
|
-
['value', kit.getI128Encoder()],
|
|
1246
|
-
['precision', kit.getU32Encoder()],
|
|
1247
|
-
['lastUpdateSlot', kit.getU64Encoder()],
|
|
1248
|
-
['controller', kit.getAddressEncoder()],
|
|
1249
|
-
['baseMint', kit.getAddressEncoder()],
|
|
1250
|
-
['quoteMint', kit.getAddressEncoder()],
|
|
1251
|
-
['reserved', kit.fixEncoderSize(kit.getBytesEncoder(), 64)],
|
|
1252
|
-
['feeds', kit.getArrayEncoder(getFeedEncoder(), { size: 1 })],
|
|
1253
|
-
]);
|
|
1254
|
-
}
|
|
1255
|
-
function getOracleDecoder() {
|
|
1256
|
-
return kit.getStructDecoder([
|
|
1257
|
-
['version', kit.getU8Decoder()],
|
|
1258
|
-
['authority', kit.getAddressDecoder()],
|
|
1259
|
-
['nonce', kit.getAddressDecoder()],
|
|
1260
|
-
['value', kit.getI128Decoder()],
|
|
1261
|
-
['precision', kit.getU32Decoder()],
|
|
1262
|
-
['lastUpdateSlot', kit.getU64Decoder()],
|
|
1263
|
-
['controller', kit.getAddressDecoder()],
|
|
1264
|
-
['baseMint', kit.getAddressDecoder()],
|
|
1265
|
-
['quoteMint', kit.getAddressDecoder()],
|
|
1266
|
-
['reserved', kit.fixDecoderSize(kit.getBytesDecoder(), 64)],
|
|
1267
|
-
['feeds', kit.getArrayDecoder(getFeedDecoder(), { size: 1 })],
|
|
1268
|
-
]);
|
|
1269
|
-
}
|
|
1270
|
-
function getOracleCodec() {
|
|
1271
|
-
return kit.combineCodec(getOracleEncoder(), getOracleDecoder());
|
|
1272
|
-
}
|
|
1273
|
-
function decodeOracle(encodedAccount) {
|
|
1274
|
-
return kit.decodeAccount(encodedAccount, getOracleDecoder());
|
|
1275
|
-
}
|
|
1276
|
-
async function fetchOracle(rpc, address, config) {
|
|
1277
|
-
const maybeAccount = await fetchMaybeOracle(rpc, address, config);
|
|
1278
|
-
kit.assertAccountExists(maybeAccount);
|
|
1279
|
-
return maybeAccount;
|
|
1280
|
-
}
|
|
1281
|
-
async function fetchMaybeOracle(rpc, address, config) {
|
|
1282
|
-
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1283
|
-
return decodeOracle(maybeAccount);
|
|
1284
|
-
}
|
|
1285
|
-
async function fetchAllOracle(rpc, addresses, config) {
|
|
1286
|
-
const maybeAccounts = await fetchAllMaybeOracle(rpc, addresses, config);
|
|
1287
|
-
kit.assertAccountsExist(maybeAccounts);
|
|
1288
|
-
return maybeAccounts;
|
|
1289
|
-
}
|
|
1290
|
-
async function fetchAllMaybeOracle(rpc, addresses, config) {
|
|
1291
|
-
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
1292
|
-
return maybeAccounts.map((maybeAccount) => decodeOracle(maybeAccount));
|
|
1293
|
-
}
|
|
1294
|
-
function getOracleSize() {
|
|
1295
|
-
return 349;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
function getPermissionEncoder() {
|
|
1299
|
-
return kit.getStructEncoder([
|
|
1300
|
-
['controller', kit.getAddressEncoder()],
|
|
1301
|
-
['authority', kit.getAddressEncoder()],
|
|
1302
|
-
['status', getPermissionStatusEncoder()],
|
|
1303
|
-
['canManagePermissions', kit.getBooleanEncoder()],
|
|
1304
|
-
['canInvokeExternalTransfer', kit.getBooleanEncoder()],
|
|
1305
|
-
['canExecuteSwap', kit.getBooleanEncoder()],
|
|
1306
|
-
['canReallocate', kit.getBooleanEncoder()],
|
|
1307
|
-
['canFreezeController', kit.getBooleanEncoder()],
|
|
1308
|
-
['canUnfreezeController', kit.getBooleanEncoder()],
|
|
1309
|
-
['canManageReservesAndIntegrations', kit.getBooleanEncoder()],
|
|
1310
|
-
['canSuspendPermissions', kit.getBooleanEncoder()],
|
|
1311
|
-
['canLiquidate', kit.getBooleanEncoder()],
|
|
1312
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 30)],
|
|
1313
|
-
]);
|
|
1314
|
-
}
|
|
1315
|
-
function getPermissionDecoder() {
|
|
1316
|
-
return kit.getStructDecoder([
|
|
1317
|
-
['controller', kit.getAddressDecoder()],
|
|
1318
|
-
['authority', kit.getAddressDecoder()],
|
|
1319
|
-
['status', getPermissionStatusDecoder()],
|
|
1320
|
-
['canManagePermissions', kit.getBooleanDecoder()],
|
|
1321
|
-
['canInvokeExternalTransfer', kit.getBooleanDecoder()],
|
|
1322
|
-
['canExecuteSwap', kit.getBooleanDecoder()],
|
|
1323
|
-
['canReallocate', kit.getBooleanDecoder()],
|
|
1324
|
-
['canFreezeController', kit.getBooleanDecoder()],
|
|
1325
|
-
['canUnfreezeController', kit.getBooleanDecoder()],
|
|
1326
|
-
['canManageReservesAndIntegrations', kit.getBooleanDecoder()],
|
|
1327
|
-
['canSuspendPermissions', kit.getBooleanDecoder()],
|
|
1328
|
-
['canLiquidate', kit.getBooleanDecoder()],
|
|
1329
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 30)],
|
|
1324
|
+
kit.getStructDecoder([
|
|
1325
|
+
['fields', kit.getTupleDecoder([getOracleUpdateEventDecoder()])],
|
|
1326
|
+
]),
|
|
1327
|
+
],
|
|
1330
1328
|
]);
|
|
1331
1329
|
}
|
|
1332
|
-
function
|
|
1333
|
-
return kit.combineCodec(
|
|
1334
|
-
}
|
|
1335
|
-
function decodePermission(encodedAccount) {
|
|
1336
|
-
return kit.decodeAccount(encodedAccount, getPermissionDecoder());
|
|
1337
|
-
}
|
|
1338
|
-
async function fetchPermission(rpc, address, config) {
|
|
1339
|
-
const maybeAccount = await fetchMaybePermission(rpc, address, config);
|
|
1340
|
-
kit.assertAccountExists(maybeAccount);
|
|
1341
|
-
return maybeAccount;
|
|
1342
|
-
}
|
|
1343
|
-
async function fetchMaybePermission(rpc, address, config) {
|
|
1344
|
-
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1345
|
-
return decodePermission(maybeAccount);
|
|
1346
|
-
}
|
|
1347
|
-
async function fetchAllPermission(rpc, addresses, config) {
|
|
1348
|
-
const maybeAccounts = await fetchAllMaybePermission(rpc, addresses, config);
|
|
1349
|
-
kit.assertAccountsExist(maybeAccounts);
|
|
1350
|
-
return maybeAccounts;
|
|
1330
|
+
function getSvmAlmControllerEventCodec() {
|
|
1331
|
+
return kit.combineCodec(getSvmAlmControllerEventEncoder(), getSvmAlmControllerEventDecoder());
|
|
1351
1332
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1333
|
+
function svmAlmControllerEvent(kind, data) {
|
|
1334
|
+
return Array.isArray(data)
|
|
1335
|
+
? { __kind: kind, fields: data }
|
|
1336
|
+
: { __kind: kind, ...(data ?? {}) };
|
|
1355
1337
|
}
|
|
1356
|
-
function
|
|
1357
|
-
return
|
|
1338
|
+
function isSvmAlmControllerEvent(kind, value) {
|
|
1339
|
+
return value.__kind === kind;
|
|
1358
1340
|
}
|
|
1359
1341
|
|
|
1360
|
-
function
|
|
1342
|
+
function getControllerEncoder() {
|
|
1361
1343
|
return kit.getStructEncoder([
|
|
1362
|
-
['
|
|
1363
|
-
['
|
|
1364
|
-
['
|
|
1365
|
-
['
|
|
1366
|
-
['
|
|
1367
|
-
['
|
|
1368
|
-
['rateLimitOutflowAmountAvailable', kit.getU64Encoder()],
|
|
1369
|
-
['rateLimitRemainder', kit.getU64Encoder()],
|
|
1370
|
-
['lastBalance', kit.getU64Encoder()],
|
|
1371
|
-
['lastRefreshTimestamp', kit.getI64Encoder()],
|
|
1372
|
-
['lastRefreshSlot', kit.getU64Encoder()],
|
|
1373
|
-
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 120)],
|
|
1344
|
+
['id', kit.getU16Encoder()],
|
|
1345
|
+
['bump', kit.getU8Encoder()],
|
|
1346
|
+
['status', getControllerStatusEncoder()],
|
|
1347
|
+
['authority', kit.getAddressEncoder()],
|
|
1348
|
+
['authorityBump', kit.getU8Encoder()],
|
|
1349
|
+
['padding', kit.fixEncoderSize(kit.getBytesEncoder(), 128)],
|
|
1374
1350
|
]);
|
|
1375
1351
|
}
|
|
1376
|
-
function
|
|
1352
|
+
function getControllerDecoder() {
|
|
1377
1353
|
return kit.getStructDecoder([
|
|
1378
|
-
['
|
|
1379
|
-
['
|
|
1380
|
-
['
|
|
1381
|
-
['
|
|
1382
|
-
['
|
|
1383
|
-
['
|
|
1384
|
-
['rateLimitOutflowAmountAvailable', kit.getU64Decoder()],
|
|
1385
|
-
['rateLimitRemainder', kit.getU64Decoder()],
|
|
1386
|
-
['lastBalance', kit.getU64Decoder()],
|
|
1387
|
-
['lastRefreshTimestamp', kit.getI64Decoder()],
|
|
1388
|
-
['lastRefreshSlot', kit.getU64Decoder()],
|
|
1389
|
-
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 120)],
|
|
1354
|
+
['id', kit.getU16Decoder()],
|
|
1355
|
+
['bump', kit.getU8Decoder()],
|
|
1356
|
+
['status', getControllerStatusDecoder()],
|
|
1357
|
+
['authority', kit.getAddressDecoder()],
|
|
1358
|
+
['authorityBump', kit.getU8Decoder()],
|
|
1359
|
+
['padding', kit.fixDecoderSize(kit.getBytesDecoder(), 128)],
|
|
1390
1360
|
]);
|
|
1391
1361
|
}
|
|
1392
|
-
function
|
|
1393
|
-
return kit.combineCodec(
|
|
1362
|
+
function getControllerCodec() {
|
|
1363
|
+
return kit.combineCodec(getControllerEncoder(), getControllerDecoder());
|
|
1394
1364
|
}
|
|
1395
|
-
function
|
|
1396
|
-
return kit.decodeAccount(encodedAccount,
|
|
1365
|
+
function decodeController(encodedAccount) {
|
|
1366
|
+
return kit.decodeAccount(encodedAccount, getControllerDecoder());
|
|
1397
1367
|
}
|
|
1398
|
-
async function
|
|
1399
|
-
const maybeAccount = await
|
|
1368
|
+
async function fetchController(rpc, address, config) {
|
|
1369
|
+
const maybeAccount = await fetchMaybeController(rpc, address, config);
|
|
1400
1370
|
kit.assertAccountExists(maybeAccount);
|
|
1401
1371
|
return maybeAccount;
|
|
1402
1372
|
}
|
|
1403
|
-
async function
|
|
1373
|
+
async function fetchMaybeController(rpc, address, config) {
|
|
1404
1374
|
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
1405
|
-
return
|
|
1375
|
+
return decodeController(maybeAccount);
|
|
1406
1376
|
}
|
|
1407
|
-
async function
|
|
1408
|
-
const maybeAccounts = await
|
|
1377
|
+
async function fetchAllController(rpc, addresses, config) {
|
|
1378
|
+
const maybeAccounts = await fetchAllMaybeController(rpc, addresses, config);
|
|
1409
1379
|
kit.assertAccountsExist(maybeAccounts);
|
|
1410
1380
|
return maybeAccounts;
|
|
1411
1381
|
}
|
|
1412
|
-
async function
|
|
1382
|
+
async function fetchAllMaybeController(rpc, addresses, config) {
|
|
1413
1383
|
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
1414
|
-
return maybeAccounts.map((maybeAccount) =>
|
|
1384
|
+
return maybeAccounts.map((maybeAccount) => decodeController(maybeAccount));
|
|
1415
1385
|
}
|
|
1416
|
-
function
|
|
1417
|
-
return
|
|
1386
|
+
function getControllerSize() {
|
|
1387
|
+
return 165;
|
|
1418
1388
|
}
|
|
1419
1389
|
|
|
1420
|
-
const SVM_ALM_CONTROLLER_PROGRAM_ADDRESS = '
|
|
1390
|
+
const SVM_ALM_CONTROLLER_PROGRAM_ADDRESS = 'ALM1JSnEhc5PkNecbSZotgprBuJujL5objTbwGtpTgTd';
|
|
1421
1391
|
exports.SvmAlmControllerAccount = void 0;
|
|
1422
1392
|
(function (SvmAlmControllerAccount) {
|
|
1423
1393
|
SvmAlmControllerAccount[SvmAlmControllerAccount["Controller"] = 0] = "Controller";
|
|
@@ -1446,6 +1416,7 @@ exports.SvmAlmControllerInstruction = void 0;
|
|
|
1446
1416
|
SvmAlmControllerInstruction[SvmAlmControllerInstruction["AtomicSwapBorrow"] = 15] = "AtomicSwapBorrow";
|
|
1447
1417
|
SvmAlmControllerInstruction[SvmAlmControllerInstruction["AtomicSwapRepay"] = 16] = "AtomicSwapRepay";
|
|
1448
1418
|
SvmAlmControllerInstruction[SvmAlmControllerInstruction["ResetLzPushInFlight"] = 17] = "ResetLzPushInFlight";
|
|
1419
|
+
SvmAlmControllerInstruction[SvmAlmControllerInstruction["ClaimRent"] = 18] = "ClaimRent";
|
|
1449
1420
|
})(exports.SvmAlmControllerInstruction || (exports.SvmAlmControllerInstruction = {}));
|
|
1450
1421
|
function identifySvmAlmControllerInstruction(instruction) {
|
|
1451
1422
|
const data = 'data' in instruction ? instruction.data : instruction;
|
|
@@ -1503,6 +1474,9 @@ function identifySvmAlmControllerInstruction(instruction) {
|
|
|
1503
1474
|
if (kit.containsBytes(data, kit.getU8Encoder().encode(17), 0)) {
|
|
1504
1475
|
return exports.SvmAlmControllerInstruction.ResetLzPushInFlight;
|
|
1505
1476
|
}
|
|
1477
|
+
if (kit.containsBytes(data, kit.getU8Encoder().encode(18), 0)) {
|
|
1478
|
+
return exports.SvmAlmControllerInstruction.ClaimRent;
|
|
1479
|
+
}
|
|
1506
1480
|
throw new Error('The provided instruction could not be identified as a svmAlmController instruction.');
|
|
1507
1481
|
}
|
|
1508
1482
|
|
|
@@ -1567,7 +1541,7 @@ function getAtomicSwapBorrowInstructionDataCodec() {
|
|
|
1567
1541
|
function getAtomicSwapBorrowInstruction(input, config) {
|
|
1568
1542
|
const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
|
|
1569
1543
|
const originalAccounts = {
|
|
1570
|
-
controller: { value: input.controller ?? null, isWritable:
|
|
1544
|
+
controller: { value: input.controller ?? null, isWritable: true },
|
|
1571
1545
|
controllerAuthority: {
|
|
1572
1546
|
value: input.controllerAuthority ?? null,
|
|
1573
1547
|
isWritable: false,
|
|
@@ -1678,7 +1652,7 @@ function getAtomicSwapRepayInstruction(input, config) {
|
|
|
1678
1652
|
const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
|
|
1679
1653
|
const originalAccounts = {
|
|
1680
1654
|
payer: { value: input.payer ?? null, isWritable: false },
|
|
1681
|
-
controller: { value: input.controller ?? null, isWritable:
|
|
1655
|
+
controller: { value: input.controller ?? null, isWritable: true },
|
|
1682
1656
|
controllerAuthority: {
|
|
1683
1657
|
value: input.controllerAuthority ?? null,
|
|
1684
1658
|
isWritable: false,
|
|
@@ -1759,6 +1733,75 @@ function parseAtomicSwapRepayInstruction(instruction) {
|
|
|
1759
1733
|
};
|
|
1760
1734
|
}
|
|
1761
1735
|
|
|
1736
|
+
const CLAIM_RENT_DISCRIMINATOR = 18;
|
|
1737
|
+
function getClaimRentDiscriminatorBytes() {
|
|
1738
|
+
return kit.getU8Encoder().encode(CLAIM_RENT_DISCRIMINATOR);
|
|
1739
|
+
}
|
|
1740
|
+
function getClaimRentInstructionDataEncoder() {
|
|
1741
|
+
return kit.transformEncoder(kit.getStructEncoder([['discriminator', kit.getU8Encoder()]]), (value) => ({ ...value, discriminator: CLAIM_RENT_DISCRIMINATOR }));
|
|
1742
|
+
}
|
|
1743
|
+
function getClaimRentInstructionDataDecoder() {
|
|
1744
|
+
return kit.getStructDecoder([['discriminator', kit.getU8Decoder()]]);
|
|
1745
|
+
}
|
|
1746
|
+
function getClaimRentInstructionDataCodec() {
|
|
1747
|
+
return kit.combineCodec(getClaimRentInstructionDataEncoder(), getClaimRentInstructionDataDecoder());
|
|
1748
|
+
}
|
|
1749
|
+
function getClaimRentInstruction(input, config) {
|
|
1750
|
+
const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
|
|
1751
|
+
const originalAccounts = {
|
|
1752
|
+
controller: { value: input.controller ?? null, isWritable: false },
|
|
1753
|
+
controllerAuthority: {
|
|
1754
|
+
value: input.controllerAuthority ?? null,
|
|
1755
|
+
isWritable: true,
|
|
1756
|
+
},
|
|
1757
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
1758
|
+
permission: { value: input.permission ?? null, isWritable: false },
|
|
1759
|
+
destination: { value: input.destination ?? null, isWritable: true },
|
|
1760
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1761
|
+
};
|
|
1762
|
+
const accounts = originalAccounts;
|
|
1763
|
+
if (!accounts.systemProgram.value) {
|
|
1764
|
+
accounts.systemProgram.value =
|
|
1765
|
+
'11111111111111111111111111111111';
|
|
1766
|
+
}
|
|
1767
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
1768
|
+
return Object.freeze({
|
|
1769
|
+
accounts: [
|
|
1770
|
+
getAccountMeta(accounts.controller),
|
|
1771
|
+
getAccountMeta(accounts.controllerAuthority),
|
|
1772
|
+
getAccountMeta(accounts.authority),
|
|
1773
|
+
getAccountMeta(accounts.permission),
|
|
1774
|
+
getAccountMeta(accounts.destination),
|
|
1775
|
+
getAccountMeta(accounts.systemProgram),
|
|
1776
|
+
],
|
|
1777
|
+
data: getClaimRentInstructionDataEncoder().encode({}),
|
|
1778
|
+
programAddress,
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
function parseClaimRentInstruction(instruction) {
|
|
1782
|
+
if (instruction.accounts.length < 6) {
|
|
1783
|
+
throw new Error('Not enough accounts');
|
|
1784
|
+
}
|
|
1785
|
+
let accountIndex = 0;
|
|
1786
|
+
const getNextAccount = () => {
|
|
1787
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1788
|
+
accountIndex += 1;
|
|
1789
|
+
return accountMeta;
|
|
1790
|
+
};
|
|
1791
|
+
return {
|
|
1792
|
+
programAddress: instruction.programAddress,
|
|
1793
|
+
accounts: {
|
|
1794
|
+
controller: getNextAccount(),
|
|
1795
|
+
controllerAuthority: getNextAccount(),
|
|
1796
|
+
authority: getNextAccount(),
|
|
1797
|
+
permission: getNextAccount(),
|
|
1798
|
+
destination: getNextAccount(),
|
|
1799
|
+
systemProgram: getNextAccount(),
|
|
1800
|
+
},
|
|
1801
|
+
data: getClaimRentInstructionDataDecoder().decode(instruction.data),
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1762
1805
|
const EMIT_EVENT_DISCRIMINATOR = 0;
|
|
1763
1806
|
function getEmitEventDiscriminatorBytes() {
|
|
1764
1807
|
return kit.getU8Encoder().encode(EMIT_EVENT_DISCRIMINATOR);
|
|
@@ -2564,13 +2607,12 @@ function getPullInstruction(input, config) {
|
|
|
2564
2607
|
controller: { value: input.controller ?? null, isWritable: false },
|
|
2565
2608
|
controllerAuthority: {
|
|
2566
2609
|
value: input.controllerAuthority ?? null,
|
|
2567
|
-
isWritable:
|
|
2610
|
+
isWritable: true,
|
|
2568
2611
|
},
|
|
2569
2612
|
authority: { value: input.authority ?? null, isWritable: false },
|
|
2570
2613
|
permission: { value: input.permission ?? null, isWritable: false },
|
|
2571
2614
|
integration: { value: input.integration ?? null, isWritable: true },
|
|
2572
2615
|
reserveA: { value: input.reserveA ?? null, isWritable: true },
|
|
2573
|
-
reserveB: { value: input.reserveB ?? null, isWritable: true },
|
|
2574
2616
|
programId: { value: input.programId ?? null, isWritable: false },
|
|
2575
2617
|
};
|
|
2576
2618
|
const accounts = originalAccounts;
|
|
@@ -2588,7 +2630,6 @@ function getPullInstruction(input, config) {
|
|
|
2588
2630
|
getAccountMeta(accounts.permission),
|
|
2589
2631
|
getAccountMeta(accounts.integration),
|
|
2590
2632
|
getAccountMeta(accounts.reserveA),
|
|
2591
|
-
getAccountMeta(accounts.reserveB),
|
|
2592
2633
|
getAccountMeta(accounts.programId),
|
|
2593
2634
|
],
|
|
2594
2635
|
data: getPullInstructionDataEncoder().encode(args),
|
|
@@ -2596,7 +2637,7 @@ function getPullInstruction(input, config) {
|
|
|
2596
2637
|
});
|
|
2597
2638
|
}
|
|
2598
2639
|
function parsePullInstruction(instruction) {
|
|
2599
|
-
if (instruction.accounts.length <
|
|
2640
|
+
if (instruction.accounts.length < 7) {
|
|
2600
2641
|
throw new Error('Not enough accounts');
|
|
2601
2642
|
}
|
|
2602
2643
|
let accountIndex = 0;
|
|
@@ -2614,7 +2655,6 @@ function parsePullInstruction(instruction) {
|
|
|
2614
2655
|
permission: getNextAccount(),
|
|
2615
2656
|
integration: getNextAccount(),
|
|
2616
2657
|
reserveA: getNextAccount(),
|
|
2617
|
-
reserveB: getNextAccount(),
|
|
2618
2658
|
programId: getNextAccount(),
|
|
2619
2659
|
},
|
|
2620
2660
|
data: getPullInstructionDataDecoder().decode(instruction.data),
|
|
@@ -2646,13 +2686,12 @@ function getPushInstruction(input, config) {
|
|
|
2646
2686
|
controller: { value: input.controller ?? null, isWritable: false },
|
|
2647
2687
|
controllerAuthority: {
|
|
2648
2688
|
value: input.controllerAuthority ?? null,
|
|
2649
|
-
isWritable:
|
|
2689
|
+
isWritable: true,
|
|
2650
2690
|
},
|
|
2651
2691
|
authority: { value: input.authority ?? null, isWritable: false },
|
|
2652
2692
|
permission: { value: input.permission ?? null, isWritable: false },
|
|
2653
2693
|
integration: { value: input.integration ?? null, isWritable: true },
|
|
2654
2694
|
reserveA: { value: input.reserveA ?? null, isWritable: true },
|
|
2655
|
-
reserveB: { value: input.reserveB ?? null, isWritable: true },
|
|
2656
2695
|
programId: { value: input.programId ?? null, isWritable: false },
|
|
2657
2696
|
};
|
|
2658
2697
|
const accounts = originalAccounts;
|
|
@@ -2670,7 +2709,6 @@ function getPushInstruction(input, config) {
|
|
|
2670
2709
|
getAccountMeta(accounts.permission),
|
|
2671
2710
|
getAccountMeta(accounts.integration),
|
|
2672
2711
|
getAccountMeta(accounts.reserveA),
|
|
2673
|
-
getAccountMeta(accounts.reserveB),
|
|
2674
2712
|
getAccountMeta(accounts.programId),
|
|
2675
2713
|
],
|
|
2676
2714
|
data: getPushInstructionDataEncoder().encode(args),
|
|
@@ -2678,7 +2716,7 @@ function getPushInstruction(input, config) {
|
|
|
2678
2716
|
});
|
|
2679
2717
|
}
|
|
2680
2718
|
function parsePushInstruction(instruction) {
|
|
2681
|
-
if (instruction.accounts.length <
|
|
2719
|
+
if (instruction.accounts.length < 7) {
|
|
2682
2720
|
throw new Error('Not enough accounts');
|
|
2683
2721
|
}
|
|
2684
2722
|
let accountIndex = 0;
|
|
@@ -2696,7 +2734,6 @@ function parsePushInstruction(instruction) {
|
|
|
2696
2734
|
permission: getNextAccount(),
|
|
2697
2735
|
integration: getNextAccount(),
|
|
2698
2736
|
reserveA: getNextAccount(),
|
|
2699
|
-
reserveB: getNextAccount(),
|
|
2700
2737
|
programId: getNextAccount(),
|
|
2701
2738
|
},
|
|
2702
2739
|
data: getPushInstructionDataDecoder().decode(instruction.data),
|
|
@@ -2832,9 +2869,11 @@ function getSyncInstruction(input, config) {
|
|
|
2832
2869
|
controller: { value: input.controller ?? null, isWritable: false },
|
|
2833
2870
|
controllerAuthority: {
|
|
2834
2871
|
value: input.controllerAuthority ?? null,
|
|
2835
|
-
isWritable:
|
|
2872
|
+
isWritable: true,
|
|
2836
2873
|
},
|
|
2874
|
+
payer: { value: input.payer ?? null, isWritable: true },
|
|
2837
2875
|
integration: { value: input.integration ?? null, isWritable: true },
|
|
2876
|
+
reserve: { value: input.reserve ?? null, isWritable: true },
|
|
2838
2877
|
};
|
|
2839
2878
|
const accounts = originalAccounts;
|
|
2840
2879
|
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
@@ -2842,14 +2881,16 @@ function getSyncInstruction(input, config) {
|
|
|
2842
2881
|
accounts: [
|
|
2843
2882
|
getAccountMeta(accounts.controller),
|
|
2844
2883
|
getAccountMeta(accounts.controllerAuthority),
|
|
2884
|
+
getAccountMeta(accounts.payer),
|
|
2845
2885
|
getAccountMeta(accounts.integration),
|
|
2886
|
+
getAccountMeta(accounts.reserve),
|
|
2846
2887
|
],
|
|
2847
2888
|
data: getSyncInstructionDataEncoder().encode({}),
|
|
2848
2889
|
programAddress,
|
|
2849
2890
|
});
|
|
2850
2891
|
}
|
|
2851
2892
|
function parseSyncInstruction(instruction) {
|
|
2852
|
-
if (instruction.accounts.length <
|
|
2893
|
+
if (instruction.accounts.length < 5) {
|
|
2853
2894
|
throw new Error('Not enough accounts');
|
|
2854
2895
|
}
|
|
2855
2896
|
let accountIndex = 0;
|
|
@@ -2863,7 +2904,9 @@ function parseSyncInstruction(instruction) {
|
|
|
2863
2904
|
accounts: {
|
|
2864
2905
|
controller: getNextAccount(),
|
|
2865
2906
|
controllerAuthority: getNextAccount(),
|
|
2907
|
+
payer: getNextAccount(),
|
|
2866
2908
|
integration: getNextAccount(),
|
|
2909
|
+
reserve: getNextAccount(),
|
|
2867
2910
|
},
|
|
2868
2911
|
data: getSyncInstructionDataDecoder().decode(instruction.data),
|
|
2869
2912
|
};
|
|
@@ -2935,13 +2978,13 @@ function getUpdateOracleDiscriminatorBytes() {
|
|
|
2935
2978
|
function getUpdateOracleInstructionDataEncoder() {
|
|
2936
2979
|
return kit.transformEncoder(kit.getStructEncoder([
|
|
2937
2980
|
['discriminator', kit.getU8Encoder()],
|
|
2938
|
-
['feedArgs', kit.getOptionEncoder(
|
|
2981
|
+
['feedArgs', kit.getOptionEncoder(getFeedEncoder())],
|
|
2939
2982
|
]), (value) => ({ ...value, discriminator: UPDATE_ORACLE_DISCRIMINATOR }));
|
|
2940
2983
|
}
|
|
2941
2984
|
function getUpdateOracleInstructionDataDecoder() {
|
|
2942
2985
|
return kit.getStructDecoder([
|
|
2943
2986
|
['discriminator', kit.getU8Decoder()],
|
|
2944
|
-
['feedArgs', kit.getOptionDecoder(
|
|
2987
|
+
['feedArgs', kit.getOptionDecoder(getFeedDecoder())],
|
|
2945
2988
|
]);
|
|
2946
2989
|
}
|
|
2947
2990
|
function getUpdateOracleInstructionDataCodec() {
|
|
@@ -3053,21 +3096,225 @@ const deriveReservePda = async (controller, mint) => {
|
|
|
3053
3096
|
});
|
|
3054
3097
|
return reservePda;
|
|
3055
3098
|
};
|
|
3056
|
-
|
|
3099
|
+
|
|
3100
|
+
const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
|
|
3101
|
+
const deriveDriftSigner = async () => {
|
|
3102
|
+
const [driftSignerPda] = await addresses.getProgramDerivedAddress({
|
|
3103
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3104
|
+
seeds: ["drift_signer"],
|
|
3105
|
+
});
|
|
3106
|
+
return driftSignerPda;
|
|
3107
|
+
};
|
|
3108
|
+
const deriveDriftSignerNonce = async () => {
|
|
3109
|
+
const [, nonce] = await addresses.getProgramDerivedAddress({
|
|
3110
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3111
|
+
seeds: ["drift_signer"],
|
|
3112
|
+
});
|
|
3113
|
+
return nonce;
|
|
3114
|
+
};
|
|
3115
|
+
const deriveStatePda = async () => {
|
|
3116
|
+
const [statePda] = await addresses.getProgramDerivedAddress({
|
|
3117
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3118
|
+
seeds: ["drift_state"],
|
|
3119
|
+
});
|
|
3120
|
+
return statePda;
|
|
3121
|
+
};
|
|
3122
|
+
const deriveUserStatsPda = async (authority) => {
|
|
3057
3123
|
const addressEncoder = addresses.getAddressEncoder();
|
|
3058
|
-
const [
|
|
3059
|
-
programAddress:
|
|
3124
|
+
const [userStatsPda] = await addresses.getProgramDerivedAddress({
|
|
3125
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3126
|
+
seeds: ["user_stats", addressEncoder.encode(authority)],
|
|
3127
|
+
});
|
|
3128
|
+
return userStatsPda;
|
|
3129
|
+
};
|
|
3130
|
+
const deriveUserPda = async (authority, subAccountId) => {
|
|
3131
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3132
|
+
const [userPda] = await addresses.getProgramDerivedAddress({
|
|
3133
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3060
3134
|
seeds: [
|
|
3061
|
-
"
|
|
3062
|
-
addressEncoder.encode(
|
|
3063
|
-
|
|
3135
|
+
"user",
|
|
3136
|
+
addressEncoder.encode(authority),
|
|
3137
|
+
Buffer.from(new Uint16Array([subAccountId]).buffer),
|
|
3138
|
+
],
|
|
3139
|
+
});
|
|
3140
|
+
return userPda;
|
|
3141
|
+
};
|
|
3142
|
+
const deriveSpotMarketPda = async (marketIndex) => {
|
|
3143
|
+
const [spotMarketPda] = await addresses.getProgramDerivedAddress({
|
|
3144
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3145
|
+
seeds: [
|
|
3146
|
+
"spot_market",
|
|
3147
|
+
Buffer.from(new Uint16Array([marketIndex]).buffer),
|
|
3148
|
+
],
|
|
3149
|
+
});
|
|
3150
|
+
return spotMarketPda;
|
|
3151
|
+
};
|
|
3152
|
+
const deriveSpotMarketVaultPda = async (marketIndex) => {
|
|
3153
|
+
const [spotMarketVaultPda] = await addresses.getProgramDerivedAddress({
|
|
3154
|
+
programAddress: DRIFT_PROGRAM_ID,
|
|
3155
|
+
seeds: [
|
|
3156
|
+
"spot_market_vault",
|
|
3157
|
+
Buffer.from(new Uint16Array([marketIndex]).buffer),
|
|
3158
|
+
],
|
|
3159
|
+
});
|
|
3160
|
+
return spotMarketVaultPda;
|
|
3161
|
+
};
|
|
3162
|
+
|
|
3163
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
3164
|
+
__proto__: null,
|
|
3165
|
+
DRIFT_PROGRAM_ID: DRIFT_PROGRAM_ID,
|
|
3166
|
+
deriveDriftSigner: deriveDriftSigner,
|
|
3167
|
+
deriveDriftSignerNonce: deriveDriftSignerNonce,
|
|
3168
|
+
deriveSpotMarketPda: deriveSpotMarketPda,
|
|
3169
|
+
deriveSpotMarketVaultPda: deriveSpotMarketVaultPda,
|
|
3170
|
+
deriveStatePda: deriveStatePda,
|
|
3171
|
+
deriveUserPda: deriveUserPda,
|
|
3172
|
+
deriveUserStatsPda: deriveUserStatsPda
|
|
3173
|
+
});
|
|
3174
|
+
|
|
3175
|
+
const KAMINO_LEND_PROGRAM_ID = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD";
|
|
3176
|
+
const KAMINO_FARMS_PROGRAM_ID = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr";
|
|
3177
|
+
const DEFAULT_PUBLIC_KEY = "11111111111111111111111111111111";
|
|
3178
|
+
const deriveVanillaObligationAddress = async (obligationId, authority, market) => {
|
|
3179
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3180
|
+
const [obligationPda] = await addresses.getProgramDerivedAddress({
|
|
3181
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3182
|
+
seeds: [
|
|
3183
|
+
Buffer.from([0]),
|
|
3184
|
+
Buffer.from(new Uint8Array([obligationId])),
|
|
3185
|
+
addressEncoder.encode(authority),
|
|
3186
|
+
addressEncoder.encode(market),
|
|
3187
|
+
addressEncoder.encode(DEFAULT_PUBLIC_KEY),
|
|
3188
|
+
addressEncoder.encode(DEFAULT_PUBLIC_KEY),
|
|
3189
|
+
],
|
|
3190
|
+
});
|
|
3191
|
+
return obligationPda;
|
|
3192
|
+
};
|
|
3193
|
+
const deriveReserveLiquiditySupply = async (market, reserveLiquidityMint) => {
|
|
3194
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3195
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3196
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3197
|
+
seeds: [
|
|
3198
|
+
"reserve_liq_supply",
|
|
3199
|
+
addressEncoder.encode(market),
|
|
3200
|
+
addressEncoder.encode(reserveLiquidityMint),
|
|
3201
|
+
],
|
|
3202
|
+
});
|
|
3203
|
+
return pda;
|
|
3204
|
+
};
|
|
3205
|
+
const deriveReserveCollateralMint = async (market, reserveLiquidityMint) => {
|
|
3206
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3207
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3208
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3209
|
+
seeds: [
|
|
3210
|
+
"reserve_coll_mint",
|
|
3211
|
+
addressEncoder.encode(market),
|
|
3212
|
+
addressEncoder.encode(reserveLiquidityMint),
|
|
3213
|
+
],
|
|
3214
|
+
});
|
|
3215
|
+
return pda;
|
|
3216
|
+
};
|
|
3217
|
+
const deriveReserveCollateralSupply = async (market, reserveLiquidityMint) => {
|
|
3218
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3219
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3220
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3221
|
+
seeds: [
|
|
3222
|
+
"reserve_coll_supply",
|
|
3223
|
+
addressEncoder.encode(market),
|
|
3224
|
+
addressEncoder.encode(reserveLiquidityMint),
|
|
3225
|
+
],
|
|
3226
|
+
});
|
|
3227
|
+
return pda;
|
|
3228
|
+
};
|
|
3229
|
+
const deriveMarketAuthorityAddress = async (market) => {
|
|
3230
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3231
|
+
const [pda, bump] = await addresses.getProgramDerivedAddress({
|
|
3232
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3233
|
+
seeds: ["lma", addressEncoder.encode(market)],
|
|
3234
|
+
});
|
|
3235
|
+
return { address: pda, bump };
|
|
3236
|
+
};
|
|
3237
|
+
const deriveObligationFarmAddress = async (reserveFarm, obligation) => {
|
|
3238
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3239
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3240
|
+
programAddress: KAMINO_FARMS_PROGRAM_ID,
|
|
3241
|
+
seeds: [
|
|
3242
|
+
"user",
|
|
3243
|
+
addressEncoder.encode(reserveFarm),
|
|
3244
|
+
addressEncoder.encode(obligation),
|
|
3245
|
+
],
|
|
3246
|
+
});
|
|
3247
|
+
return pda;
|
|
3248
|
+
};
|
|
3249
|
+
const deriveUserMetadataAddress = async (user) => {
|
|
3250
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3251
|
+
const [pda, bump] = await addresses.getProgramDerivedAddress({
|
|
3252
|
+
programAddress: KAMINO_LEND_PROGRAM_ID,
|
|
3253
|
+
seeds: ["user_meta", addressEncoder.encode(user)],
|
|
3254
|
+
});
|
|
3255
|
+
return { address: pda, bump };
|
|
3256
|
+
};
|
|
3257
|
+
const deriveRewardsVault = async (farmState, rewardsVaultMint) => {
|
|
3258
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3259
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3260
|
+
programAddress: KAMINO_FARMS_PROGRAM_ID,
|
|
3261
|
+
seeds: [
|
|
3262
|
+
"rvault",
|
|
3263
|
+
addressEncoder.encode(farmState),
|
|
3264
|
+
addressEncoder.encode(rewardsVaultMint),
|
|
3265
|
+
],
|
|
3266
|
+
});
|
|
3267
|
+
return pda;
|
|
3268
|
+
};
|
|
3269
|
+
const deriveRewardsTreasuryVault = async (globalConfig, rewardsVaultMint) => {
|
|
3270
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3271
|
+
const [pda] = await addresses.getProgramDerivedAddress({
|
|
3272
|
+
programAddress: KAMINO_FARMS_PROGRAM_ID,
|
|
3273
|
+
seeds: [
|
|
3274
|
+
"tvault",
|
|
3275
|
+
addressEncoder.encode(globalConfig),
|
|
3276
|
+
addressEncoder.encode(rewardsVaultMint),
|
|
3064
3277
|
],
|
|
3065
3278
|
});
|
|
3066
|
-
return
|
|
3279
|
+
return pda;
|
|
3280
|
+
};
|
|
3281
|
+
const deriveFarmVaultsAuthority = async (farmState) => {
|
|
3282
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3283
|
+
const [pda, bump] = await addresses.getProgramDerivedAddress({
|
|
3284
|
+
programAddress: KAMINO_FARMS_PROGRAM_ID,
|
|
3285
|
+
seeds: ["authority", addressEncoder.encode(farmState)],
|
|
3286
|
+
});
|
|
3287
|
+
return { address: pda, bump };
|
|
3067
3288
|
};
|
|
3289
|
+
const deriveKFarmsTreasuryVaultAuthority = async (globalConfig) => {
|
|
3290
|
+
const addressEncoder = addresses.getAddressEncoder();
|
|
3291
|
+
const [pda, bump] = await addresses.getProgramDerivedAddress({
|
|
3292
|
+
programAddress: KAMINO_FARMS_PROGRAM_ID,
|
|
3293
|
+
seeds: ["authority", addressEncoder.encode(globalConfig)],
|
|
3294
|
+
});
|
|
3295
|
+
return { address: pda, bump };
|
|
3296
|
+
};
|
|
3297
|
+
|
|
3298
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
3299
|
+
__proto__: null,
|
|
3300
|
+
KAMINO_FARMS_PROGRAM_ID: KAMINO_FARMS_PROGRAM_ID,
|
|
3301
|
+
KAMINO_LEND_PROGRAM_ID: KAMINO_LEND_PROGRAM_ID,
|
|
3302
|
+
deriveFarmVaultsAuthority: deriveFarmVaultsAuthority,
|
|
3303
|
+
deriveKFarmsTreasuryVaultAuthority: deriveKFarmsTreasuryVaultAuthority,
|
|
3304
|
+
deriveMarketAuthorityAddress: deriveMarketAuthorityAddress,
|
|
3305
|
+
deriveObligationFarmAddress: deriveObligationFarmAddress,
|
|
3306
|
+
deriveReserveCollateralMint: deriveReserveCollateralMint,
|
|
3307
|
+
deriveReserveCollateralSupply: deriveReserveCollateralSupply,
|
|
3308
|
+
deriveReserveLiquiditySupply: deriveReserveLiquiditySupply,
|
|
3309
|
+
deriveRewardsTreasuryVault: deriveRewardsTreasuryVault,
|
|
3310
|
+
deriveRewardsVault: deriveRewardsVault,
|
|
3311
|
+
deriveUserMetadataAddress: deriveUserMetadataAddress,
|
|
3312
|
+
deriveVanillaObligationAddress: deriveVanillaObligationAddress
|
|
3313
|
+
});
|
|
3068
3314
|
|
|
3069
3315
|
exports.ATOMIC_SWAP_BORROW_DISCRIMINATOR = ATOMIC_SWAP_BORROW_DISCRIMINATOR;
|
|
3070
3316
|
exports.ATOMIC_SWAP_REPAY_DISCRIMINATOR = ATOMIC_SWAP_REPAY_DISCRIMINATOR;
|
|
3317
|
+
exports.CLAIM_RENT_DISCRIMINATOR = CLAIM_RENT_DISCRIMINATOR;
|
|
3071
3318
|
exports.EMIT_EVENT_DISCRIMINATOR = EMIT_EVENT_DISCRIMINATOR;
|
|
3072
3319
|
exports.INITIALIZE_CONTROLLER_DISCRIMINATOR = INITIALIZE_CONTROLLER_DISCRIMINATOR;
|
|
3073
3320
|
exports.INITIALIZE_INTEGRATION_DISCRIMINATOR = INITIALIZE_INTEGRATION_DISCRIMINATOR;
|
|
@@ -3095,7 +3342,7 @@ exports.deriveControllerPda = deriveControllerPda;
|
|
|
3095
3342
|
exports.deriveIntegrationPda = deriveIntegrationPda;
|
|
3096
3343
|
exports.derivePermissionPda = derivePermissionPda;
|
|
3097
3344
|
exports.deriveReservePda = deriveReservePda;
|
|
3098
|
-
exports.
|
|
3345
|
+
exports.drift = index$1;
|
|
3099
3346
|
exports.fetchAllController = fetchAllController;
|
|
3100
3347
|
exports.fetchAllIntegration = fetchAllIntegration;
|
|
3101
3348
|
exports.fetchAllMaybeController = fetchAllMaybeController;
|
|
@@ -3150,6 +3397,11 @@ exports.getCctpBridgeConfigEncoder = getCctpBridgeConfigEncoder;
|
|
|
3150
3397
|
exports.getCctpBridgeStateCodec = getCctpBridgeStateCodec;
|
|
3151
3398
|
exports.getCctpBridgeStateDecoder = getCctpBridgeStateDecoder;
|
|
3152
3399
|
exports.getCctpBridgeStateEncoder = getCctpBridgeStateEncoder;
|
|
3400
|
+
exports.getClaimRentDiscriminatorBytes = getClaimRentDiscriminatorBytes;
|
|
3401
|
+
exports.getClaimRentInstruction = getClaimRentInstruction;
|
|
3402
|
+
exports.getClaimRentInstructionDataCodec = getClaimRentInstructionDataCodec;
|
|
3403
|
+
exports.getClaimRentInstructionDataDecoder = getClaimRentInstructionDataDecoder;
|
|
3404
|
+
exports.getClaimRentInstructionDataEncoder = getClaimRentInstructionDataEncoder;
|
|
3153
3405
|
exports.getControllerCodec = getControllerCodec;
|
|
3154
3406
|
exports.getControllerDecoder = getControllerDecoder;
|
|
3155
3407
|
exports.getControllerEncoder = getControllerEncoder;
|
|
@@ -3160,12 +3412,9 @@ exports.getControllerStatusEncoder = getControllerStatusEncoder;
|
|
|
3160
3412
|
exports.getControllerUpdateEventCodec = getControllerUpdateEventCodec;
|
|
3161
3413
|
exports.getControllerUpdateEventDecoder = getControllerUpdateEventDecoder;
|
|
3162
3414
|
exports.getControllerUpdateEventEncoder = getControllerUpdateEventEncoder;
|
|
3163
|
-
exports.
|
|
3164
|
-
exports.
|
|
3165
|
-
exports.
|
|
3166
|
-
exports.getDepositSingleTokenTypeExactAmountInArgsCodec = getDepositSingleTokenTypeExactAmountInArgsCodec;
|
|
3167
|
-
exports.getDepositSingleTokenTypeExactAmountInArgsDecoder = getDepositSingleTokenTypeExactAmountInArgsDecoder;
|
|
3168
|
-
exports.getDepositSingleTokenTypeExactAmountInArgsEncoder = getDepositSingleTokenTypeExactAmountInArgsEncoder;
|
|
3415
|
+
exports.getDriftConfigCodec = getDriftConfigCodec;
|
|
3416
|
+
exports.getDriftConfigDecoder = getDriftConfigDecoder;
|
|
3417
|
+
exports.getDriftConfigEncoder = getDriftConfigEncoder;
|
|
3169
3418
|
exports.getEmitEventDiscriminatorBytes = getEmitEventDiscriminatorBytes;
|
|
3170
3419
|
exports.getEmitEventInstruction = getEmitEventInstruction;
|
|
3171
3420
|
exports.getEmitEventInstructionDataCodec = getEmitEventInstructionDataCodec;
|
|
@@ -3219,6 +3468,12 @@ exports.getIntegrationTypeEncoder = getIntegrationTypeEncoder;
|
|
|
3219
3468
|
exports.getIntegrationUpdateEventCodec = getIntegrationUpdateEventCodec;
|
|
3220
3469
|
exports.getIntegrationUpdateEventDecoder = getIntegrationUpdateEventDecoder;
|
|
3221
3470
|
exports.getIntegrationUpdateEventEncoder = getIntegrationUpdateEventEncoder;
|
|
3471
|
+
exports.getKaminoConfigCodec = getKaminoConfigCodec;
|
|
3472
|
+
exports.getKaminoConfigDecoder = getKaminoConfigDecoder;
|
|
3473
|
+
exports.getKaminoConfigEncoder = getKaminoConfigEncoder;
|
|
3474
|
+
exports.getLendingStateCodec = getLendingStateCodec;
|
|
3475
|
+
exports.getLendingStateDecoder = getLendingStateDecoder;
|
|
3476
|
+
exports.getLendingStateEncoder = getLendingStateEncoder;
|
|
3222
3477
|
exports.getLocalTokenCodec = getLocalTokenCodec;
|
|
3223
3478
|
exports.getLocalTokenDecoder = getLocalTokenDecoder;
|
|
3224
3479
|
exports.getLocalTokenEncoder = getLocalTokenEncoder;
|
|
@@ -3319,18 +3574,9 @@ exports.getSplTokenExternalConfigEncoder = getSplTokenExternalConfigEncoder;
|
|
|
3319
3574
|
exports.getSplTokenExternalStateCodec = getSplTokenExternalStateCodec;
|
|
3320
3575
|
exports.getSplTokenExternalStateDecoder = getSplTokenExternalStateDecoder;
|
|
3321
3576
|
exports.getSplTokenExternalStateEncoder = getSplTokenExternalStateEncoder;
|
|
3322
|
-
exports.getSplTokenSwapConfigCodec = getSplTokenSwapConfigCodec;
|
|
3323
|
-
exports.getSplTokenSwapConfigDecoder = getSplTokenSwapConfigDecoder;
|
|
3324
|
-
exports.getSplTokenSwapConfigEncoder = getSplTokenSwapConfigEncoder;
|
|
3325
|
-
exports.getSplTokenSwapStateCodec = getSplTokenSwapStateCodec;
|
|
3326
|
-
exports.getSplTokenSwapStateDecoder = getSplTokenSwapStateDecoder;
|
|
3327
|
-
exports.getSplTokenSwapStateEncoder = getSplTokenSwapStateEncoder;
|
|
3328
3577
|
exports.getSvmAlmControllerEventCodec = getSvmAlmControllerEventCodec;
|
|
3329
3578
|
exports.getSvmAlmControllerEventDecoder = getSvmAlmControllerEventDecoder;
|
|
3330
3579
|
exports.getSvmAlmControllerEventEncoder = getSvmAlmControllerEventEncoder;
|
|
3331
|
-
exports.getSwapV1SubsetCodec = getSwapV1SubsetCodec;
|
|
3332
|
-
exports.getSwapV1SubsetDecoder = getSwapV1SubsetDecoder;
|
|
3333
|
-
exports.getSwapV1SubsetEncoder = getSwapV1SubsetEncoder;
|
|
3334
3580
|
exports.getSyncDiscriminatorBytes = getSyncDiscriminatorBytes;
|
|
3335
3581
|
exports.getSyncInstruction = getSyncInstruction;
|
|
3336
3582
|
exports.getSyncInstructionDataCodec = getSyncInstructionDataCodec;
|
|
@@ -3346,9 +3592,6 @@ exports.getUpdateOracleInstruction = getUpdateOracleInstruction;
|
|
|
3346
3592
|
exports.getUpdateOracleInstructionDataCodec = getUpdateOracleInstructionDataCodec;
|
|
3347
3593
|
exports.getUpdateOracleInstructionDataDecoder = getUpdateOracleInstructionDataDecoder;
|
|
3348
3594
|
exports.getUpdateOracleInstructionDataEncoder = getUpdateOracleInstructionDataEncoder;
|
|
3349
|
-
exports.getWithdrawSingleTokenTypeExactAmountOutArgsCodec = getWithdrawSingleTokenTypeExactAmountOutArgsCodec;
|
|
3350
|
-
exports.getWithdrawSingleTokenTypeExactAmountOutArgsDecoder = getWithdrawSingleTokenTypeExactAmountOutArgsDecoder;
|
|
3351
|
-
exports.getWithdrawSingleTokenTypeExactAmountOutArgsEncoder = getWithdrawSingleTokenTypeExactAmountOutArgsEncoder;
|
|
3352
3595
|
exports.identifySvmAlmControllerInstruction = identifySvmAlmControllerInstruction;
|
|
3353
3596
|
exports.initializeArgs = initializeArgs;
|
|
3354
3597
|
exports.integrationConfig = integrationConfig;
|
|
@@ -3359,8 +3602,10 @@ exports.isIntegrationState = isIntegrationState;
|
|
|
3359
3602
|
exports.isPullArgs = isPullArgs;
|
|
3360
3603
|
exports.isPushArgs = isPushArgs;
|
|
3361
3604
|
exports.isSvmAlmControllerEvent = isSvmAlmControllerEvent;
|
|
3605
|
+
exports.kamino = index;
|
|
3362
3606
|
exports.parseAtomicSwapBorrowInstruction = parseAtomicSwapBorrowInstruction;
|
|
3363
3607
|
exports.parseAtomicSwapRepayInstruction = parseAtomicSwapRepayInstruction;
|
|
3608
|
+
exports.parseClaimRentInstruction = parseClaimRentInstruction;
|
|
3364
3609
|
exports.parseEmitEventInstruction = parseEmitEventInstruction;
|
|
3365
3610
|
exports.parseInitializeControllerInstruction = parseInitializeControllerInstruction;
|
|
3366
3611
|
exports.parseInitializeIntegrationInstruction = parseInitializeIntegrationInstruction;
|