@scallop-io/sui-scallop-sdk 0.47.0-alpha.5 → 0.47.0

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
@@ -73,7 +73,8 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
73
73
  "hasui",
74
74
  "vsui",
75
75
  "weth",
76
- "sca"
76
+ "sca",
77
+ "usdc"
77
78
  ];
78
79
  var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
79
80
  var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
@@ -188,6 +189,7 @@ var spoolRewardCoins = {
188
189
  susdc: "sui"
189
190
  };
190
191
  var borrowIncentiveRewardCoins = {
192
+ usdc: ["sui", "sca"],
191
193
  sui: ["sui", "sca"],
192
194
  wusdc: ["sui", "sca"],
193
195
  wusdt: ["sui", "sca"],
@@ -224,8 +226,7 @@ var voloCoinIds = {
224
226
  vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
225
227
  };
226
228
  var sCoinIds = {
227
- susdc: "",
228
- // TODO: sCoin contract
229
+ susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
229
230
  ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
230
231
  scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
231
232
  ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
@@ -641,7 +642,8 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
641
642
  index: Number(originBorrowIncentivePoolPointData.index),
642
643
  baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
643
644
  weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
644
- lastUpdate: Number(originBorrowIncentivePoolPointData.last_update)
645
+ lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
646
+ createdAt: Number(originBorrowIncentivePoolPointData.created_at)
645
647
  };
646
648
  };
647
649
  var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
@@ -650,7 +652,6 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
650
652
  minStakes: Number(originBorrowIncentivePoolData.min_stakes),
651
653
  maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
652
654
  staked: Number(originBorrowIncentivePoolData.stakes),
653
- createdAt: Number(originBorrowIncentivePoolData.created_at),
654
655
  poolPoints: originBorrowIncentivePoolData.points.reduce(
655
656
  (acc, point) => {
656
657
  const parsed = parseOriginBorrowIncentivesPoolPointData(point);
@@ -2374,8 +2375,8 @@ var queryMarket = async (query, indexer = false) => {
2374
2375
  }
2375
2376
  return {
2376
2377
  pools,
2377
- collaterals,
2378
- data: marketData
2378
+ collaterals
2379
+ // data: marketData,
2379
2380
  };
2380
2381
  };
2381
2382
  var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer = false) => {
@@ -2757,8 +2758,7 @@ var queryObligation = async ({
2757
2758
  );
2758
2759
  return queryResult?.events[0]?.parsedJson;
2759
2760
  };
2760
- var getCoinAmounts = async (query, assetCoinNames, ownerAddress) => {
2761
- assetCoinNames = assetCoinNames || [...SUPPORT_POOLS];
2761
+ var getCoinAmounts = async (query, assetCoinNames = [...SUPPORT_POOLS], ownerAddress) => {
2762
2762
  const owner = ownerAddress || query.suiKit.currentAddress();
2763
2763
  const assetCoins2 = {};
2764
2764
  await Promise.allSettled(
@@ -3252,7 +3252,19 @@ var getStakeRewardPool = async ({
3252
3252
  // src/queries/borrowIncentiveQuery.ts
3253
3253
  import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
3254
3254
  import BigNumber3 from "bignumber.js";
3255
- var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3255
+ var queryBorrowIncentivePools = async (address) => {
3256
+ const queryPkgId = address.get("borrowIncentive.query");
3257
+ const incentivePoolsId = address.get("borrowIncentive.incentivePools");
3258
+ const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
3259
+ const args = [incentivePoolsId];
3260
+ const queryResult = await address.cache.queryInspectTxn({
3261
+ queryTarget,
3262
+ args
3263
+ });
3264
+ const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
3265
+ return borrowIncentivePoolsQueryData;
3266
+ };
3267
+ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3256
3268
  ...SUPPORT_BORROW_INCENTIVE_POOLS
3257
3269
  ], indexer = false) => {
3258
3270
  const borrowIncentivePools = {};
@@ -3275,12 +3287,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3275
3287
  );
3276
3288
  return borrowIncentivePools;
3277
3289
  }
3278
- const queryPkgId = query.address.get("borrowIncentive.query");
3279
- const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
3280
- const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
3281
- const args = [incentivePoolsId];
3282
- const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
3283
- const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
3290
+ const borrowIncentivePoolsQueryData = await queryBorrowIncentivePools(
3291
+ query.address
3292
+ );
3284
3293
  for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
3285
3294
  const borrowIncentivePoolPoints = {};
3286
3295
  const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
@@ -3343,10 +3352,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
3343
3352
  };
3344
3353
  var queryBorrowIncentiveAccounts = async ({
3345
3354
  utils
3346
- }, obligationId, borrowIncentiveCoinNames) => {
3347
- borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
3348
- ...SUPPORT_BORROW_INCENTIVE_POOLS
3349
- ];
3355
+ }, obligationId, borrowIncentiveCoinNames = [
3356
+ ...SUPPORT_BORROW_INCENTIVE_POOLS
3357
+ ]) => {
3350
3358
  const queryPkgId = utils.address.get("borrowIncentive.query");
3351
3359
  const incentiveAccountsId = utils.address.get(
3352
3360
  "borrowIncentive.incentiveAccounts"
@@ -4568,10 +4576,9 @@ var ScallopUtils = class {
4568
4576
  * @param assetCoinNames - Specific an array of support asset coin name.
4569
4577
  * @return Asset coin price.
4570
4578
  */
4571
- async getCoinPrices(assetCoinNames) {
4572
- assetCoinNames = assetCoinNames || [
4573
- .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4574
- ];
4579
+ async getCoinPrices(assetCoinNames = [
4580
+ .../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4581
+ ]) {
4575
4582
  const coinPrices = {};
4576
4583
  const existPricesCoinNames = [];
4577
4584
  const lackPricesCoinNames = [];
@@ -6521,8 +6528,7 @@ var getSCoinTotalSupply = async ({
6521
6528
  };
6522
6529
  var getSCoinAmounts = async ({
6523
6530
  utils
6524
- }, sCoinNames, ownerAddress) => {
6525
- sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
6531
+ }, sCoinNames = [...SUPPORT_SCOIN], ownerAddress) => {
6526
6532
  const owner = ownerAddress || utils.suiKit.currentAddress();
6527
6533
  const sCoins2 = {};
6528
6534
  await Promise.allSettled(
@@ -6886,7 +6892,7 @@ var ScallopQuery = class {
6886
6892
  * @return Borrow incentive pools data.
6887
6893
  */
6888
6894
  async getBorrowIncentivePools(coinNames, indexer = false) {
6889
- return await queryBorrowIncentivePools(this, coinNames, indexer);
6895
+ return await getBorrowIncentivePools(this, coinNames, indexer);
6890
6896
  }
6891
6897
  /**
6892
6898
  * Get borrow incentive accounts data.