@scallop-io/sui-scallop-sdk 0.47.4 → 0.47.6

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/index.mjs CHANGED
@@ -11,6 +11,8 @@ var OLD_BORROW_INCENTIVE_PROTOCOL_ID = "0xc63072e7f5f4983a2efaf5bdba1480d5e7d74d
11
11
  var SUPPORT_POOLS = [
12
12
  "usdc",
13
13
  // native USDC
14
+ "sbeth",
15
+ // native ETH
14
16
  "weth",
15
17
  "wbtc",
16
18
  "wusdc",
@@ -26,6 +28,9 @@ var SUPPORT_POOLS = [
26
28
  ];
27
29
  var SUPPORT_COLLATERALS = [
28
30
  "usdc",
31
+ // native USDC
32
+ "sbeth",
33
+ // native ETH
29
34
  "weth",
30
35
  "wbtc",
31
36
  "wusdc",
@@ -52,6 +57,7 @@ var SUPPORT_SPOOLS = [
52
57
  ];
53
58
  var SUPPORT_SCOIN = [
54
59
  "susdc",
60
+ "ssbeth",
55
61
  "ssui",
56
62
  "swusdc",
57
63
  "swusdt",
@@ -64,6 +70,15 @@ var SUPPORT_SCOIN = [
64
70
  "swsol",
65
71
  "swbtc"
66
72
  ];
73
+ var SUPPORT_SUI_BRIDGE = ["sbeth"];
74
+ var SUPPORT_WORMHOLE = [
75
+ "wusdc",
76
+ "wusdt",
77
+ "weth",
78
+ "wbtc",
79
+ "wapt",
80
+ "wsol"
81
+ ];
67
82
  var SUPPORT_SPOOLS_REWARDS = ["sui"];
68
83
  var SUPPORT_BORROW_INCENTIVE_POOLS = [
69
84
  "sui",
@@ -73,6 +88,7 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
73
88
  "hasui",
74
89
  "vsui",
75
90
  "weth",
91
+ "sbeth",
76
92
  "sca",
77
93
  "usdc"
78
94
  ];
@@ -96,6 +112,7 @@ var SUPPORT_PACKAGES = [
96
112
  // src/constants/enum.ts
97
113
  var coinDecimals = {
98
114
  usdc: 6,
115
+ sbeth: 8,
99
116
  weth: 8,
100
117
  wbtc: 8,
101
118
  wusdc: 6,
@@ -110,6 +127,7 @@ var coinDecimals = {
110
127
  sca: 9,
111
128
  susdc: 6,
112
129
  sweth: 8,
130
+ ssbeth: 8,
113
131
  swbtc: 8,
114
132
  swusdc: 6,
115
133
  swusdt: 6,
@@ -124,6 +142,7 @@ var coinDecimals = {
124
142
  };
125
143
  var assetCoins = {
126
144
  usdc: "usdc",
145
+ sbeth: "sbeth",
127
146
  weth: "weth",
128
147
  wbtc: "wbtc",
129
148
  wusdc: "wusdc",
@@ -139,6 +158,7 @@ var assetCoins = {
139
158
  };
140
159
  var marketCoins = {
141
160
  susdc: "susdc",
161
+ ssbeth: "ssbeth",
142
162
  sweth: "sweth",
143
163
  swbtc: "swbtc",
144
164
  swusdc: "swusdc",
@@ -154,6 +174,7 @@ var marketCoins = {
154
174
  };
155
175
  var sCoins = {
156
176
  susdc: "susdc",
177
+ ssbeth: "ssbeth",
157
178
  sweth: "sweth",
158
179
  swusdc: "swusdc",
159
180
  swusdt: "swusdt",
@@ -188,6 +209,9 @@ var spoolRewardCoins = {
188
209
  svsui: "sui",
189
210
  susdc: "sui"
190
211
  };
212
+ var suiBridgeCoins = {
213
+ sbeth: "sbeth"
214
+ };
191
215
  var borrowIncentiveRewardCoins = {
192
216
  usdc: ["sui", "sca"],
193
217
  sui: ["sui", "sca"],
@@ -197,11 +221,13 @@ var borrowIncentiveRewardCoins = {
197
221
  afsui: ["sui"],
198
222
  hasui: ["sui"],
199
223
  vsui: ["sui"],
200
- weth: ["sui"]
224
+ weth: ["sui"],
225
+ sbeth: ["sui"]
201
226
  };
202
227
  var coinIds = {
203
228
  usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
204
229
  sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
230
+ sbeth: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
205
231
  weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
206
232
  wbtc: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
207
233
  wusdc: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
@@ -227,6 +253,7 @@ var voloCoinIds = {
227
253
  };
228
254
  var sCoinIds = {
229
255
  susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
256
+ ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
230
257
  ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
231
258
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
232
259
  ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
@@ -787,11 +814,23 @@ var isMarketCoin = (coinName) => {
787
814
  const assetCoinName = coinName.slice(1).toLowerCase();
788
815
  return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
789
816
  };
817
+ var isSuiBridgeAsset = (coinName) => {
818
+ return SUPPORT_SUI_BRIDGE.includes(coinName);
819
+ };
820
+ var isWormholeAsset = (coinName) => {
821
+ return SUPPORT_WORMHOLE.includes(coinName);
822
+ };
790
823
  var parseAssetSymbol = (coinName) => {
791
- const isWormhole = coinName.charAt(0) === "w";
792
- if (isWormhole) {
824
+ if (isWormholeAsset(coinName)) {
793
825
  return `w${coinName.slice(1).toUpperCase()}`;
794
826
  }
827
+ if (isSuiBridgeAsset(coinName)) {
828
+ return `sb${coinName.slice(2).toUpperCase()}`;
829
+ }
830
+ if (isMarketCoin(coinName)) {
831
+ const assetCoinName = coinName.slice(1).toLowerCase();
832
+ return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
833
+ }
795
834
  switch (coinName) {
796
835
  case "afsui":
797
836
  return "afSUI";
@@ -1893,7 +1932,7 @@ var EMPTY_ADDRESSES = {
1893
1932
  };
1894
1933
  var ScallopAddress = class {
1895
1934
  constructor(params, instance) {
1896
- const { id, auth, network } = params;
1935
+ const { id, auth, network, forceInterface } = params;
1897
1936
  this.cache = instance?.cache ?? new ScallopCache(
1898
1937
  instance?.suiKit ?? new SuiKit({}),
1899
1938
  void 0,
@@ -1914,6 +1953,17 @@ var ScallopAddress = class {
1914
1953
  this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
1915
1954
  if (USE_TEST_ADDRESS)
1916
1955
  this._currentAddresses = TEST_ADDRESSES;
1956
+ if (forceInterface) {
1957
+ for (const [network2, addresses] of Object.entries(
1958
+ forceInterface
1959
+ )) {
1960
+ if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
1961
+ if (network2 === this._network)
1962
+ this._currentAddresses = addresses;
1963
+ this._addressesMap.set(network2, addresses);
1964
+ }
1965
+ }
1966
+ }
1917
1967
  }
1918
1968
  /**
1919
1969
  * Get addresses API id.
@@ -3035,18 +3085,13 @@ var getStakeAccounts = async ({
3035
3085
  hasNextPage = false;
3036
3086
  }
3037
3087
  } while (hasNextPage);
3038
- const stakeAccounts = {
3039
- susdc: [],
3040
- sweth: [],
3041
- ssui: [],
3042
- swusdc: [],
3043
- swusdt: [],
3044
- scetus: [],
3045
- safsui: [],
3046
- shasui: [],
3047
- svsui: []
3048
- // ssca: [],
3049
- };
3088
+ const stakeAccounts = SUPPORT_SPOOLS.reduce(
3089
+ (acc, stakeName) => {
3090
+ acc[stakeName] = [];
3091
+ return acc;
3092
+ },
3093
+ {}
3094
+ );
3050
3095
  const stakeMarketCoinTypes = Object.keys(stakeAccounts).reduce(
3051
3096
  (types, stakeMarketCoinName) => {
3052
3097
  const stakeCoinName = utils.parseCoinName(stakeMarketCoinName);
@@ -3056,6 +3101,13 @@ var getStakeAccounts = async ({
3056
3101
  },
3057
3102
  {}
3058
3103
  );
3104
+ const reversedStakeMarketCoinTypes = Object.entries(stakeMarketCoinTypes).reduce(
3105
+ (reversedTypes, [key, value]) => {
3106
+ reversedTypes[value] = key;
3107
+ return reversedTypes;
3108
+ },
3109
+ {}
3110
+ );
3059
3111
  const stakeObjectIds = stakeObjectsResponse.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
3060
3112
  const stakeObjects = await utils.cache.queryGetObjects(stakeObjectIds, {
3061
3113
  showContent: true,
@@ -3072,98 +3124,23 @@ var getStakeAccounts = async ({
3072
3124
  const index = Number(fields.index);
3073
3125
  const points = Number(fields.points);
3074
3126
  const totalPoints = Number(fields.total_points);
3075
- if (normalizeStructTag4(type) === stakeMarketCoinTypes.sweth) {
3076
- stakeAccounts.sweth.push({
3077
- id,
3078
- type: normalizeStructTag4(type),
3079
- stakePoolId,
3080
- stakeType: normalizeStructTag4(stakeType),
3081
- staked,
3082
- index,
3083
- points,
3084
- totalPoints
3085
- });
3086
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.ssui) {
3087
- stakeAccounts.ssui.push({
3088
- id,
3089
- type: normalizeStructTag4(type),
3090
- stakePoolId,
3091
- stakeType: normalizeStructTag4(stakeType),
3092
- staked,
3093
- index,
3094
- points,
3095
- totalPoints
3096
- });
3097
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.swusdc) {
3098
- stakeAccounts.swusdc.push({
3099
- id,
3100
- type: normalizeStructTag4(type),
3101
- stakePoolId,
3102
- stakeType: normalizeStructTag4(stakeType),
3103
- staked,
3104
- index,
3105
- points,
3106
- totalPoints
3107
- });
3108
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.swusdt) {
3109
- stakeAccounts.swusdt.push({
3110
- id,
3111
- type: normalizeStructTag4(type),
3112
- stakePoolId,
3113
- stakeType: normalizeStructTag4(stakeType),
3114
- staked,
3115
- index,
3116
- points,
3117
- totalPoints
3118
- });
3119
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.scetus) {
3120
- stakeAccounts.scetus.push({
3121
- id,
3122
- type: normalizeStructTag4(type),
3123
- stakePoolId,
3124
- stakeType: normalizeStructTag4(stakeType),
3125
- staked,
3126
- index,
3127
- points,
3128
- totalPoints
3129
- });
3130
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.safsui) {
3131
- stakeAccounts.safsui.push({
3132
- id,
3133
- type: normalizeStructTag4(type),
3134
- stakePoolId,
3135
- stakeType: normalizeStructTag4(stakeType),
3136
- staked,
3137
- index,
3138
- points,
3139
- totalPoints
3140
- });
3141
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.shasui) {
3142
- stakeAccounts.shasui.push({
3143
- id,
3144
- type: normalizeStructTag4(type),
3145
- stakePoolId,
3146
- stakeType: normalizeStructTag4(stakeType),
3147
- staked,
3148
- index,
3149
- points,
3150
- totalPoints
3151
- });
3152
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.svsui) {
3153
- stakeAccounts.svsui.push({
3154
- id,
3155
- type: normalizeStructTag4(type),
3156
- stakePoolId,
3157
- stakeType: normalizeStructTag4(stakeType),
3158
- staked,
3159
- index,
3160
- points,
3161
- totalPoints
3162
- });
3163
- } else if (normalizeStructTag4(type) === stakeMarketCoinTypes.susdc) {
3164
- stakeAccounts.susdc.push({
3127
+ const stakeMarketCoinTypeMap = {
3128
+ sweth: stakeAccounts.sweth,
3129
+ ssui: stakeAccounts.ssui,
3130
+ swusdc: stakeAccounts.swusdc,
3131
+ swusdt: stakeAccounts.swusdt,
3132
+ scetus: stakeAccounts.scetus,
3133
+ safsui: stakeAccounts.safsui,
3134
+ shasui: stakeAccounts.shasui,
3135
+ svsui: stakeAccounts.svsui,
3136
+ susdc: stakeAccounts.susdc
3137
+ };
3138
+ const normalizedType = normalizeStructTag4(type);
3139
+ const stakeAccountArray = stakeMarketCoinTypeMap[reversedStakeMarketCoinTypes[normalizedType]];
3140
+ if (stakeAccountArray) {
3141
+ stakeAccountArray.push({
3165
3142
  id,
3166
- type: normalizeStructTag4(type),
3143
+ type: normalizedType,
3167
3144
  stakePoolId,
3168
3145
  stakeType: normalizeStructTag4(stakeType),
3169
3146
  staked,
@@ -4338,6 +4315,13 @@ var ScallopUtils = class {
4338
4315
  }
4339
4316
  this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
4340
4317
  }
4318
+ // -------------- TYPE GUARDS --------------
4319
+ isSuiBridgeAsset(coinName) {
4320
+ return isSuiBridgeAsset(coinName);
4321
+ }
4322
+ isWormholeAsset(coinName) {
4323
+ return isWormholeAsset(coinName);
4324
+ }
4341
4325
  /**
4342
4326
  * Request the scallop API to initialize data.
4343
4327
  *
@@ -4358,12 +4342,7 @@ var ScallopUtils = class {
4358
4342
  * @return Symbol string.
4359
4343
  */
4360
4344
  parseSymbol(coinName) {
4361
- if (isMarketCoin(coinName)) {
4362
- const assetCoinName = coinName.slice(1).toLowerCase();
4363
- return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
4364
- } else {
4365
- return parseAssetSymbol(coinName);
4366
- }
4345
+ return parseAssetSymbol(coinName);
4367
4346
  }
4368
4347
  /**
4369
4348
  * Convert coin name to coin type.
@@ -4395,10 +4374,21 @@ var ScallopUtils = class {
4395
4374
  const voloPackageIds = [
4396
4375
  this.address.get("core.coins.vsui.id") ?? voloCoinIds.vsui
4397
4376
  ];
4377
+ const suiBridgePackageIds = Object.values(
4378
+ suiBridgeCoins
4379
+ ).reduce((curr, coinName2) => {
4380
+ curr.push(
4381
+ this.address.get(`core.coins.${coinName2}.id`) ?? coinIds[coinName2]
4382
+ );
4383
+ return curr;
4384
+ }, []);
4398
4385
  if (wormHolePackageIds.includes(coinPackageId)) {
4399
4386
  return `${coinPackageId}::coin::COIN`;
4400
4387
  } else if (voloPackageIds.includes(coinPackageId)) {
4401
4388
  return `${coinPackageId}::cert::CERT`;
4389
+ } else if (suiBridgePackageIds.includes(coinPackageId)) {
4390
+ const typeCoinName = coinName.slice(2);
4391
+ return `${coinPackageId}::${typeCoinName}::${typeCoinName.toUpperCase()}`;
4402
4392
  } else {
4403
4393
  return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
4404
4394
  }
@@ -4474,11 +4464,20 @@ var ScallopUtils = class {
4474
4464
  const voloCoinTypeMap = {
4475
4465
  [`${this.address.get("core.coins.vsui.id") ?? voloCoinIds.vsui}::cert::CERT`]: "vsui"
4476
4466
  };
4477
- const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4467
+ const suiBridgeTypeMap = Object.values(
4468
+ suiBridgeCoins
4469
+ ).reduce(
4470
+ (curr, coinName) => {
4471
+ curr[this.parseCoinType(coinName)] = coinName;
4472
+ return curr;
4473
+ },
4474
+ {}
4475
+ );
4476
+ const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
4478
4477
  return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
4479
4478
  }
4480
4479
  /**
4481
- * Convert marke coin name to coin name.
4480
+ * Convert market coin name to coin name.
4482
4481
  *
4483
4482
  * @param marketCoinName - Specific support market coin name.
4484
4483
  * @return Coin Name.
@@ -4509,10 +4508,18 @@ var ScallopUtils = class {
4509
4508
  * return Coin wrapped type.
4510
4509
  */
4511
4510
  getCoinWrappedType(assetCoinName) {
4512
- return assetCoinName === "wusdc" || assetCoinName === "wusdt" || assetCoinName === "weth" || assetCoinName === "wbtc" || assetCoinName === "wapt" || assetCoinName === "wsol" ? {
4513
- from: "Wormhole",
4514
- type: "Portal from Ethereum"
4515
- } : void 0;
4511
+ if (this.isSuiBridgeAsset(assetCoinName)) {
4512
+ return {
4513
+ from: "Sui Bridge",
4514
+ type: "Asset from Sui Bridge"
4515
+ };
4516
+ } else if (this.isWormholeAsset(assetCoinName)) {
4517
+ return {
4518
+ from: "Wormhole",
4519
+ type: "Portal from Ethereum"
4520
+ };
4521
+ }
4522
+ return void 0;
4516
4523
  }
4517
4524
  /**
4518
4525
  * Select coin id that add up to the given amount as transaction arguments.
@@ -7257,6 +7264,7 @@ var ScallopClient = class {
7257
7264
  this.address = new ScallopAddress(
7258
7265
  {
7259
7266
  id: params?.addressesId || ADDRESSES_ID,
7267
+ forceInterface: params?.forceAddressesInterface,
7260
7268
  network: params?.networkType
7261
7269
  },
7262
7270
  {
@@ -7920,7 +7928,8 @@ var Scallop = class {
7920
7928
  this.address = new ScallopAddress(
7921
7929
  {
7922
7930
  id: params?.addressesId || ADDRESSES_ID,
7923
- network: params?.networkType
7931
+ network: params?.networkType,
7932
+ forceInterface: params?.forceAddressesInterface
7924
7933
  },
7925
7934
  { cache: this.cache }
7926
7935
  );
@@ -8041,6 +8050,8 @@ export {
8041
8050
  SUPPORT_SCOIN,
8042
8051
  SUPPORT_SPOOLS,
8043
8052
  SUPPORT_SPOOLS_REWARDS,
8053
+ SUPPORT_SUI_BRIDGE,
8054
+ SUPPORT_WORMHOLE,
8044
8055
  Scallop,
8045
8056
  ScallopAddress,
8046
8057
  ScallopBuilder,
@@ -8060,6 +8071,7 @@ export {
8060
8071
  sCoins,
8061
8072
  spoolRewardCoins,
8062
8073
  stakeMarketCoins,
8074
+ suiBridgeCoins,
8063
8075
  voloCoinIds,
8064
8076
  wormholeCoinIds
8065
8077
  };