@basedone/core 0.2.8 → 0.3.1

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
@@ -1,5 +1,5 @@
1
- export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantBusinessType, MerchantEcommerceClient, MerchantReturnPolicyType, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-NKSQEISP.mjs';
2
- export { AssetIdUtils, InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
1
+ export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantBusinessType, MerchantEcommerceClient, MerchantReturnPolicyType, MerchantStatus, ORDER_STATUS_TRANSITIONS, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition } from './chunk-35WGIB5F.mjs';
2
+ export { AssetIdUtils, InstrumentClient } from './chunk-OZPAOG43.mjs';
3
3
  import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
4
4
  import { signL1Action, signUserSignedAction } from '@nktkas/hyperliquid/signing';
5
5
 
@@ -544,6 +544,48 @@ var TESTNET_USDC_SPOT_TOKEN = {
544
544
  deployerTradingFeeShare: "0.0"
545
545
  };
546
546
 
547
+ // lib/constants/admin.ts
548
+ var SUPER_ADMINS = [
549
+ "did:privy:cmc3hycnb00pljs0m1z010geq",
550
+ "did:privy:cmc8w2ddl01rdju0nylb6rp1v",
551
+ "did:privy:cmc3oftiz005fjx0msox3xgey",
552
+ "did:privy:cmcbx7i4400q8l90mawdymaag",
553
+ "did:privy:cmctbwphs00vzjz0m3la3zm4c",
554
+ "did:privy:cmcblrplb009ol70mia13winn",
555
+ "did:privy:cmcd2bvft00w3l90ljeyb4wn6",
556
+ "did:privy:cmc4y13ka0119kv0nckvgla1u",
557
+ "did:privy:cmc8qc36g00c1l70nnutuscue",
558
+ "did:privy:cmc8f1tf9019zlh0myjpi420p",
559
+ "did:privy:cmc6bturg002ql80mhzqr1d76",
560
+ "did:privy:cmc8uyr4t01kljo0mk3unzjl3",
561
+ "did:privy:cmcke9v7h00yijy0o2a41nhms"
562
+ ];
563
+ var ADMINS = [
564
+ "did:privy:cmgfcjt2y0024kz0cpymoqbmp",
565
+ // aayush
566
+ "did:privy:cmeqj8tsi01k6la0c3s7gsl6w",
567
+ // elroy
568
+ "did:privy:cmiwrno1i00cdl70c5ro13eyp",
569
+ // adele
570
+ "did:privy:cmkc0jyy200abji0d42a0syil",
571
+ // matthew
572
+ "did:privy:cmlgc2zjk005vjo0cct10trdl",
573
+ // marketing
574
+ "did:privy:cme2d56i90091i90bdhuyaj7e",
575
+ // jun
576
+ "did:privy:cmm4av80f00140cldz3uv7io2",
577
+ // shubit
578
+ "did:privy:cmcbndjjm02fvjr0mrs42yahs"
579
+ // zlace
580
+ ];
581
+ var ALL_ADMINS = [...SUPER_ADMINS, ...ADMINS];
582
+ var ADMIN_WALLETS = [
583
+ "0x0c7582A67B8B6AD04Ea404A6C2A06aAc9E0d4e7c",
584
+ "0xDec587aDD20A6447fF0b29D70E95b10b197b1283",
585
+ "0x3e83987019c4CE29680401b72F8b18A2dE3f8fe6",
586
+ "0x5446A5Bc711170d5197DE33D8C193487794f30C0"
587
+ ];
588
+
547
589
  // lib/meta/metadata.ts
548
590
  var ROOT_DEX = "hyperliquid";
549
591
  var formatPriceAndSize = ({
@@ -780,10 +822,139 @@ function getDexFromCollateralTokenSymbol(collateralTokenSymbol) {
780
822
  }
781
823
 
782
824
  // lib/hip3/market-info.ts
783
- async function getAllPerpsMeta(infoClient) {
825
+ async function getPerpConciseAnnotations(infoClient) {
784
826
  return infoClient.transport.request("info", {
785
- type: "allPerpMetas"
827
+ type: "perpConciseAnnotations"
828
+ });
829
+ }
830
+ function enrichAllPerpsMetaWithAnnotations(metas, annotations) {
831
+ const map = new Map(annotations);
832
+ return metas.map((meta) => ({
833
+ ...meta,
834
+ universe: meta.universe.map((u) => {
835
+ const ann = map.get(u.name);
836
+ if (!ann) return u;
837
+ return {
838
+ ...u,
839
+ ...ann.category != null && ann.category !== "" ? { category: ann.category } : {},
840
+ ...ann.displayName != null && ann.displayName !== "" ? { displayName: ann.displayName } : {},
841
+ ...ann.keywords != null && ann.keywords.length > 0 ? { keywords: ann.keywords } : {}
842
+ };
843
+ })
844
+ }));
845
+ }
846
+ async function getAllPerpsMeta(infoClient) {
847
+ const [metas, annotations] = await Promise.all([
848
+ infoClient.transport.request("info", {
849
+ type: "allPerpMetas"
850
+ }),
851
+ getPerpConciseAnnotations(infoClient).catch(() => {
852
+ return [];
853
+ })
854
+ ]);
855
+ if (!annotations.length) {
856
+ return metas;
857
+ }
858
+ return enrichAllPerpsMetaWithAnnotations(metas, annotations);
859
+ }
860
+
861
+ // lib/abstraction/types.ts
862
+ var ABSTRACTION_MODE_TO_AGENT_CODE = {
863
+ disabled: "i",
864
+ unifiedAccount: "u",
865
+ portfolioMargin: "p"
866
+ };
867
+ var AGENT_CODE_TO_ABSTRACTION_MODE = {
868
+ i: "disabled",
869
+ u: "unifiedAccount",
870
+ p: "portfolioMargin"
871
+ };
872
+ var UserSetAbstractionTypes = {
873
+ "HyperliquidTransaction:UserSetAbstraction": [
874
+ { name: "hyperliquidChain", type: "string" },
875
+ { name: "user", type: "address" },
876
+ { name: "abstraction", type: "string" },
877
+ { name: "nonce", type: "uint64" }
878
+ ]
879
+ };
880
+ async function getUserAbstraction(client, user) {
881
+ return await client.transport.request("info", {
882
+ type: "userAbstraction",
883
+ user
786
884
  });
787
885
  }
886
+ async function setUserAbstraction(client, abstraction, user) {
887
+ const nonce = Date.now();
888
+ const isTestnet = client.isTestnet;
889
+ const action = {
890
+ type: "userSetAbstraction",
891
+ hyperliquidChain: isTestnet ? "Testnet" : "Mainnet",
892
+ signatureChainId: isTestnet ? "0x66eee" : "0xa4b1",
893
+ user,
894
+ abstraction,
895
+ nonce
896
+ };
897
+ const signature = await signUserSignedAction({
898
+ wallet: client.wallet,
899
+ action,
900
+ types: UserSetAbstractionTypes
901
+ });
902
+ return await client.transport.request("exchange", {
903
+ action,
904
+ signature,
905
+ nonce: action.nonce
906
+ });
907
+ }
908
+ async function agentSetAbstraction(client, abstraction) {
909
+ const nonce = Date.now();
910
+ const code = ABSTRACTION_MODE_TO_AGENT_CODE[abstraction];
911
+ const action = {
912
+ type: "agentSetAbstraction",
913
+ abstraction: code
914
+ };
915
+ const signature = await signL1Action({
916
+ wallet: client.wallet,
917
+ action,
918
+ isTestnet: client.isTestnet,
919
+ nonce
920
+ });
921
+ return await client.transport.request("exchange", {
922
+ action,
923
+ signature,
924
+ nonce
925
+ });
926
+ }
927
+
928
+ // lib/abstraction/ratio.ts
929
+ function computeUnifiedAccountRatio(multiverse, perpDexStates, spotBalances) {
930
+ const indexToCollateralToken = {};
931
+ for (const meta of Object.values(multiverse)) {
932
+ indexToCollateralToken[meta.index] = meta.collateralToken;
933
+ }
934
+ const crossMarginByToken = {};
935
+ const isolatedMarginByToken = {};
936
+ for (let index = 0; index < perpDexStates.length; index++) {
937
+ const dex = perpDexStates[index];
938
+ const token = indexToCollateralToken[index];
939
+ if (dex === void 0 || token === void 0) continue;
940
+ crossMarginByToken[token] = (crossMarginByToken[token] ?? 0) + dex.clearinghouseState.crossMaintenanceMarginUsed;
941
+ for (const ap of dex.clearinghouseState.assetPositions) {
942
+ if (ap.position.leverage.type === "isolated") {
943
+ isolatedMarginByToken[token] = (isolatedMarginByToken[token] ?? 0) + ap.position.marginUsed;
944
+ }
945
+ }
946
+ }
947
+ let maxRatio = 0;
948
+ for (const [tokenStr, crossMargin] of Object.entries(crossMarginByToken)) {
949
+ const token = Number(tokenStr);
950
+ const spotTotal = spotBalances.find((b) => b.token === token)?.total ?? 0;
951
+ const isolatedMargin = isolatedMarginByToken[token] ?? 0;
952
+ const available = spotTotal - isolatedMargin;
953
+ if (available > 0) {
954
+ maxRatio = Math.max(maxRatio, crossMargin / available);
955
+ }
956
+ }
957
+ return maxRatio;
958
+ }
788
959
 
789
- export { CloidClientCode, CloidClientCodeNameById, DayOfWeek, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, USDC_SPOT_TOKEN, UserDexAbstractionTypes, WidgetType, WidgetTypeById, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
960
+ export { ABSTRACTION_MODE_TO_AGENT_CODE, ADMINS, ADMIN_WALLETS, AGENT_CODE_TO_ABSTRACTION_MODE, ALL_ADMINS, CloidClientCode, CloidClientCodeNameById, DayOfWeek, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, ROOT_DEX, SUPER_ADMINS, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, USDC_SPOT_TOKEN, UserDexAbstractionTypes, UserSetAbstractionTypes, WidgetType, WidgetTypeById, XP_BOOST_PERCENTAGES, agentSetAbstraction, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, computeUnifiedAccountRatio, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, enrichAllPerpsMetaWithAnnotations, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPerpConciseAnnotations, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getUserAbstraction, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, setUserAbstraction, stableQuoteTokens };
package/dist/react.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { SpotMeta } from '@nktkas/hyperliquid';
4
- import { A as AllPerpsMeta, I as InstrumentClient } from './client-DMVXX1Gw.mjs';
4
+ import { A as AllPerpsMeta, I as InstrumentClient } from './client-1sWFpTpK.mjs';
5
5
 
6
6
  interface InstrumentsProviderProps {
7
7
  spotMeta: SpotMeta;
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { SpotMeta } from '@nktkas/hyperliquid';
4
- import { A as AllPerpsMeta, I as InstrumentClient } from './client-DMVXX1Gw.js';
4
+ import { A as AllPerpsMeta, I as InstrumentClient } from './client-1sWFpTpK.js';
5
5
 
6
6
  interface InstrumentsProviderProps {
7
7
  spotMeta: SpotMeta;
package/dist/react.js CHANGED
@@ -188,7 +188,10 @@ var InstrumentClient = class {
188
188
  type: "futures",
189
189
  isDelisted: info.isDelisted,
190
190
  dex: AssetIdUtils.extractDexName(info.name),
191
- collateralTokenIndex: perpMeta.collateralToken
191
+ collateralTokenIndex: perpMeta.collateralToken,
192
+ category: info.category,
193
+ displayName: info.displayName,
194
+ keywords: info.keywords
192
195
  };
193
196
  this.addInstrument(instrument);
194
197
  }
package/dist/react.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
1
+ import { InstrumentClient } from './chunk-OZPAOG43.mjs';
2
2
  import { createContext, useMemo, useContext } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
package/index.ts CHANGED
@@ -2,13 +2,16 @@ export * from "./lib/cloid/cloid";
2
2
  export * from "./lib/fee";
3
3
  export * from "./lib/pup";
4
4
  export * from "./lib/constants/tokens";
5
+ export * from "./lib/constants/admin";
5
6
  export * from "./lib/meta/metadata";
6
7
  export * from "./lib/utils/formatter";
7
8
  export * from "./lib/utils/flooredDateTime";
8
9
  export * from "./lib/utils/time";
9
10
  export * from "./lib/hip3/utils";
10
11
  export * from "./lib/hip3/market-info";
12
+ export * from "./lib/abstraction";
11
13
  export * from "./lib/instrument/client";
14
+ export * from "./lib/types";
12
15
 
13
16
  // Ecommerce SDK
14
17
  export * from "./lib/ecommerce";
@@ -0,0 +1,106 @@
1
+ import {
2
+ ExchangeClient,
3
+ InfoClient,
4
+ SuccessResponse,
5
+ } from "@nktkas/hyperliquid";
6
+ import {
7
+ signL1Action,
8
+ signUserSignedAction,
9
+ } from "@nktkas/hyperliquid/signing";
10
+ import type {
11
+ UserAbstractionMode,
12
+ SettableAbstractionMode,
13
+ AgentAbstractionCode,
14
+ } from "./types";
15
+ import { ABSTRACTION_MODE_TO_AGENT_CODE } from "./types";
16
+
17
+ export const UserSetAbstractionTypes = {
18
+ "HyperliquidTransaction:UserSetAbstraction": [
19
+ { name: "hyperliquidChain", type: "string" },
20
+ { name: "user", type: "address" },
21
+ { name: "abstraction", type: "string" },
22
+ { name: "nonce", type: "uint64" },
23
+ ],
24
+ };
25
+
26
+ /**
27
+ * Query a user's current account abstraction mode.
28
+ */
29
+ export async function getUserAbstraction(
30
+ client: InfoClient,
31
+ user: string,
32
+ ): Promise<UserAbstractionMode> {
33
+ return await client.transport.request<UserAbstractionMode>("info", {
34
+ type: "userAbstraction",
35
+ user,
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Set account abstraction mode using the owner wallet (user-signed action).
41
+ *
42
+ * Requires EIP-712 signature from the account owner.
43
+ */
44
+ export async function setUserAbstraction(
45
+ client: ExchangeClient,
46
+ abstraction: SettableAbstractionMode,
47
+ user: string,
48
+ ): Promise<SuccessResponse> {
49
+ const nonce = Date.now();
50
+ const isTestnet = client.isTestnet;
51
+
52
+ const action = {
53
+ type: "userSetAbstraction" as const,
54
+ hyperliquidChain: isTestnet ? "Testnet" : ("Mainnet" as string),
55
+ signatureChainId: isTestnet
56
+ ? ("0x66eee" as `0x${string}`)
57
+ : ("0xa4b1" as `0x${string}`),
58
+ user,
59
+ abstraction,
60
+ nonce,
61
+ };
62
+
63
+ const signature = await signUserSignedAction({
64
+ wallet: client.wallet,
65
+ action,
66
+ types: UserSetAbstractionTypes,
67
+ });
68
+
69
+ return await client.transport.request<SuccessResponse>("exchange", {
70
+ action,
71
+ signature,
72
+ nonce: action.nonce,
73
+ });
74
+ }
75
+
76
+ /**
77
+ * Set account abstraction mode using an agent wallet.
78
+ *
79
+ * Uses shorthand codes: "i" (disabled), "u" (unifiedAccount), "p" (portfolioMargin).
80
+ */
81
+ export async function agentSetAbstraction(
82
+ client: ExchangeClient,
83
+ abstraction: SettableAbstractionMode,
84
+ ): Promise<SuccessResponse> {
85
+ const nonce = Date.now();
86
+ const code: AgentAbstractionCode =
87
+ ABSTRACTION_MODE_TO_AGENT_CODE[abstraction];
88
+
89
+ const action = {
90
+ type: "agentSetAbstraction" as const,
91
+ abstraction: code,
92
+ };
93
+
94
+ const signature = await signL1Action({
95
+ wallet: client.wallet,
96
+ action,
97
+ isTestnet: client.isTestnet,
98
+ nonce,
99
+ });
100
+
101
+ return await client.transport.request<SuccessResponse>("exchange", {
102
+ action,
103
+ signature,
104
+ nonce,
105
+ });
106
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./api";
3
+ export * from "./ratio";
@@ -0,0 +1,61 @@
1
+ import type {
2
+ MultiverseMeta,
3
+ PerpDexClearinghouseState,
4
+ SpotBalance,
5
+ } from "./types";
6
+
7
+ /**
8
+ * Compute the unified account ratio for monitoring liquidation risk.
9
+ *
10
+ * The ratio represents cross maintenance margin used / available balance
11
+ * for the most leveraged collateral token. A higher ratio means closer
12
+ * to liquidation.
13
+ *
14
+ * @param multiverse - Map of DEX name to its metadata (index and collateral token)
15
+ * @param perpDexStates - Array of per-DEX clearinghouse states
16
+ * @param spotBalances - Array of spot balances per token
17
+ * @returns The maximum ratio across all collateral tokens (0 if no margin used)
18
+ */
19
+ export function computeUnifiedAccountRatio(
20
+ multiverse: Record<string, MultiverseMeta>,
21
+ perpDexStates: PerpDexClearinghouseState[],
22
+ spotBalances: SpotBalance[],
23
+ ): number {
24
+ const indexToCollateralToken: Record<number, number> = {};
25
+ for (const meta of Object.values(multiverse)) {
26
+ indexToCollateralToken[meta.index] = meta.collateralToken;
27
+ }
28
+
29
+ const crossMarginByToken: Record<number, number> = {};
30
+ const isolatedMarginByToken: Record<number, number> = {};
31
+
32
+ for (let index = 0; index < perpDexStates.length; index++) {
33
+ const dex = perpDexStates[index];
34
+ const token = indexToCollateralToken[index];
35
+ if (dex === undefined || token === undefined) continue;
36
+
37
+ crossMarginByToken[token] =
38
+ (crossMarginByToken[token] ?? 0) +
39
+ dex.clearinghouseState.crossMaintenanceMarginUsed;
40
+
41
+ for (const ap of dex.clearinghouseState.assetPositions) {
42
+ if (ap.position.leverage.type === "isolated") {
43
+ isolatedMarginByToken[token] =
44
+ (isolatedMarginByToken[token] ?? 0) + ap.position.marginUsed;
45
+ }
46
+ }
47
+ }
48
+
49
+ let maxRatio = 0;
50
+ for (const [tokenStr, crossMargin] of Object.entries(crossMarginByToken)) {
51
+ const token = Number(tokenStr);
52
+ const spotTotal = spotBalances.find((b) => b.token === token)?.total ?? 0;
53
+ const isolatedMargin = isolatedMarginByToken[token] ?? 0;
54
+ const available = spotTotal - isolatedMargin;
55
+ if (available > 0) {
56
+ maxRatio = Math.max(maxRatio, crossMargin / available);
57
+ }
58
+ }
59
+
60
+ return maxRatio;
61
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * User abstraction modes for controlling how spot and perps balances interact.
3
+ *
4
+ * - `disabled` (Standard): Separate perp and spot balances, separate DEX balances.
5
+ * - `unifiedAccount`: Single balance per asset collateralizing all cross margin positions.
6
+ * - `portfolioMargin`: Single portfolio unifying all eligible assets (pre-alpha).
7
+ * - `dexAbstraction`: Legacy mode (to be discontinued).
8
+ * - `default`: Server default (equivalent to standard/disabled for most users).
9
+ */
10
+ export type UserAbstractionMode =
11
+ | "unifiedAccount"
12
+ | "portfolioMargin"
13
+ | "disabled"
14
+ | "default"
15
+ | "dexAbstraction";
16
+
17
+ /**
18
+ * Shorthand codes used with agent-based abstraction setting.
19
+ * - `i` = disabled (standard)
20
+ * - `u` = unifiedAccount
21
+ * - `p` = portfolioMargin
22
+ */
23
+ export type AgentAbstractionCode = "i" | "u" | "p";
24
+
25
+ /**
26
+ * Settable abstraction modes (excludes read-only states like "default" and "dexAbstraction").
27
+ */
28
+ export type SettableAbstractionMode =
29
+ | "disabled"
30
+ | "unifiedAccount"
31
+ | "portfolioMargin";
32
+
33
+ export const ABSTRACTION_MODE_TO_AGENT_CODE: Record<
34
+ SettableAbstractionMode,
35
+ AgentAbstractionCode
36
+ > = {
37
+ disabled: "i",
38
+ unifiedAccount: "u",
39
+ portfolioMargin: "p",
40
+ };
41
+
42
+ export const AGENT_CODE_TO_ABSTRACTION_MODE: Record<
43
+ AgentAbstractionCode,
44
+ SettableAbstractionMode
45
+ > = {
46
+ i: "disabled",
47
+ u: "unifiedAccount",
48
+ p: "portfolioMargin",
49
+ };
50
+
51
+ export interface MultiverseMeta {
52
+ index: number;
53
+ collateralToken: number;
54
+ }
55
+
56
+ export interface PerpDexAssetPosition {
57
+ position: {
58
+ leverage: { type: string };
59
+ marginUsed: number;
60
+ };
61
+ }
62
+
63
+ export interface PerpDexClearinghouseState {
64
+ clearinghouseState: {
65
+ crossMaintenanceMarginUsed: number;
66
+ assetPositions: PerpDexAssetPosition[];
67
+ };
68
+ }
69
+
70
+ export interface SpotBalance {
71
+ token: number;
72
+ total: number;
73
+ }
@@ -0,0 +1,39 @@
1
+ // Super admin Privy user IDs — full unrestricted access
2
+ export const SUPER_ADMINS = [
3
+ "did:privy:cmc3hycnb00pljs0m1z010geq",
4
+ "did:privy:cmc8w2ddl01rdju0nylb6rp1v",
5
+ "did:privy:cmc3oftiz005fjx0msox3xgey",
6
+ "did:privy:cmcbx7i4400q8l90mawdymaag",
7
+ "did:privy:cmctbwphs00vzjz0m3la3zm4c",
8
+ "did:privy:cmcblrplb009ol70mia13winn",
9
+ "did:privy:cmcd2bvft00w3l90ljeyb4wn6",
10
+ "did:privy:cmc4y13ka0119kv0nckvgla1u",
11
+ "did:privy:cmc8qc36g00c1l70nnutuscue",
12
+ "did:privy:cmc8f1tf9019zlh0myjpi420p",
13
+ "did:privy:cmc6bturg002ql80mhzqr1d76",
14
+ "did:privy:cmc8uyr4t01kljo0mk3unzjl3",
15
+ "did:privy:cmcke9v7h00yijy0o2a41nhms",
16
+ ];
17
+
18
+ // Regular admin Privy user IDs — restricted access (no payouts/airdrops/launchpads/API keys/cache)
19
+ export const ADMINS = [
20
+ "did:privy:cmgfcjt2y0024kz0cpymoqbmp", // aayush
21
+ "did:privy:cmeqj8tsi01k6la0c3s7gsl6w", // elroy
22
+ "did:privy:cmiwrno1i00cdl70c5ro13eyp", // adele
23
+ "did:privy:cmkc0jyy200abji0d42a0syil", // matthew
24
+ "did:privy:cmlgc2zjk005vjo0cct10trdl", // marketing
25
+ "did:privy:cme2d56i90091i90bdhuyaj7e", // jun
26
+ "did:privy:cmm4av80f00140cldz3uv7io2", // shubit
27
+ "did:privy:cmcbndjjm02fvjr0mrs42yahs", // zlace
28
+ ];
29
+
30
+ // All admin IDs combined — use for "is this user any kind of admin?" checks
31
+ export const ALL_ADMINS = [...SUPER_ADMINS, ...ADMINS];
32
+
33
+ // Global admin wallet addresses
34
+ export const ADMIN_WALLETS: string[] = [
35
+ "0x0c7582A67B8B6AD04Ea404A6C2A06aAc9E0d4e7c",
36
+ "0xDec587aDD20A6447fF0b29D70E95b10b197b1283",
37
+ "0x3e83987019c4CE29680401b72F8b18A2dE3f8fe6",
38
+ "0x5446A5Bc711170d5197DE33D8C193487794f30C0",
39
+ ];
@@ -68,6 +68,8 @@ import type {
68
68
  GetExpiringGemsResponse,
69
69
  CashAccountBalanceResponse,
70
70
  DeliveryAddressResponse,
71
+ CustomerNotificationsResponse,
72
+ MarkNotificationsReadResponse,
71
73
  } from "../types";
72
74
 
73
75
  /**
@@ -1110,4 +1112,44 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
1110
1112
  async getDeliveryAddress(): Promise<DeliveryAddressResponse> {
1111
1113
  return this.get("/api/basedpay/delivery-address");
1112
1114
  }
1115
+
1116
+ /**
1117
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
1118
+ *
1119
+ * Returns the USDC balance available for escrow deposits via usdSend.
1120
+ *
1121
+ * @returns Balance response with amount and currency
1122
+ */
1123
+ async getUsdcBalance(): Promise<CashAccountBalanceResponse> {
1124
+ return this.get("/api/marketplace/usdc-balance");
1125
+ }
1126
+
1127
+ // ============================================================================
1128
+ // Notifications API
1129
+ // ============================================================================
1130
+
1131
+ /**
1132
+ * List notifications for the authenticated customer
1133
+ *
1134
+ * @param params - Query parameters for filtering and pagination
1135
+ * @returns Paginated list of notifications with unread count
1136
+ */
1137
+ async listNotifications(params?: {
1138
+ limit?: number;
1139
+ offset?: number;
1140
+ unreadOnly?: boolean;
1141
+ }): Promise<CustomerNotificationsResponse> {
1142
+ const queryString = params ? buildQueryString(params) : "";
1143
+ return this.get(`/api/marketplace/notifications${queryString}`);
1144
+ }
1145
+
1146
+ /**
1147
+ * Mark notifications as read
1148
+ *
1149
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
1150
+ * @returns Count of updated notifications
1151
+ */
1152
+ async markNotificationsAsRead(ids?: string[]): Promise<MarkNotificationsReadResponse> {
1153
+ return this.patch("/api/marketplace/notifications/read", { ids });
1154
+ }
1113
1155
  }
@@ -46,6 +46,20 @@ export {
46
46
  calculateFinalPrice,
47
47
  } from "./utils/helpers";
48
48
 
49
+ // Export order state machine
50
+ export {
51
+ ORDER_STATUS_TRANSITIONS,
52
+ validateStatusTransition,
53
+ getNextStatuses,
54
+ isPickupOrder,
55
+ getStatusLabel,
56
+ getStatusColor,
57
+ canCancelOrder,
58
+ requiresTrackingInfo,
59
+ shouldNotifyCustomer,
60
+ getStatusProgress,
61
+ } from "./utils/orderStateMachine";
62
+
49
63
  // Export client config type
50
64
  export type { EcommerceClientConfig } from "./client/base";
51
65
 
@@ -357,6 +357,20 @@ export interface Order extends BaseEntity {
357
357
  };
358
358
  /** Order events */
359
359
  events?: OrderEvent[];
360
+ /** Expected ship date */
361
+ expectedShipDate?: string | null;
362
+ /** Estimated delivery date */
363
+ estimatedDeliveryDate?: string | null;
364
+ /** Estimated delivery days */
365
+ estimatedDeliveryDays?: number | null;
366
+ /** Auto-complete deadline */
367
+ autoCompleteDeadline?: string | null;
368
+ /** Customer confirmed receipt timestamp */
369
+ customerConfirmedAt?: string | null;
370
+ /** Auto-completed timestamp */
371
+ autoCompletedAt?: string | null;
372
+ /** Status transition timestamps */
373
+ statusTransitions?: Record<string, string> | null;
360
374
  }
361
375
 
362
376
  /**
@@ -22,6 +22,8 @@ export enum OrderStatus {
22
22
  DELIVERED = "DELIVERED",
23
23
  /** Order has been cancelled */
24
24
  CANCELLED = "CANCELLED",
25
+ /** Payment settled / escrow released to merchant */
26
+ SETTLED = "SETTLED",
25
27
  /** Order is confirmed (legacy status) */
26
28
  CONFIRMED = "CONFIRMED",
27
29
  /** Order is completed (legacy status) */
@@ -286,8 +288,10 @@ export enum ProductSortBy {
286
288
  PRICE_ASC = "price_asc",
287
289
  /** Sort by price (high to low) */
288
290
  PRICE_DESC = "price_desc",
289
- /** Sort by popularity */
291
+ /** Sort by popularity (views) */
290
292
  POPULAR = "popular",
293
+ /** Sort by best selling (sold quantity) */
294
+ BEST_SELLING = "best_selling",
291
295
  /** Sort by featured status */
292
296
  FEATURED = "featured",
293
297
  /** Sort by proximity to user location (requires lat/lng) */