@scallop-io/sui-scallop-sdk 0.47.6 → 1.3.0-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.
- package/dist/builders/borrowIncentiveBuilder.d.ts +2 -2
- package/dist/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
- package/dist/builders/referralBuilder.d.ts +2 -2
- package/dist/builders/sCoinBuilder.d.ts +2 -2
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/builders/vescaBuilder.d.ts +2 -2
- package/dist/constants/common.d.ts +4 -4
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/vesca.d.ts +3 -3
- package/dist/index.js +149 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -89
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +6 -4
- package/dist/models/scallopCache.d.ts +5 -9
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +1 -1
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
- package/dist/queries/priceQuery.d.ts +1 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +1 -1
- package/dist/types/builder/core.d.ts +16 -16
- package/dist/types/builder/spool.d.ts +3 -3
- package/dist/types/builder/vesca.d.ts +5 -5
- package/dist/types/model.d.ts +6 -6
- package/dist/types/query/vesca.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +4 -3
- package/package.json +15 -11
- package/src/builders/borrowIncentiveBuilder.ts +6 -6
- package/src/builders/coreBuilder.ts +17 -17
- package/src/builders/index.ts +2 -2
- package/src/builders/loyaltyProgramBuilder.ts +5 -5
- package/src/builders/oracle.ts +5 -4
- package/src/builders/referralBuilder.ts +7 -7
- package/src/builders/sCoinBuilder.ts +5 -8
- package/src/builders/spoolBuilder.ts +10 -10
- package/src/builders/vescaBuilder.ts +5 -5
- package/src/constants/common.ts +4 -4
- package/src/constants/index.ts +1 -1
- package/src/constants/vesca.ts +5 -6
- package/src/models/scallopBuilder.ts +15 -7
- package/src/models/scallopCache.ts +43 -34
- package/src/models/scallopClient.ts +10 -9
- package/src/models/scallopQuery.ts +36 -2
- package/src/models/scallopUtils.ts +5 -4
- package/src/queries/borrowIncentiveQuery.ts +1 -1
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/loyaltyProgramQuery.ts +1 -1
- package/src/queries/priceQuery.ts +1 -1
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +4 -5
- package/src/queries/vescaQuery.ts +6 -3
- package/src/test.ts +26 -0
- package/src/types/address.ts +26 -26
- package/src/types/builder/borrowIncentive.ts +1 -1
- package/src/types/builder/core.ts +26 -28
- package/src/types/builder/spool.ts +2 -3
- package/src/types/builder/vesca.ts +5 -9
- package/src/types/model.ts +6 -9
- package/src/types/query/vesca.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/indexer.ts +39 -0
- package/src/utils/query.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -348,13 +348,6 @@ var sCoinIds = {
|
|
|
348
348
|
swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
-
// src/constants/vesca.ts
|
|
352
|
-
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
353
|
-
var MAX_LOCK_ROUNDS = 1460;
|
|
354
|
-
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
355
|
-
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
356
|
-
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
357
|
-
|
|
358
351
|
// src/constants/flashloan.ts
|
|
359
352
|
var FlashLoanFeeObjectMap = {
|
|
360
353
|
vsui: "0x0069cddee7a5c0b1d34beb5ef0620f978096525f1830b055f38b110f40d73fbb",
|
|
@@ -371,6 +364,13 @@ var FlashLoanFeeObjectMap = {
|
|
|
371
364
|
wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
|
|
372
365
|
};
|
|
373
366
|
|
|
367
|
+
// src/constants/vesca.ts
|
|
368
|
+
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
369
|
+
var MAX_LOCK_ROUNDS = 1460;
|
|
370
|
+
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
371
|
+
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
372
|
+
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
373
|
+
|
|
374
374
|
// src/models/scallop.ts
|
|
375
375
|
var import_sui_kit16 = require("@scallop-io/sui-kit");
|
|
376
376
|
|
|
@@ -495,7 +495,7 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
|
|
|
495
495
|
|
|
496
496
|
// src/utils/query.ts
|
|
497
497
|
var import_bignumber = __toESM(require("bignumber.js"));
|
|
498
|
-
var import_utils = require("@mysten/sui
|
|
498
|
+
var import_utils = require("@mysten/sui/utils");
|
|
499
499
|
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
500
500
|
return {
|
|
501
501
|
coinType: (0, import_utils.normalizeStructTag)(originMarketPoolData.type.name),
|
|
@@ -1013,6 +1013,25 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
|
|
|
1013
1013
|
return tryRequest();
|
|
1014
1014
|
};
|
|
1015
1015
|
|
|
1016
|
+
// src/utils/indexer.ts
|
|
1017
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1018
|
+
const indexer = args[args.length - 1];
|
|
1019
|
+
if (indexer) {
|
|
1020
|
+
try {
|
|
1021
|
+
return await method.apply(context, args);
|
|
1022
|
+
} catch (_e) {
|
|
1023
|
+
console.warn("Indexer requests failed. Retrying without indexer..");
|
|
1024
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
return await method.apply(context, args);
|
|
1028
|
+
}
|
|
1029
|
+
function withIndexerFallback(method) {
|
|
1030
|
+
return (...args) => {
|
|
1031
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1016
1035
|
// src/models/scallopCache.ts
|
|
1017
1036
|
var ScallopCache = class {
|
|
1018
1037
|
constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
|
|
@@ -1044,21 +1063,40 @@ var ScallopCache = class {
|
|
|
1044
1063
|
refetchType
|
|
1045
1064
|
});
|
|
1046
1065
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
(
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1066
|
+
async resolveArgs(txb, args) {
|
|
1067
|
+
return await Promise.all(
|
|
1068
|
+
args.map(async (arg) => {
|
|
1069
|
+
if (typeof arg === "string") {
|
|
1070
|
+
const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
|
|
1071
|
+
if (!objData)
|
|
1072
|
+
return arg;
|
|
1073
|
+
const owner = objData?.owner;
|
|
1074
|
+
if (!owner)
|
|
1075
|
+
return arg;
|
|
1076
|
+
if ("Shared" in owner) {
|
|
1077
|
+
return txb.sharedObjectRef({
|
|
1078
|
+
objectId: objData.objectId,
|
|
1079
|
+
initialSharedVersion: owner.Shared.initial_shared_version,
|
|
1080
|
+
mutable: true
|
|
1081
|
+
});
|
|
1082
|
+
} else {
|
|
1083
|
+
return txb.objectRef({
|
|
1084
|
+
objectId: objData.objectId,
|
|
1085
|
+
version: objData.version,
|
|
1086
|
+
digest: objData.digest
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
} else if ("objectId" in arg && "version" in arg && "digest" in arg) {
|
|
1090
|
+
return txb.objectRef({
|
|
1091
|
+
objectId: arg.objectId,
|
|
1092
|
+
version: arg.version,
|
|
1093
|
+
digest: arg.digest
|
|
1094
|
+
});
|
|
1095
|
+
} else {
|
|
1096
|
+
return arg;
|
|
1097
|
+
}
|
|
1098
|
+
})
|
|
1099
|
+
);
|
|
1062
1100
|
}
|
|
1063
1101
|
/**
|
|
1064
1102
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
@@ -1072,20 +1110,8 @@ var ScallopCache = class {
|
|
|
1072
1110
|
typeArgs
|
|
1073
1111
|
}) {
|
|
1074
1112
|
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
1075
|
-
const resolvedArgs = await
|
|
1076
|
-
args.map(async (arg) => {
|
|
1077
|
-
if (typeof arg === "string") {
|
|
1078
|
-
return (await this.queryGetObject(arg, { showContent: true }))?.data;
|
|
1079
|
-
}
|
|
1080
|
-
return arg;
|
|
1081
|
-
})
|
|
1082
|
-
);
|
|
1113
|
+
const resolvedArgs = await this.resolveArgs(txBlock, args);
|
|
1083
1114
|
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
1084
|
-
const txBytes = await txBlock.txBlock.build({
|
|
1085
|
-
client: this.client,
|
|
1086
|
-
onlyTransactionKind: true,
|
|
1087
|
-
protocolConfig: await this.getProtocolConfig() ?? void 0
|
|
1088
|
-
});
|
|
1089
1115
|
const query = await this.queryClient.fetchQuery({
|
|
1090
1116
|
queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
|
|
1091
1117
|
"inspectTxn",
|
|
@@ -1096,7 +1122,7 @@ var ScallopCache = class {
|
|
|
1096
1122
|
queryFn: async () => {
|
|
1097
1123
|
return await callWithRateLimit(
|
|
1098
1124
|
this.tokenBucket,
|
|
1099
|
-
() => this.suiKit.inspectTxn(
|
|
1125
|
+
() => this.suiKit.inspectTxn(txBlock)
|
|
1100
1126
|
);
|
|
1101
1127
|
}
|
|
1102
1128
|
});
|
|
@@ -2328,16 +2354,16 @@ var ScallopAddress = class {
|
|
|
2328
2354
|
};
|
|
2329
2355
|
|
|
2330
2356
|
// src/models/scallopClient.ts
|
|
2331
|
-
var import_utils25 = require("@mysten/sui
|
|
2357
|
+
var import_utils25 = require("@mysten/sui/utils");
|
|
2332
2358
|
var import_sui_kit15 = require("@scallop-io/sui-kit");
|
|
2333
2359
|
|
|
2334
2360
|
// src/models/scallopUtils.ts
|
|
2335
|
-
var import_utils10 = require("@mysten/sui
|
|
2361
|
+
var import_utils10 = require("@mysten/sui/utils");
|
|
2336
2362
|
var import_sui_kit4 = require("@scallop-io/sui-kit");
|
|
2337
2363
|
var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
|
|
2338
2364
|
|
|
2339
2365
|
// src/queries/coreQuery.ts
|
|
2340
|
-
var import_utils3 = require("@mysten/sui
|
|
2366
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
2341
2367
|
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
2342
2368
|
|
|
2343
2369
|
// src/queries/supplyLimit.ts
|
|
@@ -2992,7 +3018,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2992
3018
|
};
|
|
2993
3019
|
|
|
2994
3020
|
// src/queries/spoolQuery.ts
|
|
2995
|
-
var import_utils5 = require("@mysten/sui
|
|
3021
|
+
var import_utils5 = require("@mysten/sui/utils");
|
|
2996
3022
|
var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
|
|
2997
3023
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
2998
3024
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
@@ -3315,7 +3341,7 @@ var getStakeRewardPool = async ({
|
|
|
3315
3341
|
};
|
|
3316
3342
|
|
|
3317
3343
|
// src/queries/borrowIncentiveQuery.ts
|
|
3318
|
-
var import_utils7 = require("@mysten/sui
|
|
3344
|
+
var import_utils7 = require("@mysten/sui/utils");
|
|
3319
3345
|
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
3320
3346
|
var queryBorrowIncentivePools = async (address) => {
|
|
3321
3347
|
const queryPkgId = address.get("borrowIncentive.query");
|
|
@@ -4102,8 +4128,9 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4102
4128
|
// src/queries/vescaQuery.ts
|
|
4103
4129
|
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
4104
4130
|
var import_sui_kit3 = require("@scallop-io/sui-kit");
|
|
4105
|
-
var import_bcs = require("@mysten/sui
|
|
4131
|
+
var import_bcs = require("@mysten/sui/bcs");
|
|
4106
4132
|
var import_zod2 = require("zod");
|
|
4133
|
+
var import_assert = __toESM(require("assert"));
|
|
4107
4134
|
var getVescaKeys = async (utils, ownerAddress) => {
|
|
4108
4135
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
4109
4136
|
const veScaObjId = utils.address.get("vesca.object");
|
|
@@ -4241,7 +4268,8 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
|
|
|
4241
4268
|
if (results && results[1].returnValues) {
|
|
4242
4269
|
const value = Uint8Array.from(results[1].returnValues[0][0]);
|
|
4243
4270
|
const type = results[1].returnValues[0][1];
|
|
4244
|
-
|
|
4271
|
+
(0, import_assert.default)(type === "u64", "Result type is not u64");
|
|
4272
|
+
return import_bcs.bcs.u64().parse(value);
|
|
4245
4273
|
}
|
|
4246
4274
|
return "0";
|
|
4247
4275
|
};
|
|
@@ -4383,7 +4411,8 @@ var ScallopUtils = class {
|
|
|
4383
4411
|
this.address = instance?.address ?? new ScallopAddress(
|
|
4384
4412
|
{
|
|
4385
4413
|
id: params?.addressesId || ADDRESSES_ID,
|
|
4386
|
-
network: params?.networkType
|
|
4414
|
+
network: params?.networkType,
|
|
4415
|
+
forceInterface: params?.forceAddressesInterface
|
|
4387
4416
|
},
|
|
4388
4417
|
{
|
|
4389
4418
|
cache: this.cache
|
|
@@ -4632,7 +4661,7 @@ var ScallopUtils = class {
|
|
|
4632
4661
|
if (existingCoins.length > 0) {
|
|
4633
4662
|
txBlock.mergeCoins(dest, existingCoins.slice(0, 500));
|
|
4634
4663
|
}
|
|
4635
|
-
} catch (
|
|
4664
|
+
} catch (_e) {
|
|
4636
4665
|
}
|
|
4637
4666
|
}
|
|
4638
4667
|
/**
|
|
@@ -4808,17 +4837,18 @@ var ScallopUtils = class {
|
|
|
4808
4837
|
};
|
|
4809
4838
|
|
|
4810
4839
|
// src/models/scallopBuilder.ts
|
|
4811
|
-
var import_utils24 = require("@mysten/sui
|
|
4840
|
+
var import_utils24 = require("@mysten/sui/utils");
|
|
4812
4841
|
var import_sui_kit14 = require("@scallop-io/sui-kit");
|
|
4813
4842
|
|
|
4814
4843
|
// src/builders/coreBuilder.ts
|
|
4815
|
-
var
|
|
4816
|
-
var import_utils13 = require("@mysten/sui
|
|
4844
|
+
var import_transactions2 = require("@mysten/sui/transactions");
|
|
4845
|
+
var import_utils13 = require("@mysten/sui/utils");
|
|
4817
4846
|
var import_sui_kit5 = require("@scallop-io/sui-kit");
|
|
4818
4847
|
|
|
4819
4848
|
// src/builders/oracle.ts
|
|
4820
|
-
var import_utils12 = require("@mysten/sui
|
|
4849
|
+
var import_utils12 = require("@mysten/sui/utils");
|
|
4821
4850
|
var import_pyth_sui_js2 = require("@pythnetwork/pyth-sui-js");
|
|
4851
|
+
var import_transactions = require("@mysten/sui.js/transactions");
|
|
4822
4852
|
var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
|
|
4823
4853
|
const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
|
|
4824
4854
|
assetCoinNames = assetCoinNames ?? [
|
|
@@ -4827,7 +4857,7 @@ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePyth
|
|
|
4827
4857
|
const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
|
|
4828
4858
|
if (usePythPullModel && rules.includes("pyth")) {
|
|
4829
4859
|
const pythClient = new import_pyth_sui_js2.SuiPythClient(
|
|
4830
|
-
builder.
|
|
4860
|
+
builder.oldSuiClient,
|
|
4831
4861
|
builder.address.get("core.oracles.pyth.state"),
|
|
4832
4862
|
builder.address.get("core.oracles.pyth.wormholeState")
|
|
4833
4863
|
);
|
|
@@ -4840,7 +4870,8 @@ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePyth
|
|
|
4840
4870
|
const pythConnection = new import_pyth_sui_js2.SuiPriceServiceConnection(endpoint);
|
|
4841
4871
|
const priceUpdateData = await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
4842
4872
|
await pythClient.updatePriceFeeds(
|
|
4843
|
-
txBlock.
|
|
4873
|
+
import_transactions.TransactionBlock.from(txBlock.serialize()),
|
|
4874
|
+
// convert txBlock to TransactionBlock because pyth sdk not support new @mysten/sui yet
|
|
4844
4875
|
priceUpdateData,
|
|
4845
4876
|
priceIds
|
|
4846
4877
|
);
|
|
@@ -5021,7 +5052,7 @@ var generateCoreNormalMethod = ({
|
|
|
5021
5052
|
obligationKey,
|
|
5022
5053
|
coreIds.market,
|
|
5023
5054
|
coreIds.coinDecimalsRegistry,
|
|
5024
|
-
amount,
|
|
5055
|
+
txBlock.pure.u64(amount),
|
|
5025
5056
|
coreIds.xOracle,
|
|
5026
5057
|
import_utils13.SUI_CLOCK_OBJECT_ID
|
|
5027
5058
|
],
|
|
@@ -5088,7 +5119,7 @@ var generateCoreNormalMethod = ({
|
|
|
5088
5119
|
coreIds.market,
|
|
5089
5120
|
coreIds.coinDecimalsRegistry,
|
|
5090
5121
|
borrowReferral,
|
|
5091
|
-
amount,
|
|
5122
|
+
txBlock.pure.u64(amount),
|
|
5092
5123
|
coreIds.xOracle,
|
|
5093
5124
|
import_utils13.SUI_CLOCK_OBJECT_ID
|
|
5094
5125
|
],
|
|
@@ -5105,7 +5136,7 @@ var generateCoreNormalMethod = ({
|
|
|
5105
5136
|
obligationKey,
|
|
5106
5137
|
coreIds.market,
|
|
5107
5138
|
coreIds.coinDecimalsRegistry,
|
|
5108
|
-
amount,
|
|
5139
|
+
txBlock.pure.u64(amount),
|
|
5109
5140
|
coreIds.xOracle,
|
|
5110
5141
|
import_utils13.SUI_CLOCK_OBJECT_ID
|
|
5111
5142
|
],
|
|
@@ -5235,10 +5266,10 @@ var generateCoreQuickMethod = ({
|
|
|
5235
5266
|
txBlock.transferObjects([leftCoin2], sender);
|
|
5236
5267
|
txBlock.mergeCoins(marketCoins2, [walletMarketCoins]);
|
|
5237
5268
|
}
|
|
5238
|
-
} catch (
|
|
5269
|
+
} catch (_e) {
|
|
5239
5270
|
}
|
|
5240
5271
|
return txBlock.withdraw(marketCoins2, poolCoinName);
|
|
5241
|
-
} catch (
|
|
5272
|
+
} catch (_e) {
|
|
5242
5273
|
const { leftCoin, takeCoin: walletMarketCoins } = await builder.selectMarketCoin(
|
|
5243
5274
|
txBlock,
|
|
5244
5275
|
marketCoinName,
|
|
@@ -5323,7 +5354,7 @@ var generateCoreQuickMethod = ({
|
|
|
5323
5354
|
};
|
|
5324
5355
|
};
|
|
5325
5356
|
var newCoreTxBlock = (builder, initTxBlock) => {
|
|
5326
|
-
const txBlock = initTxBlock instanceof
|
|
5357
|
+
const txBlock = initTxBlock instanceof import_transactions2.Transaction ? new import_sui_kit5.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit5.SuiTxBlock();
|
|
5327
5358
|
const normalMethod = generateCoreNormalMethod({
|
|
5328
5359
|
builder,
|
|
5329
5360
|
txBlock
|
|
@@ -5351,8 +5382,8 @@ var newCoreTxBlock = (builder, initTxBlock) => {
|
|
|
5351
5382
|
};
|
|
5352
5383
|
|
|
5353
5384
|
// src/builders/spoolBuilder.ts
|
|
5354
|
-
var
|
|
5355
|
-
var import_utils15 = require("@mysten/sui
|
|
5385
|
+
var import_transactions3 = require("@mysten/sui/transactions");
|
|
5386
|
+
var import_utils15 = require("@mysten/sui/utils");
|
|
5356
5387
|
var import_sui_kit6 = require("@scallop-io/sui-kit");
|
|
5357
5388
|
var requireStakeAccountIds = async (...params) => {
|
|
5358
5389
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
@@ -5388,7 +5419,7 @@ var stakeHelper = async (builder, txBlock, stakeAccount, coinName, amount, sende
|
|
|
5388
5419
|
}
|
|
5389
5420
|
txBlock.transferObjects([leftCoin], sender);
|
|
5390
5421
|
return totalAmount;
|
|
5391
|
-
} catch (
|
|
5422
|
+
} catch (_e) {
|
|
5392
5423
|
return 0;
|
|
5393
5424
|
}
|
|
5394
5425
|
};
|
|
@@ -5545,7 +5576,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5545
5576
|
};
|
|
5546
5577
|
};
|
|
5547
5578
|
var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
5548
|
-
const txBlock = initTxBlock instanceof
|
|
5579
|
+
const txBlock = initTxBlock instanceof import_transactions3.Transaction ? new import_sui_kit6.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit6.SuiTxBlock();
|
|
5549
5580
|
const normalMethod = generateSpoolNormalMethod({
|
|
5550
5581
|
builder,
|
|
5551
5582
|
txBlock
|
|
@@ -5573,8 +5604,8 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
|
5573
5604
|
};
|
|
5574
5605
|
|
|
5575
5606
|
// src/builders/borrowIncentiveBuilder.ts
|
|
5576
|
-
var
|
|
5577
|
-
var import_utils17 = require("@mysten/sui
|
|
5607
|
+
var import_transactions4 = require("@mysten/sui/transactions");
|
|
5608
|
+
var import_utils17 = require("@mysten/sui/utils");
|
|
5578
5609
|
var import_sui_kit7 = require("@scallop-io/sui-kit");
|
|
5579
5610
|
var requireObligationInfo2 = async (...params) => {
|
|
5580
5611
|
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
@@ -5775,7 +5806,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
5775
5806
|
};
|
|
5776
5807
|
};
|
|
5777
5808
|
var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
|
|
5778
|
-
const txBlock = initTxBlock instanceof
|
|
5809
|
+
const txBlock = initTxBlock instanceof import_transactions4.Transaction ? new import_sui_kit7.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit7.SuiTxBlock();
|
|
5779
5810
|
const normalMethod = generateBorrowIncentiveNormalMethod({
|
|
5780
5811
|
builder,
|
|
5781
5812
|
txBlock
|
|
@@ -6051,7 +6082,7 @@ var generateQuickVeScaMethod = ({
|
|
|
6051
6082
|
};
|
|
6052
6083
|
};
|
|
6053
6084
|
var newVeScaTxBlock = (builder, initTxBlock) => {
|
|
6054
|
-
const txBlock = initTxBlock instanceof import_sui_kit8.
|
|
6085
|
+
const txBlock = initTxBlock instanceof import_sui_kit8.Transaction ? new import_sui_kit8.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit8.SuiTxBlock();
|
|
6055
6086
|
const normalMethod = generateNormalVeScaMethod({
|
|
6056
6087
|
builder,
|
|
6057
6088
|
txBlock
|
|
@@ -6101,7 +6132,7 @@ var generateReferralNormalMethod = ({
|
|
|
6101
6132
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
6102
6133
|
[
|
|
6103
6134
|
referralIds.referralBindings,
|
|
6104
|
-
txBlock.pure(veScaKeyId),
|
|
6135
|
+
txBlock.pure.id(veScaKeyId),
|
|
6105
6136
|
veScaTable,
|
|
6106
6137
|
import_sui_kit9.SUI_CLOCK_OBJECT_ID
|
|
6107
6138
|
],
|
|
@@ -6172,7 +6203,7 @@ var generateReferralQuickMethod = ({
|
|
|
6172
6203
|
builder.utils.parseCoinType(coinName)
|
|
6173
6204
|
);
|
|
6174
6205
|
txBlock.mergeCoins(rewardCoin, coins.slice(0, 500));
|
|
6175
|
-
} catch (
|
|
6206
|
+
} catch (_e) {
|
|
6176
6207
|
} finally {
|
|
6177
6208
|
objToTransfer.push(rewardCoin);
|
|
6178
6209
|
}
|
|
@@ -6185,7 +6216,7 @@ var generateReferralQuickMethod = ({
|
|
|
6185
6216
|
};
|
|
6186
6217
|
};
|
|
6187
6218
|
var newReferralTxBlock = (builder, initTxBlock) => {
|
|
6188
|
-
const txBlock = initTxBlock instanceof import_sui_kit9.
|
|
6219
|
+
const txBlock = initTxBlock instanceof import_sui_kit9.Transaction ? new import_sui_kit9.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit9.SuiTxBlock();
|
|
6189
6220
|
const normalMethod = generateReferralNormalMethod({
|
|
6190
6221
|
builder,
|
|
6191
6222
|
txBlock
|
|
@@ -6213,7 +6244,7 @@ var newReferralTxBlock = (builder, initTxBlock) => {
|
|
|
6213
6244
|
};
|
|
6214
6245
|
|
|
6215
6246
|
// src/builders/loyaltyProgramBuilder.ts
|
|
6216
|
-
var
|
|
6247
|
+
var import_transactions5 = require("@mysten/sui/transactions");
|
|
6217
6248
|
var import_sui_kit10 = require("@scallop-io/sui-kit");
|
|
6218
6249
|
var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
6219
6250
|
const loyaltyProgramIds = {
|
|
@@ -6254,7 +6285,7 @@ var generateLoyaltyProgramQuickMethod = ({
|
|
|
6254
6285
|
};
|
|
6255
6286
|
};
|
|
6256
6287
|
var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
6257
|
-
const txBlock = initTxBlock instanceof
|
|
6288
|
+
const txBlock = initTxBlock instanceof import_transactions5.Transaction ? new import_sui_kit10.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit10.SuiTxBlock();
|
|
6258
6289
|
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
6259
6290
|
builder,
|
|
6260
6291
|
txBlock
|
|
@@ -6343,7 +6374,7 @@ var generateSCoinQuickMethod = ({
|
|
|
6343
6374
|
};
|
|
6344
6375
|
};
|
|
6345
6376
|
var newSCoinTxBlock = (builder, initTxBlock) => {
|
|
6346
|
-
const txBlock = initTxBlock instanceof import_sui_kit11.
|
|
6377
|
+
const txBlock = initTxBlock instanceof import_sui_kit11.Transaction ? new import_sui_kit11.SuiTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new import_sui_kit11.SuiTxBlock();
|
|
6347
6378
|
const normalMethod = generateSCoinNormalMethod({
|
|
6348
6379
|
builder,
|
|
6349
6380
|
txBlock
|
|
@@ -6575,8 +6606,8 @@ var ScallopIndexer = class {
|
|
|
6575
6606
|
};
|
|
6576
6607
|
|
|
6577
6608
|
// src/queries/sCoinQuery.ts
|
|
6578
|
-
var import_bcs2 = require("@mysten/sui
|
|
6579
|
-
var
|
|
6609
|
+
var import_bcs2 = require("@mysten/sui/bcs");
|
|
6610
|
+
var import_assert2 = __toESM(require("assert"));
|
|
6580
6611
|
var import_bignumber7 = __toESM(require("bignumber.js"));
|
|
6581
6612
|
var getSCoinTotalSupply = async ({
|
|
6582
6613
|
utils
|
|
@@ -6597,8 +6628,8 @@ var getSCoinTotalSupply = async ({
|
|
|
6597
6628
|
if (results && results[0].returnValues) {
|
|
6598
6629
|
const value = Uint8Array.from(results[0].returnValues[0][0]);
|
|
6599
6630
|
const type = results[0].returnValues[0][1];
|
|
6600
|
-
(0,
|
|
6601
|
-
return (0, import_bignumber7.default)(import_bcs2.bcs.
|
|
6631
|
+
(0, import_assert2.default)(type === "u64", "Result type is not u64");
|
|
6632
|
+
return (0, import_bignumber7.default)(import_bcs2.bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
|
|
6602
6633
|
}
|
|
6603
6634
|
return 0;
|
|
6604
6635
|
};
|
|
@@ -6668,7 +6699,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
6668
6699
|
};
|
|
6669
6700
|
|
|
6670
6701
|
// src/models/scallopQuery.ts
|
|
6671
|
-
var import_utils23 = require("@mysten/sui
|
|
6702
|
+
var import_utils23 = require("@mysten/sui/utils");
|
|
6672
6703
|
var ScallopQuery = class {
|
|
6673
6704
|
constructor(params, instance) {
|
|
6674
6705
|
this.params = params;
|
|
@@ -6689,7 +6720,8 @@ var ScallopQuery = class {
|
|
|
6689
6720
|
this.address = new ScallopAddress(
|
|
6690
6721
|
{
|
|
6691
6722
|
id: params?.addressesId || ADDRESSES_ID,
|
|
6692
|
-
network: params?.networkType
|
|
6723
|
+
network: params?.networkType,
|
|
6724
|
+
forceInterface: params?.forceAddressesInterface
|
|
6693
6725
|
},
|
|
6694
6726
|
{
|
|
6695
6727
|
cache: this.cache
|
|
@@ -6700,7 +6732,36 @@ var ScallopQuery = class {
|
|
|
6700
6732
|
});
|
|
6701
6733
|
}
|
|
6702
6734
|
this.indexer = instance?.indexer ?? new ScallopIndexer(this.params, { cache: this.cache });
|
|
6735
|
+
this.queryMarket = withIndexerFallback.call(this, this.queryMarket);
|
|
6736
|
+
this.getMarketPools = withIndexerFallback.call(this, this.getMarketPools);
|
|
6737
|
+
this.getMarketPool = withIndexerFallback.call(this, this.getMarketPool);
|
|
6738
|
+
this.getMarketCollaterals = withIndexerFallback.call(
|
|
6739
|
+
this,
|
|
6740
|
+
this.getMarketCollaterals
|
|
6741
|
+
);
|
|
6742
|
+
this.getMarketCollateral = withIndexerFallback.call(
|
|
6743
|
+
this,
|
|
6744
|
+
this.getMarketCollateral
|
|
6745
|
+
);
|
|
6746
|
+
this.getSpools = withIndexerFallback.call(this, this.getSpools);
|
|
6747
|
+
this.getSpool = withIndexerFallback.call(this, this.getSpool);
|
|
6748
|
+
this.getBorrowIncentivePools = withIndexerFallback.call(
|
|
6749
|
+
this,
|
|
6750
|
+
this.getBorrowIncentivePools
|
|
6751
|
+
);
|
|
6752
|
+
this.getLendings = withIndexerFallback.call(this, this.getLendings);
|
|
6753
|
+
this.getLending = withIndexerFallback.call(this, this.getLending);
|
|
6754
|
+
this.getObligationAccounts = withIndexerFallback.call(
|
|
6755
|
+
this,
|
|
6756
|
+
this.getObligationAccounts
|
|
6757
|
+
);
|
|
6758
|
+
this.getObligationAccount = withIndexerFallback.call(
|
|
6759
|
+
this,
|
|
6760
|
+
this.getObligationAccount
|
|
6761
|
+
);
|
|
6762
|
+
this.getTvl = withIndexerFallback.call(this, this.getTvl);
|
|
6703
6763
|
}
|
|
6764
|
+
/* ========================================================== */
|
|
6704
6765
|
/**
|
|
6705
6766
|
* Request the scallop API to initialize data.
|
|
6706
6767
|
*
|
|
@@ -7159,6 +7220,7 @@ var ScallopQuery = class {
|
|
|
7159
7220
|
};
|
|
7160
7221
|
|
|
7161
7222
|
// src/models/scallopBuilder.ts
|
|
7223
|
+
var import_client = require("@mysten/sui.js/client");
|
|
7162
7224
|
var ScallopBuilder = class {
|
|
7163
7225
|
constructor(params, instance) {
|
|
7164
7226
|
this.suiKit = instance?.suiKit ?? new import_sui_kit14.SuiKit(params);
|
|
@@ -7180,7 +7242,8 @@ var ScallopBuilder = class {
|
|
|
7180
7242
|
this.address = new ScallopAddress(
|
|
7181
7243
|
{
|
|
7182
7244
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7183
|
-
network: params?.networkType
|
|
7245
|
+
network: params?.networkType,
|
|
7246
|
+
forceInterface: params?.forceAddressesInterface
|
|
7184
7247
|
},
|
|
7185
7248
|
{
|
|
7186
7249
|
cache: this.cache
|
|
@@ -7199,6 +7262,9 @@ var ScallopBuilder = class {
|
|
|
7199
7262
|
);
|
|
7200
7263
|
}
|
|
7201
7264
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
7265
|
+
this.oldSuiClient = new import_client.SuiClient({
|
|
7266
|
+
url: this.suiKit.suiInteractor.currentFullNode
|
|
7267
|
+
});
|
|
7202
7268
|
}
|
|
7203
7269
|
/**
|
|
7204
7270
|
* Request the scallop API to initialize data.
|
|
@@ -7327,8 +7393,8 @@ var ScallopClient = class {
|
|
|
7327
7393
|
this.address = new ScallopAddress(
|
|
7328
7394
|
{
|
|
7329
7395
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7330
|
-
|
|
7331
|
-
|
|
7396
|
+
network: params?.networkType,
|
|
7397
|
+
forceInterface: params?.forceAddressesInterface
|
|
7332
7398
|
},
|
|
7333
7399
|
{
|
|
7334
7400
|
cache: this.cache
|
|
@@ -7887,7 +7953,7 @@ var ScallopClient = class {
|
|
|
7887
7953
|
if (sCoin) {
|
|
7888
7954
|
sCoins2.push(sCoin);
|
|
7889
7955
|
}
|
|
7890
|
-
} catch (
|
|
7956
|
+
} catch (_e) {
|
|
7891
7957
|
}
|
|
7892
7958
|
}
|
|
7893
7959
|
}
|
|
@@ -7928,7 +7994,7 @@ var ScallopClient = class {
|
|
|
7928
7994
|
if (!scaCoin)
|
|
7929
7995
|
return;
|
|
7930
7996
|
scaCoins.push(scaCoin);
|
|
7931
|
-
} catch (
|
|
7997
|
+
} catch (_e) {
|
|
7932
7998
|
}
|
|
7933
7999
|
})
|
|
7934
8000
|
);
|