@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.mjs
CHANGED
|
@@ -267,13 +267,6 @@ var sCoinIds = {
|
|
|
267
267
|
swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
|
|
268
268
|
};
|
|
269
269
|
|
|
270
|
-
// src/constants/vesca.ts
|
|
271
|
-
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
272
|
-
var MAX_LOCK_ROUNDS = 1460;
|
|
273
|
-
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
274
|
-
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
275
|
-
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
276
|
-
|
|
277
270
|
// src/constants/flashloan.ts
|
|
278
271
|
var FlashLoanFeeObjectMap = {
|
|
279
272
|
vsui: "0x0069cddee7a5c0b1d34beb5ef0620f978096525f1830b055f38b110f40d73fbb",
|
|
@@ -290,6 +283,13 @@ var FlashLoanFeeObjectMap = {
|
|
|
290
283
|
wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
|
|
291
284
|
};
|
|
292
285
|
|
|
286
|
+
// src/constants/vesca.ts
|
|
287
|
+
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
288
|
+
var MAX_LOCK_ROUNDS = 1460;
|
|
289
|
+
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
290
|
+
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
291
|
+
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
292
|
+
|
|
293
293
|
// src/models/scallop.ts
|
|
294
294
|
import { SuiKit as SuiKit7 } from "@scallop-io/sui-kit";
|
|
295
295
|
|
|
@@ -418,7 +418,7 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
|
|
|
418
418
|
|
|
419
419
|
// src/utils/query.ts
|
|
420
420
|
import BigNumber from "bignumber.js";
|
|
421
|
-
import { normalizeStructTag, parseStructTag } from "@mysten/sui
|
|
421
|
+
import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
|
|
422
422
|
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
423
423
|
return {
|
|
424
424
|
coinType: normalizeStructTag(originMarketPoolData.type.name),
|
|
@@ -936,6 +936,25 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
|
|
|
936
936
|
return tryRequest();
|
|
937
937
|
};
|
|
938
938
|
|
|
939
|
+
// src/utils/indexer.ts
|
|
940
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
941
|
+
const indexer = args[args.length - 1];
|
|
942
|
+
if (indexer) {
|
|
943
|
+
try {
|
|
944
|
+
return await method.apply(context, args);
|
|
945
|
+
} catch (_e) {
|
|
946
|
+
console.warn("Indexer requests failed. Retrying without indexer..");
|
|
947
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return await method.apply(context, args);
|
|
951
|
+
}
|
|
952
|
+
function withIndexerFallback(method) {
|
|
953
|
+
return (...args) => {
|
|
954
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
939
958
|
// src/models/scallopCache.ts
|
|
940
959
|
var ScallopCache = class {
|
|
941
960
|
constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
|
|
@@ -967,21 +986,40 @@ var ScallopCache = class {
|
|
|
967
986
|
refetchType
|
|
968
987
|
});
|
|
969
988
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
989
|
+
async resolveArgs(txb, args) {
|
|
990
|
+
return await Promise.all(
|
|
991
|
+
args.map(async (arg) => {
|
|
992
|
+
if (typeof arg === "string") {
|
|
993
|
+
const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
|
|
994
|
+
if (!objData)
|
|
995
|
+
return arg;
|
|
996
|
+
const owner = objData?.owner;
|
|
997
|
+
if (!owner)
|
|
998
|
+
return arg;
|
|
999
|
+
if ("Shared" in owner) {
|
|
1000
|
+
return txb.sharedObjectRef({
|
|
1001
|
+
objectId: objData.objectId,
|
|
1002
|
+
initialSharedVersion: owner.Shared.initial_shared_version,
|
|
1003
|
+
mutable: true
|
|
1004
|
+
});
|
|
1005
|
+
} else {
|
|
1006
|
+
return txb.objectRef({
|
|
1007
|
+
objectId: objData.objectId,
|
|
1008
|
+
version: objData.version,
|
|
1009
|
+
digest: objData.digest
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
} else if ("objectId" in arg && "version" in arg && "digest" in arg) {
|
|
1013
|
+
return txb.objectRef({
|
|
1014
|
+
objectId: arg.objectId,
|
|
1015
|
+
version: arg.version,
|
|
1016
|
+
digest: arg.digest
|
|
1017
|
+
});
|
|
1018
|
+
} else {
|
|
1019
|
+
return arg;
|
|
1020
|
+
}
|
|
1021
|
+
})
|
|
1022
|
+
);
|
|
985
1023
|
}
|
|
986
1024
|
/**
|
|
987
1025
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
@@ -995,20 +1033,8 @@ var ScallopCache = class {
|
|
|
995
1033
|
typeArgs
|
|
996
1034
|
}) {
|
|
997
1035
|
const txBlock = new SuiTxBlock();
|
|
998
|
-
const resolvedArgs = await
|
|
999
|
-
args.map(async (arg) => {
|
|
1000
|
-
if (typeof arg === "string") {
|
|
1001
|
-
return (await this.queryGetObject(arg, { showContent: true }))?.data;
|
|
1002
|
-
}
|
|
1003
|
-
return arg;
|
|
1004
|
-
})
|
|
1005
|
-
);
|
|
1036
|
+
const resolvedArgs = await this.resolveArgs(txBlock, args);
|
|
1006
1037
|
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
1007
|
-
const txBytes = await txBlock.txBlock.build({
|
|
1008
|
-
client: this.client,
|
|
1009
|
-
onlyTransactionKind: true,
|
|
1010
|
-
protocolConfig: await this.getProtocolConfig() ?? void 0
|
|
1011
|
-
});
|
|
1012
1038
|
const query = await this.queryClient.fetchQuery({
|
|
1013
1039
|
queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
|
|
1014
1040
|
"inspectTxn",
|
|
@@ -1019,7 +1045,7 @@ var ScallopCache = class {
|
|
|
1019
1045
|
queryFn: async () => {
|
|
1020
1046
|
return await callWithRateLimit(
|
|
1021
1047
|
this.tokenBucket,
|
|
1022
|
-
() => this.suiKit.inspectTxn(
|
|
1048
|
+
() => this.suiKit.inspectTxn(txBlock)
|
|
1023
1049
|
);
|
|
1024
1050
|
}
|
|
1025
1051
|
});
|
|
@@ -2251,16 +2277,16 @@ var ScallopAddress = class {
|
|
|
2251
2277
|
};
|
|
2252
2278
|
|
|
2253
2279
|
// src/models/scallopClient.ts
|
|
2254
|
-
import { normalizeSuiAddress as normalizeSuiAddress4 } from "@mysten/sui
|
|
2280
|
+
import { normalizeSuiAddress as normalizeSuiAddress4 } from "@mysten/sui/utils";
|
|
2255
2281
|
import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
|
|
2256
2282
|
|
|
2257
2283
|
// src/models/scallopUtils.ts
|
|
2258
|
-
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui
|
|
2284
|
+
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
2259
2285
|
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
2260
2286
|
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
2261
2287
|
|
|
2262
2288
|
// src/queries/coreQuery.ts
|
|
2263
|
-
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui
|
|
2289
|
+
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
2264
2290
|
import BigNumber2 from "bignumber.js";
|
|
2265
2291
|
|
|
2266
2292
|
// src/queries/supplyLimit.ts
|
|
@@ -2915,7 +2941,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2915
2941
|
};
|
|
2916
2942
|
|
|
2917
2943
|
// src/queries/spoolQuery.ts
|
|
2918
|
-
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui
|
|
2944
|
+
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
|
|
2919
2945
|
var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false) => {
|
|
2920
2946
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
2921
2947
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
@@ -3238,7 +3264,7 @@ var getStakeRewardPool = async ({
|
|
|
3238
3264
|
};
|
|
3239
3265
|
|
|
3240
3266
|
// src/queries/borrowIncentiveQuery.ts
|
|
3241
|
-
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui
|
|
3267
|
+
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
|
|
3242
3268
|
import BigNumber3 from "bignumber.js";
|
|
3243
3269
|
var queryBorrowIncentivePools = async (address) => {
|
|
3244
3270
|
const queryPkgId = address.get("borrowIncentive.query");
|
|
@@ -4025,8 +4051,9 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4025
4051
|
// src/queries/vescaQuery.ts
|
|
4026
4052
|
import BigNumber5 from "bignumber.js";
|
|
4027
4053
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
4028
|
-
import { bcs } from "@mysten/sui
|
|
4054
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
4029
4055
|
import { z as zod2 } from "zod";
|
|
4056
|
+
import assert from "assert";
|
|
4030
4057
|
var getVescaKeys = async (utils, ownerAddress) => {
|
|
4031
4058
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
4032
4059
|
const veScaObjId = utils.address.get("vesca.object");
|
|
@@ -4164,7 +4191,8 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
|
|
|
4164
4191
|
if (results && results[1].returnValues) {
|
|
4165
4192
|
const value = Uint8Array.from(results[1].returnValues[0][0]);
|
|
4166
4193
|
const type = results[1].returnValues[0][1];
|
|
4167
|
-
|
|
4194
|
+
assert(type === "u64", "Result type is not u64");
|
|
4195
|
+
return bcs.u64().parse(value);
|
|
4168
4196
|
}
|
|
4169
4197
|
return "0";
|
|
4170
4198
|
};
|
|
@@ -4306,7 +4334,8 @@ var ScallopUtils = class {
|
|
|
4306
4334
|
this.address = instance?.address ?? new ScallopAddress(
|
|
4307
4335
|
{
|
|
4308
4336
|
id: params?.addressesId || ADDRESSES_ID,
|
|
4309
|
-
network: params?.networkType
|
|
4337
|
+
network: params?.networkType,
|
|
4338
|
+
forceInterface: params?.forceAddressesInterface
|
|
4310
4339
|
},
|
|
4311
4340
|
{
|
|
4312
4341
|
cache: this.cache
|
|
@@ -4555,7 +4584,7 @@ var ScallopUtils = class {
|
|
|
4555
4584
|
if (existingCoins.length > 0) {
|
|
4556
4585
|
txBlock.mergeCoins(dest, existingCoins.slice(0, 500));
|
|
4557
4586
|
}
|
|
4558
|
-
} catch (
|
|
4587
|
+
} catch (_e) {
|
|
4559
4588
|
}
|
|
4560
4589
|
}
|
|
4561
4590
|
/**
|
|
@@ -4731,20 +4760,21 @@ var ScallopUtils = class {
|
|
|
4731
4760
|
};
|
|
4732
4761
|
|
|
4733
4762
|
// src/models/scallopBuilder.ts
|
|
4734
|
-
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui
|
|
4763
|
+
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
|
|
4735
4764
|
import { SuiKit as SuiKit5 } from "@scallop-io/sui-kit";
|
|
4736
4765
|
|
|
4737
4766
|
// src/builders/coreBuilder.ts
|
|
4738
|
-
import {
|
|
4739
|
-
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui
|
|
4767
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
4768
|
+
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui/utils";
|
|
4740
4769
|
import { SuiTxBlock as SuiKitTxBlock } from "@scallop-io/sui-kit";
|
|
4741
4770
|
|
|
4742
4771
|
// src/builders/oracle.ts
|
|
4743
|
-
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui
|
|
4772
|
+
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui/utils";
|
|
4744
4773
|
import {
|
|
4745
4774
|
SuiPythClient,
|
|
4746
4775
|
SuiPriceServiceConnection as SuiPriceServiceConnection2
|
|
4747
4776
|
} from "@pythnetwork/pyth-sui-js";
|
|
4777
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
4748
4778
|
var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
|
|
4749
4779
|
const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
|
|
4750
4780
|
assetCoinNames = assetCoinNames ?? [
|
|
@@ -4753,7 +4783,7 @@ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePyth
|
|
|
4753
4783
|
const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
|
|
4754
4784
|
if (usePythPullModel && rules.includes("pyth")) {
|
|
4755
4785
|
const pythClient = new SuiPythClient(
|
|
4756
|
-
builder.
|
|
4786
|
+
builder.oldSuiClient,
|
|
4757
4787
|
builder.address.get("core.oracles.pyth.state"),
|
|
4758
4788
|
builder.address.get("core.oracles.pyth.wormholeState")
|
|
4759
4789
|
);
|
|
@@ -4766,7 +4796,8 @@ var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePyth
|
|
|
4766
4796
|
const pythConnection = new SuiPriceServiceConnection2(endpoint);
|
|
4767
4797
|
const priceUpdateData = await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
4768
4798
|
await pythClient.updatePriceFeeds(
|
|
4769
|
-
txBlock.
|
|
4799
|
+
TransactionBlock.from(txBlock.serialize()),
|
|
4800
|
+
// convert txBlock to TransactionBlock because pyth sdk not support new @mysten/sui yet
|
|
4770
4801
|
priceUpdateData,
|
|
4771
4802
|
priceIds
|
|
4772
4803
|
);
|
|
@@ -4947,7 +4978,7 @@ var generateCoreNormalMethod = ({
|
|
|
4947
4978
|
obligationKey,
|
|
4948
4979
|
coreIds.market,
|
|
4949
4980
|
coreIds.coinDecimalsRegistry,
|
|
4950
|
-
amount,
|
|
4981
|
+
txBlock.pure.u64(amount),
|
|
4951
4982
|
coreIds.xOracle,
|
|
4952
4983
|
SUI_CLOCK_OBJECT_ID3
|
|
4953
4984
|
],
|
|
@@ -5014,7 +5045,7 @@ var generateCoreNormalMethod = ({
|
|
|
5014
5045
|
coreIds.market,
|
|
5015
5046
|
coreIds.coinDecimalsRegistry,
|
|
5016
5047
|
borrowReferral,
|
|
5017
|
-
amount,
|
|
5048
|
+
txBlock.pure.u64(amount),
|
|
5018
5049
|
coreIds.xOracle,
|
|
5019
5050
|
SUI_CLOCK_OBJECT_ID3
|
|
5020
5051
|
],
|
|
@@ -5031,7 +5062,7 @@ var generateCoreNormalMethod = ({
|
|
|
5031
5062
|
obligationKey,
|
|
5032
5063
|
coreIds.market,
|
|
5033
5064
|
coreIds.coinDecimalsRegistry,
|
|
5034
|
-
amount,
|
|
5065
|
+
txBlock.pure.u64(amount),
|
|
5035
5066
|
coreIds.xOracle,
|
|
5036
5067
|
SUI_CLOCK_OBJECT_ID3
|
|
5037
5068
|
],
|
|
@@ -5161,10 +5192,10 @@ var generateCoreQuickMethod = ({
|
|
|
5161
5192
|
txBlock.transferObjects([leftCoin2], sender);
|
|
5162
5193
|
txBlock.mergeCoins(marketCoins2, [walletMarketCoins]);
|
|
5163
5194
|
}
|
|
5164
|
-
} catch (
|
|
5195
|
+
} catch (_e) {
|
|
5165
5196
|
}
|
|
5166
5197
|
return txBlock.withdraw(marketCoins2, poolCoinName);
|
|
5167
|
-
} catch (
|
|
5198
|
+
} catch (_e) {
|
|
5168
5199
|
const { leftCoin, takeCoin: walletMarketCoins } = await builder.selectMarketCoin(
|
|
5169
5200
|
txBlock,
|
|
5170
5201
|
marketCoinName,
|
|
@@ -5249,7 +5280,7 @@ var generateCoreQuickMethod = ({
|
|
|
5249
5280
|
};
|
|
5250
5281
|
};
|
|
5251
5282
|
var newCoreTxBlock = (builder, initTxBlock) => {
|
|
5252
|
-
const txBlock = initTxBlock instanceof
|
|
5283
|
+
const txBlock = initTxBlock instanceof Transaction ? new SuiKitTxBlock(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock();
|
|
5253
5284
|
const normalMethod = generateCoreNormalMethod({
|
|
5254
5285
|
builder,
|
|
5255
5286
|
txBlock
|
|
@@ -5277,8 +5308,8 @@ var newCoreTxBlock = (builder, initTxBlock) => {
|
|
|
5277
5308
|
};
|
|
5278
5309
|
|
|
5279
5310
|
// src/builders/spoolBuilder.ts
|
|
5280
|
-
import {
|
|
5281
|
-
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui
|
|
5311
|
+
import { Transaction as Transaction2 } from "@mysten/sui/transactions";
|
|
5312
|
+
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui/utils";
|
|
5282
5313
|
import { SuiTxBlock as SuiKitTxBlock2 } from "@scallop-io/sui-kit";
|
|
5283
5314
|
var requireStakeAccountIds = async (...params) => {
|
|
5284
5315
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
@@ -5314,7 +5345,7 @@ var stakeHelper = async (builder, txBlock, stakeAccount, coinName, amount, sende
|
|
|
5314
5345
|
}
|
|
5315
5346
|
txBlock.transferObjects([leftCoin], sender);
|
|
5316
5347
|
return totalAmount;
|
|
5317
|
-
} catch (
|
|
5348
|
+
} catch (_e) {
|
|
5318
5349
|
return 0;
|
|
5319
5350
|
}
|
|
5320
5351
|
};
|
|
@@ -5471,7 +5502,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5471
5502
|
};
|
|
5472
5503
|
};
|
|
5473
5504
|
var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
5474
|
-
const txBlock = initTxBlock instanceof
|
|
5505
|
+
const txBlock = initTxBlock instanceof Transaction2 ? new SuiKitTxBlock2(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock2();
|
|
5475
5506
|
const normalMethod = generateSpoolNormalMethod({
|
|
5476
5507
|
builder,
|
|
5477
5508
|
txBlock
|
|
@@ -5499,8 +5530,8 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
|
5499
5530
|
};
|
|
5500
5531
|
|
|
5501
5532
|
// src/builders/borrowIncentiveBuilder.ts
|
|
5502
|
-
import {
|
|
5503
|
-
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui
|
|
5533
|
+
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
5534
|
+
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID5 } from "@mysten/sui/utils";
|
|
5504
5535
|
import { SuiTxBlock as SuiKitTxBlock3 } from "@scallop-io/sui-kit";
|
|
5505
5536
|
var requireObligationInfo2 = async (...params) => {
|
|
5506
5537
|
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
@@ -5701,7 +5732,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
5701
5732
|
};
|
|
5702
5733
|
};
|
|
5703
5734
|
var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
|
|
5704
|
-
const txBlock = initTxBlock instanceof
|
|
5735
|
+
const txBlock = initTxBlock instanceof Transaction3 ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
|
|
5705
5736
|
const normalMethod = generateBorrowIncentiveNormalMethod({
|
|
5706
5737
|
builder,
|
|
5707
5738
|
txBlock
|
|
@@ -5731,7 +5762,7 @@ var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
|
|
|
5731
5762
|
// src/builders/vescaBuilder.ts
|
|
5732
5763
|
import {
|
|
5733
5764
|
SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID6,
|
|
5734
|
-
|
|
5765
|
+
Transaction as Transaction4,
|
|
5735
5766
|
SuiTxBlock as SuiKitTxBlock4
|
|
5736
5767
|
} from "@scallop-io/sui-kit";
|
|
5737
5768
|
var requireVeSca = async (...params) => {
|
|
@@ -5981,7 +6012,7 @@ var generateQuickVeScaMethod = ({
|
|
|
5981
6012
|
};
|
|
5982
6013
|
};
|
|
5983
6014
|
var newVeScaTxBlock = (builder, initTxBlock) => {
|
|
5984
|
-
const txBlock = initTxBlock instanceof
|
|
6015
|
+
const txBlock = initTxBlock instanceof Transaction4 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
|
|
5985
6016
|
const normalMethod = generateNormalVeScaMethod({
|
|
5986
6017
|
builder,
|
|
5987
6018
|
txBlock
|
|
@@ -6012,7 +6043,7 @@ var newVeScaTxBlock = (builder, initTxBlock) => {
|
|
|
6012
6043
|
import {
|
|
6013
6044
|
SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID7,
|
|
6014
6045
|
SuiTxBlock as SuiKitTxBlock5,
|
|
6015
|
-
|
|
6046
|
+
Transaction as Transaction5
|
|
6016
6047
|
} from "@scallop-io/sui-kit";
|
|
6017
6048
|
var generateReferralNormalMethod = ({
|
|
6018
6049
|
builder,
|
|
@@ -6035,7 +6066,7 @@ var generateReferralNormalMethod = ({
|
|
|
6035
6066
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
6036
6067
|
[
|
|
6037
6068
|
referralIds.referralBindings,
|
|
6038
|
-
txBlock.pure(veScaKeyId),
|
|
6069
|
+
txBlock.pure.id(veScaKeyId),
|
|
6039
6070
|
veScaTable,
|
|
6040
6071
|
SUI_CLOCK_OBJECT_ID7
|
|
6041
6072
|
],
|
|
@@ -6106,7 +6137,7 @@ var generateReferralQuickMethod = ({
|
|
|
6106
6137
|
builder.utils.parseCoinType(coinName)
|
|
6107
6138
|
);
|
|
6108
6139
|
txBlock.mergeCoins(rewardCoin, coins.slice(0, 500));
|
|
6109
|
-
} catch (
|
|
6140
|
+
} catch (_e) {
|
|
6110
6141
|
} finally {
|
|
6111
6142
|
objToTransfer.push(rewardCoin);
|
|
6112
6143
|
}
|
|
@@ -6119,7 +6150,7 @@ var generateReferralQuickMethod = ({
|
|
|
6119
6150
|
};
|
|
6120
6151
|
};
|
|
6121
6152
|
var newReferralTxBlock = (builder, initTxBlock) => {
|
|
6122
|
-
const txBlock = initTxBlock instanceof
|
|
6153
|
+
const txBlock = initTxBlock instanceof Transaction5 ? new SuiKitTxBlock5(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock5();
|
|
6123
6154
|
const normalMethod = generateReferralNormalMethod({
|
|
6124
6155
|
builder,
|
|
6125
6156
|
txBlock
|
|
@@ -6147,7 +6178,7 @@ var newReferralTxBlock = (builder, initTxBlock) => {
|
|
|
6147
6178
|
};
|
|
6148
6179
|
|
|
6149
6180
|
// src/builders/loyaltyProgramBuilder.ts
|
|
6150
|
-
import {
|
|
6181
|
+
import { Transaction as Transaction6 } from "@mysten/sui/transactions";
|
|
6151
6182
|
import { SuiTxBlock as SuiKitTxBlock6 } from "@scallop-io/sui-kit";
|
|
6152
6183
|
var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
6153
6184
|
const loyaltyProgramIds = {
|
|
@@ -6188,7 +6219,7 @@ var generateLoyaltyProgramQuickMethod = ({
|
|
|
6188
6219
|
};
|
|
6189
6220
|
};
|
|
6190
6221
|
var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
6191
|
-
const txBlock = initTxBlock instanceof
|
|
6222
|
+
const txBlock = initTxBlock instanceof Transaction6 ? new SuiKitTxBlock6(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock6();
|
|
6192
6223
|
const normalMethod = generateLoyaltyProgramNormalMethod({
|
|
6193
6224
|
builder,
|
|
6194
6225
|
txBlock
|
|
@@ -6216,10 +6247,7 @@ var newLoyaltyProgramTxBlock = (builder, initTxBlock) => {
|
|
|
6216
6247
|
};
|
|
6217
6248
|
|
|
6218
6249
|
// src/builders/sCoinBuilder.ts
|
|
6219
|
-
import {
|
|
6220
|
-
TransactionBlock as TransactionBlock7,
|
|
6221
|
-
SuiTxBlock as SuiKitTxBlock7
|
|
6222
|
-
} from "@scallop-io/sui-kit";
|
|
6250
|
+
import { Transaction as Transaction7, SuiTxBlock as SuiKitTxBlock7 } from "@scallop-io/sui-kit";
|
|
6223
6251
|
var generateSCoinNormalMethod = ({
|
|
6224
6252
|
builder,
|
|
6225
6253
|
txBlock
|
|
@@ -6280,7 +6308,7 @@ var generateSCoinQuickMethod = ({
|
|
|
6280
6308
|
};
|
|
6281
6309
|
};
|
|
6282
6310
|
var newSCoinTxBlock = (builder, initTxBlock) => {
|
|
6283
|
-
const txBlock = initTxBlock instanceof
|
|
6311
|
+
const txBlock = initTxBlock instanceof Transaction7 ? new SuiKitTxBlock7(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock7();
|
|
6284
6312
|
const normalMethod = generateSCoinNormalMethod({
|
|
6285
6313
|
builder,
|
|
6286
6314
|
txBlock
|
|
@@ -6512,8 +6540,8 @@ var ScallopIndexer = class {
|
|
|
6512
6540
|
};
|
|
6513
6541
|
|
|
6514
6542
|
// src/queries/sCoinQuery.ts
|
|
6515
|
-
import { bcs as bcs2 } from "@mysten/sui
|
|
6516
|
-
import
|
|
6543
|
+
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
6544
|
+
import assert2 from "assert";
|
|
6517
6545
|
import BigNumber7 from "bignumber.js";
|
|
6518
6546
|
var getSCoinTotalSupply = async ({
|
|
6519
6547
|
utils
|
|
@@ -6534,8 +6562,8 @@ var getSCoinTotalSupply = async ({
|
|
|
6534
6562
|
if (results && results[0].returnValues) {
|
|
6535
6563
|
const value = Uint8Array.from(results[0].returnValues[0][0]);
|
|
6536
6564
|
const type = results[0].returnValues[0][1];
|
|
6537
|
-
|
|
6538
|
-
return BigNumber7(bcs2.
|
|
6565
|
+
assert2(type === "u64", "Result type is not u64");
|
|
6566
|
+
return BigNumber7(bcs2.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
|
|
6539
6567
|
}
|
|
6540
6568
|
return 0;
|
|
6541
6569
|
};
|
|
@@ -6605,7 +6633,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
6605
6633
|
};
|
|
6606
6634
|
|
|
6607
6635
|
// src/models/scallopQuery.ts
|
|
6608
|
-
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui
|
|
6636
|
+
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
|
|
6609
6637
|
var ScallopQuery = class {
|
|
6610
6638
|
constructor(params, instance) {
|
|
6611
6639
|
this.params = params;
|
|
@@ -6626,7 +6654,8 @@ var ScallopQuery = class {
|
|
|
6626
6654
|
this.address = new ScallopAddress(
|
|
6627
6655
|
{
|
|
6628
6656
|
id: params?.addressesId || ADDRESSES_ID,
|
|
6629
|
-
network: params?.networkType
|
|
6657
|
+
network: params?.networkType,
|
|
6658
|
+
forceInterface: params?.forceAddressesInterface
|
|
6630
6659
|
},
|
|
6631
6660
|
{
|
|
6632
6661
|
cache: this.cache
|
|
@@ -6637,7 +6666,36 @@ var ScallopQuery = class {
|
|
|
6637
6666
|
});
|
|
6638
6667
|
}
|
|
6639
6668
|
this.indexer = instance?.indexer ?? new ScallopIndexer(this.params, { cache: this.cache });
|
|
6669
|
+
this.queryMarket = withIndexerFallback.call(this, this.queryMarket);
|
|
6670
|
+
this.getMarketPools = withIndexerFallback.call(this, this.getMarketPools);
|
|
6671
|
+
this.getMarketPool = withIndexerFallback.call(this, this.getMarketPool);
|
|
6672
|
+
this.getMarketCollaterals = withIndexerFallback.call(
|
|
6673
|
+
this,
|
|
6674
|
+
this.getMarketCollaterals
|
|
6675
|
+
);
|
|
6676
|
+
this.getMarketCollateral = withIndexerFallback.call(
|
|
6677
|
+
this,
|
|
6678
|
+
this.getMarketCollateral
|
|
6679
|
+
);
|
|
6680
|
+
this.getSpools = withIndexerFallback.call(this, this.getSpools);
|
|
6681
|
+
this.getSpool = withIndexerFallback.call(this, this.getSpool);
|
|
6682
|
+
this.getBorrowIncentivePools = withIndexerFallback.call(
|
|
6683
|
+
this,
|
|
6684
|
+
this.getBorrowIncentivePools
|
|
6685
|
+
);
|
|
6686
|
+
this.getLendings = withIndexerFallback.call(this, this.getLendings);
|
|
6687
|
+
this.getLending = withIndexerFallback.call(this, this.getLending);
|
|
6688
|
+
this.getObligationAccounts = withIndexerFallback.call(
|
|
6689
|
+
this,
|
|
6690
|
+
this.getObligationAccounts
|
|
6691
|
+
);
|
|
6692
|
+
this.getObligationAccount = withIndexerFallback.call(
|
|
6693
|
+
this,
|
|
6694
|
+
this.getObligationAccount
|
|
6695
|
+
);
|
|
6696
|
+
this.getTvl = withIndexerFallback.call(this, this.getTvl);
|
|
6640
6697
|
}
|
|
6698
|
+
/* ========================================================== */
|
|
6641
6699
|
/**
|
|
6642
6700
|
* Request the scallop API to initialize data.
|
|
6643
6701
|
*
|
|
@@ -7096,6 +7154,7 @@ var ScallopQuery = class {
|
|
|
7096
7154
|
};
|
|
7097
7155
|
|
|
7098
7156
|
// src/models/scallopBuilder.ts
|
|
7157
|
+
import { SuiClient as SuiClientV0 } from "@mysten/sui.js/client";
|
|
7099
7158
|
var ScallopBuilder = class {
|
|
7100
7159
|
constructor(params, instance) {
|
|
7101
7160
|
this.suiKit = instance?.suiKit ?? new SuiKit5(params);
|
|
@@ -7117,7 +7176,8 @@ var ScallopBuilder = class {
|
|
|
7117
7176
|
this.address = new ScallopAddress(
|
|
7118
7177
|
{
|
|
7119
7178
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7120
|
-
network: params?.networkType
|
|
7179
|
+
network: params?.networkType,
|
|
7180
|
+
forceInterface: params?.forceAddressesInterface
|
|
7121
7181
|
},
|
|
7122
7182
|
{
|
|
7123
7183
|
cache: this.cache
|
|
@@ -7136,6 +7196,9 @@ var ScallopBuilder = class {
|
|
|
7136
7196
|
);
|
|
7137
7197
|
}
|
|
7138
7198
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
7199
|
+
this.oldSuiClient = new SuiClientV0({
|
|
7200
|
+
url: this.suiKit.suiInteractor.currentFullNode
|
|
7201
|
+
});
|
|
7139
7202
|
}
|
|
7140
7203
|
/**
|
|
7141
7204
|
* Request the scallop API to initialize data.
|
|
@@ -7264,8 +7327,8 @@ var ScallopClient = class {
|
|
|
7264
7327
|
this.address = new ScallopAddress(
|
|
7265
7328
|
{
|
|
7266
7329
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7267
|
-
|
|
7268
|
-
|
|
7330
|
+
network: params?.networkType,
|
|
7331
|
+
forceInterface: params?.forceAddressesInterface
|
|
7269
7332
|
},
|
|
7270
7333
|
{
|
|
7271
7334
|
cache: this.cache
|
|
@@ -7824,7 +7887,7 @@ var ScallopClient = class {
|
|
|
7824
7887
|
if (sCoin) {
|
|
7825
7888
|
sCoins2.push(sCoin);
|
|
7826
7889
|
}
|
|
7827
|
-
} catch (
|
|
7890
|
+
} catch (_e) {
|
|
7828
7891
|
}
|
|
7829
7892
|
}
|
|
7830
7893
|
}
|
|
@@ -7865,7 +7928,7 @@ var ScallopClient = class {
|
|
|
7865
7928
|
if (!scaCoin)
|
|
7866
7929
|
return;
|
|
7867
7930
|
scaCoins.push(scaCoin);
|
|
7868
|
-
} catch (
|
|
7931
|
+
} catch (_e) {
|
|
7869
7932
|
}
|
|
7870
7933
|
})
|
|
7871
7934
|
);
|