@scallop-io/sui-scallop-sdk 2.1.2-merge-split-ve-sca-alpha.1 → 2.1.3-merge-split-ve-sca-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.1.2-merge-split-ve-sca-alpha.1",
3
+ "version": "2.1.3-merge-split-ve-sca-alpha.1",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -4,7 +4,6 @@ import { ScallopBuilder } from 'src/models';
4
4
  import {
5
5
  GenerateLoyaltyProgramNormalMethod,
6
6
  GenerateLoyaltyProgramQuickMethod,
7
- LoyaltyProgramIds,
8
7
  LoyaltyProgramTxBlock,
9
8
  ScallopTxBlock,
10
9
  SuiTxBlockWithLoyaltyProgramNormalMethods,
@@ -13,11 +12,21 @@ import { requireSender } from 'src/utils';
13
12
 
14
13
  const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
15
14
  ({ builder, txBlock }) => {
16
- const loyaltyProgramIds: LoyaltyProgramIds = {
17
- loyaltyProgramPkgId: builder.address.get('loyaltyProgram.id'),
18
- rewardPool: builder.address.get('loyaltyProgram.rewardPool'),
19
- userRewardTableId: builder.address.get(
20
- 'loyaltyProgram.userRewardTableId'
15
+ const loyaltyProgramIds = {
16
+ pkgId: builder.address.get('loyaltyProgram.id'),
17
+ scaRewardPool: builder.address.get('loyaltyProgram.rewardPool'),
18
+ };
19
+
20
+ const veScaProgramIds = {
21
+ protocolConfig: builder.address.get('vesca.config'),
22
+ veScaTable: builder.address.get('vesca.table'),
23
+ subsTable: builder.address.get('vesca.subsTable'),
24
+ };
25
+
26
+ const veScaLoyaltyProgramIds = {
27
+ pkgId: builder.address.get('veScaLoyaltyProgram.id'),
28
+ veScaRewardPool: builder.address.get(
29
+ 'veScaLoyaltyProgram.veScaRewardPool'
21
30
  ),
22
31
  };
23
32
 
@@ -25,8 +34,21 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
25
34
  claimLoyaltyRevenue: (veScaKey) => {
26
35
  return builder.moveCall(
27
36
  txBlock,
28
- `${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
29
- [loyaltyProgramIds.rewardPool, veScaKey]
37
+ `${loyaltyProgramIds.pkgId}::reward_pool::redeem_reward`,
38
+ [loyaltyProgramIds.scaRewardPool, veScaKey]
39
+ );
40
+ },
41
+ claimVeScaLoyaltyReward: (veScaKey) => {
42
+ return builder.moveCall(
43
+ txBlock,
44
+ `${veScaLoyaltyProgramIds.pkgId}::ve_sca_reward::redeem_reward`,
45
+ [
46
+ veScaLoyaltyProgramIds.veScaRewardPool,
47
+ veScaKey,
48
+ veScaProgramIds.protocolConfig,
49
+ veScaProgramIds.veScaTable,
50
+ veScaProgramIds.subsTable,
51
+ ]
30
52
  );
31
53
  },
32
54
  };
@@ -57,6 +79,17 @@ const generateLoyaltyProgramQuickMethod: GenerateLoyaltyProgramQuickMethod = ({
57
79
  );
58
80
  txBlock.transferObjects([rewardCoin], sender);
59
81
  },
82
+ claimVeScaLoyaltyRewardQuick: async (veScaKey) => {
83
+ veScaKey = veScaKey ?? (await builder.query.getVeScas())[0]?.keyObject;
84
+ const sender = requireSender(txBlock);
85
+ if (!veScaKey) throw new Error(`No veScaKey found for user ${sender}`);
86
+
87
+ // claim the pending reward
88
+ const rewardVeScaKey = txBlock.claimVeScaLoyaltyReward(veScaKey);
89
+
90
+ // transfer the reward veSca key to the sender
91
+ txBlock.transferObjects([rewardVeScaKey], sender);
92
+ },
60
93
  };
61
94
  };
62
95
 
@@ -49,7 +49,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
49
49
  supra: '',
50
50
  switchboard:
51
51
  // '0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594',
52
- '0xaebdb50e0a95c5aa20c60bde5f574dac90aef83b508d64146cf29b5f63c35d4f',
52
+ '0xaebdb50e0a95c5aa20c60bde5f574dac90aef83b508d64146cf29b5f63c35d4f ',
53
53
  pyth: {
54
54
  feed: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
55
55
  feedObject:
@@ -242,18 +242,18 @@ export const TEST_ADDRESSES: AddressesInterface = {
242
242
  config: '',
243
243
  },
244
244
  borrowIncentive: {
245
- id: '0x8fe05c796e779c71e7739dcaecefb8757ff9482f62e419dbd0dd9c35b740054f',
246
- adminCap:
247
- '0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c',
245
+ id: '0x045811c127a4063d78683ea61fa987b9252a798b0d3ae9e927e25adcbe5549e2',
246
+ config:
247
+ '0xe5fec608d3a30a1f75b24d2c67d227524075aa6f5ee22e5eccedacd9145b1d9d',
248
248
  object:
249
- '0x8fe05c796e779c71e7739dcaecefb8757ff9482f62e419dbd0dd9c35b740054f',
250
- query: '0x5fba54ac5862f087112c54c02339623bd245721f5e21ea3330fc8c8afc8f51f4',
249
+ '0x045811c127a4063d78683ea61fa987b9252a798b0d3ae9e927e25adcbe5549e2',
251
250
  incentivePools:
252
- '0xcace4f4736229043d9f897667d046370b8a4d6534bfd307787c40b4c9f42514a',
251
+ '0xb06657692f7f4d9eb0d7b7d6ac24db30e6fdaed64b09dee49664b496f687de46',
253
252
  incentiveAccounts:
254
- '0x41ff558f580ca0f711910fd6ef687fce9df76ee8e7fc5e150bdfae08e17fae62',
255
- config:
256
- '0x9636e7b947b806b9fe438d037f02bb24026c5b2691d2f6bad349c2e117f77cc3',
253
+ '0x0bf8168d983c18edcc6b2c2b2e85d2bdac84764babfecf1b567f98801fbf4942',
254
+ query: '0xdbc22fe051d384691634cd3b9fe473b09723084a1e4c128728c42e2de3b2228f',
255
+ adminCap:
256
+ '0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c',
257
257
  },
258
258
  vesca: {
259
259
  id: '0x0c7f5568dbd69488437ee95f2d9a028724e1de12432965ff8acca7c67310ba46',
@@ -262,7 +262,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
262
262
  adminCap:
263
263
  '0x4d105b16467acca81d18c132cdd1a3cee159920a86c1ef4bdbf2e8d7878500c5',
264
264
  tableId:
265
- '0x06f763060ea5da3d639fb56df70674490a8354511cfe61584062aafd83b1940d',
265
+ '0x5477d43c9f75faea312c0f02dd48b4e03d9cbf2b1a5436ddffb5edefbea18ff2',
266
266
  table: '0x06f763060ea5da3d639fb56df70674490a8354511cfe61584062aafd83b1940d',
267
267
  treasury:
268
268
  '0x934919cc31fa89b67578039bb10d5518fa23c50bc8f78500f1d1a718407a0a71',
@@ -307,6 +307,17 @@ export const TEST_ADDRESSES: AddressesInterface = {
307
307
  userRewardTableId:
308
308
  '0x574a11f8a0fbaa05b8f559cb65634e8eb20f26b1ec29e7d58de9167f3cedd0f7',
309
309
  },
310
+ veScaLoyaltyProgram: {
311
+ id: '0x7e95dc10fb96ffb2341f664926417b0fb261c9f3dc417344d2a3b11a2f5bb812',
312
+ object:
313
+ '0x7e95dc10fb96ffb2341f664926417b0fb261c9f3dc417344d2a3b11a2f5bb812',
314
+ adminCap:
315
+ '0x4fc52ce8aab57eaa154d9ee42e9d8ecb7add6176d19ff65ebac59bf196b12de8',
316
+ veScaRewardPool:
317
+ '0x59025ec74adfcde1e0d793ff432fa0281f47fe4239aa8811430f10307292eca4',
318
+ veScaRewardTableId:
319
+ '0xbfa64d2dcd45c9dee92b8c0e052954c05bd687b4e3b132ace9c1f6d6cf619eba',
320
+ },
310
321
  scoin: {
311
322
  id: '0x826a4934bee9487e558eed603cf42f30cdc4321d6f31083930791b95f903b9f9',
312
323
  coins: {
@@ -353,4 +364,392 @@ export const TEST_ADDRESSES: AddressesInterface = {
353
364
  },
354
365
  },
355
366
  },
367
+ // scoin: {
368
+ // id: '0x826a4934bee9487e558eed603cf42f30cdc4321d6f31083930791b95f903b9f9',
369
+ // coins: {
370
+ // ssui: {
371
+ // coinType:
372
+ // '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
373
+ // metaData: '0xac724644f481f4870ecdc29b9549aa8ea5180f10827c0d97b493f9f65a91455d',
374
+ // symbol: 'sSUI',
375
+ // treasury: '0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b',
376
+ // },
377
+ // ssca: {
378
+ // coinType:
379
+ // '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
380
+ // treasury: '0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529',
381
+ // metaData: '0x27e3877491b308dfac46fb3d9f7dfa6a1e8b7dc3c374e92ecda7976055746964',
382
+ // symbol: 'sSCA',
383
+ // },
384
+ // susdc: {
385
+ // coinType:
386
+ // '0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
387
+ // treasury: '0xbe6b63021f3d82e0e7e977cdd718ed7c019cf2eba374b7b546220402452f938e',
388
+ // metaData: '0x763a21eba338e00bc684aaad80491c89eea5f247b59c47df45b17610c9ad58f2',
389
+ // symbol: 'sUSDC',
390
+ // },
391
+ // sdeep: {
392
+ // coinType:
393
+ // '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
394
+ // treasury: '0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
395
+ // metaData: '0x2443014594a500a9119e11c6c6a86e865834f496c4614280ce8cace33c0b072e',
396
+ // symbol: 'sDEEP',
397
+ // },
398
+ // sfud: {
399
+ // coinType:
400
+ // '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
401
+ // treasury: '0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867',
402
+ // metaData: '0x4e03390de36b8c84e0a8297d3d0d08a8a34bed93787e37fcb26bfc26df33226c',
403
+ // symbol: 'sFUD',
404
+ // },
405
+ // },
406
+ // },
407
+ };
408
+
409
+ export const WHITELIST = {
410
+ lending: new Set([
411
+ 'usdc',
412
+ // 'sbeth',
413
+ // 'sbusdt',
414
+ // 'sbwbtc',
415
+ // 'weth',
416
+ // 'wbtc',
417
+ // 'wusdc',
418
+ // 'wusdt',
419
+ 'sui',
420
+ // 'wapt',
421
+ // 'wsol',
422
+ // 'cetus',
423
+ // 'afsui',
424
+ // 'hasui',
425
+ // 'vsui',
426
+ 'sca',
427
+ 'fud',
428
+ 'deep',
429
+ // 'fdusd',
430
+ // 'blub',
431
+ // 'musd',
432
+ // 'ns',
433
+ // 'usdy',
434
+ // 'wal',
435
+ ]),
436
+ collateral: new Set([
437
+ 'usdc',
438
+ // 'sbeth',
439
+ // 'sbusdt',
440
+ // 'sbwbtc',
441
+ // 'weth',
442
+ // 'wbtc',
443
+ // 'wusdc',
444
+ // 'wusdt',
445
+ 'sui',
446
+ // 'wapt',
447
+ // 'wsol',
448
+ // 'cetus',
449
+ // 'afsui',
450
+ // 'hasui',
451
+ // 'vsui',
452
+ 'sca',
453
+ // 'fdusd',
454
+ // 'usdy',
455
+ // 'wal',
456
+ 'deep',
457
+ ]),
458
+ borrowing: new Set([
459
+ 'usdc',
460
+ // 'sbeth',
461
+ // 'sbusdt',
462
+ // 'sbwbtc',
463
+ // 'weth',
464
+ // 'wbtc',
465
+ // 'wusdc',
466
+ // 'wusdt',
467
+ 'sui',
468
+ // 'wapt',
469
+ // 'wsol',
470
+ // 'cetus',
471
+ // 'afsui',
472
+ // 'hasui',
473
+ // 'vsui',
474
+ 'sca',
475
+ 'fud',
476
+ 'deep',
477
+ // 'fdusd',
478
+ // 'blub',
479
+ // 'musd',
480
+ // 'ns',
481
+ // 'usdy',
482
+ // 'wal',
483
+ ]),
484
+ packages: new Set([
485
+ 'coinDecimalsRegistry',
486
+ 'math',
487
+ 'whitelist',
488
+ 'x',
489
+ 'protocol',
490
+ 'protocolWhitelist',
491
+ 'query',
492
+ 'supra',
493
+ 'pyth',
494
+ 'switchboard',
495
+ 'xOracle',
496
+ 'testCoin',
497
+ ]),
498
+ spool: new Set([
499
+ 'susdc',
500
+ // 'sweth',
501
+ 'ssui',
502
+ // 'swusdc',
503
+ // 'swusdt',
504
+ // 'scetus',
505
+ // 'safsui',
506
+ // 'shasui',
507
+ // 'svsui',
508
+ ]),
509
+ scoin: new Set([
510
+ 'susdc',
511
+ // 'ssbeth',
512
+ // 'ssbusdt',
513
+ // 'ssbwbtc',
514
+ 'ssui',
515
+ // 'swusdc',
516
+ // 'swusdt',
517
+ // 'safsui',
518
+ // 'shasui',
519
+ // 'svsui',
520
+ // 'sweth',
521
+ 'ssca',
522
+ // 'scetus',
523
+ // 'swsol',
524
+ // 'swbtc',
525
+ 'sdeep',
526
+ 'sfud',
527
+ // 'sfdusd',
528
+ // 'sblub',
529
+ // 'smusd',
530
+ // 'sns',
531
+ // 'susdy',
532
+ // 'swal',
533
+ ]),
534
+ suiBridge: new Set(['sbeth', 'sbusdt', 'sbwbtc']),
535
+ wormhole: new Set(['wusdc', 'wusdt', 'weth', 'wbtc', 'wapt', 'wsol']),
536
+ oracles: new Set(['pyth', 'supra', 'switchboard']),
537
+ pythEndpoints: new Set([
538
+ 'https://hermes.pyth.network',
539
+ 'https://scallop.rpc.p2p.world',
540
+ ]),
541
+ deprecated: new Set(['wapt', 'wusdc', 'wusdt', 'weth', 'wbtc']),
542
+ borrowIncentiveRewards: new Set(['mpoints']),
543
+ rewardsAsPoint: new Set(['mpoints']),
544
+ emerging: new Set(['wal', 'deep', 'sca', 'cetus']),
545
+ };
546
+
547
+ export const POOL_ADDRESSES = {
548
+ usdc: {
549
+ coinName: 'usdc',
550
+ symbol: 'USDC',
551
+ lendingPoolAddress:
552
+ '0x13319d295914b390b22484373f20f822bca10314c34c227ae6e28df3d9aa8e01',
553
+ collateralPoolAddress:
554
+ '0x2fdcf63682577f6bfdd4296500067543ba9877d5d5e41ebd9e51b97ab071ce69',
555
+ borrowDynamic:
556
+ '0x7fd0660f0102789ad039542165c6cbc2d90ba3c1d9dbd4ac4ae8804d80817542',
557
+ interestModel:
558
+ '0xd4e7b06a79f63706523167f055296db641b0f8ddd6734c05e205f2de0fcefdd0',
559
+ riskModel:
560
+ '0x19e5993350186f192ffeb2cba0650b04c291390e149c8ac9b324ecf394daaa1a',
561
+ borrowFeeKey: '',
562
+ supplyLimitKey:
563
+ '0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24',
564
+ borrowLimitKey:
565
+ '0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1',
566
+ isolatedAssetKey: '',
567
+ isIsolated: false,
568
+ spool: '0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918',
569
+ spoolReward:
570
+ '0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166',
571
+ sCoinType:
572
+ '0x55ed015f9f006c0c96ad36ebe3b3570d088e8498f52defea48e5634c110e485c::scallop_usdc::SCALLOP_USDC',
573
+ sCoinTreasury:
574
+ '0x6ef82ef94472dcb8c2cdeac8df38874024c08570ca165986ba56d1e38fe0c0a3',
575
+ sCoinMetadataId:
576
+ '0x763a21eba338e00bc684aaad80491c89eea5f247b59c47df45b17610c9ad58f2',
577
+ sCoinSymbol: 'sUSDC',
578
+ sCoinName: 'susdc',
579
+ coinMetadataId:
580
+ '0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6',
581
+ coinType:
582
+ '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
583
+ spoolName: 'susdc',
584
+ decimals: 6,
585
+ pythFeed:
586
+ 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
587
+ pythFeedObjectId:
588
+ '0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab',
589
+ flashloanFeeObject:
590
+ '0x289c770f54b26a4175d57cc6061e3d05f96e52d352cb7c0a51e2e3bacb2aee30',
591
+ },
592
+ sui: {
593
+ coinName: 'sui',
594
+ symbol: 'SUI',
595
+ lendingPoolAddress:
596
+ '0xeb86ad67543c1ac2c4cbaf178d38a45ab27c2e69d60f0f8badd83f563f012c3c',
597
+ collateralPoolAddress:
598
+ '0xcba7bb07d4d3ce01d81e71d9def680aa8b417347bfd7834aee8fc3b85b61c9a1',
599
+ borrowDynamic:
600
+ '0xd47c2fd3dbb95ed06e5da92f6b99611ba94a36efa6a13d9b33b02519761cc84e',
601
+ interestModel:
602
+ '0x4742bb49aa49ab4e5d9dfa119cddc027d1b7811ac42ca1ce794818d4a4da68e7',
603
+ riskModel:
604
+ '0x6dc356e829cfca2d79f0d68a79b5ddd5296ad0c955a38e2fc397485e2b629367',
605
+ borrowFeeKey: '',
606
+ supplyLimitKey:
607
+ '0x0602418e66fb7a73fa997077bd66f248ad5b090d43344a14b9f1db598ecc1d47',
608
+ borrowLimitKey:
609
+ '0x2b33a7efdcf6a6df24f4d8a356dd52f58d75bc023c3f171d99502d4d008b53f0',
610
+ isolatedAssetKey: '',
611
+ isIsolated: false,
612
+ spool: '0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579',
613
+ spoolReward:
614
+ '0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a',
615
+ sCoinType:
616
+ '0x88618204de2dfdc2597681a8441ee726b0dc13494c41e319c3264eb7b35fea90::scallop_sui::SCALLOP_SUI',
617
+ sCoinTreasury:
618
+ '0x03f1d94a40bd9f5d556bacb5c5245732b185572f6a29b36ad8b555d9a8a24f09',
619
+ sCoinMetadataId: '',
620
+ sCoinSymbol: 'sSUI',
621
+ sCoinName: 'ssui',
622
+ coinMetadataId:
623
+ '0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3',
624
+ coinType:
625
+ '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI',
626
+ spoolName: 'ssui',
627
+ decimals: 9,
628
+ pythFeed:
629
+ '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
630
+ pythFeedObjectId:
631
+ '0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37',
632
+ flashloanFeeObject:
633
+ '0x27614284a8f0a699ffd35aae8f2572c937ec76771cb21b0d7930ec4491a76ed4',
634
+ },
635
+ sca: {
636
+ coinName: 'sca',
637
+ symbol: 'SCA',
638
+ lendingPoolAddress:
639
+ '0xd08ef85bc753616ce0f1e3ac01bbc8bd1ee53e03b1e82aaa9690db5cd285ef4c',
640
+ collateralPoolAddress:
641
+ '0x4f59b8ef2cdd195830890cf0c01e29c159e48a6a6c766c64fd4b26cfa9ee58c6',
642
+ borrowDynamic:
643
+ '0x7f6e11fbd32b5d0223f03bfda67a5b48c551a09cfff88edc187591f9a4b0ab10',
644
+ interestModel:
645
+ '0xcb10daf0fee6f416463444f5b47aac0f0197a889bc60be2c4f90916f6a8d2faa',
646
+ riskModel:
647
+ '0x043f21a35bd1e1060a7c579db46e10cfd039d0b75d6bfd758de97b60434ae708',
648
+ borrowFeeKey: '',
649
+ supplyLimitKey:
650
+ '0x8dd938856b972a10ea27ecab2af7ed78e48fc5f6ccedaf2b2119959f747dc2e3',
651
+ borrowLimitKey:
652
+ '0x04c7de61c5b42972f9bf6a8b1848e5fea2d037ee8deba81741ecd4a70aa80d30',
653
+ isolatedAssetKey: '',
654
+ isIsolated: false,
655
+ spool: '',
656
+ spoolReward: '',
657
+ sCoinType:
658
+ '0x9f64a180373a6b66595025ae16a4ab701f0af1dd5c7ce1ac91dc112e52c2a3f8::scallop_sca::SCALLOP_SCA',
659
+ sCoinTreasury:
660
+ '0x1b05d2cd8b20dba19da073a54195fc52d2f438ea19dea0713bae7a7dab308199',
661
+ sCoinMetadataId: '',
662
+ sCoinSymbol: 'sSCA',
663
+ sCoinName: 'ssca',
664
+ coinMetadataId:
665
+ '0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844',
666
+ coinType:
667
+ '0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA',
668
+ spoolName: 'ssca',
669
+ decimals: 9,
670
+ pythFeed:
671
+ '7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc',
672
+ pythFeedObjectId:
673
+ '0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985',
674
+ flashloanFeeObject:
675
+ '0xe04e46471754b6f48d81c549ecfec09de02733715a63bec02364c6ac7c4dd2dc',
676
+ },
677
+ fud: {
678
+ coinName: 'fud',
679
+ symbol: 'FUD',
680
+ lendingPoolAddress:
681
+ '0xc8a078d15ee7bbff49a14835f36951833d2d55c91ffd2972251dadbff8045ca8',
682
+ collateralPoolAddress: '',
683
+ borrowDynamic:
684
+ '0x345a2fa0fe5d5d704fd8ad609a9b7529f22e3cda738ad26756ad2a85e5d43777',
685
+ interestModel:
686
+ '0xc84a22d8bca58e5f05673d1de2a7406b1b7bc9dcd15fd848ba6555c7ecab9d83',
687
+ borrowFeeKey: '',
688
+ supplyLimitKey:
689
+ '0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d',
690
+ borrowLimitKey:
691
+ '0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8',
692
+ isolatedAssetKey: '',
693
+ isIsolated: false,
694
+ spool: '',
695
+ spoolReward: '',
696
+ sCoinType:
697
+ '0x3b23c05f917052255a0b16a534dbd4446911aa4a30bd3497cdf5b736551e7ef8::scallop_fud::SCALLOP_FUD',
698
+ sCoinTreasury:
699
+ '0x858c492d51425b922c040c1a389e185b3b00d565e7d72ead1a81dc733104660d',
700
+ sCoinMetadataId: '',
701
+ sCoinSymbol: 'sFUD',
702
+ sCoinName: 'sfud',
703
+ coinMetadataId:
704
+ '0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e',
705
+ coinType:
706
+ '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD',
707
+ spoolName: 'sfud',
708
+ decimals: 5,
709
+ pythFeed:
710
+ '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
711
+ pythFeedObjectId:
712
+ '0x4531c3ed0d22f21f5fce882905372006c9aafa30f01db03b789e95a6c50de7b2',
713
+ flashloanFeeObject:
714
+ '0x1ddda368a5f37d7b8c53879cb333ccfd520fc4a3e2fc98b9b5fdacd1a5945d5a',
715
+ },
716
+ deep: {
717
+ coinName: 'deep',
718
+ symbol: 'DEEP',
719
+ lendingPoolAddress:
720
+ '0xfb8e4f68c9b14034da7f1f4703013dda69ebbb4578f835825bcf92ab89c3b5ae',
721
+ collateralPoolAddress: '',
722
+ borrowDynamic:
723
+ '0xbf983b12a8707b174c0b037096ba2fbf1b30e6efb9cce14fc35207de0a696f79',
724
+ interestModel:
725
+ '0xb7f04cd3aaaefe671a79f9aed8646ae085a7e6812c1604044977c9355e0769c8',
726
+ borrowFeeKey: '',
727
+ supplyLimitKey:
728
+ '0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
729
+ borrowLimitKey:
730
+ '0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
731
+ isolatedAssetKey: '',
732
+ isIsolated: false,
733
+ spool: '',
734
+ spoolReward: '',
735
+ sCoinType:
736
+ '0x34f0a2e793e1f79ceac72cfe3bb95f65541da449418289ccd12922d16140c882::scallop_deep::SCALLOP_DEEP',
737
+ sCoinTreasury:
738
+ '0x71d41465cf2d16fa0206126526bebdf65c8871d1fcfbd0c2237db2306afd67ba',
739
+ sCoinMetadataId: '',
740
+ sCoinSymbol: 'sDEEP',
741
+ sCoinName: 'sdeep',
742
+ coinMetadataId:
743
+ '0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
744
+ coinType:
745
+ '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
746
+ spoolName: 'sdeep',
747
+ decimals: 6,
748
+ pythFeed:
749
+ '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
750
+ pythFeedObjectId:
751
+ '0x8c7f3a322b94cc69db2a2ac575cbd94bf5766113324c3a3eceac91e3e88a51ed',
752
+ flashloanFeeObject:
753
+ '0xd54dfb677e9e011e2451375a7a2e318b4f2225c2a0b369bde0afcef8cbb1a863',
754
+ },
356
755
  };
@@ -358,6 +358,12 @@ const EMPTY_ADDRESSES: AddressesInterface = {
358
358
  rewardPool: '',
359
359
  userRewardTableId: '',
360
360
  },
361
+ veScaLoyaltyProgram: {
362
+ id: '',
363
+ object: '',
364
+ veScaRewardPool: '',
365
+ veScaRewardTableId: '',
366
+ },
361
367
  scoin: {
362
368
  id: '',
363
369
  coins: {
@@ -49,6 +49,7 @@ import {
49
49
  getTotalValueLocked,
50
50
  getUserPortfolio,
51
51
  getVeSca,
52
+ getVeScaLoyaltyProgramInformations,
52
53
  getVeScas,
53
54
  getVeScaTreasuryInfo,
54
55
  isIsolatedAsset,
@@ -684,13 +685,22 @@ class ScallopQuery implements ScallopQueryInterface {
684
685
 
685
686
  /**
686
687
  * Get user's veSCA loyalty program informations
687
- * @param walletAddress
688
+ * @param veScaKey
688
689
  * @returns Loyalty program information
689
690
  */
690
691
  async getLoyaltyProgramInfos(veScaKey?: string | SuiObjectData) {
691
692
  return await getLoyaltyProgramInformations(this, veScaKey);
692
693
  }
693
694
 
695
+ /**
696
+ * Get user's veSCA rewards informations from loyalty program
697
+ * @param veScaKey
698
+ * @returns Loyalty program information
699
+ */
700
+ async getVeScaLoyaltyProgramInfos(veScaKey?: string | SuiObjectData) {
701
+ return await getVeScaLoyaltyProgramInformations(this, veScaKey);
702
+ }
703
+
694
704
  /**
695
705
  * Get total supply of sCoin
696
706
  * @param sCoinName - Supported sCoin name
@@ -264,6 +264,9 @@ class ScallopSuiKit extends ScallopQueryClient {
264
264
  queryKey,
265
265
  });
266
266
  prevDatas.forEach(([key, prevData]) => {
267
+ if (!prevData) {
268
+ prevData = { data: prevData };
269
+ }
267
270
  this.queryClient.setQueryData(
268
271
  key,
269
272
  deepMergeObject(prevData, { data: result, error: null }),
@@ -1,7 +1,7 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { ScallopQuery } from 'src/models';
4
- import { LoyaltyProgramInfo } from 'src/types';
4
+ import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types';
5
5
  import { z as zod } from 'zod';
6
6
 
7
7
  const rewardPoolFieldsZod = zod
@@ -75,3 +75,84 @@ export const getLoyaltyProgramInformations = async (
75
75
  ) as UserRewardFields;
76
76
  return result;
77
77
  };
78
+
79
+ const veScaRewardPoolFieldsZod = zod
80
+ .object({
81
+ reserve_ve_sca_key: zod.nullable(
82
+ zod.object({
83
+ fields: zod.object({
84
+ id: zod.object({
85
+ id: zod.string(),
86
+ }),
87
+ }),
88
+ type: zod.string(),
89
+ })
90
+ ),
91
+ enable_claim: zod.boolean(),
92
+ })
93
+ .transform((value) => ({
94
+ reserveVeScaKey: value.reserve_ve_sca_key?.fields.id.id,
95
+ isClaimEnabled: value.enable_claim,
96
+ }));
97
+
98
+ const userVeScaRewardFieldsZod = zod
99
+ .object({
100
+ value: zod.string(),
101
+ })
102
+ .transform((value) => BigNumber(value.value).shiftedBy(-9).toNumber());
103
+
104
+ type VeScaRewardPoolFields = zod.infer<typeof veScaRewardPoolFieldsZod>;
105
+ type UserVeScaRewardFields = zod.infer<typeof userVeScaRewardFieldsZod>;
106
+
107
+ export const getVeScaLoyaltyProgramInformations = async (
108
+ query: ScallopQuery,
109
+ veScaKey?: string | SuiObjectData
110
+ ): Promise<VeScaLoyaltyProgramInfo | null> => {
111
+ const rewardPool = query.address.get('veScaLoyaltyProgram.veScaRewardPool');
112
+
113
+ // get fields from rewardPool object
114
+ const rewardPoolObject = await query.scallopSuiKit.queryGetObject(rewardPool);
115
+
116
+ if (rewardPoolObject?.data?.content?.dataType !== 'moveObject') return null;
117
+ const rewardPoolFields = rewardPoolObject.data.content.fields;
118
+ const { isClaimEnabled, reserveVeScaKey } = veScaRewardPoolFieldsZod.parse(
119
+ rewardPoolFields
120
+ ) as VeScaRewardPoolFields;
121
+
122
+ const result: VeScaLoyaltyProgramInfo = {
123
+ pendingVeScaReward: 0,
124
+ totalPoolReward: 0,
125
+ isClaimEnabled,
126
+ };
127
+
128
+ // calculate totalPoolreward from reserveVeScaKey
129
+ if (reserveVeScaKey) {
130
+ const reserveVeSca = await query.getVeSca(reserveVeScaKey);
131
+ result.totalPoolReward = reserveVeSca?.currentVeScaBalance ?? 0;
132
+ }
133
+
134
+ // query the user pending reward if exist
135
+ veScaKey = veScaKey ?? (await query.getVeScas())[0]?.keyObject;
136
+ if (!veScaKey) return result;
137
+
138
+ const veScaRewardTableId = query.address.get(
139
+ 'veScaLoyaltyProgram.veScaRewardTableId'
140
+ );
141
+
142
+ const userRewardObject = await query.scallopSuiKit.queryGetDynamicFieldObject(
143
+ {
144
+ parentId: veScaRewardTableId,
145
+ name: {
146
+ type: '0x2::object::ID',
147
+ value: typeof veScaKey === 'string' ? veScaKey : veScaKey.objectId,
148
+ },
149
+ }
150
+ );
151
+
152
+ if (userRewardObject?.data?.content?.dataType !== 'moveObject') return result;
153
+ const userRewardFields = userRewardObject.data.content.fields;
154
+ result.pendingVeScaReward = userVeScaRewardFieldsZod.parse(
155
+ userRewardFields
156
+ ) as UserVeScaRewardFields;
157
+ return result;
158
+ };