@basedone/core 0.1.6 → 0.1.8

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/index.mjs CHANGED
@@ -284,6 +284,9 @@ function isMiniAppTriggeredCloid(cloidHex) {
284
284
  return cloidData.miniAppTriggered;
285
285
  }
286
286
 
287
+ // lib/fee.ts
288
+ import Decimal from "decimal.js";
289
+
287
290
  // lib/constants/fee.ts
288
291
  var BASED_FEE_WALLET = "0x1924b8561eeF20e70Ede628A296175D358BE80e5";
289
292
  var BASED_REFERRAL_CODE = "SHIFU";
@@ -299,13 +302,19 @@ var TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = `0.1%`;
299
302
  var getApprovalAmount = ({
300
303
  customFeeEnabled,
301
304
  perpetualTradingFee,
302
- spotTradingFee
305
+ spotTradingFee,
306
+ feeDiscount
303
307
  }) => {
308
+ if (feeDiscount !== void 0 && (feeDiscount < 0 || feeDiscount > 1)) {
309
+ console.warn("Fee discount is not between 0 and 1, setting to 0");
310
+ feeDiscount = 0;
311
+ }
312
+ const discountMultiplier = feeDiscount ? new Decimal(1).sub(feeDiscount) : 1;
304
313
  if (!customFeeEnabled) {
305
314
  return {
306
- approvalAmount: TARGET_APPROVED_MAX_BUILDER_FEE,
307
- perpFee: TARGET_FUTURES_BUILDER_FEE,
308
- spotFee: TARGET_SPOT_BUILDER_FEE,
315
+ approvalAmount: new Decimal(TARGET_APPROVED_MAX_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
316
+ perpFee: new Decimal(TARGET_FUTURES_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
317
+ spotFee: new Decimal(TARGET_SPOT_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
309
318
  approvalPercent: TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
310
319
  builder: BASED_FEE_WALLET,
311
320
  referralCode: BASED_REFERRAL_CODE
@@ -315,6 +324,7 @@ var getApprovalAmount = ({
315
324
  if (validatedPerpFeePct === void 0) {
316
325
  validatedPerpFeePct = TARGET_FUTURES_BUILDER_FEE / 1e3;
317
326
  }
327
+ validatedPerpFeePct = new Decimal(validatedPerpFeePct).mul(discountMultiplier).toNumber();
318
328
  if (validatedPerpFeePct > 0 && validatedPerpFeePct < 0.01) {
319
329
  console.warn("Perp fee is less than 0.01%, setting to 0.01%");
320
330
  validatedPerpFeePct = 0.01;
@@ -331,6 +341,7 @@ var getApprovalAmount = ({
331
341
  if (validatedSpotFeePct === void 0) {
332
342
  validatedSpotFeePct = TARGET_SPOT_BUILDER_FEE / 1e3;
333
343
  }
344
+ validatedSpotFeePct = new Decimal(validatedSpotFeePct).mul(discountMultiplier).toNumber();
334
345
  if (validatedSpotFeePct > 0 && validatedSpotFeePct < 0.025) {
335
346
  console.warn("Spot fee is less than 0.025%, setting to 0.025%");
336
347
  validatedSpotFeePct = 0.025;
@@ -608,7 +619,9 @@ async function getHip3DexAbstraction(client, user) {
608
619
  }
609
620
  var dexToCollateralTokenSymbol = {
610
621
  rrrrr: "USDEEE",
611
- hyena: "USDE"
622
+ hyena: "USDE",
623
+ flx: "USDH",
624
+ vntl: "USDH"
612
625
  };
613
626
  var isSpotSymbol = (coin) => {
614
627
  if (!coin) return false;
@@ -624,6 +637,10 @@ function getStaticCollateralTokenSymbol(coin) {
624
637
  if (!dex) return "USDC";
625
638
  return getStaticCollateralTokenByDex(dex);
626
639
  }
640
+ var stableQuoteTokens = ["USDC", "USDT0", "USDE", "USDEEE", "USDH"];
641
+ function isStableQuoteToken(coin) {
642
+ return stableQuoteTokens.includes(coin);
643
+ }
627
644
  function getDisplayMarketSymbol(coin, showCollateralTokenSymbol = true, collateralTokenSymbol) {
628
645
  if (!coin || isSpotSymbol(coin)) return coin;
629
646
  if (isHip3Symbol(coin)) {
@@ -648,20 +665,20 @@ var globImport_data_staticMeta_json = __glob({
648
665
 
649
666
  // import("./data/**/*/spotMeta.json") in lib/meta/metadata.ts
650
667
  var globImport_data_spotMeta_json = __glob({
651
- "./data/mainnet/spotMeta.json": () => import("./spotMeta-NK626IKQ.mjs"),
652
- "./data/testnet/spotMeta.json": () => import("./spotMeta-4LMKHJUT.mjs")
668
+ "./data/mainnet/spotMeta.json": () => import("./spotMeta-WQ4PXRNY.mjs"),
669
+ "./data/testnet/spotMeta.json": () => import("./spotMeta-Y7G2GI7B.mjs")
653
670
  });
654
671
 
655
672
  // import("./data/**/*/meta.json") in lib/meta/metadata.ts
656
673
  var globImport_data_meta_json = __glob({
657
- "./data/mainnet/meta.json": () => import("./meta-HEOHBPHS.mjs"),
658
- "./data/testnet/meta.json": () => import("./meta-CDVVRMMG.mjs")
674
+ "./data/mainnet/meta.json": () => import("./meta-RSZFFH63.mjs"),
675
+ "./data/testnet/meta.json": () => import("./meta-57AY44US.mjs")
659
676
  });
660
677
 
661
678
  // import("./data/**/*/perpDexs.json") in lib/meta/metadata.ts
662
679
  var globImport_data_perpDexs_json = __glob({
663
- "./data/mainnet/perpDexs.json": () => import("./perpDexs-G5YWV3II.mjs"),
664
- "./data/testnet/perpDexs.json": () => import("./perpDexs-PGY6VMYS.mjs")
680
+ "./data/mainnet/perpDexs.json": () => import("./perpDexs-PBKWKKQU.mjs"),
681
+ "./data/testnet/perpDexs.json": () => import("./perpDexs-XSB4Y2BP.mjs")
665
682
  });
666
683
 
667
684
  // lib/meta/metadata.ts
@@ -1165,7 +1182,7 @@ var MetadataClient = class {
1165
1182
  };
1166
1183
 
1167
1184
  // lib/utils/formatter.ts
1168
- import { Decimal } from "decimal.js";
1185
+ import { Decimal as Decimal2 } from "decimal.js";
1169
1186
  var formatPriceAndSize = ({
1170
1187
  px,
1171
1188
  sz,
@@ -1173,8 +1190,8 @@ var formatPriceAndSize = ({
1173
1190
  isSpot
1174
1191
  }) => {
1175
1192
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
1176
- const price = new Decimal(px).toDP(priceDecimals).toNumber();
1177
- const size = new Decimal(sz).toDP(szDecimals, Decimal.ROUND_DOWN).toNumber();
1193
+ const price = new Decimal2(px).toDP(priceDecimals).toNumber();
1194
+ const size = new Decimal2(sz).toDP(szDecimals, Decimal2.ROUND_DOWN).toNumber();
1178
1195
  return {
1179
1196
  price,
1180
1197
  size
@@ -1186,7 +1203,7 @@ var formatPriceForOrder = ({
1186
1203
  isSpot
1187
1204
  }) => {
1188
1205
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
1189
- const price = new Decimal(px).toDP(priceDecimals).toNumber();
1206
+ const price = new Decimal2(px).toDP(priceDecimals).toNumber();
1190
1207
  return price;
1191
1208
  };
1192
1209
  var formatPriceForDisplay = ({
@@ -1205,7 +1222,7 @@ var formatSizeForOrder = ({
1205
1222
  sz,
1206
1223
  szDecimals
1207
1224
  }) => {
1208
- return new Decimal(sz).toDP(szDecimals, Decimal.ROUND_DOWN).toNumber();
1225
+ return new Decimal2(sz).toDP(szDecimals, Decimal2.ROUND_DOWN).toNumber();
1209
1226
  };
1210
1227
  var formatSizeForDisplay = ({
1211
1228
  sz,
@@ -1275,6 +1292,7 @@ export {
1275
1292
  isMiniAppCloid,
1276
1293
  isMiniAppTriggeredCloid,
1277
1294
  isSpotSymbol,
1295
+ isStableQuoteToken,
1278
1296
  isTenantCloid,
1279
1297
  isTrackingIdCloid,
1280
1298
  isWidgetType,
@@ -1282,5 +1300,6 @@ export {
1282
1300
  normaliseTrackingId,
1283
1301
  normalizeAirdropAmount,
1284
1302
  parseCloid,
1285
- setHip3DexAbstraction
1303
+ setHip3DexAbstraction,
1304
+ stableQuoteTokens
1286
1305
  };
@@ -113,7 +113,8 @@ var universe = [
113
113
  maxLeverage: 2,
114
114
  marginTableId: 2,
115
115
  onlyIsolated: true,
116
- isDelisted: true
116
+ isDelisted: true,
117
+ marginMode: "strictIsolated"
117
118
  },
118
119
  {
119
120
  szDecimals: 2,
@@ -196,7 +197,8 @@ var universe = [
196
197
  maxLeverage: 3,
197
198
  marginTableId: 3,
198
199
  onlyIsolated: true,
199
- isDelisted: true
200
+ isDelisted: true,
201
+ marginMode: "strictIsolated"
200
202
  },
201
203
  {
202
204
  szDecimals: 1,
@@ -204,14 +206,16 @@ var universe = [
204
206
  maxLeverage: 3,
205
207
  marginTableId: 3,
206
208
  onlyIsolated: true,
207
- isDelisted: true
209
+ isDelisted: true,
210
+ marginMode: "strictIsolated"
208
211
  },
209
212
  {
210
213
  szDecimals: 1,
211
214
  name: "ZRO",
212
215
  maxLeverage: 10,
213
216
  marginTableId: 55,
214
- onlyIsolated: true
217
+ onlyIsolated: true,
218
+ marginMode: "strictIsolated"
215
219
  },
216
220
  {
217
221
  szDecimals: 0,
@@ -225,7 +229,8 @@ var universe = [
225
229
  name: "BANANA",
226
230
  maxLeverage: 3,
227
231
  marginTableId: 3,
228
- onlyIsolated: true
232
+ onlyIsolated: true,
233
+ marginMode: "strictIsolated"
229
234
  },
230
235
  {
231
236
  szDecimals: 1,
@@ -245,7 +250,8 @@ var universe = [
245
250
  maxLeverage: 3,
246
251
  marginTableId: 3,
247
252
  onlyIsolated: true,
248
- isDelisted: true
253
+ isDelisted: true,
254
+ marginMode: "strictIsolated"
249
255
  },
250
256
  {
251
257
  szDecimals: 0,
@@ -293,8 +299,8 @@ var universe = [
293
299
  {
294
300
  szDecimals: 0,
295
301
  name: "ADA",
296
- maxLeverage: 3,
297
- marginTableId: 3
302
+ maxLeverage: 10,
303
+ marginTableId: 55
298
304
  },
299
305
  {
300
306
  szDecimals: 0,
@@ -439,7 +445,8 @@ var universe = [
439
445
  maxLeverage: 3,
440
446
  marginTableId: 3,
441
447
  onlyIsolated: true,
442
- isDelisted: true
448
+ isDelisted: true,
449
+ marginMode: "strictIsolated"
443
450
  },
444
451
  {
445
452
  szDecimals: 0,
@@ -501,7 +508,8 @@ var universe = [
501
508
  name: "WIF",
502
509
  maxLeverage: 5,
503
510
  marginTableId: 5,
504
- onlyIsolated: true
511
+ onlyIsolated: true,
512
+ marginMode: "strictIsolated"
505
513
  },
506
514
  {
507
515
  szDecimals: 1,
@@ -587,7 +595,8 @@ var universe = [
587
595
  name: "W",
588
596
  maxLeverage: 3,
589
597
  marginTableId: 3,
590
- onlyIsolated: true
598
+ onlyIsolated: true,
599
+ marginMode: "strictIsolated"
591
600
  },
592
601
  {
593
602
  szDecimals: 5,
@@ -595,7 +604,8 @@ var universe = [
595
604
  maxLeverage: 3,
596
605
  marginTableId: 3,
597
606
  onlyIsolated: true,
598
- isDelisted: true
607
+ isDelisted: true,
608
+ marginMode: "strictIsolated"
599
609
  },
600
610
  {
601
611
  szDecimals: 1,
@@ -701,7 +711,8 @@ var universe = [
701
711
  name: "ZK",
702
712
  maxLeverage: 3,
703
713
  marginTableId: 3,
704
- onlyIsolated: true
714
+ onlyIsolated: true,
715
+ marginMode: "strictIsolated"
705
716
  },
706
717
  {
707
718
  szDecimals: 0,
@@ -788,14 +799,16 @@ var universe = [
788
799
  {
789
800
  szDecimals: 0,
790
801
  name: "MOODENG",
791
- maxLeverage: 5,
792
- marginTableId: 5
802
+ maxLeverage: 3,
803
+ marginTableId: 3
793
804
  },
794
805
  {
795
806
  szDecimals: 0,
796
807
  name: "PURR",
797
808
  maxLeverage: 3,
798
- marginTableId: 3
809
+ marginTableId: 3,
810
+ onlyIsolated: true,
811
+ marginMode: "strictIsolated"
799
812
  },
800
813
  {
801
814
  szDecimals: 1,
@@ -856,7 +869,9 @@ var universe = [
856
869
  szDecimals: 2,
857
870
  name: "HYPE",
858
871
  maxLeverage: 10,
859
- marginTableId: 10
872
+ marginTableId: 10,
873
+ onlyIsolated: true,
874
+ marginMode: "strictIsolated"
860
875
  },
861
876
  {
862
877
  szDecimals: 1,
@@ -904,7 +919,8 @@ var universe = [
904
919
  szDecimals: 1,
905
920
  name: "AI16Z",
906
921
  maxLeverage: 5,
907
- marginTableId: 5
922
+ marginTableId: 5,
923
+ isDelisted: true
908
924
  },
909
925
  {
910
926
  szDecimals: 0,
@@ -953,14 +969,16 @@ var universe = [
953
969
  name: "ANIME",
954
970
  maxLeverage: 12,
955
971
  marginTableId: 12,
956
- onlyIsolated: true
972
+ onlyIsolated: true,
973
+ marginMode: "strictIsolated"
957
974
  },
958
975
  {
959
976
  szDecimals: 1,
960
977
  name: "MELANIA",
961
978
  maxLeverage: 3,
962
979
  marginTableId: 3,
963
- onlyIsolated: true
980
+ onlyIsolated: true,
981
+ marginMode: "strictIsolated"
964
982
  },
965
983
  {
966
984
  szDecimals: 0,
@@ -980,7 +998,8 @@ var universe = [
980
998
  maxLeverage: 3,
981
999
  marginTableId: 3,
982
1000
  onlyIsolated: true,
983
- isDelisted: true
1001
+ isDelisted: true,
1002
+ marginMode: "strictIsolated"
984
1003
  },
985
1004
  {
986
1005
  szDecimals: 0,
@@ -988,7 +1007,8 @@ var universe = [
988
1007
  maxLeverage: 3,
989
1008
  marginTableId: 3,
990
1009
  onlyIsolated: true,
991
- isDelisted: true
1010
+ isDelisted: true,
1011
+ marginMode: "strictIsolated"
992
1012
  },
993
1013
  {
994
1014
  szDecimals: 1,
@@ -1048,8 +1068,8 @@ var universe = [
1048
1068
  {
1049
1069
  szDecimals: 0,
1050
1070
  name: "PROMPT",
1051
- maxLeverage: 10,
1052
- marginTableId: 10
1071
+ maxLeverage: 3,
1072
+ marginTableId: 3
1053
1073
  },
1054
1074
  {
1055
1075
  szDecimals: 0,
@@ -1097,7 +1117,8 @@ var universe = [
1097
1117
  szDecimals: 0,
1098
1118
  name: "LAUNCHCOIN",
1099
1119
  maxLeverage: 3,
1100
- marginTableId: 3
1120
+ marginTableId: 3,
1121
+ isDelisted: true
1101
1122
  },
1102
1123
  {
1103
1124
  szDecimals: 0,
@@ -1170,7 +1191,8 @@ var universe = [
1170
1191
  name: "ASTER",
1171
1192
  maxLeverage: 5,
1172
1193
  marginTableId: 5,
1173
- onlyIsolated: true
1194
+ onlyIsolated: true,
1195
+ marginMode: "strictIsolated"
1174
1196
  },
1175
1197
  {
1176
1198
  szDecimals: 0,
@@ -1189,7 +1211,8 @@ var universe = [
1189
1211
  name: "0G",
1190
1212
  maxLeverage: 3,
1191
1213
  marginTableId: 3,
1192
- onlyIsolated: true
1214
+ onlyIsolated: true,
1215
+ marginMode: "strictIsolated"
1193
1216
  },
1194
1217
  {
1195
1218
  szDecimals: 0,
@@ -1221,7 +1244,8 @@ var universe = [
1221
1244
  name: "MON",
1222
1245
  maxLeverage: 3,
1223
1246
  marginTableId: 3,
1224
- onlyIsolated: true
1247
+ onlyIsolated: true,
1248
+ marginMode: "strictIsolated"
1225
1249
  },
1226
1250
  {
1227
1251
  szDecimals: 0,
@@ -1234,7 +1258,20 @@ var universe = [
1234
1258
  name: "MEGA",
1235
1259
  maxLeverage: 3,
1236
1260
  marginTableId: 3,
1237
- onlyIsolated: true
1261
+ onlyIsolated: true,
1262
+ marginMode: "strictIsolated"
1263
+ },
1264
+ {
1265
+ szDecimals: 0,
1266
+ name: "CC",
1267
+ maxLeverage: 3,
1268
+ marginTableId: 3
1269
+ },
1270
+ {
1271
+ szDecimals: 0,
1272
+ name: "AERO",
1273
+ maxLeverage: 3,
1274
+ marginTableId: 3
1238
1275
  }
1239
1276
  ];
1240
1277
  var marginTables = [