@scallop-io/sui-scallop-sdk 0.37.9 → 0.37.10

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.
@@ -1,5 +1,6 @@
1
1
  export declare const API_BASE_URL = "https://sui.api.scallop.io";
2
2
  export declare const ADDRESSES_ID = "6462a088a7ace142bb6d7e9b";
3
+ export declare const PROTOCOL_OBJECT_ID = "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
3
4
  export declare const SUPPORT_ASSET_COINS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus"];
4
5
  export declare const SUPPORT_COLLATERAL_COINS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus"];
5
6
  export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  ADDRESSES_ID: () => ADDRESSES_ID,
34
34
  API_BASE_URL: () => API_BASE_URL,
35
+ PROTOCOL_OBJECT_ID: () => PROTOCOL_OBJECT_ID,
35
36
  SUI_COIN_TYPE_ARG_REGEX: () => SUI_COIN_TYPE_ARG_REGEX,
36
37
  SUPPORT_ASSET_COINS: () => SUPPORT_ASSET_COINS,
37
38
  SUPPORT_COLLATERAL_COINS: () => SUPPORT_COLLATERAL_COINS,
@@ -47,6 +48,7 @@ module.exports = __toCommonJS(src_exports);
47
48
  // src/constants/common.ts
48
49
  var API_BASE_URL = "https://sui.api.scallop.io";
49
50
  var ADDRESSES_ID = "6462a088a7ace142bb6d7e9b";
51
+ var PROTOCOL_OBJECT_ID = "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
50
52
  var SUPPORT_ASSET_COINS = [
51
53
  "eth",
52
54
  "btc",
@@ -619,17 +621,16 @@ var ScallopUtils = class {
619
621
  * @description Handle market coin types.
620
622
  *
621
623
  * @param coinPackageId Package id of coin.
622
- * @param protocolPkgId Package id of protocol.
623
624
  * @param coinName specific support coin name.
624
625
  *
625
626
  * @return marketCoinType.
626
627
  */
627
- parseMarketCoinType(coinPackageId, protocolPkgId, coinName) {
628
+ parseMarketCoinType(coinPackageId, coinName) {
628
629
  const coinType = this.parseCoinType(
629
630
  coinName === "sui" ? import_sui.SUI_FRAMEWORK_ADDRESS : coinPackageId,
630
631
  coinName
631
632
  );
632
- return `${protocolPkgId}::reserve::MarketCoin<${coinType}>`;
633
+ return `${PROTOCOL_OBJECT_ID}::reserve::MarketCoin<${coinType}>`;
633
634
  }
634
635
  };
635
636
 
@@ -693,7 +694,6 @@ var queryMarket = async (scallopAddress, suiKit, scallopUtils, rateType) => {
693
694
  const symbol = coin.toUpperCase();
694
695
  const marketCoinType = scallopUtils.parseMarketCoinType(
695
696
  scallopAddress.get(`core.coins.${coin}.id`),
696
- scallopAddress.get("core.packages.protocol.id"),
697
697
  coin
698
698
  );
699
699
  const wrappedType = coin === "usdc" || coin === "usdt" || coin === "eth" || coin === "btc" || coin === "apt" || coin === "sol" ? {
@@ -790,14 +790,12 @@ var queryObligation = async (obligationId, scallopAddress, suiKit) => {
790
790
  const queryResult = await suiKit.inspectTxn(txBlock);
791
791
  return queryResult.events[0].parsedJson;
792
792
  };
793
- var getObligations = async (ownerAddress, scallopAddress, suiKit) => {
793
+ var getObligations = async (ownerAddress, suiKit) => {
794
794
  const owner = ownerAddress || suiKit.currentAddress();
795
795
  const keyObjectRefs = await suiKit.provider().getOwnedObjects({
796
796
  owner,
797
797
  filter: {
798
- StructType: `${scallopAddress.get(
799
- "core.packages.protocol.id"
800
- )}::obligation::ObligationKey`
798
+ StructType: `${PROTOCOL_OBJECT_ID}::obligation::ObligationKey`
801
799
  }
802
800
  });
803
801
  const keyIds = keyObjectRefs.data.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
@@ -1173,12 +1171,7 @@ var selectCoin = async (txBlock, scallopAddress, scallopUtils, coinName, amount,
1173
1171
  };
1174
1172
  var selectMarketCoin = async (txBlock, scallopAddress, scallopUtils, coinName, amount, sender) => {
1175
1173
  const coinPackageId = scallopAddress.get(`core.coins.${coinName}.id`);
1176
- const protocolPackageId = scallopAddress.get("core.packages.protocol.id");
1177
- const coinType = scallopUtils.parseMarketCoinType(
1178
- coinPackageId,
1179
- protocolPackageId,
1180
- coinName
1181
- );
1174
+ const coinType = scallopUtils.parseMarketCoinType(coinPackageId, coinName);
1182
1175
  const coins = await scallopUtils.selectCoins(sender, amount, coinType);
1183
1176
  const [takeCoin, leftCoin] = txBlock.takeAmountFromCoins(coins, amount);
1184
1177
  return { takeCoin, leftCoin };
@@ -1193,13 +1186,13 @@ var requireSender = (txBlock) => {
1193
1186
  return sender;
1194
1187
  };
1195
1188
  var requireObligationInfo = async (...args) => {
1196
- const [txBlock, scallopAddress, suiKit, obligationId, obligationKey] = args;
1197
- if (args.length === 4 && obligationId)
1189
+ const [txBlock, suiKit, obligationId, obligationKey] = args;
1190
+ if (args.length === 3 && obligationId)
1198
1191
  return { obligationId };
1199
- if (args.length === 5 && obligationId && obligationKey)
1192
+ if (args.length === 4 && obligationId && obligationKey)
1200
1193
  return { obligationId, obligationKey };
1201
1194
  const sender = requireSender(txBlock);
1202
- const obligations = await getObligations(sender, scallopAddress, suiKit);
1195
+ const obligations = await getObligations(sender, suiKit);
1203
1196
  if (obligations.length === 0) {
1204
1197
  throw new Error(`No obligation found for sender ${sender}`);
1205
1198
  }
@@ -1213,7 +1206,6 @@ var scallopQuickMethodsHandler = {
1213
1206
  const sender = requireSender(txBlock);
1214
1207
  const { obligationId: obligationArg } = await requireObligationInfo(
1215
1208
  txBlock,
1216
- scallopAddress,
1217
1209
  suiKit,
1218
1210
  obligationId
1219
1211
  );
@@ -1236,7 +1228,6 @@ var scallopQuickMethodsHandler = {
1236
1228
  takeCollateralQuick: ({ txBlock, suiKit, scallopUtils, scallopAddress, isTestnet }) => async (amount, coinName, obligationId, obligationKey) => {
1237
1229
  const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo(
1238
1230
  txBlock,
1239
- scallopAddress,
1240
1231
  suiKit,
1241
1232
  obligationId,
1242
1233
  obligationKey
@@ -1290,7 +1281,6 @@ var scallopQuickMethodsHandler = {
1290
1281
  borrowQuick: ({ txBlock, suiKit, scallopUtils, scallopAddress, isTestnet }) => async (amount, coinName, obligationId, obligationKey) => {
1291
1282
  const { obligationId: obligationArg, obligationKey: obligationKeyArg } = await requireObligationInfo(
1292
1283
  txBlock,
1293
- scallopAddress,
1294
1284
  suiKit,
1295
1285
  obligationId,
1296
1286
  obligationKey
@@ -1315,7 +1305,6 @@ var scallopQuickMethodsHandler = {
1315
1305
  const sender = requireSender(txBlock);
1316
1306
  const { obligationId: obligationArg } = await requireObligationInfo(
1317
1307
  txBlock,
1318
- scallopAddress,
1319
1308
  suiKit,
1320
1309
  obligationId
1321
1310
  );
@@ -1400,7 +1389,7 @@ var ScallopClient = class {
1400
1389
  */
1401
1390
  async getObligations(ownerAddress) {
1402
1391
  const owner = ownerAddress || this.walletAddress;
1403
- return getObligations(owner, this.address, this.suiKit);
1392
+ return getObligations(owner, this.suiKit);
1404
1393
  }
1405
1394
  /**
1406
1395
  * Query obligation data.
@@ -1640,6 +1629,7 @@ var Scallop = class {
1640
1629
  0 && (module.exports = {
1641
1630
  ADDRESSES_ID,
1642
1631
  API_BASE_URL,
1632
+ PROTOCOL_OBJECT_ID,
1643
1633
  SUI_COIN_TYPE_ARG_REGEX,
1644
1634
  SUPPORT_ASSET_COINS,
1645
1635
  SUPPORT_COLLATERAL_COINS,