@scallop-io/sui-scallop-sdk 1.3.0-alpha.1 → 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/constants/common.d.ts +6 -4
- package/dist/constants/enum.d.ts +1 -0
- package/dist/index.js +211 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +208 -137
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +4 -4
- package/dist/models/scallopQuery.d.ts +11 -3
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -0
- package/dist/queries/coreQuery.d.ts +2 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/types/constant/common.d.ts +3 -1
- package/dist/types/constant/enum.d.ts +7 -1
- package/dist/types/model.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/util.d.ts +4 -2
- package/package.json +6 -6
- package/src/builders/coreBuilder.ts +2 -2
- package/src/builders/referralBuilder.ts +1 -1
- package/src/builders/spoolBuilder.ts +1 -1
- package/src/constants/common.ts +15 -1
- package/src/constants/enum.ts +13 -0
- package/src/models/scallop.ts +1 -0
- package/src/models/scallopAddress.ts +13 -1
- package/src/models/scallopBuilder.ts +1 -0
- package/src/models/scallopClient.ts +6 -4
- package/src/models/scallopQuery.ts +42 -2
- package/src/models/scallopUtils.ts +54 -23
- package/src/queries/coreQuery.ts +0 -1
- package/src/queries/spoolQuery.ts +40 -103
- package/src/queries/vescaQuery.ts +8 -2
- package/src/types/constant/common.ts +4 -0
- package/src/types/constant/enum.ts +9 -0
- package/src/types/model.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/indexer.ts +39 -0
- package/src/utils/util.ts +25 -3
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,8 @@ var OLD_BORROW_INCENTIVE_PROTOCOL_ID = "0xc63072e7f5f4983a2efaf5bdba1480d5e7d74d
|
|
|
11
11
|
var SUPPORT_POOLS = [
|
|
12
12
|
"usdc",
|
|
13
13
|
// native USDC
|
|
14
|
+
"sbeth",
|
|
15
|
+
// native ETH
|
|
14
16
|
"weth",
|
|
15
17
|
"wbtc",
|
|
16
18
|
"wusdc",
|
|
@@ -26,6 +28,9 @@ var SUPPORT_POOLS = [
|
|
|
26
28
|
];
|
|
27
29
|
var SUPPORT_COLLATERALS = [
|
|
28
30
|
"usdc",
|
|
31
|
+
// native USDC
|
|
32
|
+
"sbeth",
|
|
33
|
+
// native ETH
|
|
29
34
|
"weth",
|
|
30
35
|
"wbtc",
|
|
31
36
|
"wusdc",
|
|
@@ -52,6 +57,7 @@ var SUPPORT_SPOOLS = [
|
|
|
52
57
|
];
|
|
53
58
|
var SUPPORT_SCOIN = [
|
|
54
59
|
"susdc",
|
|
60
|
+
"ssbeth",
|
|
55
61
|
"ssui",
|
|
56
62
|
"swusdc",
|
|
57
63
|
"swusdt",
|
|
@@ -64,6 +70,15 @@ var SUPPORT_SCOIN = [
|
|
|
64
70
|
"swsol",
|
|
65
71
|
"swbtc"
|
|
66
72
|
];
|
|
73
|
+
var SUPPORT_SUI_BRIDGE = ["sbeth"];
|
|
74
|
+
var SUPPORT_WORMHOLE = [
|
|
75
|
+
"wusdc",
|
|
76
|
+
"wusdt",
|
|
77
|
+
"weth",
|
|
78
|
+
"wbtc",
|
|
79
|
+
"wapt",
|
|
80
|
+
"wsol"
|
|
81
|
+
];
|
|
67
82
|
var SUPPORT_SPOOLS_REWARDS = ["sui"];
|
|
68
83
|
var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
69
84
|
"sui",
|
|
@@ -73,6 +88,7 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
|
73
88
|
"hasui",
|
|
74
89
|
"vsui",
|
|
75
90
|
"weth",
|
|
91
|
+
"sbeth",
|
|
76
92
|
"sca",
|
|
77
93
|
"usdc"
|
|
78
94
|
];
|
|
@@ -96,6 +112,7 @@ var SUPPORT_PACKAGES = [
|
|
|
96
112
|
// src/constants/enum.ts
|
|
97
113
|
var coinDecimals = {
|
|
98
114
|
usdc: 6,
|
|
115
|
+
sbeth: 8,
|
|
99
116
|
weth: 8,
|
|
100
117
|
wbtc: 8,
|
|
101
118
|
wusdc: 6,
|
|
@@ -110,6 +127,7 @@ var coinDecimals = {
|
|
|
110
127
|
sca: 9,
|
|
111
128
|
susdc: 6,
|
|
112
129
|
sweth: 8,
|
|
130
|
+
ssbeth: 8,
|
|
113
131
|
swbtc: 8,
|
|
114
132
|
swusdc: 6,
|
|
115
133
|
swusdt: 6,
|
|
@@ -124,6 +142,7 @@ var coinDecimals = {
|
|
|
124
142
|
};
|
|
125
143
|
var assetCoins = {
|
|
126
144
|
usdc: "usdc",
|
|
145
|
+
sbeth: "sbeth",
|
|
127
146
|
weth: "weth",
|
|
128
147
|
wbtc: "wbtc",
|
|
129
148
|
wusdc: "wusdc",
|
|
@@ -139,6 +158,7 @@ var assetCoins = {
|
|
|
139
158
|
};
|
|
140
159
|
var marketCoins = {
|
|
141
160
|
susdc: "susdc",
|
|
161
|
+
ssbeth: "ssbeth",
|
|
142
162
|
sweth: "sweth",
|
|
143
163
|
swbtc: "swbtc",
|
|
144
164
|
swusdc: "swusdc",
|
|
@@ -154,6 +174,7 @@ var marketCoins = {
|
|
|
154
174
|
};
|
|
155
175
|
var sCoins = {
|
|
156
176
|
susdc: "susdc",
|
|
177
|
+
ssbeth: "ssbeth",
|
|
157
178
|
sweth: "sweth",
|
|
158
179
|
swusdc: "swusdc",
|
|
159
180
|
swusdt: "swusdt",
|
|
@@ -188,6 +209,9 @@ var spoolRewardCoins = {
|
|
|
188
209
|
svsui: "sui",
|
|
189
210
|
susdc: "sui"
|
|
190
211
|
};
|
|
212
|
+
var suiBridgeCoins = {
|
|
213
|
+
sbeth: "sbeth"
|
|
214
|
+
};
|
|
191
215
|
var borrowIncentiveRewardCoins = {
|
|
192
216
|
usdc: ["sui", "sca"],
|
|
193
217
|
sui: ["sui", "sca"],
|
|
@@ -197,11 +221,13 @@ var borrowIncentiveRewardCoins = {
|
|
|
197
221
|
afsui: ["sui"],
|
|
198
222
|
hasui: ["sui"],
|
|
199
223
|
vsui: ["sui"],
|
|
200
|
-
weth: ["sui"]
|
|
224
|
+
weth: ["sui"],
|
|
225
|
+
sbeth: ["sui"]
|
|
201
226
|
};
|
|
202
227
|
var coinIds = {
|
|
203
228
|
usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
204
229
|
sui: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
230
|
+
sbeth: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
|
|
205
231
|
weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
206
232
|
wbtc: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
207
233
|
wusdc: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
@@ -227,6 +253,7 @@ var voloCoinIds = {
|
|
|
227
253
|
};
|
|
228
254
|
var sCoinIds = {
|
|
229
255
|
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
256
|
+
ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
230
257
|
ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
|
|
231
258
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
232
259
|
ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
|
|
@@ -787,11 +814,23 @@ var isMarketCoin = (coinName) => {
|
|
|
787
814
|
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
788
815
|
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
789
816
|
};
|
|
817
|
+
var isSuiBridgeAsset = (coinName) => {
|
|
818
|
+
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
819
|
+
};
|
|
820
|
+
var isWormholeAsset = (coinName) => {
|
|
821
|
+
return SUPPORT_WORMHOLE.includes(coinName);
|
|
822
|
+
};
|
|
790
823
|
var parseAssetSymbol = (coinName) => {
|
|
791
|
-
|
|
792
|
-
if (isWormhole) {
|
|
824
|
+
if (isWormholeAsset(coinName)) {
|
|
793
825
|
return `w${coinName.slice(1).toUpperCase()}`;
|
|
794
826
|
}
|
|
827
|
+
if (isSuiBridgeAsset(coinName)) {
|
|
828
|
+
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
829
|
+
}
|
|
830
|
+
if (isMarketCoin(coinName)) {
|
|
831
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
832
|
+
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
833
|
+
}
|
|
795
834
|
switch (coinName) {
|
|
796
835
|
case "afsui":
|
|
797
836
|
return "afSUI";
|
|
@@ -897,6 +936,25 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
|
|
|
897
936
|
return tryRequest();
|
|
898
937
|
};
|
|
899
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
|
+
|
|
900
958
|
// src/models/scallopCache.ts
|
|
901
959
|
var ScallopCache = class {
|
|
902
960
|
constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
|
|
@@ -1900,7 +1958,7 @@ var EMPTY_ADDRESSES = {
|
|
|
1900
1958
|
};
|
|
1901
1959
|
var ScallopAddress = class {
|
|
1902
1960
|
constructor(params, instance) {
|
|
1903
|
-
const { id, auth, network } = params;
|
|
1961
|
+
const { id, auth, network, forceInterface } = params;
|
|
1904
1962
|
this.cache = instance?.cache ?? new ScallopCache(
|
|
1905
1963
|
instance?.suiKit ?? new SuiKit({}),
|
|
1906
1964
|
void 0,
|
|
@@ -1921,6 +1979,17 @@ var ScallopAddress = class {
|
|
|
1921
1979
|
this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1922
1980
|
if (USE_TEST_ADDRESS)
|
|
1923
1981
|
this._currentAddresses = TEST_ADDRESSES;
|
|
1982
|
+
if (forceInterface) {
|
|
1983
|
+
for (const [network2, addresses] of Object.entries(
|
|
1984
|
+
forceInterface
|
|
1985
|
+
)) {
|
|
1986
|
+
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
1987
|
+
if (network2 === this._network)
|
|
1988
|
+
this._currentAddresses = addresses;
|
|
1989
|
+
this._addressesMap.set(network2, addresses);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1924
1993
|
}
|
|
1925
1994
|
/**
|
|
1926
1995
|
* Get addresses API id.
|
|
@@ -3042,18 +3111,13 @@ var getStakeAccounts = async ({
|
|
|
3042
3111
|
hasNextPage = false;
|
|
3043
3112
|
}
|
|
3044
3113
|
} while (hasNextPage);
|
|
3045
|
-
const stakeAccounts =
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
safsui: [],
|
|
3053
|
-
shasui: [],
|
|
3054
|
-
svsui: []
|
|
3055
|
-
// ssca: [],
|
|
3056
|
-
};
|
|
3114
|
+
const stakeAccounts = SUPPORT_SPOOLS.reduce(
|
|
3115
|
+
(acc, stakeName) => {
|
|
3116
|
+
acc[stakeName] = [];
|
|
3117
|
+
return acc;
|
|
3118
|
+
},
|
|
3119
|
+
{}
|
|
3120
|
+
);
|
|
3057
3121
|
const stakeMarketCoinTypes = Object.keys(stakeAccounts).reduce(
|
|
3058
3122
|
(types, stakeMarketCoinName) => {
|
|
3059
3123
|
const stakeCoinName = utils.parseCoinName(stakeMarketCoinName);
|
|
@@ -3063,6 +3127,13 @@ var getStakeAccounts = async ({
|
|
|
3063
3127
|
},
|
|
3064
3128
|
{}
|
|
3065
3129
|
);
|
|
3130
|
+
const reversedStakeMarketCoinTypes = Object.entries(stakeMarketCoinTypes).reduce(
|
|
3131
|
+
(reversedTypes, [key, value]) => {
|
|
3132
|
+
reversedTypes[value] = key;
|
|
3133
|
+
return reversedTypes;
|
|
3134
|
+
},
|
|
3135
|
+
{}
|
|
3136
|
+
);
|
|
3066
3137
|
const stakeObjectIds = stakeObjectsResponse.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
|
|
3067
3138
|
const stakeObjects = await utils.cache.queryGetObjects(stakeObjectIds, {
|
|
3068
3139
|
showContent: true,
|
|
@@ -3079,98 +3150,23 @@ var getStakeAccounts = async ({
|
|
|
3079
3150
|
const index = Number(fields.index);
|
|
3080
3151
|
const points = Number(fields.points);
|
|
3081
3152
|
const totalPoints = Number(fields.total_points);
|
|
3082
|
-
|
|
3083
|
-
stakeAccounts.sweth
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
stakePoolId,
|
|
3098
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3099
|
-
staked,
|
|
3100
|
-
index,
|
|
3101
|
-
points,
|
|
3102
|
-
totalPoints
|
|
3103
|
-
});
|
|
3104
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.swusdc) {
|
|
3105
|
-
stakeAccounts.swusdc.push({
|
|
3106
|
-
id,
|
|
3107
|
-
type: normalizeStructTag4(type),
|
|
3108
|
-
stakePoolId,
|
|
3109
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3110
|
-
staked,
|
|
3111
|
-
index,
|
|
3112
|
-
points,
|
|
3113
|
-
totalPoints
|
|
3114
|
-
});
|
|
3115
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.swusdt) {
|
|
3116
|
-
stakeAccounts.swusdt.push({
|
|
3117
|
-
id,
|
|
3118
|
-
type: normalizeStructTag4(type),
|
|
3119
|
-
stakePoolId,
|
|
3120
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3121
|
-
staked,
|
|
3122
|
-
index,
|
|
3123
|
-
points,
|
|
3124
|
-
totalPoints
|
|
3125
|
-
});
|
|
3126
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.scetus) {
|
|
3127
|
-
stakeAccounts.scetus.push({
|
|
3128
|
-
id,
|
|
3129
|
-
type: normalizeStructTag4(type),
|
|
3130
|
-
stakePoolId,
|
|
3131
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3132
|
-
staked,
|
|
3133
|
-
index,
|
|
3134
|
-
points,
|
|
3135
|
-
totalPoints
|
|
3136
|
-
});
|
|
3137
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.safsui) {
|
|
3138
|
-
stakeAccounts.safsui.push({
|
|
3139
|
-
id,
|
|
3140
|
-
type: normalizeStructTag4(type),
|
|
3141
|
-
stakePoolId,
|
|
3142
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3143
|
-
staked,
|
|
3144
|
-
index,
|
|
3145
|
-
points,
|
|
3146
|
-
totalPoints
|
|
3147
|
-
});
|
|
3148
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.shasui) {
|
|
3149
|
-
stakeAccounts.shasui.push({
|
|
3150
|
-
id,
|
|
3151
|
-
type: normalizeStructTag4(type),
|
|
3152
|
-
stakePoolId,
|
|
3153
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3154
|
-
staked,
|
|
3155
|
-
index,
|
|
3156
|
-
points,
|
|
3157
|
-
totalPoints
|
|
3158
|
-
});
|
|
3159
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.svsui) {
|
|
3160
|
-
stakeAccounts.svsui.push({
|
|
3161
|
-
id,
|
|
3162
|
-
type: normalizeStructTag4(type),
|
|
3163
|
-
stakePoolId,
|
|
3164
|
-
stakeType: normalizeStructTag4(stakeType),
|
|
3165
|
-
staked,
|
|
3166
|
-
index,
|
|
3167
|
-
points,
|
|
3168
|
-
totalPoints
|
|
3169
|
-
});
|
|
3170
|
-
} else if (normalizeStructTag4(type) === stakeMarketCoinTypes.susdc) {
|
|
3171
|
-
stakeAccounts.susdc.push({
|
|
3153
|
+
const stakeMarketCoinTypeMap = {
|
|
3154
|
+
sweth: stakeAccounts.sweth,
|
|
3155
|
+
ssui: stakeAccounts.ssui,
|
|
3156
|
+
swusdc: stakeAccounts.swusdc,
|
|
3157
|
+
swusdt: stakeAccounts.swusdt,
|
|
3158
|
+
scetus: stakeAccounts.scetus,
|
|
3159
|
+
safsui: stakeAccounts.safsui,
|
|
3160
|
+
shasui: stakeAccounts.shasui,
|
|
3161
|
+
svsui: stakeAccounts.svsui,
|
|
3162
|
+
susdc: stakeAccounts.susdc
|
|
3163
|
+
};
|
|
3164
|
+
const normalizedType = normalizeStructTag4(type);
|
|
3165
|
+
const stakeAccountArray = stakeMarketCoinTypeMap[reversedStakeMarketCoinTypes[normalizedType]];
|
|
3166
|
+
if (stakeAccountArray) {
|
|
3167
|
+
stakeAccountArray.push({
|
|
3172
3168
|
id,
|
|
3173
|
-
type:
|
|
3169
|
+
type: normalizedType,
|
|
3174
3170
|
stakePoolId,
|
|
3175
3171
|
stakeType: normalizeStructTag4(stakeType),
|
|
3176
3172
|
staked,
|
|
@@ -4089,7 +4085,7 @@ var getVescaKeys = async (utils, ownerAddress) => {
|
|
|
4089
4085
|
};
|
|
4090
4086
|
var getVeScas = async ({
|
|
4091
4087
|
utils
|
|
4092
|
-
}, ownerAddress) => {
|
|
4088
|
+
}, ownerAddress, excludeEmpty) => {
|
|
4093
4089
|
const keyObjectDatas = await getVescaKeys(utils, ownerAddress);
|
|
4094
4090
|
const veScas = Array(keyObjectDatas.length).fill(null);
|
|
4095
4091
|
const tasks = keyObjectDatas.map(async (veScaKey, idx) => {
|
|
@@ -4099,7 +4095,11 @@ var getVeScas = async ({
|
|
|
4099
4095
|
}
|
|
4100
4096
|
});
|
|
4101
4097
|
await Promise.allSettled(tasks);
|
|
4102
|
-
|
|
4098
|
+
const result = veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
4099
|
+
if (excludeEmpty) {
|
|
4100
|
+
return result.filter((v) => v.lockedScaAmount !== "0");
|
|
4101
|
+
}
|
|
4102
|
+
return result;
|
|
4103
4103
|
};
|
|
4104
4104
|
var SuiObjectRefZod = zod2.object({
|
|
4105
4105
|
objectId: zod2.string(),
|
|
@@ -4334,7 +4334,8 @@ var ScallopUtils = class {
|
|
|
4334
4334
|
this.address = instance?.address ?? new ScallopAddress(
|
|
4335
4335
|
{
|
|
4336
4336
|
id: params?.addressesId || ADDRESSES_ID,
|
|
4337
|
-
network: params?.networkType
|
|
4337
|
+
network: params?.networkType,
|
|
4338
|
+
forceInterface: params?.forceAddressesInterface
|
|
4338
4339
|
},
|
|
4339
4340
|
{
|
|
4340
4341
|
cache: this.cache
|
|
@@ -4343,6 +4344,13 @@ var ScallopUtils = class {
|
|
|
4343
4344
|
}
|
|
4344
4345
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
4345
4346
|
}
|
|
4347
|
+
// -------------- TYPE GUARDS --------------
|
|
4348
|
+
isSuiBridgeAsset(coinName) {
|
|
4349
|
+
return isSuiBridgeAsset(coinName);
|
|
4350
|
+
}
|
|
4351
|
+
isWormholeAsset(coinName) {
|
|
4352
|
+
return isWormholeAsset(coinName);
|
|
4353
|
+
}
|
|
4346
4354
|
/**
|
|
4347
4355
|
* Request the scallop API to initialize data.
|
|
4348
4356
|
*
|
|
@@ -4363,12 +4371,7 @@ var ScallopUtils = class {
|
|
|
4363
4371
|
* @return Symbol string.
|
|
4364
4372
|
*/
|
|
4365
4373
|
parseSymbol(coinName) {
|
|
4366
|
-
|
|
4367
|
-
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
4368
|
-
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
4369
|
-
} else {
|
|
4370
|
-
return parseAssetSymbol(coinName);
|
|
4371
|
-
}
|
|
4374
|
+
return parseAssetSymbol(coinName);
|
|
4372
4375
|
}
|
|
4373
4376
|
/**
|
|
4374
4377
|
* Convert coin name to coin type.
|
|
@@ -4400,10 +4403,21 @@ var ScallopUtils = class {
|
|
|
4400
4403
|
const voloPackageIds = [
|
|
4401
4404
|
this.address.get("core.coins.vsui.id") ?? voloCoinIds.vsui
|
|
4402
4405
|
];
|
|
4406
|
+
const suiBridgePackageIds = Object.values(
|
|
4407
|
+
suiBridgeCoins
|
|
4408
|
+
).reduce((curr, coinName2) => {
|
|
4409
|
+
curr.push(
|
|
4410
|
+
this.address.get(`core.coins.${coinName2}.id`) ?? coinIds[coinName2]
|
|
4411
|
+
);
|
|
4412
|
+
return curr;
|
|
4413
|
+
}, []);
|
|
4403
4414
|
if (wormHolePackageIds.includes(coinPackageId)) {
|
|
4404
4415
|
return `${coinPackageId}::coin::COIN`;
|
|
4405
4416
|
} else if (voloPackageIds.includes(coinPackageId)) {
|
|
4406
4417
|
return `${coinPackageId}::cert::CERT`;
|
|
4418
|
+
} else if (suiBridgePackageIds.includes(coinPackageId)) {
|
|
4419
|
+
const typeCoinName = coinName.slice(2);
|
|
4420
|
+
return `${coinPackageId}::${typeCoinName}::${typeCoinName.toUpperCase()}`;
|
|
4407
4421
|
} else {
|
|
4408
4422
|
return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
|
|
4409
4423
|
}
|
|
@@ -4479,11 +4493,20 @@ var ScallopUtils = class {
|
|
|
4479
4493
|
const voloCoinTypeMap = {
|
|
4480
4494
|
[`${this.address.get("core.coins.vsui.id") ?? voloCoinIds.vsui}::cert::CERT`]: "vsui"
|
|
4481
4495
|
};
|
|
4482
|
-
const
|
|
4496
|
+
const suiBridgeTypeMap = Object.values(
|
|
4497
|
+
suiBridgeCoins
|
|
4498
|
+
).reduce(
|
|
4499
|
+
(curr, coinName) => {
|
|
4500
|
+
curr[this.parseCoinType(coinName)] = coinName;
|
|
4501
|
+
return curr;
|
|
4502
|
+
},
|
|
4503
|
+
{}
|
|
4504
|
+
);
|
|
4505
|
+
const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
|
|
4483
4506
|
return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
|
|
4484
4507
|
}
|
|
4485
4508
|
/**
|
|
4486
|
-
* Convert
|
|
4509
|
+
* Convert market coin name to coin name.
|
|
4487
4510
|
*
|
|
4488
4511
|
* @param marketCoinName - Specific support market coin name.
|
|
4489
4512
|
* @return Coin Name.
|
|
@@ -4514,10 +4537,18 @@ var ScallopUtils = class {
|
|
|
4514
4537
|
* return Coin wrapped type.
|
|
4515
4538
|
*/
|
|
4516
4539
|
getCoinWrappedType(assetCoinName) {
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4540
|
+
if (this.isSuiBridgeAsset(assetCoinName)) {
|
|
4541
|
+
return {
|
|
4542
|
+
from: "Sui Bridge",
|
|
4543
|
+
type: "Asset from Sui Bridge"
|
|
4544
|
+
};
|
|
4545
|
+
} else if (this.isWormholeAsset(assetCoinName)) {
|
|
4546
|
+
return {
|
|
4547
|
+
from: "Wormhole",
|
|
4548
|
+
type: "Portal from Ethereum"
|
|
4549
|
+
};
|
|
4550
|
+
}
|
|
4551
|
+
return void 0;
|
|
4521
4552
|
}
|
|
4522
4553
|
/**
|
|
4523
4554
|
* Select coin id that add up to the given amount as transaction arguments.
|
|
@@ -4553,7 +4584,7 @@ var ScallopUtils = class {
|
|
|
4553
4584
|
if (existingCoins.length > 0) {
|
|
4554
4585
|
txBlock.mergeCoins(dest, existingCoins.slice(0, 500));
|
|
4555
4586
|
}
|
|
4556
|
-
} catch (
|
|
4587
|
+
} catch (_e) {
|
|
4557
4588
|
}
|
|
4558
4589
|
}
|
|
4559
4590
|
/**
|
|
@@ -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,
|
|
@@ -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
|
};
|
|
@@ -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
|
}
|
|
@@ -6623,7 +6654,8 @@ var ScallopQuery = class {
|
|
|
6623
6654
|
this.address = new ScallopAddress(
|
|
6624
6655
|
{
|
|
6625
6656
|
id: params?.addressesId || ADDRESSES_ID,
|
|
6626
|
-
network: params?.networkType
|
|
6657
|
+
network: params?.networkType,
|
|
6658
|
+
forceInterface: params?.forceAddressesInterface
|
|
6627
6659
|
},
|
|
6628
6660
|
{
|
|
6629
6661
|
cache: this.cache
|
|
@@ -6634,7 +6666,36 @@ var ScallopQuery = class {
|
|
|
6634
6666
|
});
|
|
6635
6667
|
}
|
|
6636
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);
|
|
6637
6697
|
}
|
|
6698
|
+
/* ========================================================== */
|
|
6638
6699
|
/**
|
|
6639
6700
|
* Request the scallop API to initialize data.
|
|
6640
6701
|
*
|
|
@@ -6993,8 +7054,11 @@ var ScallopQuery = class {
|
|
|
6993
7054
|
* @param walletAddress
|
|
6994
7055
|
* @returns array of veSca
|
|
6995
7056
|
*/
|
|
6996
|
-
async getVeScas(
|
|
6997
|
-
|
|
7057
|
+
async getVeScas({
|
|
7058
|
+
walletAddress = this.walletAddress,
|
|
7059
|
+
excludeEmpty = false
|
|
7060
|
+
} = {}) {
|
|
7061
|
+
return await getVeScas(this, walletAddress, excludeEmpty);
|
|
6998
7062
|
}
|
|
6999
7063
|
/**
|
|
7000
7064
|
* Get total vesca treasury with movecall
|
|
@@ -7112,7 +7176,8 @@ var ScallopBuilder = class {
|
|
|
7112
7176
|
this.address = new ScallopAddress(
|
|
7113
7177
|
{
|
|
7114
7178
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7115
|
-
network: params?.networkType
|
|
7179
|
+
network: params?.networkType,
|
|
7180
|
+
forceInterface: params?.forceAddressesInterface
|
|
7116
7181
|
},
|
|
7117
7182
|
{
|
|
7118
7183
|
cache: this.cache
|
|
@@ -7262,7 +7327,8 @@ var ScallopClient = class {
|
|
|
7262
7327
|
this.address = new ScallopAddress(
|
|
7263
7328
|
{
|
|
7264
7329
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7265
|
-
network: params?.networkType
|
|
7330
|
+
network: params?.networkType,
|
|
7331
|
+
forceInterface: params?.forceAddressesInterface
|
|
7266
7332
|
},
|
|
7267
7333
|
{
|
|
7268
7334
|
cache: this.cache
|
|
@@ -7655,7 +7721,6 @@ var ScallopClient = class {
|
|
|
7655
7721
|
false
|
|
7656
7722
|
);
|
|
7657
7723
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
7658
|
-
console.log(stakeMarketCoin, stakeCoinName);
|
|
7659
7724
|
if (stakeMarketCoin) {
|
|
7660
7725
|
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
7661
7726
|
await this.utils.mergeSimilarCoins(
|
|
@@ -7822,7 +7887,7 @@ var ScallopClient = class {
|
|
|
7822
7887
|
if (sCoin) {
|
|
7823
7888
|
sCoins2.push(sCoin);
|
|
7824
7889
|
}
|
|
7825
|
-
} catch (
|
|
7890
|
+
} catch (_e) {
|
|
7826
7891
|
}
|
|
7827
7892
|
}
|
|
7828
7893
|
}
|
|
@@ -7847,7 +7912,9 @@ var ScallopClient = class {
|
|
|
7847
7912
|
}
|
|
7848
7913
|
}
|
|
7849
7914
|
async claimAllUnlockedSca(sign = true) {
|
|
7850
|
-
const veScaKeys = (await this.query.getVeScas(
|
|
7915
|
+
const veScaKeys = (await this.query.getVeScas({
|
|
7916
|
+
walletAddress: this.walletAddress
|
|
7917
|
+
}) ?? []).map(({ keyObject }) => keyObject);
|
|
7851
7918
|
if (veScaKeys.length === 0) {
|
|
7852
7919
|
throw new Error("No veSCA found in the wallet");
|
|
7853
7920
|
}
|
|
@@ -7861,7 +7928,7 @@ var ScallopClient = class {
|
|
|
7861
7928
|
if (!scaCoin)
|
|
7862
7929
|
return;
|
|
7863
7930
|
scaCoins.push(scaCoin);
|
|
7864
|
-
} catch (
|
|
7931
|
+
} catch (_e) {
|
|
7865
7932
|
}
|
|
7866
7933
|
})
|
|
7867
7934
|
);
|
|
@@ -7924,7 +7991,8 @@ var Scallop = class {
|
|
|
7924
7991
|
this.address = new ScallopAddress(
|
|
7925
7992
|
{
|
|
7926
7993
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7927
|
-
network: params?.networkType
|
|
7994
|
+
network: params?.networkType,
|
|
7995
|
+
forceInterface: params?.forceAddressesInterface
|
|
7928
7996
|
},
|
|
7929
7997
|
{ cache: this.cache }
|
|
7930
7998
|
);
|
|
@@ -8045,6 +8113,8 @@ export {
|
|
|
8045
8113
|
SUPPORT_SCOIN,
|
|
8046
8114
|
SUPPORT_SPOOLS,
|
|
8047
8115
|
SUPPORT_SPOOLS_REWARDS,
|
|
8116
|
+
SUPPORT_SUI_BRIDGE,
|
|
8117
|
+
SUPPORT_WORMHOLE,
|
|
8048
8118
|
Scallop,
|
|
8049
8119
|
ScallopAddress,
|
|
8050
8120
|
ScallopBuilder,
|
|
@@ -8064,6 +8134,7 @@ export {
|
|
|
8064
8134
|
sCoins,
|
|
8065
8135
|
spoolRewardCoins,
|
|
8066
8136
|
stakeMarketCoins,
|
|
8137
|
+
suiBridgeCoins,
|
|
8067
8138
|
voloCoinIds,
|
|
8068
8139
|
wormholeCoinIds
|
|
8069
8140
|
};
|