@pear-protocol/types 2.21.0 → 2.22.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/bundle.d.ts +1 -0
- package/dist/fee/entities.d.ts +1 -0
- package/dist/fee/responses.d.ts +26 -0
- package/dist/index.js +7355 -3
- package/dist/rewards/entities.d.ts +28 -0
- package/dist/rewards/payloads.d.ts +7 -0
- package/dist/rewards/responses.d.ts +73 -0
- package/dist/users/entities.d.ts +4 -0
- package/dist/users/response.d.ts +2 -0
- package/package.json +3 -2
- package/dist/auth/api-keys.js +0 -44
- package/dist/auth/entities.js +0 -25
- package/dist/auth/index.js +0 -4
- package/dist/auth/payloads.js +0 -84
- package/dist/auth/response.js +0 -82
- package/dist/baskets/recommended/entities.js +0 -22
- package/dist/baskets/recommended/index.js +0 -2
- package/dist/baskets/recommended/responses.js +0 -8
- package/dist/baskets/saved/entities.js +0 -23
- package/dist/baskets/saved/payloads.js +0 -18
- package/dist/baskets/saved/responses.js +0 -14
- package/dist/bundle.js +0 -36
- package/dist/common/address.js +0 -5
- package/dist/common/array.js +0 -17
- package/dist/common/client-id.js +0 -5
- package/dist/common/hex-string.js +0 -5
- package/dist/common/index.js +0 -4
- package/dist/common/refinement.js +0 -64
- package/dist/common/request.js +0 -24
- package/dist/common/response.js +0 -28
- package/dist/common/schema.js +0 -18
- package/dist/common/trade-legs.js +0 -50
- package/dist/connector/index.js +0 -12
- package/dist/copy/entities.js +0 -151
- package/dist/copy/index.js +0 -5
- package/dist/copy/payloads.js +0 -8
- package/dist/copy/performance.js +0 -63
- package/dist/copy/queries.js +0 -20
- package/dist/copy/responses.js +0 -89
- package/dist/execution/entities.js +0 -196
- package/dist/execution/index.js +0 -3
- package/dist/execution/queries.js +0 -18
- package/dist/execution/responses.js +0 -12
- package/dist/fee/entities.js +0 -34
- package/dist/fee/index.js +0 -3
- package/dist/fee/queries.js +0 -12
- package/dist/fee/responses.js +0 -29
- package/dist/fill/entities.js +0 -82
- package/dist/fill/index.js +0 -3
- package/dist/fill/queries.js +0 -14
- package/dist/fill/responses.js +0 -23
- package/dist/funding/entities.js +0 -16
- package/dist/funding/index.js +0 -3
- package/dist/funding/queries.js +0 -8
- package/dist/funding/responses.js +0 -11
- package/dist/instrument/entities.js +0 -102
- package/dist/instrument/index.js +0 -3
- package/dist/instrument/queries.js +0 -15
- package/dist/instrument/responses.js +0 -20
- package/dist/instrument-precision/index.js +0 -56
- package/dist/ladder/entities.js +0 -24
- package/dist/ladder/index.js +0 -4
- package/dist/ladder/payloads.js +0 -96
- package/dist/ladder/queries.js +0 -12
- package/dist/ladder/responses.js +0 -18
- package/dist/leverage/index.js +0 -2
- package/dist/leverage/payloads.js +0 -14
- package/dist/leverage/response.js +0 -5
- package/dist/margin/index.js +0 -2
- package/dist/margin/payloads.js +0 -20
- package/dist/margin/response.js +0 -11
- package/dist/market/entities.js +0 -52
- package/dist/market/index.js +0 -4
- package/dist/market/payloads.js +0 -11
- package/dist/market/queries.js +0 -19
- package/dist/market/responses.js +0 -18
- package/dist/misc/index.js +0 -2
- package/dist/misc/payloads.js +0 -99
- package/dist/misc/responses.js +0 -85
- package/dist/notification/entities.js +0 -274
- package/dist/notification/index.js +0 -4
- package/dist/notification/payloads.js +0 -15
- package/dist/notification/queries.js +0 -29
- package/dist/notification/responses.js +0 -20
- package/dist/order/entities.js +0 -81
- package/dist/order/index.js +0 -1
- package/dist/portfolio/entities.js +0 -77
- package/dist/portfolio/index.js +0 -3
- package/dist/portfolio/queries.js +0 -34
- package/dist/portfolio/responses.js +0 -33
- package/dist/position/entities.js +0 -433
- package/dist/position/index.js +0 -3
- package/dist/position/queries.js +0 -109
- package/dist/position/responses.js +0 -41
- package/dist/price/entities.js +0 -10
- package/dist/price/index.js +0 -3
- package/dist/price/queries.js +0 -8
- package/dist/price/responses.js +0 -15
- package/dist/realtime/channels.js +0 -16
- package/dist/realtime/frames.js +0 -140
- package/dist/realtime/index.js +0 -6
- package/dist/realtime/messages.js +0 -118
- package/dist/realtime/public-events.js +0 -92
- package/dist/realtime/user-events.js +0 -32
- package/dist/realtime/vault-events.js +0 -42
- package/dist/rebalance/entities.js +0 -86
- package/dist/rebalance/index.js +0 -4
- package/dist/rebalance/payloads.js +0 -56
- package/dist/rebalance/queries.js +0 -14
- package/dist/rebalance/responses.js +0 -41
- package/dist/schedule/entities.js +0 -239
- package/dist/schedule/index.js +0 -5
- package/dist/schedule/payloads.js +0 -85
- package/dist/schedule/queries.js +0 -30
- package/dist/schedule/randomization.js +0 -15
- package/dist/schedule/responses.js +0 -22
- package/dist/schedule/twap-config.js +0 -29
- package/dist/statistics/entities.js +0 -105
- package/dist/statistics/index.js +0 -3
- package/dist/statistics/queries.js +0 -111
- package/dist/statistics/responses.js +0 -67
- package/dist/sync/index.js +0 -2
- package/dist/sync/payloads.js +0 -136
- package/dist/sync/responses.js +0 -28
- package/dist/tca/entities.js +0 -9
- package/dist/tca/index.js +0 -3
- package/dist/tca/queries.js +0 -14
- package/dist/tca/responses.js +0 -126
- package/dist/trade/entities.js +0 -101
- package/dist/trade/index.js +0 -4
- package/dist/trade/payloads.js +0 -84
- package/dist/trade/queries.js +0 -9
- package/dist/trade/responses.js +0 -25
- package/dist/trade-accounts/entities.js +0 -61
- package/dist/trade-accounts/index.js +0 -4
- package/dist/trade-accounts/payloads.js +0 -132
- package/dist/trade-accounts/queries.js +0 -7
- package/dist/trade-accounts/response.js +0 -79
- package/dist/traders/index.js +0 -2
- package/dist/traders/performance.js +0 -21
- package/dist/traders/public.js +0 -192
- package/dist/trigger/common/index.js +0 -39
- package/dist/trigger/entities/conditions.js +0 -174
- package/dist/trigger/entities/index.js +0 -257
- package/dist/trigger/index.js +0 -9
- package/dist/trigger/oracle.js +0 -22
- package/dist/trigger/payloads/conditions.js +0 -213
- package/dist/trigger/payloads/config.js +0 -3
- package/dist/trigger/payloads/index.js +0 -173
- package/dist/trigger/queries.js +0 -16
- package/dist/trigger/refinement/index.js +0 -2
- package/dist/trigger/refinement/static.refinement.js +0 -50
- package/dist/trigger/refinement/trailing.refinement.js +0 -83
- package/dist/trigger/responses.js +0 -18
- package/dist/triggers/entities.js +0 -27
- package/dist/triggers/index.js +0 -3
- package/dist/triggers/queries.js +0 -10
- package/dist/triggers/responses.js +0 -9
- package/dist/users/entities.js +0 -45
- package/dist/users/index.js +0 -4
- package/dist/users/payloads.js +0 -33
- package/dist/users/queries.js +0 -8
- package/dist/users/response.js +0 -28
- package/dist/vaults/entities.js +0 -96
- package/dist/vaults/index.js +0 -4
- package/dist/vaults/payloads.js +0 -65
- package/dist/vaults/queries.js +0 -66
- package/dist/vaults/responses.js +0 -368
- /package/dist/{baskets/saved/index.js → rewards/index.d.ts} +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Connector } from '../connector';
|
|
3
|
-
import { CopyFollower } from '../copy/entities';
|
|
4
|
-
|
|
5
|
-
const LeaderboardRow = z.object({
|
|
6
|
-
// The row's identity, and the only safe key to render or join by.
|
|
7
|
-
tradeAccountId: z.string(),
|
|
8
|
-
// The trader the account belongs to, so a consumer can group the several rows one person
|
|
9
|
-
// earns across venues. The board deliberately publishes no exchange identifier: a wallet
|
|
10
|
-
// address beside a real name and a PnL deanonymizes a trader for good, and an address is
|
|
11
|
-
// not reversible once scraped. Neither id here is a credential — every route that takes
|
|
12
|
-
// one checks ownership or role, never knowledge of the id.
|
|
13
|
-
// This guarantee applies to private routes. Shared public profiles are addressable by
|
|
14
|
-
// tradeAccountId and omit the exchange identifier, including when the owner shows X identity.
|
|
15
|
-
userId: z.string(),
|
|
16
|
-
connector: Connector,
|
|
17
|
-
// Followers when this board was cached, independent of the performance date range.
|
|
18
|
-
followers: z.array(CopyFollower),
|
|
19
|
-
followerCount: z.number().int().nonnegative(),
|
|
20
|
-
// Every fill inside the window, whatever period its position began in — so unlike the
|
|
21
|
-
// money fields below, this can report trading whose fees and PnL belong to another window.
|
|
22
|
-
volume: z.string(),
|
|
23
|
-
// Positions the window watched open, as are the fees and the return beside them.
|
|
24
|
-
grossRealizedPnl: z.string(),
|
|
25
|
-
// Zero once the window has closed — unrealized PnL is a value as of now, so only a window
|
|
26
|
-
// that still contains now can report it. A window ending in the future does.
|
|
27
|
-
grossUpnl: z.string(),
|
|
28
|
-
// Net funding carry over the range, signed: negative when the trader paid to hold.
|
|
29
|
-
// Account-level, so a client-scoped board reports the account's whole carry —
|
|
30
|
-
// funding_payments carries no position id to attribute it any finer.
|
|
31
|
-
fundingPayment: z.string(),
|
|
32
|
-
totalNetPnl: z.string(),
|
|
33
|
-
// V2 calls this builderFee; V3 names it for the column it comes from.
|
|
34
|
-
pearFee: z.string(),
|
|
35
|
-
tradeFee: z.string(),
|
|
36
|
-
totalTrades: z.number(),
|
|
37
|
-
// This account's return over the window, as a ratio: "0.25" is +25%. The measured
|
|
38
|
-
// positions' PnL divided by the capital that earned it, so each position weighs by the
|
|
39
|
-
// money it put at risk — a measure of how the account's dollars did, not of how its
|
|
40
|
-
// individual calls went.
|
|
41
|
-
//
|
|
42
|
-
// One formula on every position: (realized + unrealized - fees paid) over the most cash that
|
|
43
|
-
// position had committed at one time. A closed position holds nothing, so its unrealized half
|
|
44
|
-
// is zero and this reduces to what the trader kept; a partly reduced open position counts
|
|
45
|
-
// both the profit it banked and the worth of what it still holds. Only fees of fills that
|
|
46
|
-
// happened are charged, so a running position never pays for the exit it has not made.
|
|
47
|
-
//
|
|
48
|
-
// The denominator is cash committed, not market value: each opening fill adds what it paid,
|
|
49
|
-
// each closing fill releases the share of that commitment the quantity it closed was holding,
|
|
50
|
-
// and the peak of that running total is what the return is measured against. So it is not the
|
|
51
|
-
// size the position opened at — a position scaled up afterwards is measured against what it
|
|
52
|
-
// went on to risk — and not the sum of everything it ever opened either, since capital
|
|
53
|
-
// reduced and recommitted counts once rather than twice.
|
|
54
|
-
//
|
|
55
|
-
// Measuring cash rather than market value is deliberate. A market-value denominator can fall
|
|
56
|
-
// below the money actually put in when a position is averaged down, which inflates the
|
|
57
|
-
// return; and no historical price series is kept, so market value could only ever be sampled
|
|
58
|
-
// at the fills themselves.
|
|
59
|
-
//
|
|
60
|
-
// Measured only where the window holds both the position's open and the moment the
|
|
61
|
-
// measurement is taken at: now for a running position, the closing fill for a finished
|
|
62
|
-
// one. A position that closed after the window ended is therefore left out — the window
|
|
63
|
-
// holds only part of what it realized, and part of a return is not a return.
|
|
64
|
-
//
|
|
65
|
-
// Absent when the board could measure none of the account's positions — never "0", which
|
|
66
|
-
// would claim a break-even trader. An account reaches the board with nothing measurable
|
|
67
|
-
// when its only trading in the window closed positions opened before it, when a closed
|
|
68
|
-
// window left its open positions unpriced, or when every position it opened in the window
|
|
69
|
-
// closed after it.
|
|
70
|
-
roi: z.string().optional(),
|
|
71
|
-
// The trader's linked X account, published to every caller — the board names its traders
|
|
72
|
-
// on the open internet, signed in or not. Absent for an account whose owner has connected
|
|
73
|
-
// no X account, and absent for one who hid the link from the board. Never null-with-a-key:
|
|
74
|
-
// absence is the signal.
|
|
75
|
-
//
|
|
76
|
-
// Whatever X reported at the owner's last authorization. Nothing re-reads X in between,
|
|
77
|
-
// so a trader who renamed and has not signed in since is named by their old handle.
|
|
78
|
-
xHandle: z.string().optional(),
|
|
79
|
-
xName: z.string().optional(),
|
|
80
|
-
xAvatarUrl: z.string().optional(),
|
|
81
|
-
// Immutable X numeric id. Link by this, never by the handle: X frees a renamed handle
|
|
82
|
-
// for anyone to claim immediately, so a cached handle can point at a stranger.
|
|
83
|
-
xUserId: z.string().optional()
|
|
84
|
-
});
|
|
85
|
-
const VolumeStatistics = z.object({
|
|
86
|
-
timestamp: z.number(),
|
|
87
|
-
volume: z.number(),
|
|
88
|
-
fees: z.number(),
|
|
89
|
-
trades: z.number(),
|
|
90
|
-
users: z.number(),
|
|
91
|
-
newUsers: z.number()
|
|
92
|
-
});
|
|
93
|
-
const OiStatistics = z.object({
|
|
94
|
-
timestamp: z.number(),
|
|
95
|
-
openInterest: z.number(),
|
|
96
|
-
openPositions: z.number()
|
|
97
|
-
});
|
|
98
|
-
const StatisticsTotals = z.object({
|
|
99
|
-
totalVolume: z.number(),
|
|
100
|
-
totalFees: z.number(),
|
|
101
|
-
totalTrades: z.number(),
|
|
102
|
-
totalUsers: z.number()
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export { LeaderboardRow, OiStatistics, StatisticsTotals, VolumeStatistics };
|
package/dist/statistics/index.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { normalizeArray } from '../common/array';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
|
|
5
|
-
const VolumeStatisticsQueryParams = z.object({
|
|
6
|
-
connector: Connector.optional(),
|
|
7
|
-
resolution: z.enum([
|
|
8
|
-
"1h",
|
|
9
|
-
"4h",
|
|
10
|
-
"24h"
|
|
11
|
-
]),
|
|
12
|
-
startDate: z.coerce.date().optional(),
|
|
13
|
-
endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
14
|
-
// Per-client scope; absent serves the global series. The literal 'other'
|
|
15
|
-
// selects the unattributed (NULL) bucket; an unknown code returns an empty series.
|
|
16
|
-
clientId: z.string().trim().min(1).optional()
|
|
17
|
-
}).refine((data) => !data.startDate || data.startDate < data.endDate, {
|
|
18
|
-
message: "startDate must be before endDate"
|
|
19
|
-
});
|
|
20
|
-
const OiStatisticsQueryParams = z.object({
|
|
21
|
-
connector: Connector.optional(),
|
|
22
|
-
resolution: z.enum([
|
|
23
|
-
"1h",
|
|
24
|
-
"4h",
|
|
25
|
-
"24h"
|
|
26
|
-
]),
|
|
27
|
-
startDate: z.coerce.date().optional(),
|
|
28
|
-
endDate: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
29
|
-
// Per-client scope; absent serves the global series. The literal 'other'
|
|
30
|
-
// selects the unattributed (NULL) bucket; an unknown code returns an empty series.
|
|
31
|
-
clientId: z.string().trim().min(1).optional()
|
|
32
|
-
}).refine((data) => !data.startDate || data.startDate < data.endDate, {
|
|
33
|
-
message: "startDate must be before endDate"
|
|
34
|
-
});
|
|
35
|
-
const StatisticsTotalsQueryParams = z.object({
|
|
36
|
-
connector: Connector.optional(),
|
|
37
|
-
// Per-client scope; absent serves the global totals. The literal 'other'
|
|
38
|
-
// selects the unattributed (NULL) bucket; an unknown code returns zero totals.
|
|
39
|
-
clientId: z.string().trim().min(1).optional()
|
|
40
|
-
});
|
|
41
|
-
const LeaderboardSortBy = z.enum([
|
|
42
|
-
"trades",
|
|
43
|
-
"totalNetPnl",
|
|
44
|
-
"volume",
|
|
45
|
-
"roi"
|
|
46
|
-
]);
|
|
47
|
-
const LEADERBOARD_MAX_LIMIT = 200;
|
|
48
|
-
const UnixSeconds = z.coerce.number().int().min(0).transform((seconds) => new Date(seconds * 1e3));
|
|
49
|
-
const ConnectorArray = z.preprocess((arg) => normalizeArray(arg), z.array(Connector));
|
|
50
|
-
const AssetArray = z.preprocess((arg) => normalizeArray(arg), z.array(z.string().trim().min(1)));
|
|
51
|
-
const LeaderboardQueryParams = z.object({
|
|
52
|
-
// Attribution filter, not a scope boundary — any caller may pass any client.
|
|
53
|
-
clientId: z.string().optional(),
|
|
54
|
-
// Absent means every connector. The filter applies before the top-N cut, so
|
|
55
|
-
// two connectors return the top N across both combined, not N of each.
|
|
56
|
-
connector: ConnectorArray.optional(),
|
|
57
|
-
// Absent means every asset. Filtering is per-leg: a long-BTC / short-ETH basket
|
|
58
|
-
// contributes only its BTC leg to an asset=BTC board. Each asset's realized-PnL
|
|
59
|
-
// walk is independent, so selecting a subset leaves every remaining walk complete.
|
|
60
|
-
asset: AssetArray.optional(),
|
|
61
|
-
sortBy: LeaderboardSortBy.default("totalNetPnl"),
|
|
62
|
-
// Inclusive, and it scopes the money without scoping the trading. Volume and totalTrades
|
|
63
|
-
// count every fill inside the window, whatever period its position began in. Realized
|
|
64
|
-
// PnL, unrealized PnL, the fees behind them and roi count only for a position whose
|
|
65
|
-
// opening fill lands at or after this, so an exit is never booked — nor its fee charged —
|
|
66
|
-
// against an entry the window never saw. Volume is therefore additive across two adjacent
|
|
67
|
-
// windows and PnL is not, and a row can report volume beside no fees at all.
|
|
68
|
-
startDate: UnixSeconds.optional(),
|
|
69
|
-
// Exclusive. Unrealized PnL is included whenever the window still contains now — an
|
|
70
|
-
// absent endDate, or one that has not yet arrived. Only a window that has already closed
|
|
71
|
-
// is settled and reproducible, and only there is unrealized PnL omitted: it is a value as
|
|
72
|
-
// of now, and now is outside such a window.
|
|
73
|
-
endDate: UnixSeconds.optional(),
|
|
74
|
-
// Whether an account whose owner linked no X account may hold a row. Off by default,
|
|
75
|
-
// because a trader who has not linked X does not qualify for the campaign the board
|
|
76
|
-
// feeds. Eligibility turns on linking, so admission does too: a trader who linked X
|
|
77
|
-
// and then withheld the handle keeps their rank and loses only their name.
|
|
78
|
-
// The gate is on the account, not on the viewer: it applies before the top-N cut, so
|
|
79
|
-
// it selects who makes the board rather than thinning the rows that came back, and
|
|
80
|
-
// every caller is served exactly the same board.
|
|
81
|
-
//
|
|
82
|
-
// Deliberately not `z.coerce.boolean()`, which reads the string "false" as true and
|
|
83
|
-
// would leave the default impossible to restore explicitly from a URL.
|
|
84
|
-
includeUnlinkedX: z.union([
|
|
85
|
-
z.boolean(),
|
|
86
|
-
z.stringbool()
|
|
87
|
-
]).optional().default(false),
|
|
88
|
-
limit: z.coerce.number().int().positive().max(LEADERBOARD_MAX_LIMIT).default(LEADERBOARD_MAX_LIMIT)
|
|
89
|
-
}).refine((data) => !data.startDate || !data.endDate || data.startDate < data.endDate, {
|
|
90
|
-
message: "startDate must be before endDate"
|
|
91
|
-
});
|
|
92
|
-
const LeaderboardSnapshotParams = z.object({
|
|
93
|
-
slug: z.string()
|
|
94
|
-
});
|
|
95
|
-
const LeaderboardSnapshotQueryParams = z.object({
|
|
96
|
-
// Absent means the default the board was published with, never the registry's current one.
|
|
97
|
-
sortBy: LeaderboardSortBy.optional(),
|
|
98
|
-
// Defaults to the free-form board's 200, so a migrating client sees no change. Deliberately
|
|
99
|
-
// uncapped, unlike LEADERBOARD_MAX_LIMIT there: the snapshot already holds every qualifying
|
|
100
|
-
// row, so a larger limit costs response size, not a ranking.
|
|
101
|
-
limit: z.coerce.number().int().positive().default(200)
|
|
102
|
-
});
|
|
103
|
-
const LeaderboardArchiveParams = z.object({
|
|
104
|
-
slug: z.string()
|
|
105
|
-
});
|
|
106
|
-
const LeaderboardArchivePeriodParams = z.object({
|
|
107
|
-
slug: z.string(),
|
|
108
|
-
startDate: UnixSeconds
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
export { LEADERBOARD_MAX_LIMIT, LeaderboardArchiveParams, LeaderboardArchivePeriodParams, LeaderboardQueryParams, LeaderboardSnapshotParams, LeaderboardSnapshotQueryParams, LeaderboardSortBy, OiStatisticsQueryParams, StatisticsTotalsQueryParams, VolumeStatisticsQueryParams };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { LeaderboardRow, VolumeStatistics, OiStatistics, StatisticsTotals } from './entities';
|
|
3
|
-
import { LeaderboardSortBy } from './queries';
|
|
4
|
-
|
|
5
|
-
const LeaderboardResponse = z.object({
|
|
6
|
-
data: z.array(LeaderboardRow)
|
|
7
|
-
});
|
|
8
|
-
const UnixSeconds = z.number().int().nonnegative();
|
|
9
|
-
const LeaderboardStatus = z.enum([
|
|
10
|
-
"upcoming",
|
|
11
|
-
"live",
|
|
12
|
-
"final"
|
|
13
|
-
]);
|
|
14
|
-
const LeaderboardSnapshotResponse = z.object({
|
|
15
|
-
// Echoes the path parameter.
|
|
16
|
-
slug: z.string(),
|
|
17
|
-
// Lifecycle of the requested competition; final rows come from its frozen archive.
|
|
18
|
-
status: LeaderboardStatus,
|
|
19
|
-
// The order the rows are in, including when the board's published default was applied.
|
|
20
|
-
sortBy: LeaderboardSortBy,
|
|
21
|
-
// Live: computed at; final: archived at; upcoming: lifecycle evaluated at.
|
|
22
|
-
updatedAt: z.iso.datetime(),
|
|
23
|
-
// The period the rows cover, in the free-form board's query units, so a consumer can feed
|
|
24
|
-
// these back as its startDate/endDate to reproduce the board. An absent bound is open.
|
|
25
|
-
window: z.object({
|
|
26
|
-
startDate: UnixSeconds.optional(),
|
|
27
|
-
endDate: UnixSeconds.optional()
|
|
28
|
-
}),
|
|
29
|
-
data: z.array(LeaderboardRow)
|
|
30
|
-
});
|
|
31
|
-
const LeaderboardArchiveListResponse = z.object({
|
|
32
|
-
// Echoes the path parameter.
|
|
33
|
-
slug: z.string(),
|
|
34
|
-
periods: z.array(z.object({
|
|
35
|
-
// The period's bounds in the free-form board's query units; startDate addresses the period.
|
|
36
|
-
startDate: UnixSeconds,
|
|
37
|
-
endDate: UnixSeconds,
|
|
38
|
-
// When the period was ranked — not a freshness signal, the board never changes after it.
|
|
39
|
-
archivedAt: z.iso.datetime()
|
|
40
|
-
}))
|
|
41
|
-
});
|
|
42
|
-
const LeaderboardArchiveResponse = z.object({
|
|
43
|
-
// Echoes the path parameter.
|
|
44
|
-
slug: z.string(),
|
|
45
|
-
// The order the rows are in, including when the archived query's default was applied.
|
|
46
|
-
sortBy: LeaderboardSortBy,
|
|
47
|
-
// A finished period always has both bounds, in the free-form board's query units, so a
|
|
48
|
-
// consumer can feed them back as its startDate/endDate to re-query the period.
|
|
49
|
-
window: z.object({
|
|
50
|
-
startDate: UnixSeconds,
|
|
51
|
-
endDate: UnixSeconds
|
|
52
|
-
}),
|
|
53
|
-
// When the period was ranked; distinct from a live board's updatedAt, it says nothing of freshness.
|
|
54
|
-
archivedAt: z.iso.datetime(),
|
|
55
|
-
data: z.array(LeaderboardRow)
|
|
56
|
-
});
|
|
57
|
-
const VolumeStatisticsResponse = z.object({
|
|
58
|
-
data: z.array(VolumeStatistics)
|
|
59
|
-
});
|
|
60
|
-
const OiStatisticsResponse = z.object({
|
|
61
|
-
data: z.array(OiStatistics)
|
|
62
|
-
});
|
|
63
|
-
const StatisticsTotalsResponse = z.object({
|
|
64
|
-
data: StatisticsTotals
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export { LeaderboardArchiveListResponse, LeaderboardArchiveResponse, LeaderboardResponse, LeaderboardSnapshotResponse, LeaderboardStatus, OiStatisticsResponse, StatisticsTotalsResponse, VolumeStatisticsResponse };
|
package/dist/sync/index.js
DELETED
package/dist/sync/payloads.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { UnsignedDecimalString, DecimalString, Side, SignedDecimalString } from '../common/schema';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
import { InstrumentId } from '../instrument';
|
|
5
|
-
import { PositionClosedReason, PositionStatus, PositionOrigin } from '../position/entities';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const ExchangeFillId = z.string().trim().min(1, "Exchange fill ID must be non-empty");
|
|
10
|
-
const MsTimestamp = z.number().int().positive().describe("Unix timestamp in milliseconds");
|
|
11
|
-
const LiquidationMark = z.object({
|
|
12
|
-
mark: UnsignedDecimalString
|
|
13
|
-
}).nullable();
|
|
14
|
-
const TradeFee = DecimalString;
|
|
15
|
-
const OriginalFillRef = z.object({
|
|
16
|
-
exchangeFillId: ExchangeFillId,
|
|
17
|
-
quantity: UnsignedDecimalString
|
|
18
|
-
});
|
|
19
|
-
const UnknownExternalFill = z.object({
|
|
20
|
-
exchangeFillId: ExchangeFillId,
|
|
21
|
-
cloid: z.string().nullable(),
|
|
22
|
-
connector: Connector,
|
|
23
|
-
symbol: InstrumentId,
|
|
24
|
-
price: UnsignedDecimalString,
|
|
25
|
-
quantity: UnsignedDecimalString,
|
|
26
|
-
side: Side,
|
|
27
|
-
reduceOnly: z.boolean(),
|
|
28
|
-
timestamp: MsTimestamp,
|
|
29
|
-
tradeFee: TradeFee,
|
|
30
|
-
builderFee: UnsignedDecimalString,
|
|
31
|
-
liquidation: LiquidationMark
|
|
32
|
-
});
|
|
33
|
-
const SyncFillsSinceRequest = z.object({
|
|
34
|
-
overlapMs: z.number().int().positive()
|
|
35
|
-
});
|
|
36
|
-
const SyncFundingSinceRequest = z.object({
|
|
37
|
-
overlapMs: z.number().int().positive()
|
|
38
|
-
});
|
|
39
|
-
const ExternalPosition = z.object({
|
|
40
|
-
symbol: InstrumentId,
|
|
41
|
-
size: UnsignedDecimalString.describe("BASE units, contractSize applied; always >= 0"),
|
|
42
|
-
side: Side.describe("sign of the net position"),
|
|
43
|
-
entryPrice: UnsignedDecimalString.describe("exchange-reported average entry"),
|
|
44
|
-
markPrice: UnsignedDecimalString
|
|
45
|
-
});
|
|
46
|
-
const ApplicableFill = z.object({
|
|
47
|
-
// Deterministic synthetic id (`synthetic-{positionKey}-{symbol}-{side}`) for synthetic fills,
|
|
48
|
-
// exchange-native id for real fills.
|
|
49
|
-
exchangeFillId: ExchangeFillId,
|
|
50
|
-
cloid: z.string().nullable(),
|
|
51
|
-
connector: Connector,
|
|
52
|
-
symbol: InstrumentId,
|
|
53
|
-
side: Side,
|
|
54
|
-
quantity: UnsignedDecimalString.describe("BASE units"),
|
|
55
|
-
price: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'),
|
|
56
|
-
usd: UnsignedDecimalString.describe('"0" only on an unpriceable gone-close synthetic'),
|
|
57
|
-
timestamp: MsTimestamp.describe("ms \u2014 apply replays in this order"),
|
|
58
|
-
reduceOnly: z.boolean(),
|
|
59
|
-
synthetic: z.boolean(),
|
|
60
|
-
isExternal: z.boolean(),
|
|
61
|
-
tradeFee: TradeFee,
|
|
62
|
-
builderFee: UnsignedDecimalString,
|
|
63
|
-
closedReason: PositionClosedReason.optional().describe("e.g. NETTED for a synthetic close fill"),
|
|
64
|
-
liquidation: LiquidationMark.unwrap().extend({
|
|
65
|
-
outcome: z.enum([
|
|
66
|
-
"CLOSED",
|
|
67
|
-
"REDUCED"
|
|
68
|
-
]).optional().describe("Position outcome after this reducing slice")
|
|
69
|
-
}).nullable().optional(),
|
|
70
|
-
original: OriginalFillRef.optional()
|
|
71
|
-
});
|
|
72
|
-
const ApplicableMetadata = z.object({
|
|
73
|
-
initialExposureUSD: z.record(InstrumentId, SignedDecimalString).describe("opening cost basis from this position\u2019s own real fills; partial map allowed")
|
|
74
|
-
});
|
|
75
|
-
const ApplicablePosition = z.object({
|
|
76
|
-
positionKey: z.string().trim().min(1, "positionKey must be non-empty"),
|
|
77
|
-
exposure: z.record(InstrumentId, SignedDecimalString).describe("final position exposure (signed, BASE units)"),
|
|
78
|
-
origin: PositionOrigin,
|
|
79
|
-
status: PositionStatus,
|
|
80
|
-
closedReason: PositionClosedReason.optional().describe("set when status is CLOSED, e.g. NETTED"),
|
|
81
|
-
fills: z.array(ApplicableFill).min(1, "Applicable must carry at least one fill"),
|
|
82
|
-
metadata: ApplicableMetadata
|
|
83
|
-
});
|
|
84
|
-
const WATERMARK_FUTURE_SKEW_MS = 3e5;
|
|
85
|
-
const SyncMeta = z.object({
|
|
86
|
-
externalMaxTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "externalMaxTs must not be ahead of server time").nullable().describe("watermark advance source")
|
|
87
|
-
});
|
|
88
|
-
const CreateApplicablesMeta = SyncMeta.extend({
|
|
89
|
-
firstSyncStartedAt: z.number().int().nonnegative().optional().describe("backend-issued timestamp returned before the first fill-history fetch"),
|
|
90
|
-
newestFillTs: z.number().int().nonnegative().refine((timestamp) => timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS, "newestFillTs must not be ahead of server time").optional().describe("raw newest fetched fill \u2014 settle-gate source, never trim-advanced; present exactly when externalMaxTs is"),
|
|
91
|
-
executionsUpdatedAtEpochMs: z.number().int().nonnegative().describe("verbatim echo of fills/since executionsUpdatedAtEpochMs \u2014 stale-read gate token, not a client clock")
|
|
92
|
-
}).superRefine(refineNewestFillTsPairsWithWatermark);
|
|
93
|
-
const CreateApplicablesBulkFields = z.object({
|
|
94
|
-
executionsUpdatedAtEpochMs: z.string().regex(/^\d+$/, "Must be a non-negative integer millisecond value").transform(Number).describe("mirror of meta.executionsUpdatedAtEpochMs, readable without decompressing the payload")
|
|
95
|
-
});
|
|
96
|
-
const CreateApplicablesRequest = z.object({
|
|
97
|
-
applicables: z.array(ApplicablePosition),
|
|
98
|
-
exchangePositions: z.array(ExternalPosition),
|
|
99
|
-
meta: CreateApplicablesMeta
|
|
100
|
-
});
|
|
101
|
-
const OptionallySignedDecimalString = z.string().regex(/^[+-]?\d+(\.\d+)?$/, "Must be a valid signed decimal string");
|
|
102
|
-
const FundingPaymentEntry = z.object({
|
|
103
|
-
connector: Connector,
|
|
104
|
-
instrumentId: InstrumentId,
|
|
105
|
-
fundingRate: OptionallySignedDecimalString.describe("applied funding rate, optionally signed"),
|
|
106
|
-
notional: OptionallySignedDecimalString.describe("funding amount in USD notional, optionally signed"),
|
|
107
|
-
fundingPerUnit: OptionallySignedDecimalString.describe("signed funding per 1 unit of size (notional / szi); attribution coefficient"),
|
|
108
|
-
timestamp: MsTimestamp
|
|
109
|
-
});
|
|
110
|
-
const CreateFundingPaymentsRequest = z.object({
|
|
111
|
-
payments: z.array(FundingPaymentEntry),
|
|
112
|
-
meta: SyncMeta
|
|
113
|
-
});
|
|
114
|
-
function refineNewestFillTsPairsWithWatermark(meta, ctx) {
|
|
115
|
-
if (meta.externalMaxTs !== null && meta.newestFillTs === void 0) {
|
|
116
|
-
ctx.addIssue({
|
|
117
|
-
code: "custom",
|
|
118
|
-
message: "newestFillTs is required when externalMaxTs is set",
|
|
119
|
-
path: [
|
|
120
|
-
"newestFillTs"
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
if (meta.externalMaxTs === null && meta.newestFillTs !== void 0) {
|
|
125
|
-
ctx.addIssue({
|
|
126
|
-
code: "custom",
|
|
127
|
-
message: "newestFillTs must be absent when externalMaxTs is null",
|
|
128
|
-
path: [
|
|
129
|
-
"newestFillTs"
|
|
130
|
-
]
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
__name(refineNewestFillTsPairsWithWatermark, "refineNewestFillTsPairsWithWatermark");
|
|
135
|
-
|
|
136
|
-
export { ApplicableFill, ApplicableMetadata, ApplicablePosition, CreateApplicablesBulkFields, CreateApplicablesMeta, CreateApplicablesRequest, CreateFundingPaymentsRequest, ExternalPosition, FundingPaymentEntry, SyncFillsSinceRequest, SyncFundingSinceRequest, SyncMeta, UnknownExternalFill, WATERMARK_FUTURE_SKEW_MS };
|
package/dist/sync/responses.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const SyncFillsResponse = z.object({});
|
|
4
|
-
const SyncFillsSinceResponse = z.object({
|
|
5
|
-
sinceMs: z.number().int().nonnegative(),
|
|
6
|
-
// True only when the account has no checkpoint and nothing to anchor on, so sync starts from
|
|
7
|
-
// genesis. Clients use this to detect an account that has never imported its trade history —
|
|
8
|
-
// `sinceMs === 0` alone is ambiguous (a clamped watermark also yields 0).
|
|
9
|
-
neverSynced: z.boolean(),
|
|
10
|
-
// Backend-clock boundary returned only for a never-synced account. The syncer carries this
|
|
11
|
-
// through when an empty exchange fetch provides no fill-derived checkpoint.
|
|
12
|
-
firstSyncStartedAt: z.number().int().nonnegative().optional(),
|
|
13
|
-
confirmedExchangeFillIds: z.array(z.string()).optional(),
|
|
14
|
-
// A pending correction needs the next full snapshot even when there are no fills to apply.
|
|
15
|
-
hasPendingSynthetics: z.boolean().optional(),
|
|
16
|
-
// Newest executions.updatedAt this response can have observed, as epoch ms ceiled to the next
|
|
17
|
-
// whole millisecond (the column keeps microseconds); 0 when the account has no executions. The
|
|
18
|
-
// client echoes it verbatim in the create meta — core defers the create when any execution
|
|
19
|
-
// write postdates it. No client clock on the wire: ordering is against our own persisted
|
|
20
|
-
// updated_at values (Postgres now() on insert, the engine's clock on updates — the settle
|
|
21
|
-
// gate covers skew between those writers).
|
|
22
|
-
executionsUpdatedAtEpochMs: z.number().int().nonnegative()
|
|
23
|
-
});
|
|
24
|
-
const SyncFundingSinceResponse = z.object({
|
|
25
|
-
sinceMs: z.number().int().nonnegative()
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export { SyncFillsResponse, SyncFillsSinceResponse, SyncFundingSinceResponse };
|
package/dist/tca/entities.js
DELETED
package/dist/tca/index.js
DELETED
package/dist/tca/queries.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
const TcaPositionQueryParams = z.object({
|
|
4
|
-
limit: z.coerce.number().int().positive().max(2e3).optional().default(100),
|
|
5
|
-
cursor: z.iso.datetime().optional()
|
|
6
|
-
});
|
|
7
|
-
const TcaSummaryQueryParams = z.object({
|
|
8
|
-
limit: z.coerce.number().int().positive().max(2e3).optional().default(100),
|
|
9
|
-
cursor: z.iso.datetime().optional(),
|
|
10
|
-
from: z.iso.datetime().optional(),
|
|
11
|
-
to: z.iso.datetime().optional()
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export { TcaPositionQueryParams, TcaSummaryQueryParams };
|
package/dist/tca/responses.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Side } from '../common/schema';
|
|
3
|
-
import { Connector } from '../connector';
|
|
4
|
-
import { ExecutionStatus, ExecutionOrderType, ExecutionIntent } from '../execution/entities';
|
|
5
|
-
import { TcaMetricStatus, TcaTimingGranularity } from './entities';
|
|
6
|
-
|
|
7
|
-
const optionalNumeric = z.string().optional();
|
|
8
|
-
const optionalTimestamp = z.iso.datetime().optional();
|
|
9
|
-
const TcaBenchmarkResponse = z.object({
|
|
10
|
-
id: z.uuid(),
|
|
11
|
-
executionId: z.uuid(),
|
|
12
|
-
orderId: z.uuid().optional(),
|
|
13
|
-
cloid: z.string().optional(),
|
|
14
|
-
legIndex: z.number(),
|
|
15
|
-
connector: Connector,
|
|
16
|
-
symbol: z.string(),
|
|
17
|
-
side: z.enum([
|
|
18
|
-
"BUY",
|
|
19
|
-
"SELL"
|
|
20
|
-
]),
|
|
21
|
-
decisionPrice: optionalNumeric,
|
|
22
|
-
arrivalMid: optionalNumeric,
|
|
23
|
-
arrivalBid: optionalNumeric,
|
|
24
|
-
arrivalAsk: optionalNumeric,
|
|
25
|
-
markPrice: optionalNumeric,
|
|
26
|
-
indexPrice: optionalNumeric,
|
|
27
|
-
source: z.string(),
|
|
28
|
-
timestamp: z.iso.datetime(),
|
|
29
|
-
quoteAsset: z.string().optional(),
|
|
30
|
-
usdConversionPrice: optionalNumeric,
|
|
31
|
-
createdAt: z.iso.datetime()
|
|
32
|
-
});
|
|
33
|
-
const TcaFillMetricResponse = z.object({
|
|
34
|
-
id: z.uuid(),
|
|
35
|
-
fillId: z.uuid(),
|
|
36
|
-
benchmarkId: z.uuid().optional(),
|
|
37
|
-
executionId: z.uuid().optional(),
|
|
38
|
-
positionId: z.uuid().optional(),
|
|
39
|
-
tradeAccountId: z.uuid(),
|
|
40
|
-
connector: Connector,
|
|
41
|
-
symbol: z.string(),
|
|
42
|
-
cloid: z.string().optional(),
|
|
43
|
-
exchangeFillId: z.string().optional(),
|
|
44
|
-
slippageBps: optionalNumeric,
|
|
45
|
-
slippageQuote: optionalNumeric,
|
|
46
|
-
slippageUsd: optionalNumeric,
|
|
47
|
-
implementationShortfallBps: optionalNumeric,
|
|
48
|
-
spreadCostQuote: optionalNumeric,
|
|
49
|
-
spreadCostUsd: optionalNumeric,
|
|
50
|
-
tradeFee: optionalNumeric,
|
|
51
|
-
pearFee: optionalNumeric,
|
|
52
|
-
totalCostUsd: optionalNumeric,
|
|
53
|
-
gatewayLatencyMs: z.number().optional(),
|
|
54
|
-
timeToFillMs: z.number().optional(),
|
|
55
|
-
quoteAsset: z.string().optional(),
|
|
56
|
-
notionalQuote: optionalNumeric,
|
|
57
|
-
notionalUsd: optionalNumeric,
|
|
58
|
-
submittedAt: optionalTimestamp,
|
|
59
|
-
acknowledgedAt: optionalTimestamp,
|
|
60
|
-
exchangeExecutedAt: optionalTimestamp,
|
|
61
|
-
timingGranularity: TcaTimingGranularity.optional(),
|
|
62
|
-
status: TcaMetricStatus,
|
|
63
|
-
createdAt: z.iso.datetime(),
|
|
64
|
-
updatedAt: z.iso.datetime(),
|
|
65
|
-
benchmark: TcaBenchmarkResponse.optional()
|
|
66
|
-
});
|
|
67
|
-
const TcaExecutionSummaryLegResponse = z.object({
|
|
68
|
-
symbol: z.string(),
|
|
69
|
-
side: Side,
|
|
70
|
-
reduceOnly: z.boolean()
|
|
71
|
-
});
|
|
72
|
-
const TcaExecutionSummaryContextResponse = z.object({
|
|
73
|
-
intent: ExecutionIntent,
|
|
74
|
-
orderType: ExecutionOrderType,
|
|
75
|
-
executionStatus: ExecutionStatus,
|
|
76
|
-
positionId: z.uuid().optional(),
|
|
77
|
-
scheduleId: z.uuid().optional(),
|
|
78
|
-
triggerId: z.uuid().optional(),
|
|
79
|
-
legs: z.array(TcaExecutionSummaryLegResponse)
|
|
80
|
-
});
|
|
81
|
-
const TcaExecutionSummaryResponse = z.object({
|
|
82
|
-
id: z.uuid(),
|
|
83
|
-
executionId: z.uuid(),
|
|
84
|
-
tradeAccountId: z.uuid(),
|
|
85
|
-
connector: Connector,
|
|
86
|
-
executionContext: TcaExecutionSummaryContextResponse.optional(),
|
|
87
|
-
notionalQuote: optionalNumeric,
|
|
88
|
-
notionalUsd: optionalNumeric,
|
|
89
|
-
weightedSlippageBps: optionalNumeric,
|
|
90
|
-
totalSlippageUsd: optionalNumeric,
|
|
91
|
-
totalTradeFee: optionalNumeric,
|
|
92
|
-
totalPearFee: optionalNumeric,
|
|
93
|
-
totalCostUsd: optionalNumeric,
|
|
94
|
-
fillCount: z.number(),
|
|
95
|
-
status: TcaMetricStatus,
|
|
96
|
-
createdAt: z.iso.datetime(),
|
|
97
|
-
updatedAt: z.iso.datetime()
|
|
98
|
-
});
|
|
99
|
-
const TcaExecutionResponse = z.object({
|
|
100
|
-
summary: TcaExecutionSummaryResponse.optional(),
|
|
101
|
-
fillMetrics: z.array(TcaFillMetricResponse)
|
|
102
|
-
});
|
|
103
|
-
const TcaPositionResponse = z.object({
|
|
104
|
-
limit: z.number(),
|
|
105
|
-
nextCursor: z.iso.datetime().optional(),
|
|
106
|
-
fillMetrics: z.array(TcaFillMetricResponse)
|
|
107
|
-
});
|
|
108
|
-
const TcaSummaryTotalsResponse = z.object({
|
|
109
|
-
executionCount: z.number(),
|
|
110
|
-
fillCount: z.number(),
|
|
111
|
-
notionalQuote: optionalNumeric,
|
|
112
|
-
notionalUsd: optionalNumeric,
|
|
113
|
-
weightedSlippageBps: optionalNumeric,
|
|
114
|
-
totalSlippageUsd: optionalNumeric,
|
|
115
|
-
totalTradeFee: optionalNumeric,
|
|
116
|
-
totalPearFee: optionalNumeric,
|
|
117
|
-
totalCostUsd: optionalNumeric
|
|
118
|
-
});
|
|
119
|
-
const TcaSummaryResponse = z.object({
|
|
120
|
-
limit: z.number(),
|
|
121
|
-
nextCursor: z.iso.datetime().optional(),
|
|
122
|
-
summaries: z.array(TcaExecutionSummaryResponse),
|
|
123
|
-
totals: TcaSummaryTotalsResponse
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
export { TcaBenchmarkResponse, TcaExecutionResponse, TcaExecutionSummaryContextResponse, TcaExecutionSummaryLegResponse, TcaExecutionSummaryResponse, TcaFillMetricResponse, TcaPositionResponse, TcaSummaryResponse, TcaSummaryTotalsResponse };
|