@pear-protocol/types 2.9.0 → 2.11.0
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/bundle.d.ts +1 -0
- package/dist/bundle.js +1 -0
- package/dist/common/address.d.ts +8 -2
- package/dist/position/responses.d.ts +3 -2
- package/dist/sync/payloads.d.ts +11 -0
- package/dist/sync/payloads.js +6 -2
- package/dist/sync/responses.d.ts +1 -0
- package/dist/sync/responses.js +8 -1
- package/dist/trade-accounts/payloads.d.ts +14 -13
- package/dist/users/entities.d.ts +5 -4
- package/dist/users/response.d.ts +2 -2
- package/dist/vaults/entities.d.ts +111 -0
- package/dist/vaults/entities.js +96 -0
- package/dist/vaults/index.d.ts +4 -0
- package/dist/vaults/index.js +4 -0
- package/dist/vaults/payloads.d.ts +140 -0
- package/dist/vaults/payloads.js +65 -0
- package/dist/vaults/queries.d.ts +96 -0
- package/dist/vaults/queries.js +66 -0
- package/dist/vaults/responses.d.ts +634 -0
- package/dist/vaults/responses.js +375 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EthereumAddress } from '../common/address';
|
|
3
|
+
import { NavBucket } from './queries';
|
|
4
|
+
|
|
5
|
+
const PositiveAmount = z.string().regex(/^\d+(\.\d+)?$/).refine((amount) => /[1-9]/.test(amount), "Amount must be positive");
|
|
6
|
+
const LeaderSignedAction = z.object({
|
|
7
|
+
signature: z.string().regex(/^0x[0-9a-fA-F]{130}$/),
|
|
8
|
+
nonce: z.string().min(1),
|
|
9
|
+
deadline: z.number().int().positive()
|
|
10
|
+
});
|
|
11
|
+
const CreateVault = LeaderSignedAction.extend({
|
|
12
|
+
leader: EthereumAddress,
|
|
13
|
+
name: z.string().min(1).max(255),
|
|
14
|
+
description: z.string(),
|
|
15
|
+
imageUri: z.url().optional(),
|
|
16
|
+
configId: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
17
|
+
maxWithdrawalPeriodDays: z.number().int().min(1).optional()
|
|
18
|
+
}).strict();
|
|
19
|
+
const SetTrader = LeaderSignedAction.extend({
|
|
20
|
+
traderAddress: EthereumAddress
|
|
21
|
+
}).strict();
|
|
22
|
+
const UpdateVaultMetadata = LeaderSignedAction.extend({
|
|
23
|
+
name: z.string().min(1).max(255),
|
|
24
|
+
about: z.string(),
|
|
25
|
+
imageUri: z.union([
|
|
26
|
+
z.url(),
|
|
27
|
+
z.literal("")
|
|
28
|
+
])
|
|
29
|
+
}).strict();
|
|
30
|
+
const WithdrawToEvm = LeaderSignedAction.extend({
|
|
31
|
+
amount: PositiveAmount.refine((amount) => (amount.split(".")[1]?.length ?? 0) <= 6, "USDC supports six decimal places"),
|
|
32
|
+
tokenId: z.string().optional()
|
|
33
|
+
}).strict();
|
|
34
|
+
const AgentApprove = LeaderSignedAction.strict();
|
|
35
|
+
const SetUnifiedAccount = LeaderSignedAction.strict();
|
|
36
|
+
const BuilderFeeApproval = z.object({
|
|
37
|
+
builderAddress: EthereumAddress,
|
|
38
|
+
// Typed as the percent literal Hyperliquid's SDK demands; the predicate is the same rule the regex enforced.
|
|
39
|
+
maxFeeRate: z.custom((value) => typeof value === "string" && /^\d*\.?\d+%$/.test(value))
|
|
40
|
+
});
|
|
41
|
+
const SnapshotsBulk = z.object({
|
|
42
|
+
vaultAddresses: z.array(EthereumAddress).min(1).max(50),
|
|
43
|
+
startDate: z.string().regex(/^\d+$/).refine((value) => Number(value) <= 864e10),
|
|
44
|
+
endDate: z.string().regex(/^\d+$/).refine((value) => Number(value) <= 864e10),
|
|
45
|
+
bucket: NavBucket,
|
|
46
|
+
fields: z.array(z.enum([
|
|
47
|
+
"tvl",
|
|
48
|
+
"sharePrice",
|
|
49
|
+
"accountValue",
|
|
50
|
+
"unrealizedPnl",
|
|
51
|
+
"cumulativeRealizedPnl",
|
|
52
|
+
"leaderSharePct"
|
|
53
|
+
])).min(1)
|
|
54
|
+
}).strict().refine((value) => Number(value.startDate) <= Number(value.endDate), "startDate must precede endDate");
|
|
55
|
+
const TypedDataPayload = z.object({
|
|
56
|
+
domain: z.record(z.string(), z.unknown()),
|
|
57
|
+
types: z.record(z.string(), z.array(z.object({
|
|
58
|
+
name: z.string(),
|
|
59
|
+
type: z.string()
|
|
60
|
+
}))),
|
|
61
|
+
primaryType: z.string().min(1),
|
|
62
|
+
message: z.record(z.string(), z.unknown())
|
|
63
|
+
}).strict();
|
|
64
|
+
|
|
65
|
+
export { AgentApprove, BuilderFeeApproval, CreateVault, LeaderSignedAction, PositiveAmount, SetTrader, SetUnifiedAccount, SnapshotsBulk, TypedDataPayload, UpdateVaultMetadata, WithdrawToEvm };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EthereumAddress } from '../common/address';
|
|
3
|
+
export declare const VaultListParams: z.ZodObject<{
|
|
4
|
+
owner: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EthereumAddress, string>>>;
|
|
5
|
+
trader: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EthereumAddress, string>>>;
|
|
6
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
8
|
+
cursor: z.ZodOptional<z.ZodUUID>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type VaultListParamsInput = z.input<typeof VaultListParams>;
|
|
11
|
+
export type VaultListParams = z.infer<typeof VaultListParams>;
|
|
12
|
+
export declare const NavBucket: z.ZodEnum<{
|
|
13
|
+
"1d": "1d";
|
|
14
|
+
"1m": "1m";
|
|
15
|
+
"1h": "1h";
|
|
16
|
+
"5m": "5m";
|
|
17
|
+
"15m": "15m";
|
|
18
|
+
}>;
|
|
19
|
+
export type NavBucket = z.infer<typeof NavBucket>;
|
|
20
|
+
export declare const SparklineRange: z.ZodEnum<{
|
|
21
|
+
"1h": "1h";
|
|
22
|
+
"24h": "24h";
|
|
23
|
+
"7d": "7d";
|
|
24
|
+
"30d": "30d";
|
|
25
|
+
}>;
|
|
26
|
+
export type SparklineRange = z.infer<typeof SparklineRange>;
|
|
27
|
+
export declare const VaultsOverviewQueryParams: z.ZodObject<{
|
|
28
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
29
|
+
pageSize: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
30
|
+
sparklineRange: z.ZodDefault<z.ZodEnum<{
|
|
31
|
+
"1h": "1h";
|
|
32
|
+
"24h": "24h";
|
|
33
|
+
"7d": "7d";
|
|
34
|
+
"30d": "30d";
|
|
35
|
+
}>>;
|
|
36
|
+
sparklineBucket: z.ZodDefault<z.ZodEnum<{
|
|
37
|
+
"1d": "1d";
|
|
38
|
+
"1m": "1m";
|
|
39
|
+
"1h": "1h";
|
|
40
|
+
"5m": "5m";
|
|
41
|
+
"15m": "15m";
|
|
42
|
+
}>>;
|
|
43
|
+
name: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export type VaultsOverviewQueryParamsInput = z.input<typeof VaultsOverviewQueryParams>;
|
|
46
|
+
export type VaultsOverviewQueryParams = z.output<typeof VaultsOverviewQueryParams>;
|
|
47
|
+
export declare const VaultStatsQueryParams: z.ZodObject<{
|
|
48
|
+
address: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EthereumAddress, string>>>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
export type VaultStatsQueryParamsInput = z.input<typeof VaultStatsQueryParams>;
|
|
51
|
+
export type VaultStatsQueryParams = z.output<typeof VaultStatsQueryParams>;
|
|
52
|
+
export declare const VaultInvestmentsQueryParams: z.ZodObject<{
|
|
53
|
+
address: z.ZodPipe<z.ZodString, z.ZodTransform<EthereumAddress, string>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export type VaultInvestmentsQueryParamsInput = z.input<typeof VaultInvestmentsQueryParams>;
|
|
56
|
+
export type VaultInvestmentsQueryParams = z.output<typeof VaultInvestmentsQueryParams>;
|
|
57
|
+
export declare const NavResolution: z.ZodEnum<{
|
|
58
|
+
"1d": "1d";
|
|
59
|
+
"1m": "1m";
|
|
60
|
+
"1h": "1h";
|
|
61
|
+
"5m": "5m";
|
|
62
|
+
}>;
|
|
63
|
+
export type NavResolution = z.infer<typeof NavResolution>;
|
|
64
|
+
export declare const NavStatsWindow: z.ZodEnum<{
|
|
65
|
+
"24h": "24h";
|
|
66
|
+
"7d": "7d";
|
|
67
|
+
"30d": "30d";
|
|
68
|
+
}>;
|
|
69
|
+
export type NavStatsWindow = z.infer<typeof NavStatsWindow>;
|
|
70
|
+
export declare const NavRangeQueryParams: z.ZodObject<{
|
|
71
|
+
from: z.ZodISODateTime;
|
|
72
|
+
to: z.ZodISODateTime;
|
|
73
|
+
resolution: z.ZodDefault<z.ZodEnum<{
|
|
74
|
+
"1d": "1d";
|
|
75
|
+
"1m": "1m";
|
|
76
|
+
"1h": "1h";
|
|
77
|
+
"5m": "5m";
|
|
78
|
+
}>>;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
|
+
export type NavRangeQueryParamsInput = z.input<typeof NavRangeQueryParams>;
|
|
81
|
+
export type NavRangeQueryParams = z.output<typeof NavRangeQueryParams>;
|
|
82
|
+
export declare const NavStatsQueryParams: z.ZodObject<{
|
|
83
|
+
window: z.ZodEnum<{
|
|
84
|
+
"24h": "24h";
|
|
85
|
+
"7d": "7d";
|
|
86
|
+
"30d": "30d";
|
|
87
|
+
}>;
|
|
88
|
+
}, z.core.$strict>;
|
|
89
|
+
export type NavStatsQueryParams = z.infer<typeof NavStatsQueryParams>;
|
|
90
|
+
export declare const VaultEventListParams: z.ZodObject<{
|
|
91
|
+
userAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EthereumAddress, string>>>;
|
|
92
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
93
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
export type VaultEventListParamsInput = z.input<typeof VaultEventListParams>;
|
|
96
|
+
export type VaultEventListParams = z.infer<typeof VaultEventListParams>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EthereumAddress } from '../common/address';
|
|
3
|
+
|
|
4
|
+
const VaultListParams = z.object({
|
|
5
|
+
owner: EthereumAddress.optional(),
|
|
6
|
+
trader: EthereumAddress.optional(),
|
|
7
|
+
name: z.string().max(200).optional(),
|
|
8
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
9
|
+
cursor: z.uuid().optional()
|
|
10
|
+
}).strict();
|
|
11
|
+
const NavBucket = z.enum([
|
|
12
|
+
"1m",
|
|
13
|
+
"5m",
|
|
14
|
+
"15m",
|
|
15
|
+
"1h",
|
|
16
|
+
"1d"
|
|
17
|
+
]);
|
|
18
|
+
const SparklineRange = z.enum([
|
|
19
|
+
"1h",
|
|
20
|
+
"24h",
|
|
21
|
+
"7d",
|
|
22
|
+
"30d"
|
|
23
|
+
]);
|
|
24
|
+
const VaultsOverviewQueryParams = z.object({
|
|
25
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
26
|
+
pageSize: z.coerce.number().int().min(1).max(100).default(100),
|
|
27
|
+
sparklineRange: SparklineRange.default("24h"),
|
|
28
|
+
sparklineBucket: NavBucket.default("1h"),
|
|
29
|
+
name: z.string().optional()
|
|
30
|
+
}).strict();
|
|
31
|
+
const VaultStatsQueryParams = z.object({
|
|
32
|
+
address: EthereumAddress.optional()
|
|
33
|
+
}).strict();
|
|
34
|
+
const VaultInvestmentsQueryParams = z.object({
|
|
35
|
+
address: EthereumAddress
|
|
36
|
+
}).strict();
|
|
37
|
+
const NavResolution = z.enum([
|
|
38
|
+
"1m",
|
|
39
|
+
"5m",
|
|
40
|
+
"1h",
|
|
41
|
+
"1d"
|
|
42
|
+
]);
|
|
43
|
+
const NavStatsWindow = z.enum([
|
|
44
|
+
"24h",
|
|
45
|
+
"7d",
|
|
46
|
+
"30d"
|
|
47
|
+
]);
|
|
48
|
+
const NavRangeQueryParams = z.object({
|
|
49
|
+
from: z.iso.datetime({
|
|
50
|
+
offset: true
|
|
51
|
+
}),
|
|
52
|
+
to: z.iso.datetime({
|
|
53
|
+
offset: true
|
|
54
|
+
}),
|
|
55
|
+
resolution: NavResolution.default("1m")
|
|
56
|
+
}).strict().refine((query) => new Date(query.from) <= new Date(query.to), "from must precede to");
|
|
57
|
+
const NavStatsQueryParams = z.object({
|
|
58
|
+
window: NavStatsWindow
|
|
59
|
+
}).strict();
|
|
60
|
+
const VaultEventListParams = z.object({
|
|
61
|
+
userAddress: EthereumAddress.optional(),
|
|
62
|
+
limit: z.coerce.number().int().min(1).max(1e3).optional(),
|
|
63
|
+
offset: z.coerce.number().int().min(0).optional()
|
|
64
|
+
}).strict();
|
|
65
|
+
|
|
66
|
+
export { NavBucket, NavRangeQueryParams, NavResolution, NavStatsQueryParams, NavStatsWindow, SparklineRange, VaultEventListParams, VaultInvestmentsQueryParams, VaultListParams, VaultStatsQueryParams, VaultsOverviewQueryParams };
|