@scallop-io/sui-scallop-sdk 1.3.3 → 1.3.4-alpha.2

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.
Files changed (103) hide show
  1. package/dist/index.js +1258 -1092
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +1249 -1092
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/src/builders/loyaltyProgramBuilder.ts +1 -1
  7. package/src/constants/coinGecko.ts +18 -0
  8. package/src/constants/common.ts +0 -1
  9. package/src/constants/enum.ts +8 -0
  10. package/src/constants/index.ts +6 -0
  11. package/src/constants/poolAddress.ts +94 -0
  12. package/src/constants/pyth.ts +19 -0
  13. package/src/constants/queryKeys.ts +1 -5
  14. package/src/constants/rpc.ts +16 -0
  15. package/src/constants/tokenBucket.ts +1 -1
  16. package/src/models/scallop.ts +3 -2
  17. package/src/models/scallopAddress.ts +2 -2
  18. package/src/models/scallopBuilder.ts +4 -3
  19. package/src/models/scallopCache.ts +1 -1
  20. package/src/models/scallopClient.ts +27 -26
  21. package/src/models/scallopQuery.ts +58 -15
  22. package/src/models/scallopUtils.ts +96 -96
  23. package/src/models/suiKit.ts +11 -0
  24. package/src/queries/borrowIncentiveQuery.ts +6 -13
  25. package/src/queries/coreQuery.ts +37 -22
  26. package/src/queries/loyaltyProgramQuery.ts +1 -1
  27. package/src/queries/portfolioQuery.ts +55 -34
  28. package/src/queries/spoolQuery.ts +17 -17
  29. package/src/types/utils.ts +13 -0
  30. package/src/utils/tokenBucket.ts +2 -1
  31. package/src/utils/util.ts +2 -1
  32. package/dist/builders/borrowIncentiveBuilder.d.ts +0 -12
  33. package/dist/builders/coreBuilder.d.ts +0 -12
  34. package/dist/builders/index.d.ts +0 -12
  35. package/dist/builders/loyaltyProgramBuilder.d.ts +0 -12
  36. package/dist/builders/oracle.d.ts +0 -14
  37. package/dist/builders/referralBuilder.d.ts +0 -12
  38. package/dist/builders/sCoinBuilder.d.ts +0 -4
  39. package/dist/builders/spoolBuilder.d.ts +0 -12
  40. package/dist/builders/vescaBuilder.d.ts +0 -25
  41. package/dist/constants/cache.d.ts +0 -14
  42. package/dist/constants/common.d.ts +0 -20
  43. package/dist/constants/enum.d.ts +0 -13
  44. package/dist/constants/flashloan.d.ts +0 -2
  45. package/dist/constants/index.d.ts +0 -5
  46. package/dist/constants/pyth.d.ts +0 -3
  47. package/dist/constants/queryKeys.d.ts +0 -58
  48. package/dist/constants/testAddress.d.ts +0 -2
  49. package/dist/constants/tokenBucket.d.ts +0 -2
  50. package/dist/constants/vesca.d.ts +0 -5
  51. package/dist/index.d.ts +0 -3
  52. package/dist/models/index.d.ts +0 -8
  53. package/dist/models/scallop.d.ts +0 -74
  54. package/dist/models/scallopAddress.d.ts +0 -150
  55. package/dist/models/scallopBuilder.d.ts +0 -89
  56. package/dist/models/scallopCache.d.ts +0 -74
  57. package/dist/models/scallopClient.d.ts +0 -321
  58. package/dist/models/scallopIndexer.d.ts +0 -89
  59. package/dist/models/scallopPrice.d.ts +0 -0
  60. package/dist/models/scallopQuery.d.ts +0 -474
  61. package/dist/models/scallopUtils.d.ts +0 -217
  62. package/dist/queries/borrowIncentiveQuery.d.ts +0 -61
  63. package/dist/queries/coreQuery.d.ts +0 -167
  64. package/dist/queries/index.d.ts +0 -8
  65. package/dist/queries/isolatedAsset.d.ts +0 -14
  66. package/dist/queries/loyaltyProgramQuery.d.ts +0 -10
  67. package/dist/queries/portfolioQuery.d.ts +0 -73
  68. package/dist/queries/priceQuery.d.ts +0 -16
  69. package/dist/queries/referralQuery.d.ts +0 -7
  70. package/dist/queries/sCoinQuery.d.ts +0 -41
  71. package/dist/queries/spoolQuery.d.ts +0 -70
  72. package/dist/queries/supplyLimit.d.ts +0 -9
  73. package/dist/queries/vescaQuery.d.ts +0 -36
  74. package/dist/types/address.d.ts +0 -107
  75. package/dist/types/builder/borrowIncentive.d.ts +0 -35
  76. package/dist/types/builder/core.d.ts +0 -56
  77. package/dist/types/builder/index.d.ts +0 -24
  78. package/dist/types/builder/loyaltyProgram.d.ts +0 -23
  79. package/dist/types/builder/referral.d.ts +0 -30
  80. package/dist/types/builder/sCoin.d.ts +0 -37
  81. package/dist/types/builder/spool.d.ts +0 -29
  82. package/dist/types/builder/vesca.d.ts +0 -51
  83. package/dist/types/constant/common.d.ts +0 -24
  84. package/dist/types/constant/enum.d.ts +0 -48
  85. package/dist/types/constant/index.d.ts +0 -2
  86. package/dist/types/index.d.ts +0 -6
  87. package/dist/types/model.d.ts +0 -54
  88. package/dist/types/query/borrowIncentive.d.ts +0 -124
  89. package/dist/types/query/core.d.ts +0 -361
  90. package/dist/types/query/index.d.ts +0 -7
  91. package/dist/types/query/loyaltyProgram.d.ts +0 -5
  92. package/dist/types/query/portfolio.d.ts +0 -115
  93. package/dist/types/query/sCoin.d.ts +0 -1
  94. package/dist/types/query/spool.d.ts +0 -122
  95. package/dist/types/query/vesca.d.ts +0 -26
  96. package/dist/types/utils.d.ts +0 -9
  97. package/dist/utils/builder.d.ts +0 -15
  98. package/dist/utils/index.d.ts +0 -5
  99. package/dist/utils/indexer.d.ts +0 -17
  100. package/dist/utils/query.d.ts +0 -62
  101. package/dist/utils/tokenBucket.d.ts +0 -11
  102. package/dist/utils/util.d.ts +0 -26
  103. package/src/models/scallopPrice.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.3.3",
3
+ "version": "1.3.4-alpha.2",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -149,7 +149,7 @@
149
149
  "scripts": {
150
150
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
151
151
  "build": "pnpm run build:types && pnpm run build:tsup",
152
- "build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
152
+ "build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap --clean",
153
153
  "build:types": "tsc --build",
154
154
  "watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
155
155
  "watch:types": "tsc --watch",
@@ -38,7 +38,7 @@ const generateLoyaltyProgramQuickMethod: GenerateLoyaltyProgramQuickMethod = ({
38
38
  }) => {
39
39
  return {
40
40
  claimLoyaltyRevenueQuick: async (veScaKey) => {
41
- veScaKey = veScaKey || (await builder.query.getVeScas())[0]?.keyObject;
41
+ veScaKey = veScaKey ?? (await builder.query.getVeScas())[0]?.keyObject;
42
42
  const sender = requireSender(txBlock);
43
43
  if (!veScaKey) throw new Error(`No veScaKey found for user ${sender}`);
44
44
 
@@ -0,0 +1,18 @@
1
+ import { SupportPoolCoins } from 'src/types/constant/common';
2
+
3
+ export const COIN_GECKGO_IDS: Record<SupportPoolCoins, string> = {
4
+ usdc: 'usdc-coin',
5
+ sbeth: 'ethereum',
6
+ weth: 'ethereum',
7
+ wbtc: 'bitcoin',
8
+ wusdc: 'usdc-coin',
9
+ wusdt: 'tether',
10
+ sui: 'sui',
11
+ wapt: 'aptos',
12
+ wsol: 'solana',
13
+ cetus: 'cetus-protocol',
14
+ afsui: 'sui',
15
+ hasui: 'sui',
16
+ vsui: 'sui',
17
+ sca: 'scallop-2',
18
+ };
@@ -1,4 +1,3 @@
1
- // export const API_BASE_URL = 'https://sui.api.scallop.io';
2
1
  export const API_BASE_URL = 'https://sui.apis.scallop.io' as const;
3
2
  export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io' as const;
4
3
 
@@ -183,6 +183,14 @@ export const sCoinIds: types.SCoinIds = {
183
183
  '0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC',
184
184
  } as const;
185
185
 
186
+ export const sCoinTypeToName = Object.entries(sCoinIds).reduce(
187
+ (acc, [coinName, coinType]) => {
188
+ acc[coinType] = coinName as types.SupportSCoin;
189
+ return acc;
190
+ },
191
+ {} as Record<string, types.SupportSCoin>
192
+ );
193
+
186
194
  // TEST VERSION
187
195
  // export const sCoinIds: types.SCoinIds = {
188
196
  // ssui: '0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI',
@@ -1,5 +1,11 @@
1
+ export * from './cache';
2
+ export * from './coinGecko';
1
3
  export * from './common';
2
4
  export * from './enum';
3
5
  export * from './flashloan';
6
+ export * from './poolAddress';
7
+ export * from './pyth';
4
8
  export * from './queryKeys';
9
+ export * from './testAddress';
10
+ export * from './tokenBucket';
5
11
  export * from './vesca';
@@ -0,0 +1,94 @@
1
+ import { SupportPoolCoins } from 'src/types';
2
+
3
+ export const POOL_ADDRESSES: Record<
4
+ SupportPoolCoins,
5
+ {
6
+ lendingPoolAddress: string;
7
+ collateralPoolAddress: string;
8
+ }
9
+ > = {
10
+ usdc: {
11
+ lendingPoolAddress:
12
+ '0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f',
13
+ collateralPoolAddress:
14
+ '0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af',
15
+ },
16
+ sbeth: {
17
+ lendingPoolAddress:
18
+ '0x5f08c4f71d56dd3342c452cc70ffc47f2f4180146d821941b0b9c04761bb42e7',
19
+ collateralPoolAddress:
20
+ '0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f',
21
+ },
22
+ weth: {
23
+ lendingPoolAddress:
24
+ '0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c',
25
+ collateralPoolAddress:
26
+ '0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
27
+ },
28
+ wbtc: {
29
+ lendingPoolAddress:
30
+ '0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab',
31
+ collateralPoolAddress:
32
+ '0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3',
33
+ },
34
+ wusdc: {
35
+ lendingPoolAddress:
36
+ '0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8',
37
+ collateralPoolAddress:
38
+ '0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb',
39
+ },
40
+ wusdt: {
41
+ lendingPoolAddress:
42
+ '0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879',
43
+ collateralPoolAddress:
44
+ '0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3',
45
+ },
46
+ sui: {
47
+ lendingPoolAddress:
48
+ '0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8',
49
+ collateralPoolAddress:
50
+ '0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb',
51
+ },
52
+ wapt: {
53
+ lendingPoolAddress:
54
+ '0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5',
55
+ collateralPoolAddress:
56
+ '0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c',
57
+ },
58
+ wsol: {
59
+ lendingPoolAddress:
60
+ '0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f',
61
+ collateralPoolAddress:
62
+ '0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f',
63
+ },
64
+ cetus: {
65
+ lendingPoolAddress:
66
+ '0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282',
67
+ collateralPoolAddress:
68
+ '0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a',
69
+ },
70
+ afsui: {
71
+ lendingPoolAddress:
72
+ '0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a',
73
+ collateralPoolAddress:
74
+ '0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341',
75
+ },
76
+ hasui: {
77
+ lendingPoolAddress:
78
+ '0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4',
79
+ collateralPoolAddress:
80
+ '0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d',
81
+ },
82
+ vsui: {
83
+ lendingPoolAddress:
84
+ '0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d',
85
+ collateralPoolAddress:
86
+ '0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e',
87
+ },
88
+ sca: {
89
+ lendingPoolAddress:
90
+ '0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7',
91
+ collateralPoolAddress:
92
+ '0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31',
93
+ },
94
+ };
@@ -1,6 +1,25 @@
1
+ import { SupportPoolCoins } from 'src/types';
2
+
1
3
  export const PYTH_ENDPOINTS: {
2
4
  [k in 'mainnet' | 'testnet']: string[];
3
5
  } = {
4
6
  testnet: ['https://hermes-beta.pyth.network'],
5
7
  mainnet: ['https://hermes.pyth.network', 'https://scallop.rpc.p2p.world'],
6
8
  };
9
+
10
+ export const PYTH_FEED_IDS: Record<SupportPoolCoins, string> = {
11
+ usdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
12
+ sbeth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
13
+ weth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
14
+ wbtc: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
15
+ wusdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
16
+ wusdt: '2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
17
+ sui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
18
+ wapt: '03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5',
19
+ wsol: 'ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
20
+ cetus: 'e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef',
21
+ afsui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
22
+ hasui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
23
+ vsui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
24
+ sca: '7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc',
25
+ };
@@ -99,10 +99,6 @@ export const queryKeys = {
99
99
  ],
100
100
  },
101
101
  oracle: {
102
- getPythLatestPriceFeed: (pythPriceId?: string) => [
103
- 'oracle',
104
- 'getPythPriceId',
105
- { pythPriceId },
106
- ],
102
+ getPythLatestPriceFeeds: () => ['oracle', 'getPythPriceIds'],
107
103
  },
108
104
  };
@@ -0,0 +1,16 @@
1
+ import { getFullnodeUrl } from '@mysten/sui/client';
2
+
3
+ export const RPC_PROVIDERS = [
4
+ getFullnodeUrl('mainnet'),
5
+ 'https://sui-mainnet.public.blastapi.io',
6
+ 'https://sui-mainnet-ca-2.cosmostation.io',
7
+ 'https://sui-mainnet-eu-4.cosmostation.io',
8
+ 'https://sui-mainnet-endpoint.blockvision.org',
9
+ 'https://sui-rpc.publicnode.com',
10
+ 'https://sui-mainnet-rpc.allthatnode.com',
11
+ 'https://mainnet.suiet.app',
12
+ 'https://mainnet.sui.rpcpool.com',
13
+ 'https://sui1mainnet-rpc.chainode.tech',
14
+ 'https://fullnode.mainnet.apis.scallop.io',
15
+ 'https://sui-mainnet-us-2.cosmostation.io',
16
+ ];
@@ -1,2 +1,2 @@
1
- export const DEFAULT_TOKENS_PER_INTERVAL = 50;
1
+ export const DEFAULT_TOKENS_PER_INTERVAL = 10;
2
2
  export const DEFAULT_INTERVAL_IN_MS = 300;
@@ -22,6 +22,7 @@ import {
22
22
  DEFAULT_TOKENS_PER_INTERVAL,
23
23
  } from 'src/constants/tokenBucket';
24
24
  import type { QueryClient } from '@tanstack/query-core';
25
+ import { newSuiKit } from './suiKit';
25
26
 
26
27
  /**
27
28
  * @argument params - The parameters for the Scallop instance.
@@ -54,7 +55,7 @@ export class Scallop {
54
55
  queryClient?: QueryClient
55
56
  ) {
56
57
  this.params = params;
57
- this.suiKit = new SuiKit(params);
58
+ this.suiKit = newSuiKit(params);
58
59
  this.cache = new ScallopCache(
59
60
  this.suiKit,
60
61
  params.walletAddress,
@@ -65,7 +66,7 @@ export class Scallop {
65
66
  );
66
67
  this.address = new ScallopAddress(
67
68
  {
68
- id: params?.addressesId || ADDRESSES_ID,
69
+ id: params?.addressesId ?? ADDRESSES_ID,
69
70
  network: params?.networkType,
70
71
  forceInterface: params?.forceAddressesInterface,
71
72
  },
@@ -393,11 +393,11 @@ export class ScallopAddress {
393
393
  'Content-Type': 'application/json',
394
394
  Accept: 'application/json',
395
395
  },
396
- timeout: 30000,
396
+ timeout: 8000,
397
397
  });
398
398
  if (auth) this._auth = auth;
399
399
  this._id = id;
400
- this._network = network || 'mainnet';
400
+ this._network = network ?? 'mainnet';
401
401
  this._addressesMap = USE_TEST_ADDRESS
402
402
  ? new Map([['mainnet', TEST_ADDRESSES]])
403
403
  : new Map();
@@ -19,6 +19,7 @@ import type {
19
19
  } from '../types';
20
20
  import { ScallopCache } from './scallopCache';
21
21
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
22
+ import { newSuiKit } from './suiKit';
22
23
 
23
24
  /**
24
25
  * @description
@@ -46,11 +47,11 @@ export class ScallopBuilder {
46
47
  params: ScallopBuilderParams,
47
48
  instance?: ScallopBuilderInstanceParams
48
49
  ) {
49
- this.suiKit = instance?.suiKit ?? new SuiKit(params);
50
+ this.suiKit = instance?.suiKit ?? newSuiKit(params);
50
51
 
51
52
  this.params = params;
52
53
  this.walletAddress = normalizeSuiAddress(
53
- params?.walletAddress || this.suiKit.currentAddress()
54
+ params?.walletAddress ?? this.suiKit.currentAddress()
54
55
  );
55
56
 
56
57
  if (instance?.query) {
@@ -66,7 +67,7 @@ export class ScallopBuilder {
66
67
  );
67
68
  this.address = new ScallopAddress(
68
69
  {
69
- id: params?.addressesId || ADDRESSES_ID,
70
+ id: params?.addressesId ?? ADDRESSES_ID,
70
71
  network: params?.networkType,
71
72
  forceInterface: params?.forceAddressesInterface,
72
73
  },
@@ -255,7 +255,7 @@ export class ScallopCache {
255
255
  if (!input.coinType) return '0';
256
256
 
257
257
  return (
258
- ((await this.queryGetAllCoinBalances(input.owner)) || {})[
258
+ ((await this.queryGetAllCoinBalances(input.owner)) ?? {})[
259
259
  normalizeStructTag(input.coinType)
260
260
  ] ?? '0'
261
261
  );
@@ -34,6 +34,7 @@ import type {
34
34
  ScallopClientVeScaReturnType,
35
35
  ScallopClientInstanceParams,
36
36
  } from '../types';
37
+ import { newSuiKit } from './suiKit';
37
38
 
38
39
  /**
39
40
  * @description
@@ -64,9 +65,9 @@ export class ScallopClient {
64
65
  ) {
65
66
  this.params = params;
66
67
  this.suiKit =
67
- instance?.suiKit ?? instance?.builder?.suiKit ?? new SuiKit(params);
68
+ instance?.suiKit ?? instance?.builder?.suiKit ?? newSuiKit(params);
68
69
  this.walletAddress = normalizeSuiAddress(
69
- params?.walletAddress || this.suiKit.currentAddress()
70
+ params?.walletAddress ?? this.suiKit.currentAddress()
70
71
  );
71
72
 
72
73
  if (instance?.builder) {
@@ -83,7 +84,7 @@ export class ScallopClient {
83
84
  );
84
85
  this.address = new ScallopAddress(
85
86
  {
86
- id: params?.addressesId || ADDRESSES_ID,
87
+ id: params?.addressesId ?? ADDRESSES_ID,
87
88
  network: params?.networkType,
88
89
  forceInterface: params?.forceAddressesInterface,
89
90
  },
@@ -142,7 +143,7 @@ export class ScallopClient {
142
143
  * @return Obligations data.
143
144
  */
144
145
  public async getObligations(ownerAddress?: string) {
145
- const owner = ownerAddress || this.walletAddress;
146
+ const owner = ownerAddress ?? this.walletAddress;
146
147
  return await this.query.getObligations(owner);
147
148
  }
148
149
 
@@ -169,7 +170,7 @@ export class ScallopClient {
169
170
  * @return All stake accounts data.
170
171
  */
171
172
  async getAllStakeAccounts(ownerAddress?: string) {
172
- const owner = ownerAddress || this.walletAddress;
173
+ const owner = ownerAddress ?? this.walletAddress;
173
174
  return await this.query.getAllStakeAccounts(owner);
174
175
  }
175
176
 
@@ -187,7 +188,7 @@ export class ScallopClient {
187
188
  stakeMarketCoinName: SupportStakeMarketCoins,
188
189
  ownerAddress?: string
189
190
  ) {
190
- const owner = ownerAddress || this.walletAddress;
191
+ const owner = ownerAddress ?? this.walletAddress;
191
192
  return await this.query.getStakeAccounts(stakeMarketCoinName, owner);
192
193
  }
193
194
 
@@ -272,11 +273,11 @@ export class ScallopClient {
272
273
  walletAddress?: string
273
274
  ): Promise<ScallopClientFnReturnType<S>> {
274
275
  const txBlock = this.builder.createTxBlock();
275
- const sender = walletAddress || this.walletAddress;
276
+ const sender = walletAddress ?? this.walletAddress;
276
277
  txBlock.setSender(sender);
277
278
 
278
279
  const obligations = await this.query.getObligations(sender);
279
- const specificObligationId = obligationId || obligations[0]?.id;
280
+ const specificObligationId = obligationId ?? obligations[0]?.id;
280
281
  if (specificObligationId) {
281
282
  await txBlock.addCollateralQuick(
282
283
  amount,
@@ -319,7 +320,7 @@ export class ScallopClient {
319
320
  walletAddress?: string
320
321
  ): Promise<ScallopClientFnReturnType<S>> {
321
322
  const txBlock = this.builder.createTxBlock();
322
- const sender = walletAddress || this.walletAddress;
323
+ const sender = walletAddress ?? this.walletAddress;
323
324
  txBlock.setSender(sender);
324
325
 
325
326
  const collateralCoin = await txBlock.takeCollateralQuick(
@@ -365,7 +366,7 @@ export class ScallopClient {
365
366
  walletAddress?: string
366
367
  ): Promise<ScallopClientFnReturnType<S>> {
367
368
  const txBlock = this.builder.createTxBlock();
368
- const sender = walletAddress || this.walletAddress;
369
+ const sender = walletAddress ?? this.walletAddress;
369
370
  txBlock.setSender(sender);
370
371
 
371
372
  const sCoin = await txBlock.depositQuick(amount, poolCoinName);
@@ -409,14 +410,14 @@ export class ScallopClient {
409
410
  walletAddress?: string
410
411
  ): Promise<ScallopClientFnReturnType<S>> {
411
412
  const txBlock = this.builder.createTxBlock();
412
- const sender = walletAddress || this.walletAddress;
413
+ const sender = walletAddress ?? this.walletAddress;
413
414
  txBlock.setSender(sender);
414
415
 
415
416
  const stakeMarketCoinName =
416
417
  this.utils.parseMarketCoinName<SupportStakeMarketCoins>(stakeCoinName);
417
418
  const stakeAccounts =
418
419
  await this.query.getStakeAccounts(stakeMarketCoinName);
419
- const targetStakeAccount = stakeAccountId || stakeAccounts[0]?.id;
420
+ const targetStakeAccount = stakeAccountId ?? stakeAccounts[0]?.id;
420
421
 
421
422
  const marketCoin = await txBlock.depositQuick(amount, stakeCoinName, false);
422
423
  if (targetStakeAccount) {
@@ -466,7 +467,7 @@ export class ScallopClient {
466
467
  walletAddress?: string
467
468
  ): Promise<ScallopClientFnReturnType<S>> {
468
469
  const txBlock = this.builder.createTxBlock();
469
- const sender = walletAddress || this.walletAddress;
470
+ const sender = walletAddress ?? this.walletAddress;
470
471
  txBlock.setSender(sender);
471
472
 
472
473
  const coin = await txBlock.withdrawQuick(amount, poolCoinName);
@@ -501,7 +502,7 @@ export class ScallopClient {
501
502
  walletAddress?: string
502
503
  ): Promise<ScallopClientFnReturnType<S>> {
503
504
  const txBlock = this.builder.createTxBlock();
504
- const sender = walletAddress || this.walletAddress;
505
+ const sender = walletAddress ?? this.walletAddress;
505
506
  txBlock.setSender(sender);
506
507
 
507
508
  const availableStake = (
@@ -549,7 +550,7 @@ export class ScallopClient {
549
550
  walletAddress?: string
550
551
  ): Promise<ScallopClientFnReturnType<S>> {
551
552
  const txBlock = this.builder.createTxBlock();
552
- const sender = walletAddress || this.walletAddress;
553
+ const sender = walletAddress ?? this.walletAddress;
553
554
  txBlock.setSender(sender);
554
555
 
555
556
  const availableStake = (
@@ -610,7 +611,7 @@ export class ScallopClient {
610
611
  walletAddress?: string
611
612
  ): Promise<ScallopClientFnReturnType<S>> {
612
613
  const txBlock = this.builder.createTxBlock();
613
- const sender = walletAddress || this.walletAddress;
614
+ const sender = walletAddress ?? this.walletAddress;
614
615
  txBlock.setSender(sender);
615
616
  const [coin, loan] = txBlock.borrowFlashLoan(amount, poolCoinName);
616
617
  txBlock.repayFlashLoan(await callback(txBlock, coin), loan, poolCoinName);
@@ -647,7 +648,7 @@ export class ScallopClient {
647
648
  walletAddress?: string
648
649
  ): Promise<ScallopClientFnReturnType<S>> {
649
650
  const txBlock = this.builder.createTxBlock();
650
- const sender = walletAddress || this.walletAddress;
651
+ const sender = walletAddress ?? this.walletAddress;
651
652
  txBlock.setSender(sender);
652
653
 
653
654
  const stakeAccount = txBlock.createStakeAccount(marketCoinName);
@@ -691,12 +692,12 @@ export class ScallopClient {
691
692
  walletAddress?: string
692
693
  ): Promise<ScallopClientFnReturnType<S>> {
693
694
  const txBlock = this.builder.createTxBlock();
694
- const sender = walletAddress || this.walletAddress;
695
+ const sender = walletAddress ?? this.walletAddress;
695
696
  txBlock.setSender(sender);
696
697
 
697
698
  const stakeAccounts =
698
699
  await this.query.getStakeAccounts(stakeMarketCoinName);
699
- const targetStakeAccount = stakeAccountId || stakeAccounts[0]?.id;
700
+ const targetStakeAccount = stakeAccountId ?? stakeAccounts[0]?.id;
700
701
  if (targetStakeAccount) {
701
702
  await txBlock.stakeQuick(amount, stakeMarketCoinName, targetStakeAccount);
702
703
  } else {
@@ -743,7 +744,7 @@ export class ScallopClient {
743
744
  walletAddress?: string
744
745
  ): Promise<ScallopClientFnReturnType<S>> {
745
746
  const txBlock = this.builder.createTxBlock();
746
- const sender = walletAddress || this.walletAddress;
747
+ const sender = walletAddress ?? this.walletAddress;
747
748
  txBlock.setSender(sender);
748
749
 
749
750
  const sCoin = await txBlock.unstakeQuick(
@@ -802,7 +803,7 @@ export class ScallopClient {
802
803
  walletAddress?: string
803
804
  ): Promise<ScallopClientFnReturnType<S>> {
804
805
  const txBlock = this.builder.createTxBlock();
805
- const sender = walletAddress || this.walletAddress;
806
+ const sender = walletAddress ?? this.walletAddress;
806
807
  txBlock.setSender(sender);
807
808
 
808
809
  const stakeMarketCoin = await txBlock.unstakeQuick(
@@ -863,7 +864,7 @@ export class ScallopClient {
863
864
  walletAddress?: string
864
865
  ): Promise<ScallopClientFnReturnType<S>> {
865
866
  const txBlock = this.builder.createTxBlock();
866
- const sender = walletAddress || this.walletAddress;
867
+ const sender = walletAddress ?? this.walletAddress;
867
868
  txBlock.setSender(sender);
868
869
 
869
870
  const rewardCoins = await txBlock.claimQuick(
@@ -899,7 +900,7 @@ export class ScallopClient {
899
900
  walletAddress?: string
900
901
  ): Promise<ScallopClientFnReturnType<S>> {
901
902
  const txBlock = this.builder.createTxBlock();
902
- const sender = walletAddress || this.walletAddress;
903
+ const sender = walletAddress ?? this.walletAddress;
903
904
  txBlock.setSender(sender);
904
905
 
905
906
  await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKeyId);
@@ -929,7 +930,7 @@ export class ScallopClient {
929
930
  walletAddress?: string
930
931
  ): Promise<ScallopClientFnReturnType<S>> {
931
932
  const txBlock = this.builder.createTxBlock();
932
- const sender = walletAddress || this.walletAddress;
933
+ const sender = walletAddress ?? this.walletAddress;
933
934
  txBlock.setSender(sender);
934
935
 
935
936
  await txBlock.unstakeObligationQuick(obligationId, obligationKeyId);
@@ -961,7 +962,7 @@ export class ScallopClient {
961
962
  walletAddress?: string
962
963
  ): Promise<ScallopClientFnReturnType<S>> {
963
964
  const txBlock = this.builder.createTxBlock();
964
- const sender = walletAddress || this.walletAddress;
965
+ const sender = walletAddress ?? this.walletAddress;
965
966
  txBlock.setSender(sender);
966
967
 
967
968
  const rewardCoins = [];
@@ -1186,7 +1187,7 @@ export class ScallopClient {
1186
1187
  }
1187
1188
 
1188
1189
  const txBlock = this.builder.createTxBlock();
1189
- const recipient = receiveAddress || this.walletAddress;
1190
+ const recipient = receiveAddress ?? this.walletAddress;
1190
1191
  const packageId = this.address.get('core.packages.testCoin.id');
1191
1192
  const treasuryId = this.address.get(`core.coins.${assetCoinName}.treasury`);
1192
1193
  const target = `${packageId}::${assetCoinName}::mint`;