@scallop-io/sui-scallop-sdk 0.44.1 → 0.44.3
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 +12 -0
- package/dist/constants/common.d.ts +5 -3
- package/dist/constants/enum.d.ts +4 -2
- package/dist/index.js +843 -228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -192
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +33 -2
- package/dist/models/scallopQuery.d.ts +36 -10
- package/dist/models/scallopUtils.d.ts +12 -4
- package/dist/queries/borrowIncentiveQuery.d.ts +24 -0
- package/dist/queries/coreQuery.d.ts +12 -0
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/queries/spoolQuery.d.ts +13 -5
- package/dist/types/address.d.ts +10 -2
- package/dist/types/builder/borrowIncentive.d.ts +31 -0
- package/dist/types/builder/index.d.ts +3 -1
- package/dist/types/constant/common.d.ts +5 -3
- package/dist/types/constant/enum.d.ts +9 -3
- package/dist/types/query/borrowIncentive.d.ts +118 -0
- package/dist/types/query/core.d.ts +1 -0
- package/dist/types/query/index.d.ts +1 -0
- package/dist/types/query/spool.d.ts +12 -13
- package/dist/utils/builder.d.ts +8 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/query.d.ts +33 -10
- package/dist/utils/util.d.ts +15 -1
- package/package.json +12 -12
- package/src/builders/borrowIncentiveBuilder.ts +257 -0
- package/src/builders/coreBuilder.ts +1 -14
- package/src/builders/index.ts +9 -2
- package/src/builders/spoolBuilder.ts +3 -16
- package/src/constants/common.ts +6 -1
- package/src/constants/enum.ts +18 -2
- package/src/models/scallopAddress.ts +47 -0
- package/src/models/scallopClient.ts +104 -2
- package/src/models/scallopQuery.ts +48 -14
- package/src/models/scallopUtils.ts +53 -15
- package/src/queries/borrowIncentiveQuery.ts +166 -0
- package/src/queries/coreQuery.ts +57 -15
- package/src/queries/index.ts +1 -0
- package/src/queries/spoolQuery.ts +78 -62
- package/src/types/address.ts +10 -2
- package/src/types/builder/borrowIncentive.ts +67 -0
- package/src/types/builder/index.ts +5 -1
- package/src/types/builder/spool.ts +0 -1
- package/src/types/constant/common.ts +10 -3
- package/src/types/constant/enum.ts +13 -3
- package/src/types/query/borrowIncentive.ts +150 -0
- package/src/types/query/core.ts +1 -1
- package/src/types/query/index.ts +1 -0
- package/src/types/query/spool.ts +28 -18
- package/src/utils/builder.ts +15 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/query.ts +277 -70
- package/src/utils/util.ts +59 -9
- package/dist/utils/oracle.d.ts +0 -14
- package/src/utils/oracle.ts +0 -36
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,8 @@ var SUPPORT_POOLS = [
|
|
|
12
12
|
"sol",
|
|
13
13
|
"cetus",
|
|
14
14
|
"afsui",
|
|
15
|
-
"hasui"
|
|
15
|
+
"hasui",
|
|
16
|
+
"vsui"
|
|
16
17
|
];
|
|
17
18
|
var SUPPORT_COLLATERALS = [
|
|
18
19
|
"eth",
|
|
@@ -24,10 +25,13 @@ var SUPPORT_COLLATERALS = [
|
|
|
24
25
|
"sol",
|
|
25
26
|
"cetus",
|
|
26
27
|
"afsui",
|
|
27
|
-
"hasui"
|
|
28
|
+
"hasui",
|
|
29
|
+
"vsui"
|
|
28
30
|
];
|
|
29
31
|
var SUPPORT_SPOOLS = ["ssui", "susdc", "susdt"];
|
|
30
|
-
var
|
|
32
|
+
var SUPPORT_SPOOLS_REWARDS = ["sui"];
|
|
33
|
+
var SUPPORT_BORROW_INCENTIVE_POOLS = ["sui", "usdc"];
|
|
34
|
+
var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui"];
|
|
31
35
|
var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
|
|
32
36
|
var SUPPORT_PACKAGES = [
|
|
33
37
|
"coinDecimalsRegistry",
|
|
@@ -56,6 +60,7 @@ var coinDecimals = {
|
|
|
56
60
|
cetus: 9,
|
|
57
61
|
afsui: 9,
|
|
58
62
|
hasui: 9,
|
|
63
|
+
vsui: 9,
|
|
59
64
|
seth: 8,
|
|
60
65
|
sbtc: 8,
|
|
61
66
|
susdc: 6,
|
|
@@ -65,7 +70,8 @@ var coinDecimals = {
|
|
|
65
70
|
ssol: 8,
|
|
66
71
|
scetus: 9,
|
|
67
72
|
safsui: 9,
|
|
68
|
-
shasui: 9
|
|
73
|
+
shasui: 9,
|
|
74
|
+
svsui: 9
|
|
69
75
|
};
|
|
70
76
|
var assetCoins = {
|
|
71
77
|
eth: "eth",
|
|
@@ -77,7 +83,8 @@ var assetCoins = {
|
|
|
77
83
|
sol: "sol",
|
|
78
84
|
cetus: "cetus",
|
|
79
85
|
afsui: "afsui",
|
|
80
|
-
hasui: "hasui"
|
|
86
|
+
hasui: "hasui",
|
|
87
|
+
vsui: "vsui"
|
|
81
88
|
};
|
|
82
89
|
var marketCoins = {
|
|
83
90
|
seth: "seth",
|
|
@@ -89,18 +96,23 @@ var marketCoins = {
|
|
|
89
96
|
ssol: "ssol",
|
|
90
97
|
scetus: "scetus",
|
|
91
98
|
safsui: "safsui",
|
|
92
|
-
shasui: "shasui"
|
|
99
|
+
shasui: "shasui",
|
|
100
|
+
svsui: "svsui"
|
|
93
101
|
};
|
|
94
102
|
var stakeMarketCoins = {
|
|
95
103
|
ssui: "ssui",
|
|
96
104
|
susdc: "susdc",
|
|
97
105
|
susdt: "susdt"
|
|
98
106
|
};
|
|
99
|
-
var
|
|
107
|
+
var spoolRewardCoins = {
|
|
100
108
|
ssui: "sui",
|
|
101
109
|
susdc: "sui",
|
|
102
110
|
susdt: "sui"
|
|
103
111
|
};
|
|
112
|
+
var borrowIncentiveRewardCoins = {
|
|
113
|
+
sui: "sui",
|
|
114
|
+
usdc: "sui"
|
|
115
|
+
};
|
|
104
116
|
var coinIds = {
|
|
105
117
|
sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
106
118
|
eth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
@@ -111,7 +123,8 @@ var coinIds = {
|
|
|
111
123
|
sol: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
112
124
|
cetus: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
113
125
|
afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
114
|
-
hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d"
|
|
126
|
+
hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
127
|
+
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
|
|
115
128
|
};
|
|
116
129
|
var wormholeCoinIds = {
|
|
117
130
|
eth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
@@ -121,6 +134,9 @@ var wormholeCoinIds = {
|
|
|
121
134
|
apt: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
122
135
|
sol: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8"
|
|
123
136
|
};
|
|
137
|
+
var voloCoinIds = {
|
|
138
|
+
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
|
|
139
|
+
};
|
|
124
140
|
|
|
125
141
|
// src/models/scallop.ts
|
|
126
142
|
import { SuiKit as SuiKit5 } from "@scallop-io/sui-kit";
|
|
@@ -134,6 +150,7 @@ var EMPTY_ADDRESSES = {
|
|
|
134
150
|
market: "",
|
|
135
151
|
adminCap: "",
|
|
136
152
|
coinDecimalsRegistry: "",
|
|
153
|
+
obligationAccessStore: "",
|
|
137
154
|
coins: {
|
|
138
155
|
btc: {
|
|
139
156
|
id: "",
|
|
@@ -199,6 +216,45 @@ var EMPTY_ADDRESSES = {
|
|
|
199
216
|
feedObject: ""
|
|
200
217
|
}
|
|
201
218
|
}
|
|
219
|
+
},
|
|
220
|
+
afsui: {
|
|
221
|
+
id: "",
|
|
222
|
+
metaData: "",
|
|
223
|
+
treasury: "",
|
|
224
|
+
oracle: {
|
|
225
|
+
supra: "",
|
|
226
|
+
switchboard: "",
|
|
227
|
+
pyth: {
|
|
228
|
+
feed: "",
|
|
229
|
+
feedObject: ""
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
hasui: {
|
|
234
|
+
id: "",
|
|
235
|
+
metaData: "",
|
|
236
|
+
treasury: "",
|
|
237
|
+
oracle: {
|
|
238
|
+
supra: "",
|
|
239
|
+
switchboard: "",
|
|
240
|
+
pyth: {
|
|
241
|
+
feed: "",
|
|
242
|
+
feedObject: ""
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
vsui: {
|
|
247
|
+
id: "",
|
|
248
|
+
metaData: "",
|
|
249
|
+
treasury: "",
|
|
250
|
+
oracle: {
|
|
251
|
+
supra: "",
|
|
252
|
+
switchboard: "",
|
|
253
|
+
pyth: {
|
|
254
|
+
feed: "",
|
|
255
|
+
feedObject: ""
|
|
256
|
+
}
|
|
257
|
+
}
|
|
202
258
|
}
|
|
203
259
|
},
|
|
204
260
|
oracles: {
|
|
@@ -278,6 +334,13 @@ var EMPTY_ADDRESSES = {
|
|
|
278
334
|
rewardPoolId: ""
|
|
279
335
|
}
|
|
280
336
|
}
|
|
337
|
+
},
|
|
338
|
+
borrowIncentive: {
|
|
339
|
+
id: "",
|
|
340
|
+
adminCap: "",
|
|
341
|
+
query: "",
|
|
342
|
+
incentivePools: "",
|
|
343
|
+
incentiveAccounts: ""
|
|
281
344
|
}
|
|
282
345
|
};
|
|
283
346
|
var ScallopAddress = class {
|
|
@@ -585,7 +648,7 @@ import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui.js/util
|
|
|
585
648
|
import { SuiKit as SuiKit4 } from "@scallop-io/sui-kit";
|
|
586
649
|
|
|
587
650
|
// src/models/scallopUtils.ts
|
|
588
|
-
import { SUI_TYPE_ARG, normalizeStructTag as
|
|
651
|
+
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag3 } from "@mysten/sui.js/utils";
|
|
589
652
|
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
590
653
|
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
591
654
|
|
|
@@ -596,28 +659,18 @@ import { SuiKit } from "@scallop-io/sui-kit";
|
|
|
596
659
|
import { SuiTxBlock as SuiKitTxBlock } from "@scallop-io/sui-kit";
|
|
597
660
|
import BigNumber2 from "bignumber.js";
|
|
598
661
|
|
|
599
|
-
// src/utils/
|
|
600
|
-
var
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
605
|
-
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
606
|
-
});
|
|
607
|
-
if (assetCoinName) {
|
|
608
|
-
const price = feed.price.price * 10 ** feed.price.expo;
|
|
609
|
-
return {
|
|
610
|
-
coinName: assetCoinName,
|
|
611
|
-
price,
|
|
612
|
-
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
613
|
-
};
|
|
614
|
-
} else {
|
|
615
|
-
throw new Error("Invalid feed id");
|
|
662
|
+
// src/utils/builder.ts
|
|
663
|
+
var requireSender = (txBlock) => {
|
|
664
|
+
const sender = txBlock.blockData.sender;
|
|
665
|
+
if (!sender) {
|
|
666
|
+
throw new Error("Sender is required");
|
|
616
667
|
}
|
|
668
|
+
return sender;
|
|
617
669
|
};
|
|
618
670
|
|
|
619
671
|
// src/utils/query.ts
|
|
620
672
|
import BigNumber from "bignumber.js";
|
|
673
|
+
import { normalizeStructTag } from "@mysten/sui.js/utils";
|
|
621
674
|
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
622
675
|
return {
|
|
623
676
|
coinType: "0x" + originMarketPoolData.type.name,
|
|
@@ -744,48 +797,48 @@ var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
|
|
|
744
797
|
depositCoin: depositCoin.toNumber()
|
|
745
798
|
};
|
|
746
799
|
};
|
|
747
|
-
var
|
|
800
|
+
var parseOriginSpoolData = (originSpoolData) => {
|
|
748
801
|
return {
|
|
749
|
-
stakeType: "0x" +
|
|
750
|
-
maxPoint: Number(
|
|
751
|
-
distributedPoint: Number(
|
|
752
|
-
pointPerPeriod: Number(
|
|
753
|
-
period: Number(
|
|
754
|
-
maxStake: Number(
|
|
755
|
-
staked: Number(
|
|
756
|
-
index: Number(
|
|
757
|
-
createdAt: Number(
|
|
758
|
-
lastUpdate: Number(
|
|
802
|
+
stakeType: "0x" + originSpoolData.stakeType.fields.name,
|
|
803
|
+
maxPoint: Number(originSpoolData.maxDistributedPoint),
|
|
804
|
+
distributedPoint: Number(originSpoolData.distributedPoint),
|
|
805
|
+
pointPerPeriod: Number(originSpoolData.distributedPointPerPeriod),
|
|
806
|
+
period: Number(originSpoolData.pointDistributionTime),
|
|
807
|
+
maxStake: Number(originSpoolData.maxStake),
|
|
808
|
+
staked: Number(originSpoolData.stakes),
|
|
809
|
+
index: Number(originSpoolData.index),
|
|
810
|
+
createdAt: Number(originSpoolData.createdAt),
|
|
811
|
+
lastUpdate: Number(originSpoolData.lastUpdate)
|
|
759
812
|
};
|
|
760
813
|
};
|
|
761
|
-
var
|
|
814
|
+
var calculateSpoolData = (parsedSpoolData, stakeMarketCoinPrice, stakeMarketCoinDecimal) => {
|
|
762
815
|
const baseIndexRate = 1e9;
|
|
763
816
|
const distributedPointPerSec = BigNumber(
|
|
764
|
-
|
|
765
|
-
).dividedBy(
|
|
766
|
-
const pointPerSec = BigNumber(
|
|
767
|
-
|
|
817
|
+
parsedSpoolData.pointPerPeriod
|
|
818
|
+
).dividedBy(parsedSpoolData.period);
|
|
819
|
+
const pointPerSec = BigNumber(parsedSpoolData.pointPerPeriod).dividedBy(
|
|
820
|
+
parsedSpoolData.period
|
|
768
821
|
);
|
|
769
|
-
const remainingPeriod = BigNumber(
|
|
770
|
-
const startDate =
|
|
771
|
-
const endDate = remainingPeriod.plus(
|
|
822
|
+
const remainingPeriod = BigNumber(parsedSpoolData.maxPoint).minus(parsedSpoolData.distributedPoint).dividedBy(pointPerSec);
|
|
823
|
+
const startDate = parsedSpoolData.createdAt;
|
|
824
|
+
const endDate = remainingPeriod.plus(parsedSpoolData.lastUpdate).integerValue().toNumber();
|
|
772
825
|
const timeDelta = BigNumber(
|
|
773
|
-
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) -
|
|
774
|
-
).dividedBy(
|
|
775
|
-
const remainingPoints = BigNumber(
|
|
776
|
-
|
|
826
|
+
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedSpoolData.lastUpdate
|
|
827
|
+
).dividedBy(parsedSpoolData.period).toFixed(0);
|
|
828
|
+
const remainingPoints = BigNumber(parsedSpoolData.maxPoint).minus(
|
|
829
|
+
parsedSpoolData.distributedPoint
|
|
777
830
|
);
|
|
778
831
|
const accumulatedPoints = BigNumber.minimum(
|
|
779
|
-
BigNumber(timeDelta).multipliedBy(
|
|
832
|
+
BigNumber(timeDelta).multipliedBy(parsedSpoolData.pointPerPeriod),
|
|
780
833
|
remainingPoints
|
|
781
834
|
);
|
|
782
|
-
const currentPointIndex = BigNumber(
|
|
783
|
-
accumulatedPoints.dividedBy(
|
|
835
|
+
const currentPointIndex = BigNumber(parsedSpoolData.index).plus(
|
|
836
|
+
accumulatedPoints.dividedBy(parsedSpoolData.staked).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedSpoolData.staked) : 0
|
|
784
837
|
);
|
|
785
838
|
const currentTotalDistributedPoint = BigNumber(
|
|
786
|
-
|
|
839
|
+
parsedSpoolData.distributedPoint
|
|
787
840
|
).plus(accumulatedPoints);
|
|
788
|
-
const stakedAmount = BigNumber(
|
|
841
|
+
const stakedAmount = BigNumber(parsedSpoolData.staked);
|
|
789
842
|
const stakedCoin = stakedAmount.shiftedBy(-1 * stakeMarketCoinDecimal);
|
|
790
843
|
const stakedValue = stakedCoin.multipliedBy(stakeMarketCoinPrice);
|
|
791
844
|
return {
|
|
@@ -800,35 +853,154 @@ var calculateStakePoolData = (parsedStakePoolData, stakeMarketCoinPrice, stakeMa
|
|
|
800
853
|
stakedValue: stakedValue.toNumber()
|
|
801
854
|
};
|
|
802
855
|
};
|
|
803
|
-
var
|
|
856
|
+
var parseOriginSpoolRewardPoolData = (originSpoolRewardPoolData) => {
|
|
857
|
+
return {
|
|
858
|
+
claimedRewards: Number(originSpoolRewardPoolData.claimed_rewards),
|
|
859
|
+
exchangeRateNumerator: Number(
|
|
860
|
+
originSpoolRewardPoolData.exchange_rate_numerator
|
|
861
|
+
),
|
|
862
|
+
exchangeRateDenominator: Number(
|
|
863
|
+
originSpoolRewardPoolData.exchange_rate_denominator
|
|
864
|
+
),
|
|
865
|
+
rewards: Number(originSpoolRewardPoolData.rewards),
|
|
866
|
+
spoolId: String(originSpoolRewardPoolData.spool_id)
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
var calculateSpoolRewardPoolData = (parsedSpoolData, parsedSpoolRewardPoolData, calculatedSpoolData, rewardCoinPrice, rewardCoinDecimal) => {
|
|
870
|
+
const rateYearFactor = 365 * 24 * 60 * 60;
|
|
871
|
+
const rewardPerSec = BigNumber(calculatedSpoolData.distributedPointPerSec).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
872
|
+
const totalRewardAmount = BigNumber(parsedSpoolData.maxPoint).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
873
|
+
const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
|
|
874
|
+
const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
|
|
875
|
+
const remaindRewardAmount = BigNumber(parsedSpoolRewardPoolData.rewards);
|
|
876
|
+
const remaindRewardCoin = remaindRewardAmount.shiftedBy(
|
|
877
|
+
-1 * rewardCoinDecimal
|
|
878
|
+
);
|
|
879
|
+
const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
|
|
880
|
+
const claimedRewardAmount = BigNumber(
|
|
881
|
+
parsedSpoolRewardPoolData.claimedRewards
|
|
882
|
+
);
|
|
883
|
+
const claimedRewardCoin = claimedRewardAmount.shiftedBy(
|
|
884
|
+
-1 * rewardCoinDecimal
|
|
885
|
+
);
|
|
886
|
+
const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
|
|
887
|
+
const rewardValueForYear = BigNumber(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
|
|
888
|
+
const rewardRate = rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).toNumber() : Infinity;
|
|
889
|
+
return {
|
|
890
|
+
rewardApr: rewardRate,
|
|
891
|
+
totalRewardAmount: totalRewardAmount.toNumber(),
|
|
892
|
+
totalRewardCoin: totalRewardCoin.toNumber(),
|
|
893
|
+
totalRewardValue: totalRewardValue.toNumber(),
|
|
894
|
+
remaindRewardAmount: remaindRewardAmount.toNumber(),
|
|
895
|
+
remaindRewardCoin: remaindRewardCoin.toNumber(),
|
|
896
|
+
remaindRewardValue: remaindRewardValue.toNumber(),
|
|
897
|
+
claimedRewardAmount: claimedRewardAmount.toNumber(),
|
|
898
|
+
claimedRewardCoin: claimedRewardCoin.toNumber(),
|
|
899
|
+
claimedRewardValue: claimedRewardValue.toNumber(),
|
|
900
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
901
|
+
};
|
|
902
|
+
};
|
|
903
|
+
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
904
|
+
return {
|
|
905
|
+
poolType: normalizeStructTag(originBorrowIncentivePoolData.pool_type.name),
|
|
906
|
+
maxPoint: Number(originBorrowIncentivePoolData.max_distributed_point),
|
|
907
|
+
distributedPoint: Number(originBorrowIncentivePoolData.distributed_point),
|
|
908
|
+
pointPerPeriod: Number(
|
|
909
|
+
originBorrowIncentivePoolData.distributed_point_per_period
|
|
910
|
+
),
|
|
911
|
+
period: Number(originBorrowIncentivePoolData.point_distribution_time),
|
|
912
|
+
maxStake: Number(originBorrowIncentivePoolData.max_stakes),
|
|
913
|
+
staked: Number(originBorrowIncentivePoolData.stakes),
|
|
914
|
+
index: Number(originBorrowIncentivePoolData.index),
|
|
915
|
+
createdAt: Number(originBorrowIncentivePoolData.created_at),
|
|
916
|
+
lastUpdate: Number(originBorrowIncentivePoolData.last_update)
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
var calculateBorrowIncentivePoolData = (parsedBorrowIncentivePoolData, borrowIncentiveCoinPrice, borrowIncentiveCoinDecimal) => {
|
|
920
|
+
const baseIndexRate = 1e9;
|
|
921
|
+
const distributedPointPerSec = BigNumber(
|
|
922
|
+
parsedBorrowIncentivePoolData.pointPerPeriod
|
|
923
|
+
).dividedBy(parsedBorrowIncentivePoolData.period);
|
|
924
|
+
const pointPerSec = BigNumber(
|
|
925
|
+
parsedBorrowIncentivePoolData.pointPerPeriod
|
|
926
|
+
).dividedBy(parsedBorrowIncentivePoolData.period);
|
|
927
|
+
const remainingPeriod = BigNumber(parsedBorrowIncentivePoolData.maxPoint).minus(parsedBorrowIncentivePoolData.distributedPoint).dividedBy(pointPerSec);
|
|
928
|
+
const startDate = parsedBorrowIncentivePoolData.createdAt;
|
|
929
|
+
const endDate = remainingPeriod.plus(parsedBorrowIncentivePoolData.lastUpdate).integerValue().toNumber();
|
|
930
|
+
const timeDelta = BigNumber(
|
|
931
|
+
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedBorrowIncentivePoolData.lastUpdate
|
|
932
|
+
).dividedBy(parsedBorrowIncentivePoolData.period).toFixed(0);
|
|
933
|
+
const remainingPoints = BigNumber(
|
|
934
|
+
parsedBorrowIncentivePoolData.maxPoint
|
|
935
|
+
).minus(parsedBorrowIncentivePoolData.distributedPoint);
|
|
936
|
+
const accumulatedPoints = BigNumber.minimum(
|
|
937
|
+
BigNumber(timeDelta).multipliedBy(
|
|
938
|
+
parsedBorrowIncentivePoolData.pointPerPeriod
|
|
939
|
+
),
|
|
940
|
+
remainingPoints
|
|
941
|
+
);
|
|
942
|
+
const currentPointIndex = BigNumber(parsedBorrowIncentivePoolData.index).plus(
|
|
943
|
+
accumulatedPoints.dividedBy(parsedBorrowIncentivePoolData.staked).isFinite() ? BigNumber(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedBorrowIncentivePoolData.staked) : 0
|
|
944
|
+
);
|
|
945
|
+
const currentTotalDistributedPoint = BigNumber(
|
|
946
|
+
parsedBorrowIncentivePoolData.distributedPoint
|
|
947
|
+
).plus(accumulatedPoints);
|
|
948
|
+
const stakedAmount = BigNumber(parsedBorrowIncentivePoolData.staked);
|
|
949
|
+
const stakedCoin = stakedAmount.shiftedBy(-1 * borrowIncentiveCoinDecimal);
|
|
950
|
+
const stakedValue = stakedCoin.multipliedBy(borrowIncentiveCoinPrice);
|
|
951
|
+
return {
|
|
952
|
+
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
953
|
+
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
954
|
+
currentPointIndex: currentPointIndex.toNumber(),
|
|
955
|
+
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
956
|
+
startDate: new Date(startDate * 1e3),
|
|
957
|
+
endDate: new Date(endDate * 1e3),
|
|
958
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
959
|
+
stakedCoin: stakedCoin.toNumber(),
|
|
960
|
+
stakedValue: stakedValue.toNumber()
|
|
961
|
+
};
|
|
962
|
+
};
|
|
963
|
+
var parseOriginBorrowIncentiveRewardPoolData = (originBorrowIncentiveRewardPoolData) => {
|
|
804
964
|
return {
|
|
805
|
-
|
|
806
|
-
|
|
965
|
+
rewardType: normalizeStructTag(
|
|
966
|
+
originBorrowIncentiveRewardPoolData.reward_type.name
|
|
967
|
+
),
|
|
968
|
+
claimedRewards: Number(originBorrowIncentiveRewardPoolData.claimed_rewards),
|
|
969
|
+
exchangeRateNumerator: Number(
|
|
970
|
+
originBorrowIncentiveRewardPoolData.exchange_rate_numerator
|
|
971
|
+
),
|
|
807
972
|
exchangeRateDenominator: Number(
|
|
808
|
-
|
|
973
|
+
originBorrowIncentiveRewardPoolData.exchange_rate_denominator
|
|
809
974
|
),
|
|
810
|
-
|
|
811
|
-
|
|
975
|
+
remainingRewards: Number(
|
|
976
|
+
originBorrowIncentiveRewardPoolData.remaining_reward
|
|
977
|
+
)
|
|
812
978
|
};
|
|
813
979
|
};
|
|
814
|
-
var
|
|
980
|
+
var calculateBorrowIncentiveRewardPoolData = (parsedBorrowIncentivePoolData, parsedBorrowIncentiveRewardPoolData, calculatedBorrowIncentivePoolData, rewardCoinPrice, rewardCoinDecimal) => {
|
|
815
981
|
const rateYearFactor = 365 * 24 * 60 * 60;
|
|
816
|
-
const rewardPerSec = BigNumber(
|
|
817
|
-
|
|
982
|
+
const rewardPerSec = BigNumber(
|
|
983
|
+
calculatedBorrowIncentivePoolData.distributedPointPerSec
|
|
984
|
+
).multipliedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateNumerator).dividedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateDenominator);
|
|
985
|
+
const totalRewardAmount = BigNumber(parsedBorrowIncentivePoolData.maxPoint).multipliedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateNumerator).dividedBy(parsedBorrowIncentiveRewardPoolData.exchangeRateDenominator);
|
|
818
986
|
const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
|
|
819
987
|
const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
|
|
820
|
-
const remaindRewardAmount = BigNumber(
|
|
988
|
+
const remaindRewardAmount = BigNumber(
|
|
989
|
+
parsedBorrowIncentiveRewardPoolData.remainingRewards
|
|
990
|
+
);
|
|
821
991
|
const remaindRewardCoin = remaindRewardAmount.shiftedBy(
|
|
822
992
|
-1 * rewardCoinDecimal
|
|
823
993
|
);
|
|
824
994
|
const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
|
|
825
|
-
const claimedRewardAmount = BigNumber(
|
|
995
|
+
const claimedRewardAmount = BigNumber(
|
|
996
|
+
parsedBorrowIncentiveRewardPoolData.claimedRewards
|
|
997
|
+
);
|
|
826
998
|
const claimedRewardCoin = claimedRewardAmount.shiftedBy(
|
|
827
999
|
-1 * rewardCoinDecimal
|
|
828
1000
|
);
|
|
829
1001
|
const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
|
|
830
1002
|
const rewardValueForYear = BigNumber(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
|
|
831
|
-
const rewardRate = rewardValueForYear.dividedBy(
|
|
1003
|
+
const rewardRate = rewardValueForYear.dividedBy(calculatedBorrowIncentivePoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedBorrowIncentivePoolData.stakedValue).toNumber() : Infinity;
|
|
832
1004
|
return {
|
|
833
1005
|
rewardApr: rewardRate,
|
|
834
1006
|
totalRewardAmount: totalRewardAmount.toNumber(),
|
|
@@ -840,9 +1012,18 @@ var calculateRewardPoolData = (parsedStakePoolData, parsedRewardPoolData, calcul
|
|
|
840
1012
|
claimedRewardAmount: claimedRewardAmount.toNumber(),
|
|
841
1013
|
claimedRewardCoin: claimedRewardCoin.toNumber(),
|
|
842
1014
|
claimedRewardValue: claimedRewardValue.toNumber(),
|
|
843
|
-
rewardPerSec: rewardPerSec.toNumber()
|
|
844
|
-
|
|
845
|
-
|
|
1015
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
1019
|
+
return {
|
|
1020
|
+
poolType: normalizeStructTag(
|
|
1021
|
+
originBorrowIncentiveAccountData.pool_type.name
|
|
1022
|
+
),
|
|
1023
|
+
amount: Number(originBorrowIncentiveAccountData.amount),
|
|
1024
|
+
index: Number(originBorrowIncentiveAccountData.index),
|
|
1025
|
+
points: Number(originBorrowIncentiveAccountData.points),
|
|
1026
|
+
totalPoints: Number(originBorrowIncentiveAccountData.total_points)
|
|
846
1027
|
};
|
|
847
1028
|
};
|
|
848
1029
|
var minBigNumber = (...args) => {
|
|
@@ -855,15 +1036,45 @@ var minBigNumber = (...args) => {
|
|
|
855
1036
|
|
|
856
1037
|
// src/utils/util.ts
|
|
857
1038
|
var isMarketCoin = (coinName) => {
|
|
858
|
-
const assetCoinName = coinName.slice(1);
|
|
859
|
-
return [
|
|
1039
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
1040
|
+
return coinName.charAt(0).toLowerCase() === "s" && [
|
|
860
1041
|
.../* @__PURE__ */ new Set([
|
|
861
1042
|
...SUPPORT_POOLS,
|
|
862
1043
|
...SUPPORT_COLLATERALS,
|
|
863
|
-
...
|
|
1044
|
+
...SUPPORT_SPOOLS_REWARDS
|
|
864
1045
|
])
|
|
865
1046
|
].includes(assetCoinName);
|
|
866
1047
|
};
|
|
1048
|
+
var parseAssetSymbol = (coinName) => {
|
|
1049
|
+
switch (coinName) {
|
|
1050
|
+
case "afsui":
|
|
1051
|
+
return "afSUI";
|
|
1052
|
+
case "hasui":
|
|
1053
|
+
return "haSUI";
|
|
1054
|
+
case "vsui":
|
|
1055
|
+
return "vSUI";
|
|
1056
|
+
default:
|
|
1057
|
+
return coinName.toUpperCase();
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
1061
|
+
const assetCoinNames = [
|
|
1062
|
+
.../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
|
|
1063
|
+
];
|
|
1064
|
+
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
1065
|
+
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
1066
|
+
});
|
|
1067
|
+
if (assetCoinName) {
|
|
1068
|
+
const price = feed.price.price * 10 ** feed.price.expo;
|
|
1069
|
+
return {
|
|
1070
|
+
coinName: assetCoinName,
|
|
1071
|
+
price,
|
|
1072
|
+
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
1073
|
+
};
|
|
1074
|
+
} else {
|
|
1075
|
+
throw new Error("Invalid feed id");
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
867
1078
|
|
|
868
1079
|
// src/queries/coreQuery.ts
|
|
869
1080
|
var queryMarket = async (query) => {
|
|
@@ -877,6 +1088,12 @@ var queryMarket = async (query) => {
|
|
|
877
1088
|
const pools = {};
|
|
878
1089
|
const collaterals = {};
|
|
879
1090
|
for (const pool of marketData.pools) {
|
|
1091
|
+
const coinType = "0x" + pool.type.name;
|
|
1092
|
+
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
1093
|
+
const coinPrice = (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
|
|
1094
|
+
if (!SUPPORT_POOLS.includes(poolCoinName)) {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
880
1097
|
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
881
1098
|
type: pool.type,
|
|
882
1099
|
maxBorrowRate: pool.maxBorrowRate,
|
|
@@ -901,9 +1118,6 @@ var queryMarket = async (query) => {
|
|
|
901
1118
|
query.utils,
|
|
902
1119
|
parsedMarketPoolData
|
|
903
1120
|
);
|
|
904
|
-
const coinType = "0x" + pool.type.name;
|
|
905
|
-
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
906
|
-
const coinPrice = (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
|
|
907
1121
|
pools[poolCoinName] = {
|
|
908
1122
|
coinName: poolCoinName,
|
|
909
1123
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -922,6 +1136,12 @@ var queryMarket = async (query) => {
|
|
|
922
1136
|
};
|
|
923
1137
|
}
|
|
924
1138
|
for (const collateral of marketData.collaterals) {
|
|
1139
|
+
const coinType = "0x" + collateral.type.name;
|
|
1140
|
+
const collateralCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
1141
|
+
const coinPrice = (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName] ?? 0;
|
|
1142
|
+
if (!SUPPORT_COLLATERALS.includes(collateralCoinName)) {
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
925
1145
|
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
926
1146
|
type: collateral.type,
|
|
927
1147
|
collateralFactor: collateral.collateralFactor,
|
|
@@ -936,9 +1156,6 @@ var queryMarket = async (query) => {
|
|
|
936
1156
|
query.utils,
|
|
937
1157
|
parsedMarketCollateralData
|
|
938
1158
|
);
|
|
939
|
-
const coinType = "0x" + collateral.type.name;
|
|
940
|
-
const collateralCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
941
|
-
const coinPrice = (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName] ?? 0;
|
|
942
1159
|
collaterals[collateralCoinName] = {
|
|
943
1160
|
coinName: collateralCoinName,
|
|
944
1161
|
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
@@ -1225,11 +1442,27 @@ var getObligations = async (query, ownerAddress) => {
|
|
|
1225
1442
|
if (keyObject.content && "fields" in keyObject.content) {
|
|
1226
1443
|
const fields = keyObject.content.fields;
|
|
1227
1444
|
const obligationId = String(fields.ownership.fields.of);
|
|
1228
|
-
|
|
1445
|
+
const locked = await getObligationLocked(query, obligationId);
|
|
1446
|
+
obligations.push({ id: obligationId, keyId, locked });
|
|
1229
1447
|
}
|
|
1230
1448
|
}
|
|
1231
1449
|
return obligations;
|
|
1232
1450
|
};
|
|
1451
|
+
var getObligationLocked = async (query, obligationId) => {
|
|
1452
|
+
const obligationObjectResponse = await query.suiKit.client().getObject({
|
|
1453
|
+
id: obligationId,
|
|
1454
|
+
options: {
|
|
1455
|
+
showContent: true
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
let obligationLocked = false;
|
|
1459
|
+
if (obligationObjectResponse.data && obligationObjectResponse?.data?.content?.dataType === "moveObject" && "lock_key" in obligationObjectResponse.data.content.fields) {
|
|
1460
|
+
obligationLocked = Boolean(
|
|
1461
|
+
obligationObjectResponse.data.content.fields.lock_key
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
return obligationLocked;
|
|
1465
|
+
};
|
|
1233
1466
|
var queryObligation = async (query, obligationId) => {
|
|
1234
1467
|
const packageId = query.address.get("core.packages.query.id");
|
|
1235
1468
|
const queryTarget = `${packageId}::obligation_query::obligation_data`;
|
|
@@ -1404,7 +1637,7 @@ var getMarketCoinAmount = async (query, marketCoinName, ownerAddress) => {
|
|
|
1404
1637
|
};
|
|
1405
1638
|
|
|
1406
1639
|
// src/queries/spoolQuery.ts
|
|
1407
|
-
import { normalizeStructTag } from "@mysten/sui.js/utils";
|
|
1640
|
+
import { normalizeStructTag as normalizeStructTag2 } from "@mysten/sui.js/utils";
|
|
1408
1641
|
var getSpools = async (query, stakeMarketCoinNames) => {
|
|
1409
1642
|
stakeMarketCoinNames = stakeMarketCoinNames || [...SUPPORT_SPOOLS];
|
|
1410
1643
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
@@ -1425,31 +1658,31 @@ var getSpools = async (query, stakeMarketCoinNames) => {
|
|
|
1425
1658
|
}
|
|
1426
1659
|
return spools;
|
|
1427
1660
|
};
|
|
1428
|
-
var getSpool = async (query,
|
|
1429
|
-
const
|
|
1430
|
-
marketPool = marketPool || await query.getMarketPool(
|
|
1431
|
-
const poolId = query.address.get(`spool.pools.${
|
|
1661
|
+
var getSpool = async (query, marketCoinName, marketPool) => {
|
|
1662
|
+
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
1663
|
+
marketPool = marketPool || await query.getMarketPool(coinName);
|
|
1664
|
+
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
1432
1665
|
const rewardPoolId = query.address.get(
|
|
1433
|
-
`spool.pools.${
|
|
1666
|
+
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
1434
1667
|
);
|
|
1435
1668
|
let spool = void 0;
|
|
1436
|
-
const
|
|
1669
|
+
const spoolObjectResponse = await query.suiKit.client().multiGetObjects({
|
|
1437
1670
|
ids: [poolId, rewardPoolId],
|
|
1438
1671
|
options: {
|
|
1439
1672
|
showContent: true
|
|
1440
1673
|
}
|
|
1441
1674
|
});
|
|
1442
|
-
if (marketPool &&
|
|
1443
|
-
const
|
|
1675
|
+
if (marketPool && spoolObjectResponse[0].data && spoolObjectResponse[1].data) {
|
|
1676
|
+
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
1444
1677
|
const coinPrices = await query.utils.getCoinPrices([
|
|
1445
|
-
|
|
1446
|
-
|
|
1678
|
+
coinName,
|
|
1679
|
+
rewardCoinName
|
|
1447
1680
|
]);
|
|
1448
|
-
const
|
|
1449
|
-
const rewardPoolObject =
|
|
1450
|
-
if (
|
|
1451
|
-
const fields =
|
|
1452
|
-
const
|
|
1681
|
+
const spoolObject = spoolObjectResponse[0].data;
|
|
1682
|
+
const rewardPoolObject = spoolObjectResponse[1].data;
|
|
1683
|
+
if (spoolObject.content && "fields" in spoolObject.content) {
|
|
1684
|
+
const fields = spoolObject.content.fields;
|
|
1685
|
+
const parsedSpoolData = parseOriginSpoolData({
|
|
1453
1686
|
stakeType: fields.stake_type,
|
|
1454
1687
|
maxDistributedPoint: fields.max_distributed_point,
|
|
1455
1688
|
distributedPoint: fields.distributed_point,
|
|
@@ -1461,43 +1694,48 @@ var getSpool = async (query, stakeMarketCoinName, marketPool) => {
|
|
|
1461
1694
|
createdAt: fields.created_at,
|
|
1462
1695
|
lastUpdate: fields.last_update
|
|
1463
1696
|
});
|
|
1464
|
-
const
|
|
1465
|
-
const
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1697
|
+
const marketCoinPrice = (coinPrices?.[coinName] ?? 0) * marketPool.conversionRate;
|
|
1698
|
+
const marketCoinDecimal = query.utils.getCoinDecimal(marketCoinName);
|
|
1699
|
+
const calculatedSpoolData = calculateSpoolData(
|
|
1700
|
+
parsedSpoolData,
|
|
1701
|
+
marketCoinPrice,
|
|
1702
|
+
marketCoinDecimal
|
|
1470
1703
|
);
|
|
1471
1704
|
if (rewardPoolObject.content && "fields" in rewardPoolObject.content) {
|
|
1472
1705
|
const fields2 = rewardPoolObject.content.fields;
|
|
1473
|
-
const
|
|
1706
|
+
const parsedSpoolRewardPoolData = parseOriginSpoolRewardPoolData({
|
|
1474
1707
|
claimed_rewards: fields2.claimed_rewards,
|
|
1475
1708
|
exchange_rate_numerator: fields2.exchange_rate_numerator,
|
|
1476
1709
|
exchange_rate_denominator: fields2.exchange_rate_denominator,
|
|
1477
1710
|
rewards: fields2.rewards,
|
|
1478
1711
|
spool_id: fields2.spool_id
|
|
1479
1712
|
});
|
|
1480
|
-
const rewardCoinPrice = coinPrices?.[
|
|
1481
|
-
const rewardCoinDecimal = query.utils.getCoinDecimal(
|
|
1482
|
-
const calculatedRewardPoolData =
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1713
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
1714
|
+
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
1715
|
+
const calculatedRewardPoolData = calculateSpoolRewardPoolData(
|
|
1716
|
+
parsedSpoolData,
|
|
1717
|
+
parsedSpoolRewardPoolData,
|
|
1718
|
+
calculatedSpoolData,
|
|
1486
1719
|
rewardCoinPrice,
|
|
1487
1720
|
rewardCoinDecimal
|
|
1488
1721
|
);
|
|
1489
1722
|
spool = {
|
|
1490
|
-
marketCoinName
|
|
1491
|
-
symbol: query.utils.parseSymbol(
|
|
1492
|
-
coinType: query.utils.parseCoinType(
|
|
1493
|
-
marketCoinType: query.utils.parseMarketCoinType(
|
|
1494
|
-
rewardCoinType: isMarketCoin(
|
|
1495
|
-
coinDecimal: query.utils.getCoinDecimal(
|
|
1496
|
-
rewardCoinDecimal: query.utils.getCoinDecimal(
|
|
1497
|
-
coinPrice: coinPrices?.[
|
|
1498
|
-
marketCoinPrice
|
|
1723
|
+
marketCoinName,
|
|
1724
|
+
symbol: query.utils.parseSymbol(marketCoinName),
|
|
1725
|
+
coinType: query.utils.parseCoinType(coinName),
|
|
1726
|
+
marketCoinType: query.utils.parseMarketCoinType(coinName),
|
|
1727
|
+
rewardCoinType: isMarketCoin(rewardCoinName) ? query.utils.parseMarketCoinType(rewardCoinName) : query.utils.parseCoinType(rewardCoinName),
|
|
1728
|
+
coinDecimal: query.utils.getCoinDecimal(coinName),
|
|
1729
|
+
rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
|
|
1730
|
+
coinPrice: coinPrices?.[coinName] ?? 0,
|
|
1731
|
+
marketCoinPrice,
|
|
1499
1732
|
rewardCoinPrice,
|
|
1500
|
-
|
|
1733
|
+
maxPoint: parsedSpoolData.maxPoint,
|
|
1734
|
+
distributedPoint: parsedSpoolData.distributedPoint,
|
|
1735
|
+
maxStake: parsedSpoolData.maxStake,
|
|
1736
|
+
...calculatedSpoolData,
|
|
1737
|
+
exchangeRateNumerator: parsedSpoolRewardPoolData.exchangeRateNumerator,
|
|
1738
|
+
exchangeRateDenominator: parsedSpoolRewardPoolData.exchangeRateDenominator,
|
|
1501
1739
|
...calculatedRewardPoolData
|
|
1502
1740
|
};
|
|
1503
1741
|
}
|
|
@@ -1555,7 +1793,7 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
1555
1793
|
const index = Number(fields.index);
|
|
1556
1794
|
const points = Number(fields.points);
|
|
1557
1795
|
const totalPoints = Number(fields.total_points);
|
|
1558
|
-
if (
|
|
1796
|
+
if (normalizeStructTag2(type) === stakeMarketCoinTypes.ssui) {
|
|
1559
1797
|
stakeAccounts.ssui.push({
|
|
1560
1798
|
id,
|
|
1561
1799
|
type,
|
|
@@ -1566,7 +1804,7 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
1566
1804
|
points,
|
|
1567
1805
|
totalPoints
|
|
1568
1806
|
});
|
|
1569
|
-
} else if (
|
|
1807
|
+
} else if (normalizeStructTag2(type) === stakeMarketCoinTypes.susdc) {
|
|
1570
1808
|
stakeAccounts.susdc.push({
|
|
1571
1809
|
id,
|
|
1572
1810
|
type,
|
|
@@ -1577,7 +1815,7 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
1577
1815
|
points,
|
|
1578
1816
|
totalPoints
|
|
1579
1817
|
});
|
|
1580
|
-
} else if (
|
|
1818
|
+
} else if (normalizeStructTag2(type) === stakeMarketCoinTypes.susdt) {
|
|
1581
1819
|
stakeAccounts.susdt.push({
|
|
1582
1820
|
id,
|
|
1583
1821
|
type,
|
|
@@ -1637,30 +1875,30 @@ var getStakePool = async (query, marketCoinName) => {
|
|
|
1637
1875
|
}
|
|
1638
1876
|
return stakePool;
|
|
1639
1877
|
};
|
|
1640
|
-
var
|
|
1878
|
+
var getStakeRewardPool = async (query, marketCoinName) => {
|
|
1641
1879
|
const poolId = query.address.get(
|
|
1642
1880
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
1643
1881
|
);
|
|
1644
|
-
let
|
|
1645
|
-
const
|
|
1882
|
+
let stakeRewardPool = void 0;
|
|
1883
|
+
const stakeRewardPoolObjectResponse = await query.suiKit.client().getObject({
|
|
1646
1884
|
id: poolId,
|
|
1647
1885
|
options: {
|
|
1648
1886
|
showContent: true,
|
|
1649
1887
|
showType: true
|
|
1650
1888
|
}
|
|
1651
1889
|
});
|
|
1652
|
-
if (
|
|
1653
|
-
const
|
|
1654
|
-
const id =
|
|
1655
|
-
const type =
|
|
1656
|
-
if (
|
|
1657
|
-
const fields =
|
|
1890
|
+
if (stakeRewardPoolObjectResponse.data) {
|
|
1891
|
+
const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
|
|
1892
|
+
const id = stakeRewardPoolObject.objectId;
|
|
1893
|
+
const type = stakeRewardPoolObject.type;
|
|
1894
|
+
if (stakeRewardPoolObject.content && "fields" in stakeRewardPoolObject.content) {
|
|
1895
|
+
const fields = stakeRewardPoolObject.content.fields;
|
|
1658
1896
|
const stakePoolId = String(fields.spool_id);
|
|
1659
1897
|
const ratioNumerator = Number(fields.exchange_rate_numerator);
|
|
1660
1898
|
const ratioDenominator = Number(fields.exchange_rate_denominator);
|
|
1661
1899
|
const rewards = Number(fields.rewards);
|
|
1662
1900
|
const claimedRewards = Number(fields.claimed_rewards);
|
|
1663
|
-
|
|
1901
|
+
stakeRewardPool = {
|
|
1664
1902
|
id,
|
|
1665
1903
|
type,
|
|
1666
1904
|
stakePoolId,
|
|
@@ -1671,7 +1909,106 @@ var getRewardPool = async (query, marketCoinName) => {
|
|
|
1671
1909
|
};
|
|
1672
1910
|
}
|
|
1673
1911
|
}
|
|
1674
|
-
return
|
|
1912
|
+
return stakeRewardPool;
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
// src/queries/borrowIncentiveQuery.ts
|
|
1916
|
+
import { SuiTxBlock as SuiKitTxBlock2 } from "@scallop-io/sui-kit";
|
|
1917
|
+
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames) => {
|
|
1918
|
+
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
1919
|
+
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
1920
|
+
];
|
|
1921
|
+
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
1922
|
+
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
1923
|
+
const txBlock = new SuiKitTxBlock2();
|
|
1924
|
+
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
1925
|
+
txBlock.moveCall(queryTarget, [incentivePoolsId], ["0x2::sui::SUI"]);
|
|
1926
|
+
const queryResult = await query.suiKit.inspectTxn(txBlock);
|
|
1927
|
+
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
1928
|
+
const parsedBorrowIncentiveRewardPoolData = parseOriginBorrowIncentiveRewardPoolData(
|
|
1929
|
+
borrowIncentivePoolsQueryData.reward_pool
|
|
1930
|
+
);
|
|
1931
|
+
const rewardCoinType = parsedBorrowIncentiveRewardPoolData.rewardType;
|
|
1932
|
+
const borrowIncentivePools = {};
|
|
1933
|
+
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
1934
|
+
const coinType = "0x" + pool.pool_type.name;
|
|
1935
|
+
const coinName = query.utils.parseCoinNameFromType(coinType);
|
|
1936
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(rewardCoinType);
|
|
1937
|
+
if (!borrowIncentiveCoinNames.includes(coinName)) {
|
|
1938
|
+
continue;
|
|
1939
|
+
}
|
|
1940
|
+
const coinPrices = await query.utils.getCoinPrices([
|
|
1941
|
+
coinName,
|
|
1942
|
+
rewardCoinName
|
|
1943
|
+
]);
|
|
1944
|
+
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
1945
|
+
const coinPrice = coinPrices?.[coinName] ?? 0;
|
|
1946
|
+
const coinDecimal = query.utils.getCoinDecimal(coinName);
|
|
1947
|
+
const calculatedBorrowIncentivePoolData = calculateBorrowIncentivePoolData(
|
|
1948
|
+
parsedBorrowIncentivePoolData,
|
|
1949
|
+
coinPrice,
|
|
1950
|
+
coinDecimal
|
|
1951
|
+
);
|
|
1952
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
1953
|
+
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
1954
|
+
const calculatedBorrowIncentiveRewardPoolData = calculateBorrowIncentiveRewardPoolData(
|
|
1955
|
+
parsedBorrowIncentivePoolData,
|
|
1956
|
+
parsedBorrowIncentiveRewardPoolData,
|
|
1957
|
+
calculatedBorrowIncentivePoolData,
|
|
1958
|
+
rewardCoinPrice,
|
|
1959
|
+
rewardCoinDecimal
|
|
1960
|
+
);
|
|
1961
|
+
borrowIncentivePools[coinName] = {
|
|
1962
|
+
coinName,
|
|
1963
|
+
symbol: query.utils.parseSymbol(coinName),
|
|
1964
|
+
coinType,
|
|
1965
|
+
rewardCoinType,
|
|
1966
|
+
coinDecimal,
|
|
1967
|
+
rewardCoinDecimal,
|
|
1968
|
+
coinPrice,
|
|
1969
|
+
rewardCoinPrice,
|
|
1970
|
+
maxPoint: parsedBorrowIncentivePoolData.maxPoint,
|
|
1971
|
+
distributedPoint: parsedBorrowIncentivePoolData.distributedPoint,
|
|
1972
|
+
maxStake: parsedBorrowIncentivePoolData.maxStake,
|
|
1973
|
+
...calculatedBorrowIncentivePoolData,
|
|
1974
|
+
exchangeRateNumerator: parsedBorrowIncentiveRewardPoolData.exchangeRateNumerator,
|
|
1975
|
+
exchangeRateDenominator: parsedBorrowIncentiveRewardPoolData.exchangeRateDenominator,
|
|
1976
|
+
...calculatedBorrowIncentiveRewardPoolData
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
return borrowIncentivePools;
|
|
1980
|
+
};
|
|
1981
|
+
var queryBorrowIncentiveAccounts = async (query, obligationId, borrowIncentiveCoinNames) => {
|
|
1982
|
+
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
1983
|
+
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
1984
|
+
];
|
|
1985
|
+
const queryPkgId = query.address.get("borrowIncentive.query");
|
|
1986
|
+
const incentiveAccountsId = query.address.get(
|
|
1987
|
+
"borrowIncentive.incentiveAccounts"
|
|
1988
|
+
);
|
|
1989
|
+
const queryTarget = `${queryPkgId}::incentive_account_query::incentive_account_data`;
|
|
1990
|
+
const txBlock = new SuiKitTxBlock2();
|
|
1991
|
+
txBlock.moveCall(queryTarget, [incentiveAccountsId, obligationId]);
|
|
1992
|
+
const queryResult = await query.suiKit.inspectTxn(txBlock);
|
|
1993
|
+
const borrowIncentiveAccountsQueryData = queryResult.events[0].parsedJson;
|
|
1994
|
+
const borrowIncentiveAccounts = Object.values(
|
|
1995
|
+
borrowIncentiveAccountsQueryData.incentive_states
|
|
1996
|
+
).reduce((accounts, accountData) => {
|
|
1997
|
+
const parsedBorrowIncentiveAccount = parseOriginBorrowIncentiveAccountData(accountData);
|
|
1998
|
+
const poolType = parsedBorrowIncentiveAccount.poolType;
|
|
1999
|
+
const coinName = query.utils.parseCoinNameFromType(poolType);
|
|
2000
|
+
if (borrowIncentiveCoinNames && borrowIncentiveCoinNames.includes(coinName)) {
|
|
2001
|
+
accounts[coinName] = {
|
|
2002
|
+
poolType,
|
|
2003
|
+
amount: parsedBorrowIncentiveAccount.amount,
|
|
2004
|
+
points: parsedBorrowIncentiveAccount.points,
|
|
2005
|
+
totalPoints: parsedBorrowIncentiveAccount.totalPoints,
|
|
2006
|
+
index: parsedBorrowIncentiveAccount.index
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
return accounts;
|
|
2010
|
+
}, {});
|
|
2011
|
+
return borrowIncentiveAccounts;
|
|
1675
2012
|
};
|
|
1676
2013
|
|
|
1677
2014
|
// src/queries/priceQuery.ts
|
|
@@ -2303,38 +2640,60 @@ var ScallopQuery = class {
|
|
|
2303
2640
|
return await getStakePool(this, stakeMarketCoinName);
|
|
2304
2641
|
}
|
|
2305
2642
|
/**
|
|
2306
|
-
* Get reward pools data.
|
|
2643
|
+
* Get stake reward pools data.
|
|
2307
2644
|
*
|
|
2308
2645
|
* @description
|
|
2309
2646
|
* For backward compatible, it is recommended to use `getSpools` method
|
|
2310
2647
|
* to get all spools data.
|
|
2311
2648
|
*
|
|
2312
2649
|
* @param stakeMarketCoinNames - Specific an array of stake market coin name.
|
|
2313
|
-
* @return
|
|
2650
|
+
* @return Stake reward pools data.
|
|
2314
2651
|
*/
|
|
2315
|
-
async
|
|
2652
|
+
async getStakeRewardPools(stakeMarketCoinNames) {
|
|
2316
2653
|
stakeMarketCoinNames = stakeMarketCoinNames ?? [...SUPPORT_SPOOLS];
|
|
2317
|
-
const
|
|
2654
|
+
const stakeRewardPools = {};
|
|
2318
2655
|
for (const stakeMarketCoinName of stakeMarketCoinNames) {
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2321
|
-
|
|
2656
|
+
const stakeRewardPool = await getStakeRewardPool(
|
|
2657
|
+
this,
|
|
2658
|
+
stakeMarketCoinName
|
|
2659
|
+
);
|
|
2660
|
+
if (stakeRewardPool) {
|
|
2661
|
+
stakeRewardPools[stakeMarketCoinName] = stakeRewardPool;
|
|
2322
2662
|
}
|
|
2323
2663
|
}
|
|
2324
|
-
return
|
|
2664
|
+
return stakeRewardPools;
|
|
2325
2665
|
}
|
|
2326
2666
|
/**
|
|
2327
|
-
* Get reward pool data.
|
|
2667
|
+
* Get stake reward pool data.
|
|
2328
2668
|
*
|
|
2329
2669
|
* @description
|
|
2330
2670
|
* For backward compatible, it is recommended to use `getSpool` method
|
|
2331
2671
|
* to get spool data.
|
|
2332
2672
|
*
|
|
2333
2673
|
* @param marketCoinName - Specific support stake market coin name.
|
|
2334
|
-
* @return
|
|
2674
|
+
* @return Stake reward pool data.
|
|
2675
|
+
*/
|
|
2676
|
+
async getStakeRewardPool(stakeMarketCoinName) {
|
|
2677
|
+
return await getStakeRewardPool(this, stakeMarketCoinName);
|
|
2678
|
+
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Get borrow incentive pools data.
|
|
2681
|
+
*
|
|
2682
|
+
* @param coinNames - Specific an array of support borrow incentive coin name.
|
|
2683
|
+
* @return Borrow incentive pools data.
|
|
2684
|
+
*/
|
|
2685
|
+
async getBorrowIncentivePools(coinNames) {
|
|
2686
|
+
return await queryBorrowIncentivePools(this, coinNames);
|
|
2687
|
+
}
|
|
2688
|
+
/**
|
|
2689
|
+
* Get borrow incentive accounts data.
|
|
2690
|
+
*
|
|
2691
|
+
* @param coinNames - Specific support borrow incentive coin name.
|
|
2692
|
+
* @param ownerAddress - The owner address.
|
|
2693
|
+
* @return Borrow incentive accounts data.
|
|
2335
2694
|
*/
|
|
2336
|
-
async
|
|
2337
|
-
return await
|
|
2695
|
+
async getBorrowIncentiveAccounts(obligationId, coinNames) {
|
|
2696
|
+
return await queryBorrowIncentiveAccounts(this, obligationId, coinNames);
|
|
2338
2697
|
}
|
|
2339
2698
|
/**
|
|
2340
2699
|
* Get user lending and spool infomation for specific pools.
|
|
@@ -2398,13 +2757,22 @@ var ScallopUtils = class {
|
|
|
2398
2757
|
constructor(params, instance) {
|
|
2399
2758
|
this._priceMap = /* @__PURE__ */ new Map();
|
|
2400
2759
|
/**
|
|
2401
|
-
* Get reward type of
|
|
2760
|
+
* Get reward type of spool.
|
|
2402
2761
|
*
|
|
2403
2762
|
* @param stakeMarketCoinName - Support stake market coin.
|
|
2404
|
-
* @return
|
|
2763
|
+
* @return Spool reward coin name.
|
|
2764
|
+
*/
|
|
2765
|
+
this.getSpoolRewardCoinName = (stakeMarketCoinName) => {
|
|
2766
|
+
return spoolRewardCoins[stakeMarketCoinName];
|
|
2767
|
+
};
|
|
2768
|
+
/**
|
|
2769
|
+
* Get reward type of borrow incentive pool.
|
|
2770
|
+
*
|
|
2771
|
+
* @param borrowIncentiveCoinName - Support borrow incentive coin.
|
|
2772
|
+
* @return Borrow incentive reward coin name.
|
|
2405
2773
|
*/
|
|
2406
|
-
this.
|
|
2407
|
-
return
|
|
2774
|
+
this.getBorrowIncentiveRewardCoinName = (borrowIncentiveCoinName) => {
|
|
2775
|
+
return borrowIncentiveRewardCoins[borrowIncentiveCoinName];
|
|
2408
2776
|
};
|
|
2409
2777
|
this.params = params;
|
|
2410
2778
|
this._suiKit = instance?.suiKit ?? new SuiKit2(params);
|
|
@@ -2437,9 +2805,10 @@ var ScallopUtils = class {
|
|
|
2437
2805
|
*/
|
|
2438
2806
|
parseSymbol(coinName) {
|
|
2439
2807
|
if (isMarketCoin(coinName)) {
|
|
2440
|
-
|
|
2808
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
2809
|
+
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
2441
2810
|
} else {
|
|
2442
|
-
return coinName
|
|
2811
|
+
return parseAssetSymbol(coinName);
|
|
2443
2812
|
}
|
|
2444
2813
|
}
|
|
2445
2814
|
/**
|
|
@@ -2455,13 +2824,13 @@ var ScallopUtils = class {
|
|
|
2455
2824
|
*/
|
|
2456
2825
|
parseCoinType(coinName) {
|
|
2457
2826
|
coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
|
|
2458
|
-
const coinPackageId = this._address.get(`core.coins.${coinName}.id`)
|
|
2827
|
+
const coinPackageId = this._address.get(`core.coins.${coinName}.id`) || coinIds[coinName] || void 0;
|
|
2459
2828
|
if (!coinPackageId) {
|
|
2460
2829
|
throw Error(`Coin ${coinName} is not supported`);
|
|
2461
2830
|
}
|
|
2462
2831
|
if (coinName === "sui")
|
|
2463
|
-
return
|
|
2464
|
-
const
|
|
2832
|
+
return normalizeStructTag3(`${coinPackageId}::sui::SUI`);
|
|
2833
|
+
const wormHolePckageIds = [
|
|
2465
2834
|
this._address.get("core.coins.usdc.id") ?? wormholeCoinIds.usdc,
|
|
2466
2835
|
this._address.get("core.coins.usdt.id") ?? wormholeCoinIds.usdt,
|
|
2467
2836
|
this._address.get("core.coins.eth.id") ?? wormholeCoinIds.eth,
|
|
@@ -2469,8 +2838,13 @@ var ScallopUtils = class {
|
|
|
2469
2838
|
this._address.get("core.coins.sol.id") ?? wormholeCoinIds.sol,
|
|
2470
2839
|
this._address.get("core.coins.apt.id") ?? wormholeCoinIds.apt
|
|
2471
2840
|
];
|
|
2472
|
-
|
|
2841
|
+
const voloPckageIds = [
|
|
2842
|
+
this._address.get("core.coins.vsui.id") ?? voloCoinIds.vsui
|
|
2843
|
+
];
|
|
2844
|
+
if (wormHolePckageIds.includes(coinPackageId)) {
|
|
2473
2845
|
return `${coinPackageId}::coin::COIN`;
|
|
2846
|
+
} else if (voloPckageIds.includes(coinPackageId)) {
|
|
2847
|
+
return `${coinPackageId}::cert::CERT`;
|
|
2474
2848
|
} else {
|
|
2475
2849
|
return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
|
|
2476
2850
|
}
|
|
@@ -2487,7 +2861,7 @@ var ScallopUtils = class {
|
|
|
2487
2861
|
return `${PROTOCOL_OBJECT_ID}::reserve::MarketCoin<${coinType}>`;
|
|
2488
2862
|
}
|
|
2489
2863
|
parseCoinNameFromType(coinType) {
|
|
2490
|
-
coinType =
|
|
2864
|
+
coinType = normalizeStructTag3(coinType);
|
|
2491
2865
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
2492
2866
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
2493
2867
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|
|
@@ -2500,7 +2874,10 @@ var ScallopUtils = class {
|
|
|
2500
2874
|
[`${this._address.get("core.coins.sol.id") ?? wormholeCoinIds.sol}::coin::COIN`]: "sol",
|
|
2501
2875
|
[`${this._address.get("core.coins.apt.id") ?? wormholeCoinIds.apt}::coin::COIN`]: "apt"
|
|
2502
2876
|
};
|
|
2503
|
-
const
|
|
2877
|
+
const voloCoinTypeMap = {
|
|
2878
|
+
[`${this._address.get("core.coins.vsui.id") ?? voloCoinIds.vsui}::cert::CERT`]: "vsui"
|
|
2879
|
+
};
|
|
2880
|
+
const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
|
|
2504
2881
|
return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
|
|
2505
2882
|
}
|
|
2506
2883
|
/**
|
|
@@ -2623,13 +3000,14 @@ var ScallopUtils = class {
|
|
|
2623
3000
|
);
|
|
2624
3001
|
try {
|
|
2625
3002
|
const priceFeeds = await pythConnection.getLatestPriceFeeds(priceIds) || [];
|
|
2626
|
-
for (const feed of priceFeeds) {
|
|
3003
|
+
for (const [index, feed] of priceFeeds.entries()) {
|
|
2627
3004
|
const data = parseDataFromPythPriceFeed(feed, this._address);
|
|
2628
|
-
|
|
3005
|
+
const coinName = lackPricesCoinNames[index];
|
|
3006
|
+
this._priceMap.set(coinName, {
|
|
2629
3007
|
price: data.price,
|
|
2630
3008
|
publishTime: data.publishTime
|
|
2631
3009
|
});
|
|
2632
|
-
coinPrices[
|
|
3010
|
+
coinPrices[coinName] = data.price;
|
|
2633
3011
|
}
|
|
2634
3012
|
} catch (_e) {
|
|
2635
3013
|
for (const coinName of lackPricesCoinNames) {
|
|
@@ -2673,7 +3051,7 @@ import { SuiKit as SuiKit3 } from "@scallop-io/sui-kit";
|
|
|
2673
3051
|
// src/builders/coreBuilder.ts
|
|
2674
3052
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
2675
3053
|
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui.js/utils";
|
|
2676
|
-
import { SuiTxBlock as
|
|
3054
|
+
import { SuiTxBlock as SuiKitTxBlock3 } from "@scallop-io/sui-kit";
|
|
2677
3055
|
|
|
2678
3056
|
// src/builders/oracle.ts
|
|
2679
3057
|
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui.js/utils";
|
|
@@ -2811,13 +3189,6 @@ var updatePythPrice = (txBlock, packageId, request, stateId, feedObjectId, regis
|
|
|
2811
3189
|
};
|
|
2812
3190
|
|
|
2813
3191
|
// src/builders/coreBuilder.ts
|
|
2814
|
-
var requireSender = (txBlock) => {
|
|
2815
|
-
const sender = txBlock.blockData.sender;
|
|
2816
|
-
if (!sender) {
|
|
2817
|
-
throw new Error("Sender is required");
|
|
2818
|
-
}
|
|
2819
|
-
return sender;
|
|
2820
|
-
};
|
|
2821
3192
|
var requireObligationInfo = async (...params) => {
|
|
2822
3193
|
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
2823
3194
|
if (params.length === 3 && obligationId)
|
|
@@ -3107,7 +3478,7 @@ var generateCoreQuickMethod = ({
|
|
|
3107
3478
|
};
|
|
3108
3479
|
};
|
|
3109
3480
|
var newCoreTxBlock = (builder, initTxBlock) => {
|
|
3110
|
-
const txBlock = initTxBlock instanceof TransactionBlock ? new
|
|
3481
|
+
const txBlock = initTxBlock instanceof TransactionBlock ? new SuiKitTxBlock3(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock3();
|
|
3111
3482
|
const normalMethod = generateCoreNormalMethod({
|
|
3112
3483
|
builder,
|
|
3113
3484
|
txBlock
|
|
@@ -3137,19 +3508,12 @@ var newCoreTxBlock = (builder, initTxBlock) => {
|
|
|
3137
3508
|
// src/builders/spoolBuilder.ts
|
|
3138
3509
|
import { TransactionBlock as TransactionBlock2 } from "@mysten/sui.js/transactions";
|
|
3139
3510
|
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID3 } from "@mysten/sui.js/utils";
|
|
3140
|
-
import { SuiTxBlock as
|
|
3141
|
-
var requireSender2 = (txBlock) => {
|
|
3142
|
-
const sender = txBlock.blockData.sender;
|
|
3143
|
-
if (!sender) {
|
|
3144
|
-
throw new Error("Sender is required");
|
|
3145
|
-
}
|
|
3146
|
-
return sender;
|
|
3147
|
-
};
|
|
3511
|
+
import { SuiTxBlock as SuiKitTxBlock4 } from "@scallop-io/sui-kit";
|
|
3148
3512
|
var requireStakeAccountIds = async (...params) => {
|
|
3149
3513
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
3150
3514
|
if (params.length === 4 && stakeAccountId)
|
|
3151
3515
|
return [stakeAccountId];
|
|
3152
|
-
const sender =
|
|
3516
|
+
const sender = requireSender(txBlock);
|
|
3153
3517
|
const stakeAccounts = await getStakeAccounts(builder.query, sender);
|
|
3154
3518
|
if (stakeAccounts[stakeMarketCoinName].length === 0) {
|
|
3155
3519
|
throw new Error(`No stake account id found for sender ${sender}`);
|
|
@@ -3158,7 +3522,7 @@ var requireStakeAccountIds = async (...params) => {
|
|
|
3158
3522
|
};
|
|
3159
3523
|
var requireStakeAccounts = async (...params) => {
|
|
3160
3524
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
3161
|
-
const sender =
|
|
3525
|
+
const sender = requireSender(txBlock);
|
|
3162
3526
|
const stakeAccounts = await getStakeAccounts(builder.query, sender);
|
|
3163
3527
|
if (stakeAccounts[stakeMarketCoinName].length === 0) {
|
|
3164
3528
|
throw new Error(`No stake account found for sender ${sender}`);
|
|
@@ -3217,7 +3581,7 @@ var generateSpoolNormalMethod = ({
|
|
|
3217
3581
|
`spool.pools.${stakeMarketCoinName}.rewardPoolId`
|
|
3218
3582
|
);
|
|
3219
3583
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
3220
|
-
const rewardCoinName =
|
|
3584
|
+
const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
|
|
3221
3585
|
const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
|
|
3222
3586
|
return txBlock.moveCall(
|
|
3223
3587
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
@@ -3233,7 +3597,7 @@ var generateSpoolQuickMethod = ({
|
|
|
3233
3597
|
}) => {
|
|
3234
3598
|
return {
|
|
3235
3599
|
stakeQuick: async (amountOrMarketCoin, stakeMarketCoinName, stakeAccountId) => {
|
|
3236
|
-
const sender =
|
|
3600
|
+
const sender = requireSender(txBlock);
|
|
3237
3601
|
const stakeAccountIds = await requireStakeAccountIds(
|
|
3238
3602
|
builder,
|
|
3239
3603
|
txBlock,
|
|
@@ -3292,17 +3656,17 @@ var generateSpoolQuickMethod = ({
|
|
|
3292
3656
|
stakeMarketCoinName,
|
|
3293
3657
|
stakeAccountId
|
|
3294
3658
|
);
|
|
3295
|
-
const
|
|
3659
|
+
const rewardCoins = [];
|
|
3296
3660
|
for (const accountId of stakeAccountIds) {
|
|
3297
3661
|
const rewardCoin = txBlock.claim(accountId, stakeMarketCoinName);
|
|
3298
|
-
|
|
3662
|
+
rewardCoins.push(rewardCoin);
|
|
3299
3663
|
}
|
|
3300
|
-
return
|
|
3664
|
+
return rewardCoins;
|
|
3301
3665
|
}
|
|
3302
3666
|
};
|
|
3303
3667
|
};
|
|
3304
3668
|
var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
3305
|
-
const txBlock = initTxBlock instanceof TransactionBlock2 ? new
|
|
3669
|
+
const txBlock = initTxBlock instanceof TransactionBlock2 ? new SuiKitTxBlock4(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock4();
|
|
3306
3670
|
const normalMethod = generateSpoolNormalMethod({
|
|
3307
3671
|
builder,
|
|
3308
3672
|
txBlock
|
|
@@ -3329,13 +3693,183 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
|
3329
3693
|
});
|
|
3330
3694
|
};
|
|
3331
3695
|
|
|
3696
|
+
// src/builders/borrowIncentiveBuilder.ts
|
|
3697
|
+
import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
|
|
3698
|
+
import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID4 } from "@mysten/sui.js/utils";
|
|
3699
|
+
import { SuiTxBlock as SuiKitTxBlock5 } from "@scallop-io/sui-kit";
|
|
3700
|
+
var requireObligationInfo2 = async (...params) => {
|
|
3701
|
+
const [builder, txBlock, obligationId, obligationKey] = params;
|
|
3702
|
+
if (params.length === 4 && obligationId && obligationKey && typeof obligationId === "string") {
|
|
3703
|
+
const obligationLocked = await getObligationLocked(
|
|
3704
|
+
builder.query,
|
|
3705
|
+
obligationId
|
|
3706
|
+
);
|
|
3707
|
+
return { obligationId, obligationKey, obligationLocked };
|
|
3708
|
+
}
|
|
3709
|
+
const sender = requireSender(txBlock);
|
|
3710
|
+
const obligations = await getObligations(builder.query, sender);
|
|
3711
|
+
if (obligations.length === 0) {
|
|
3712
|
+
throw new Error(`No obligation found for sender ${sender}`);
|
|
3713
|
+
}
|
|
3714
|
+
return {
|
|
3715
|
+
obligationId: obligations[0].id,
|
|
3716
|
+
obligationKey: obligations[0].keyId,
|
|
3717
|
+
obligationLocked: obligations[0].locked
|
|
3718
|
+
};
|
|
3719
|
+
};
|
|
3720
|
+
var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
3721
|
+
const borrowIncentiveIds = {
|
|
3722
|
+
borrowIncentivePkg: builder.address.get("borrowIncentive.id"),
|
|
3723
|
+
query: builder.address.get("borrowIncentive.query"),
|
|
3724
|
+
incentivePools: builder.address.get("borrowIncentive.incentivePools"),
|
|
3725
|
+
incentiveAccounts: builder.address.get(
|
|
3726
|
+
"borrowIncentive.incentiveAccounts"
|
|
3727
|
+
),
|
|
3728
|
+
obligationAccessStore: builder.address.get("core.obligationAccessStore")
|
|
3729
|
+
};
|
|
3730
|
+
return {
|
|
3731
|
+
stakeObligation: (obligationId, obligaionKey, coinName) => {
|
|
3732
|
+
const rewardCoinName = borrowIncentiveRewardCoins[coinName];
|
|
3733
|
+
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
3734
|
+
txBlock.moveCall(
|
|
3735
|
+
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
3736
|
+
[
|
|
3737
|
+
borrowIncentiveIds.incentivePools,
|
|
3738
|
+
borrowIncentiveIds.incentiveAccounts,
|
|
3739
|
+
obligaionKey,
|
|
3740
|
+
obligationId,
|
|
3741
|
+
borrowIncentiveIds.obligationAccessStore,
|
|
3742
|
+
SUI_CLOCK_OBJECT_ID4
|
|
3743
|
+
],
|
|
3744
|
+
[rewardType]
|
|
3745
|
+
);
|
|
3746
|
+
},
|
|
3747
|
+
unstakeObligation: (obligationId, obligaionKey, coinName) => {
|
|
3748
|
+
const rewardCoinName = borrowIncentiveRewardCoins[coinName];
|
|
3749
|
+
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
3750
|
+
txBlock.moveCall(
|
|
3751
|
+
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
3752
|
+
[
|
|
3753
|
+
borrowIncentiveIds.incentivePools,
|
|
3754
|
+
borrowIncentiveIds.incentiveAccounts,
|
|
3755
|
+
obligaionKey,
|
|
3756
|
+
obligationId,
|
|
3757
|
+
SUI_CLOCK_OBJECT_ID4
|
|
3758
|
+
],
|
|
3759
|
+
[rewardType]
|
|
3760
|
+
);
|
|
3761
|
+
},
|
|
3762
|
+
claimBorrowIncentive: (obligationId, obligaionKey, coinName) => {
|
|
3763
|
+
const rewardCoinName = borrowIncentiveRewardCoins[coinName];
|
|
3764
|
+
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
3765
|
+
return txBlock.moveCall(
|
|
3766
|
+
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
3767
|
+
[
|
|
3768
|
+
borrowIncentiveIds.incentivePools,
|
|
3769
|
+
borrowIncentiveIds.incentiveAccounts,
|
|
3770
|
+
obligaionKey,
|
|
3771
|
+
obligationId,
|
|
3772
|
+
SUI_CLOCK_OBJECT_ID4
|
|
3773
|
+
],
|
|
3774
|
+
[rewardType]
|
|
3775
|
+
);
|
|
3776
|
+
}
|
|
3777
|
+
};
|
|
3778
|
+
};
|
|
3779
|
+
var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
3780
|
+
return {
|
|
3781
|
+
stakeObligationQuick: async (coinName, obligation, obligationKey) => {
|
|
3782
|
+
const {
|
|
3783
|
+
obligationId: obligationArg,
|
|
3784
|
+
obligationKey: obligationtKeyArg,
|
|
3785
|
+
obligationLocked
|
|
3786
|
+
} = await requireObligationInfo2(
|
|
3787
|
+
builder,
|
|
3788
|
+
txBlock,
|
|
3789
|
+
obligation,
|
|
3790
|
+
obligationKey
|
|
3791
|
+
);
|
|
3792
|
+
const unstakeObligationBeforeStake = !!txBlock.txBlock.blockData.transactions.find(
|
|
3793
|
+
(txn) => txn.kind === "MoveCall" && txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`
|
|
3794
|
+
);
|
|
3795
|
+
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
3796
|
+
txBlock.stakeObligation(obligationArg, obligationtKeyArg, coinName);
|
|
3797
|
+
}
|
|
3798
|
+
},
|
|
3799
|
+
unstakeObligationQuick: async (coinName, obligation, obligationKey) => {
|
|
3800
|
+
const {
|
|
3801
|
+
obligationId: obligationArg,
|
|
3802
|
+
obligationKey: obligationtKeyArg,
|
|
3803
|
+
obligationLocked
|
|
3804
|
+
} = await requireObligationInfo2(
|
|
3805
|
+
builder,
|
|
3806
|
+
txBlock,
|
|
3807
|
+
obligation,
|
|
3808
|
+
obligationKey
|
|
3809
|
+
);
|
|
3810
|
+
if (obligationLocked) {
|
|
3811
|
+
txBlock.unstakeObligation(obligationArg, obligationtKeyArg, coinName);
|
|
3812
|
+
}
|
|
3813
|
+
},
|
|
3814
|
+
claimBorrowIncentiveQuick: async (coinName, obligation, obligationKey) => {
|
|
3815
|
+
const {
|
|
3816
|
+
obligationId: obligationArg,
|
|
3817
|
+
obligationKey: obligationtKeyArg
|
|
3818
|
+
} = await requireObligationInfo2(
|
|
3819
|
+
builder,
|
|
3820
|
+
txBlock,
|
|
3821
|
+
obligation,
|
|
3822
|
+
obligationKey
|
|
3823
|
+
);
|
|
3824
|
+
return txBlock.claimBorrowIncentive(
|
|
3825
|
+
obligationArg,
|
|
3826
|
+
obligationtKeyArg,
|
|
3827
|
+
coinName
|
|
3828
|
+
);
|
|
3829
|
+
}
|
|
3830
|
+
};
|
|
3831
|
+
};
|
|
3832
|
+
var newBorrowIncentiveTxBlock = (builder, initTxBlock) => {
|
|
3833
|
+
const txBlock = initTxBlock instanceof TransactionBlock3 ? new SuiKitTxBlock5(initTxBlock) : initTxBlock ? initTxBlock : new SuiKitTxBlock5();
|
|
3834
|
+
const normalMethod = generateBorrowIncentiveNormalMethod({
|
|
3835
|
+
builder,
|
|
3836
|
+
txBlock
|
|
3837
|
+
});
|
|
3838
|
+
const normalTxBlock = new Proxy(txBlock, {
|
|
3839
|
+
get: (target, prop) => {
|
|
3840
|
+
if (prop in normalMethod) {
|
|
3841
|
+
return Reflect.get(normalMethod, prop);
|
|
3842
|
+
}
|
|
3843
|
+
return Reflect.get(target, prop);
|
|
3844
|
+
}
|
|
3845
|
+
});
|
|
3846
|
+
const quickMethod = generateBorrowIncentiveQuickMethod({
|
|
3847
|
+
builder,
|
|
3848
|
+
txBlock: normalTxBlock
|
|
3849
|
+
});
|
|
3850
|
+
return new Proxy(normalTxBlock, {
|
|
3851
|
+
get: (target, prop) => {
|
|
3852
|
+
if (prop in quickMethod) {
|
|
3853
|
+
return Reflect.get(quickMethod, prop);
|
|
3854
|
+
}
|
|
3855
|
+
return Reflect.get(target, prop);
|
|
3856
|
+
}
|
|
3857
|
+
});
|
|
3858
|
+
};
|
|
3859
|
+
|
|
3332
3860
|
// src/builders/index.ts
|
|
3333
3861
|
var newScallopTxBlock = (builder, initTxBlock) => {
|
|
3334
|
-
const
|
|
3862
|
+
const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
|
|
3863
|
+
builder,
|
|
3864
|
+
initTxBlock
|
|
3865
|
+
);
|
|
3866
|
+
const spoolTxBlock = newSpoolTxBlock(builder, borrowIncentiveTxBlock);
|
|
3335
3867
|
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);
|
|
3336
3868
|
return new Proxy(coreTxBlock, {
|
|
3337
3869
|
get: (target, prop) => {
|
|
3338
|
-
if (prop in
|
|
3870
|
+
if (prop in borrowIncentiveTxBlock) {
|
|
3871
|
+
return Reflect.get(borrowIncentiveTxBlock, prop);
|
|
3872
|
+
} else if (prop in spoolTxBlock) {
|
|
3339
3873
|
return Reflect.get(spoolTxBlock, prop);
|
|
3340
3874
|
}
|
|
3341
3875
|
return Reflect.get(target, prop);
|
|
@@ -3559,8 +4093,8 @@ var ScallopClient = class {
|
|
|
3559
4093
|
* @param stakeMarketCoinName - Support stake market coin.
|
|
3560
4094
|
* @return Reward pool data.
|
|
3561
4095
|
*/
|
|
3562
|
-
async
|
|
3563
|
-
return await this.query.
|
|
4096
|
+
async getStakeRewardPool(stakeMarketCoinName) {
|
|
4097
|
+
return await this.query.getStakeRewardPool(stakeMarketCoinName);
|
|
3564
4098
|
}
|
|
3565
4099
|
async openObligation(sign = true) {
|
|
3566
4100
|
const txBlock = this.builder.createTxBlock();
|
|
@@ -3832,11 +4366,84 @@ var ScallopClient = class {
|
|
|
3832
4366
|
const txBlock = this.builder.createTxBlock();
|
|
3833
4367
|
const sender = walletAddress || this.walletAddress;
|
|
3834
4368
|
txBlock.setSender(sender);
|
|
3835
|
-
const
|
|
4369
|
+
const rewardCoins = await txBlock.claimQuick(
|
|
3836
4370
|
stakeMarketCoinName,
|
|
3837
4371
|
stakeAccountId
|
|
3838
4372
|
);
|
|
3839
|
-
txBlock.transferObjects(
|
|
4373
|
+
txBlock.transferObjects(rewardCoins, sender);
|
|
4374
|
+
if (sign) {
|
|
4375
|
+
return await this.suiKit.signAndSendTxn(
|
|
4376
|
+
txBlock
|
|
4377
|
+
);
|
|
4378
|
+
} else {
|
|
4379
|
+
return txBlock.txBlock;
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
/* ==================== Borrow Incentive Method ==================== */
|
|
4383
|
+
/**
|
|
4384
|
+
* stake obligaion.
|
|
4385
|
+
*
|
|
4386
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4387
|
+
* @param obligaionId - The obligation account object.
|
|
4388
|
+
* @param obligaionKeyId - The obligation key account object.
|
|
4389
|
+
* @param walletAddress - The wallet address of the owner.
|
|
4390
|
+
* @return Transaction block response or transaction block
|
|
4391
|
+
*/
|
|
4392
|
+
async stakeObligation(coinName, obligaionId, obligaionKeyId, sign = true, walletAddress) {
|
|
4393
|
+
const txBlock = this.builder.createTxBlock();
|
|
4394
|
+
const sender = walletAddress || this.walletAddress;
|
|
4395
|
+
txBlock.setSender(sender);
|
|
4396
|
+
await txBlock.stakeObligationQuick(coinName, obligaionId, obligaionKeyId);
|
|
4397
|
+
if (sign) {
|
|
4398
|
+
return await this.suiKit.signAndSendTxn(
|
|
4399
|
+
txBlock
|
|
4400
|
+
);
|
|
4401
|
+
} else {
|
|
4402
|
+
return txBlock.txBlock;
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
/**
|
|
4406
|
+
* unstake obligaion.
|
|
4407
|
+
*
|
|
4408
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4409
|
+
* @param obligaionId - The obligation account object.
|
|
4410
|
+
* @param obligaionKeyId - The obligation key account object.
|
|
4411
|
+
* @param walletAddress - The wallet address of the owner.
|
|
4412
|
+
* @return Transaction block response or transaction block
|
|
4413
|
+
*/
|
|
4414
|
+
async unstakeObligation(coinName, obligaionId, obligaionKeyId, sign = true, walletAddress) {
|
|
4415
|
+
const txBlock = this.builder.createTxBlock();
|
|
4416
|
+
const sender = walletAddress || this.walletAddress;
|
|
4417
|
+
txBlock.setSender(sender);
|
|
4418
|
+
await txBlock.unstakeObligationQuick(coinName, obligaionId, obligaionKeyId);
|
|
4419
|
+
if (sign) {
|
|
4420
|
+
return await this.suiKit.signAndSendTxn(
|
|
4421
|
+
txBlock
|
|
4422
|
+
);
|
|
4423
|
+
} else {
|
|
4424
|
+
return txBlock.txBlock;
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
/**
|
|
4428
|
+
* unstake market coin from the specific spool.
|
|
4429
|
+
*
|
|
4430
|
+
* @param marketCoinName - Types of mak coin.
|
|
4431
|
+
* @param amount - The amount of coins would deposit.
|
|
4432
|
+
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
4433
|
+
* @param accountId - The stake account object.
|
|
4434
|
+
* @param walletAddress - The wallet address of the owner.
|
|
4435
|
+
* @return Transaction block response or transaction block
|
|
4436
|
+
*/
|
|
4437
|
+
async claimBorrowIncentive(coinName, obligaionId, obligaionKeyId, sign = true, walletAddress) {
|
|
4438
|
+
const txBlock = this.builder.createTxBlock();
|
|
4439
|
+
const sender = walletAddress || this.walletAddress;
|
|
4440
|
+
txBlock.setSender(sender);
|
|
4441
|
+
const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
|
|
4442
|
+
coinName,
|
|
4443
|
+
obligaionId,
|
|
4444
|
+
obligaionKeyId
|
|
4445
|
+
);
|
|
4446
|
+
txBlock.transferObjects([rewardCoin], sender);
|
|
3840
4447
|
if (sign) {
|
|
3841
4448
|
return await this.suiKit.signAndSendTxn(
|
|
3842
4449
|
txBlock
|
|
@@ -3949,12 +4556,14 @@ export {
|
|
|
3949
4556
|
ADDRESSES_ID,
|
|
3950
4557
|
API_BASE_URL,
|
|
3951
4558
|
PROTOCOL_OBJECT_ID,
|
|
4559
|
+
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
4560
|
+
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
3952
4561
|
SUPPORT_COLLATERALS,
|
|
3953
4562
|
SUPPORT_ORACLES,
|
|
3954
4563
|
SUPPORT_PACKAGES,
|
|
3955
4564
|
SUPPORT_POOLS,
|
|
3956
|
-
SUPPORT_REWARD_POOLS,
|
|
3957
4565
|
SUPPORT_SPOOLS,
|
|
4566
|
+
SUPPORT_SPOOLS_REWARDS,
|
|
3958
4567
|
Scallop,
|
|
3959
4568
|
ScallopAddress,
|
|
3960
4569
|
ScallopBuilder,
|
|
@@ -3962,11 +4571,13 @@ export {
|
|
|
3962
4571
|
ScallopQuery,
|
|
3963
4572
|
ScallopUtils,
|
|
3964
4573
|
assetCoins,
|
|
4574
|
+
borrowIncentiveRewardCoins,
|
|
3965
4575
|
coinDecimals,
|
|
3966
4576
|
coinIds,
|
|
3967
4577
|
marketCoins,
|
|
3968
|
-
|
|
4578
|
+
spoolRewardCoins,
|
|
3969
4579
|
stakeMarketCoins,
|
|
4580
|
+
voloCoinIds,
|
|
3970
4581
|
wormholeCoinIds
|
|
3971
4582
|
};
|
|
3972
4583
|
//# sourceMappingURL=index.mjs.map
|