@scallop-io/sui-scallop-sdk 0.47.0-alpha.4 → 0.47.0-alpha.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.
@@ -12,7 +12,7 @@ export declare const SUPPORT_COLLATERALS: readonly ["usdc", "weth", "wbtc", "wus
12
12
  export declare const SUPPORT_SPOOLS: readonly ["susdc", "sweth", "ssui", "swusdc", "swusdt", "scetus", "safsui", "shasui", "svsui"];
13
13
  export declare const SUPPORT_SCOIN: readonly ["susdc", "ssui", "swusdc", "swusdt", "safsui", "shasui", "svsui", "sweth", "ssca", "scetus", "swsol", "swbtc"];
14
14
  export declare const SUPPORT_SPOOLS_REWARDS: readonly ["sui"];
15
- export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["sui", "wusdc", "wusdt", "afsui", "hasui", "vsui", "weth", "sca"];
15
+ export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["sui", "wusdc", "wusdt", "afsui", "hasui", "vsui", "weth", "sca", "usdc"];
16
16
  export declare const SUPPORT_BORROW_INCENTIVE_REWARDS: readonly ["sui", "sca"];
17
17
  export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
18
18
  export declare const SUPPORT_PACKAGES: readonly ["coinDecimalsRegistry", "math", "whitelist", "x", "protocol", "protocolWhitelist", "query", "supra", "pyth", "switchboard", "xOracle", "testCoin"];
package/dist/index.js CHANGED
@@ -151,7 +151,8 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
151
151
  "hasui",
152
152
  "vsui",
153
153
  "weth",
154
- "sca"
154
+ "sca",
155
+ "usdc"
155
156
  ];
156
157
  var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
157
158
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
@@ -266,6 +267,7 @@ var spoolRewardCoins = {
266
267
  susdc: "sui"
267
268
  };
268
269
  var borrowIncentiveRewardCoins = {
270
+ usdc: ["sui", "sca"],
269
271
  sui: ["sui", "sca"],
270
272
  wusdc: ["sui", "sca"],
271
273
  wusdt: ["sui", "sca"],
@@ -302,8 +304,7 @@ var voloCoinIds = {
302
304
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
303
305
  };
304
306
  var sCoinIds = {
305
- susdc: "",
306
- // TODO: sCoin contract
307
+ susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
307
308
  ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
308
309
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
309
310
  ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
@@ -715,7 +716,8 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
715
716
  index: Number(originBorrowIncentivePoolPointData.index),
716
717
  baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
717
718
  weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
718
- lastUpdate: Number(originBorrowIncentivePoolPointData.last_update)
719
+ lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
720
+ createdAt: Number(originBorrowIncentivePoolPointData.created_at)
719
721
  };
720
722
  };
721
723
  var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
@@ -724,7 +726,6 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
724
726
  minStakes: Number(originBorrowIncentivePoolData.min_stakes),
725
727
  maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
726
728
  staked: Number(originBorrowIncentivePoolData.stakes),
727
- createdAt: Number(originBorrowIncentivePoolData.created_at),
728
729
  poolPoints: originBorrowIncentivePoolData.points.reduce(
729
730
  (acc, point) => {
730
731
  const parsed = parseOriginBorrowIncentivesPoolPointData(point);
@@ -2457,7 +2458,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
2457
2458
  const marketObjectResponse = await query.cache.queryGetObject(marketId, {
2458
2459
  showContent: true
2459
2460
  });
2460
- const coinPrices = await query.utils.getCoinPrices(poolCoinNames ?? []);
2461
+ const coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
2461
2462
  const marketPools = {};
2462
2463
  if (indexer) {
2463
2464
  const marketPoolsIndexer = await query.indexer.getMarketPools();
@@ -2639,7 +2640,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
2639
2640
  };
2640
2641
  var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
2641
2642
  const marketId = query.address.get("core.market");
2642
- const coinPrices = await query.utils.getCoinPrices(collateralCoinNames ?? []);
2643
+ const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
2643
2644
  const marketCollaterals = {};
2644
2645
  if (indexer) {
2645
2646
  const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
@@ -2831,8 +2832,7 @@ var queryObligation = async ({
2831
2832
  );
2832
2833
  return queryResult?.events[0]?.parsedJson;
2833
2834
  };
2834
- var getCoinAmounts = async (query, assetCoinNames, ownerAddress) => {
2835
- assetCoinNames = assetCoinNames || [...SUPPORT_POOLS];
2835
+ var getCoinAmounts = async (query, assetCoinNames = [...SUPPORT_POOLS], ownerAddress) => {
2836
2836
  const owner = ownerAddress || query.suiKit.currentAddress();
2837
2837
  const assetCoins2 = {};
2838
2838
  await Promise.allSettled(
@@ -2948,9 +2948,9 @@ var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexe
2948
2948
  const rewardCoinName = query.utils.getSpoolRewardCoinName(stakeMarketCoinName);
2949
2949
  return rewardCoinName;
2950
2950
  });
2951
- const coinPrices = await query.utils.getCoinPrices(
2952
- [.../* @__PURE__ */ new Set([...stakeCoinNames, ...rewardCoinNames])]
2953
- );
2951
+ const coinPrices = await query.utils.getCoinPrices([
2952
+ .../* @__PURE__ */ new Set([...stakeCoinNames, ...rewardCoinNames])
2953
+ ]) ?? {};
2954
2954
  const marketPools = await query.getMarketPools(stakeCoinNames, indexer);
2955
2955
  const spools = {};
2956
2956
  if (indexer) {
@@ -3326,18 +3326,28 @@ var getStakeRewardPool = async ({
3326
3326
  // src/queries/borrowIncentiveQuery.ts
3327
3327
  var import_utils7 = require("@mysten/sui.js/utils");
3328
3328
  var import_bignumber3 = __toESM(require("bignumber.js"));
3329
- var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3329
+ var queryBorrowIncentivePools = async (address) => {
3330
+ const queryPkgId = address.get("borrowIncentive.query");
3331
+ const incentivePoolsId = address.get("borrowIncentive.incentivePools");
3332
+ const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
3333
+ const args = [incentivePoolsId];
3334
+ const queryResult = await address.cache.queryInspectTxn({
3335
+ queryTarget,
3336
+ args
3337
+ });
3338
+ const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
3339
+ return borrowIncentivePoolsQueryData;
3340
+ };
3341
+ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3330
3342
  ...SUPPORT_BORROW_INCENTIVE_POOLS
3331
3343
  ], indexer = false) => {
3332
3344
  const borrowIncentivePools = {};
3333
- const coinPrices = await query.utils.getCoinPrices(
3334
- [
3335
- .../* @__PURE__ */ new Set([
3336
- ...borrowIncentiveCoinNames,
3337
- ...SUPPORT_BORROW_INCENTIVE_REWARDS
3338
- ])
3339
- ]
3340
- );
3345
+ const coinPrices = await query.utils.getCoinPrices([
3346
+ .../* @__PURE__ */ new Set([
3347
+ ...borrowIncentiveCoinNames,
3348
+ ...SUPPORT_BORROW_INCENTIVE_REWARDS
3349
+ ])
3350
+ ]) ?? {};
3341
3351
  if (indexer) {
3342
3352
  const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
3343
3353
  const updateBorrowIncentivePool = (pool) => {
@@ -3351,12 +3361,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3351
3361
  );
3352
3362
  return borrowIncentivePools;
3353
3363
  }
3354
- const queryPkgId = query.address.get("borrowIncentive.query");
3355
- const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
3356
- const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
3357
- const args = [incentivePoolsId];
3358
- const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
3359
- const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
3364
+ const borrowIncentivePoolsQueryData = await queryBorrowIncentivePools(
3365
+ query.address
3366
+ );
3360
3367
  for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
3361
3368
  const borrowIncentivePoolPoints = {};
3362
3369
  const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
@@ -3419,10 +3426,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3419
3426
  };
3420
3427
  var queryBorrowIncentiveAccounts = async ({
3421
3428
  utils
3422
- }, obligationId, borrowIncentiveCoinNames) => {
3423
- borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
3424
- ...SUPPORT_BORROW_INCENTIVE_POOLS
3425
- ];
3429
+ }, obligationId, borrowIncentiveCoinNames = [
3430
+ ...SUPPORT_BORROW_INCENTIVE_POOLS
3431
+ ]) => {
3426
3432
  const queryPkgId = utils.address.get("borrowIncentive.query");
3427
3433
  const incentiveAccountsId = utils.address.get(
3428
3434
  "borrowIncentive.incentiveAccounts"
@@ -4644,10 +4650,9 @@ var ScallopUtils = class {
4644
4650
  * @param assetCoinNames - Specific an array of support asset coin name.
4645
4651
  * @return Asset coin price.
4646
4652
  */
4647
- async getCoinPrices(assetCoinNames) {
4648
- assetCoinNames = assetCoinNames || [
4649
- .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4650
- ];
4653
+ async getCoinPrices(assetCoinNames = [
4654
+ .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4655
+ ]) {
4651
4656
  const coinPrices = {};
4652
4657
  const existPricesCoinNames = [];
4653
4658
  const lackPricesCoinNames = [];
@@ -5228,7 +5233,7 @@ var generateCoreQuickMethod = ({
5228
5233
  const obligationCoinNames = await builder.utils.getObligationCoinNames(
5229
5234
  obligationInfo.obligationId
5230
5235
  ) ?? [];
5231
- const updateCoinNames = [...obligationCoinNames ?? [], poolCoinName];
5236
+ const updateCoinNames = [...obligationCoinNames, poolCoinName];
5232
5237
  await updateOracles(builder, txBlock, updateCoinNames);
5233
5238
  return txBlock.borrow(
5234
5239
  obligationInfo.obligationId,
@@ -6583,8 +6588,7 @@ var getSCoinTotalSupply = async ({
6583
6588
  };
6584
6589
  var getSCoinAmounts = async ({
6585
6590
  utils
6586
- }, sCoinNames, ownerAddress) => {
6587
- sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
6591
+ }, sCoinNames = [...SUPPORT_SCOIN], ownerAddress) => {
6588
6592
  const owner = ownerAddress || utils.suiKit.currentAddress();
6589
6593
  const sCoins2 = {};
6590
6594
  await Promise.allSettled(
@@ -6948,7 +6952,7 @@ var ScallopQuery = class {
6948
6952
  * @return Borrow incentive pools data.
6949
6953
  */
6950
6954
  async getBorrowIncentivePools(coinNames, indexer = false) {
6951
- return await queryBorrowIncentivePools(this, coinNames, indexer);
6955
+ return await getBorrowIncentivePools(this, coinNames, indexer);
6952
6956
  }
6953
6957
  /**
6954
6958
  * Get borrow incentive accounts data.