@scallop-io/sui-scallop-sdk 0.44.13 → 0.44.15
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/constants/common.d.ts +1 -1
- package/dist/index.js +97 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -43
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -2
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopQuery.d.ts +12 -3
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/spoolQuery.d.ts +3 -0
- package/dist/types/builder/borrowIncentive.d.ts +4 -4
- package/dist/types/query/portfolio.d.ts +2 -1
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +12 -8
- package/src/builders/spoolBuilder.ts +2 -2
- package/src/constants/common.ts +8 -1
- package/src/constants/enum.ts +6 -0
- package/src/models/scallopAddress.ts +16 -0
- package/src/models/scallopBuilder.ts +5 -5
- package/src/models/scallopClient.ts +8 -26
- package/src/queries/portfolioQuery.ts +5 -0
- package/src/queries/spoolQuery.ts +36 -0
- package/src/types/builder/borrowIncentive.ts +2 -6
- package/src/types/query/portfolio.ts +4 -1
package/dist/index.mjs
CHANGED
|
@@ -30,7 +30,14 @@ var SUPPORT_COLLATERALS = [
|
|
|
30
30
|
"hasui",
|
|
31
31
|
"vsui"
|
|
32
32
|
];
|
|
33
|
-
var SUPPORT_SPOOLS = [
|
|
33
|
+
var SUPPORT_SPOOLS = [
|
|
34
|
+
"ssui",
|
|
35
|
+
"susdc",
|
|
36
|
+
"susdt",
|
|
37
|
+
"safsui",
|
|
38
|
+
"shasui",
|
|
39
|
+
"svsui"
|
|
40
|
+
];
|
|
34
41
|
var SUPPORT_SPOOLS_REWARDS = ["sui"];
|
|
35
42
|
var SUPPORT_BORROW_INCENTIVE_POOLS = ["sui", "usdc", "usdt"];
|
|
36
43
|
var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui"];
|
|
@@ -104,12 +111,18 @@ var marketCoins = {
|
|
|
104
111
|
var stakeMarketCoins = {
|
|
105
112
|
ssui: "ssui",
|
|
106
113
|
susdc: "susdc",
|
|
107
|
-
susdt: "susdt"
|
|
114
|
+
susdt: "susdt",
|
|
115
|
+
safsui: "safsui",
|
|
116
|
+
shasui: "shasui",
|
|
117
|
+
svsui: "svsui"
|
|
108
118
|
};
|
|
109
119
|
var spoolRewardCoins = {
|
|
110
120
|
ssui: "sui",
|
|
111
121
|
susdc: "sui",
|
|
112
|
-
susdt: "sui"
|
|
122
|
+
susdt: "sui",
|
|
123
|
+
safsui: "sui",
|
|
124
|
+
shasui: "sui",
|
|
125
|
+
svsui: "sui"
|
|
113
126
|
};
|
|
114
127
|
var borrowIncentiveRewardCoins = {
|
|
115
128
|
sui: "sui",
|
|
@@ -337,6 +350,22 @@ var EMPTY_ADDRESSES = {
|
|
|
337
350
|
susdc: {
|
|
338
351
|
id: "",
|
|
339
352
|
rewardPoolId: ""
|
|
353
|
+
},
|
|
354
|
+
susdt: {
|
|
355
|
+
id: "",
|
|
356
|
+
rewardPoolId: ""
|
|
357
|
+
},
|
|
358
|
+
safsui: {
|
|
359
|
+
id: "",
|
|
360
|
+
rewardPoolId: ""
|
|
361
|
+
},
|
|
362
|
+
shasui: {
|
|
363
|
+
id: "",
|
|
364
|
+
rewardPoolId: ""
|
|
365
|
+
},
|
|
366
|
+
svsui: {
|
|
367
|
+
id: "",
|
|
368
|
+
rewardPoolId: ""
|
|
340
369
|
}
|
|
341
370
|
}
|
|
342
371
|
},
|
|
@@ -1943,7 +1972,10 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
1943
1972
|
const stakeAccounts = {
|
|
1944
1973
|
ssui: [],
|
|
1945
1974
|
susdc: [],
|
|
1946
|
-
susdt: []
|
|
1975
|
+
susdt: [],
|
|
1976
|
+
safsui: [],
|
|
1977
|
+
shasui: [],
|
|
1978
|
+
svsui: []
|
|
1947
1979
|
};
|
|
1948
1980
|
const stakeMarketCoinTypes = Object.keys(stakeAccounts).reduce(
|
|
1949
1981
|
(types, stakeMarketCoinName) => {
|
|
@@ -2000,6 +2032,39 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
2000
2032
|
points,
|
|
2001
2033
|
totalPoints
|
|
2002
2034
|
});
|
|
2035
|
+
} else if (normalizeStructTag3(type) === stakeMarketCoinTypes.safsui) {
|
|
2036
|
+
stakeAccounts.safsui.push({
|
|
2037
|
+
id,
|
|
2038
|
+
type: normalizeStructTag3(type),
|
|
2039
|
+
stakePoolId,
|
|
2040
|
+
stakeType: normalizeStructTag3(stakeType),
|
|
2041
|
+
staked,
|
|
2042
|
+
index,
|
|
2043
|
+
points,
|
|
2044
|
+
totalPoints
|
|
2045
|
+
});
|
|
2046
|
+
} else if (normalizeStructTag3(type) === stakeMarketCoinTypes.shasui) {
|
|
2047
|
+
stakeAccounts.shasui.push({
|
|
2048
|
+
id,
|
|
2049
|
+
type: normalizeStructTag3(type),
|
|
2050
|
+
stakePoolId,
|
|
2051
|
+
stakeType: normalizeStructTag3(stakeType),
|
|
2052
|
+
staked,
|
|
2053
|
+
index,
|
|
2054
|
+
points,
|
|
2055
|
+
totalPoints
|
|
2056
|
+
});
|
|
2057
|
+
} else if (normalizeStructTag3(type) === stakeMarketCoinTypes.svsui) {
|
|
2058
|
+
stakeAccounts.svsui.push({
|
|
2059
|
+
id,
|
|
2060
|
+
type: normalizeStructTag3(type),
|
|
2061
|
+
stakePoolId,
|
|
2062
|
+
stakeType: normalizeStructTag3(stakeType),
|
|
2063
|
+
staked,
|
|
2064
|
+
index,
|
|
2065
|
+
points,
|
|
2066
|
+
totalPoints
|
|
2067
|
+
});
|
|
2003
2068
|
}
|
|
2004
2069
|
}
|
|
2005
2070
|
}
|
|
@@ -2354,6 +2419,9 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2354
2419
|
);
|
|
2355
2420
|
const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
|
|
2356
2421
|
const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
|
|
2422
|
+
const marketCoinPrice = BigNumber3(coinPrice ?? 0).multipliedBy(
|
|
2423
|
+
marketPool?.conversionRate ?? 1
|
|
2424
|
+
);
|
|
2357
2425
|
const unstakedMarketAmount = BigNumber3(marketCoinAmount);
|
|
2358
2426
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
2359
2427
|
const availableSupplyAmount = BigNumber3(coinAmount);
|
|
@@ -2373,6 +2441,8 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2373
2441
|
marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
|
|
2374
2442
|
coinDecimal,
|
|
2375
2443
|
coinPrice: coinPrice ?? 0,
|
|
2444
|
+
conversionRate: marketPool?.conversionRate ?? 1,
|
|
2445
|
+
marketCoinPrice: marketCoinPrice.toNumber(),
|
|
2376
2446
|
supplyApr: marketPool?.supplyApr ?? 0,
|
|
2377
2447
|
supplyApy: marketPool?.supplyApy ?? 0,
|
|
2378
2448
|
rewardApr: spool?.rewardApr ?? 0,
|
|
@@ -4225,8 +4295,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
4225
4295
|
obligationAccessStore: builder.address.get("core.obligationAccessStore")
|
|
4226
4296
|
};
|
|
4227
4297
|
return {
|
|
4228
|
-
stakeObligation: (obligationId, obligaionKey
|
|
4229
|
-
const rewardCoinName =
|
|
4298
|
+
stakeObligation: (obligationId, obligaionKey) => {
|
|
4299
|
+
const rewardCoinName = "sui";
|
|
4230
4300
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
4231
4301
|
txBlock.moveCall(
|
|
4232
4302
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
@@ -4241,8 +4311,8 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
4241
4311
|
[rewardType]
|
|
4242
4312
|
);
|
|
4243
4313
|
},
|
|
4244
|
-
unstakeObligation: (obligationId, obligaionKey
|
|
4245
|
-
const rewardCoinName =
|
|
4314
|
+
unstakeObligation: (obligationId, obligaionKey) => {
|
|
4315
|
+
const rewardCoinName = "sui";
|
|
4246
4316
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
4247
4317
|
txBlock.moveCall(
|
|
4248
4318
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
@@ -4275,7 +4345,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
4275
4345
|
};
|
|
4276
4346
|
var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
4277
4347
|
return {
|
|
4278
|
-
stakeObligationQuick: async (
|
|
4348
|
+
stakeObligationQuick: async (obligation, obligationKey) => {
|
|
4279
4349
|
const {
|
|
4280
4350
|
obligationId: obligationArg,
|
|
4281
4351
|
obligationKey: obligationtKeyArg,
|
|
@@ -4290,10 +4360,10 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
4290
4360
|
(txn) => txn.kind === "MoveCall" && txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`
|
|
4291
4361
|
);
|
|
4292
4362
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
4293
|
-
txBlock.stakeObligation(obligationArg, obligationtKeyArg
|
|
4363
|
+
txBlock.stakeObligation(obligationArg, obligationtKeyArg);
|
|
4294
4364
|
}
|
|
4295
4365
|
},
|
|
4296
|
-
unstakeObligationQuick: async (
|
|
4366
|
+
unstakeObligationQuick: async (obligation, obligationKey) => {
|
|
4297
4367
|
const {
|
|
4298
4368
|
obligationId: obligationArg,
|
|
4299
4369
|
obligationKey: obligationtKeyArg,
|
|
@@ -4305,7 +4375,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
4305
4375
|
obligationKey
|
|
4306
4376
|
);
|
|
4307
4377
|
if (obligationLocked) {
|
|
4308
|
-
txBlock.unstakeObligation(obligationArg, obligationtKeyArg
|
|
4378
|
+
txBlock.unstakeObligation(obligationArg, obligationtKeyArg);
|
|
4309
4379
|
}
|
|
4310
4380
|
},
|
|
4311
4381
|
claimBorrowIncentiveQuick: async (coinName, obligation, obligationKey) => {
|
|
@@ -4400,14 +4470,14 @@ var ScallopBuilder = class {
|
|
|
4400
4470
|
/**
|
|
4401
4471
|
* Request the scallop API to initialize data.
|
|
4402
4472
|
*
|
|
4403
|
-
* @param
|
|
4473
|
+
* @param force - Whether to force initialization.
|
|
4404
4474
|
*/
|
|
4405
|
-
async init(
|
|
4406
|
-
if (
|
|
4475
|
+
async init(force = false) {
|
|
4476
|
+
if (force || !this.address.getAddresses()) {
|
|
4407
4477
|
await this.address.read();
|
|
4408
4478
|
}
|
|
4409
|
-
await this.query.init(
|
|
4410
|
-
await this.utils.init(
|
|
4479
|
+
await this.query.init(force);
|
|
4480
|
+
await this.utils.init(force);
|
|
4411
4481
|
}
|
|
4412
4482
|
/**
|
|
4413
4483
|
* Create a scallop txBlock instance that enhances transaction block.
|
|
@@ -4732,11 +4802,7 @@ var ScallopClient = class {
|
|
|
4732
4802
|
txBlock.setSender(sender);
|
|
4733
4803
|
const availableStake = SUPPORT_BORROW_INCENTIVE_POOLS.includes(poolCoinName);
|
|
4734
4804
|
if (sign && availableStake) {
|
|
4735
|
-
await txBlock.unstakeObligationQuick(
|
|
4736
|
-
poolCoinName,
|
|
4737
|
-
obligationId,
|
|
4738
|
-
obligationKey
|
|
4739
|
-
);
|
|
4805
|
+
await txBlock.unstakeObligationQuick(obligationId, obligationKey);
|
|
4740
4806
|
}
|
|
4741
4807
|
const coin = await txBlock.borrowQuick(
|
|
4742
4808
|
amount,
|
|
@@ -4746,11 +4812,7 @@ var ScallopClient = class {
|
|
|
4746
4812
|
);
|
|
4747
4813
|
txBlock.transferObjects([coin], sender);
|
|
4748
4814
|
if (sign && availableStake) {
|
|
4749
|
-
await txBlock.stakeObligationQuick(
|
|
4750
|
-
poolCoinName,
|
|
4751
|
-
obligationId,
|
|
4752
|
-
obligationKey
|
|
4753
|
-
);
|
|
4815
|
+
await txBlock.stakeObligationQuick(obligationId, obligationKey);
|
|
4754
4816
|
}
|
|
4755
4817
|
if (sign) {
|
|
4756
4818
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -4776,19 +4838,11 @@ var ScallopClient = class {
|
|
|
4776
4838
|
txBlock.setSender(sender);
|
|
4777
4839
|
const availableStake = SUPPORT_BORROW_INCENTIVE_POOLS.includes(poolCoinName);
|
|
4778
4840
|
if (sign && availableStake) {
|
|
4779
|
-
await txBlock.unstakeObligationQuick(
|
|
4780
|
-
poolCoinName,
|
|
4781
|
-
obligationId,
|
|
4782
|
-
obligationKey
|
|
4783
|
-
);
|
|
4841
|
+
await txBlock.unstakeObligationQuick(obligationId, obligationKey);
|
|
4784
4842
|
}
|
|
4785
4843
|
await txBlock.repayQuick(amount, poolCoinName, obligationId);
|
|
4786
4844
|
if (sign && availableStake) {
|
|
4787
|
-
await txBlock.stakeObligationQuick(
|
|
4788
|
-
poolCoinName,
|
|
4789
|
-
obligationId,
|
|
4790
|
-
obligationKey
|
|
4791
|
-
);
|
|
4845
|
+
await txBlock.stakeObligationQuick(obligationId, obligationKey);
|
|
4792
4846
|
}
|
|
4793
4847
|
if (sign) {
|
|
4794
4848
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -4910,17 +4964,17 @@ var ScallopClient = class {
|
|
|
4910
4964
|
/**
|
|
4911
4965
|
* stake obligaion.
|
|
4912
4966
|
*
|
|
4913
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4914
4967
|
* @param obligaionId - The obligation account object.
|
|
4915
4968
|
* @param obligaionKeyId - The obligation key account object.
|
|
4969
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4916
4970
|
* @param walletAddress - The wallet address of the owner.
|
|
4917
4971
|
* @return Transaction block response or transaction block
|
|
4918
4972
|
*/
|
|
4919
|
-
async stakeObligation(
|
|
4973
|
+
async stakeObligation(obligaionId, obligaionKeyId, sign = true, walletAddress) {
|
|
4920
4974
|
const txBlock = this.builder.createTxBlock();
|
|
4921
4975
|
const sender = walletAddress || this.walletAddress;
|
|
4922
4976
|
txBlock.setSender(sender);
|
|
4923
|
-
await txBlock.stakeObligationQuick(
|
|
4977
|
+
await txBlock.stakeObligationQuick(obligaionId, obligaionKeyId);
|
|
4924
4978
|
if (sign) {
|
|
4925
4979
|
return await this.suiKit.signAndSendTxn(
|
|
4926
4980
|
txBlock
|
|
@@ -4932,17 +4986,17 @@ var ScallopClient = class {
|
|
|
4932
4986
|
/**
|
|
4933
4987
|
* unstake obligaion.
|
|
4934
4988
|
*
|
|
4935
|
-
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4936
4989
|
* @param obligaionId - The obligation account object.
|
|
4937
4990
|
* @param obligaionKeyId - The obligation key account object.
|
|
4991
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4938
4992
|
* @param walletAddress - The wallet address of the owner.
|
|
4939
4993
|
* @return Transaction block response or transaction block
|
|
4940
4994
|
*/
|
|
4941
|
-
async unstakeObligation(
|
|
4995
|
+
async unstakeObligation(obligaionId, obligaionKeyId, sign = true, walletAddress) {
|
|
4942
4996
|
const txBlock = this.builder.createTxBlock();
|
|
4943
4997
|
const sender = walletAddress || this.walletAddress;
|
|
4944
4998
|
txBlock.setSender(sender);
|
|
4945
|
-
await txBlock.unstakeObligationQuick(
|
|
4999
|
+
await txBlock.unstakeObligationQuick(obligaionId, obligaionKeyId);
|
|
4946
5000
|
if (sign) {
|
|
4947
5001
|
return await this.suiKit.signAndSendTxn(
|
|
4948
5002
|
txBlock
|