@lifi/perps-types 0.0.0-preview-c72bc0b → 0.0.0-preview-e6f120b
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/cjs/account.d.ts +8 -3
- package/dist/cjs/account.d.ts.map +1 -1
- package/dist/cjs/action.d.ts +3 -0
- package/dist/cjs/action.d.ts.map +1 -1
- package/dist/cjs/enums.d.ts +3 -1
- package/dist/cjs/enums.d.ts.map +1 -1
- package/dist/cjs/enums.js +2 -0
- package/dist/cjs/enums.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/metaProvider.d.ts +2 -0
- package/dist/cjs/metaProvider.d.ts.map +1 -1
- package/dist/cjs/metaProvider.js.map +1 -1
- package/dist/cjs/referral.d.ts +93 -0
- package/dist/cjs/referral.d.ts.map +1 -0
- package/dist/cjs/referral.js +28 -0
- package/dist/cjs/referral.js.map +1 -0
- package/dist/esm/account.d.ts +40 -11
- package/dist/esm/account.d.ts.map +1 -1
- package/dist/esm/action.d.ts +3 -0
- package/dist/esm/action.d.ts.map +1 -1
- package/dist/esm/enums.d.ts +5 -1
- package/dist/esm/enums.d.ts.map +1 -1
- package/dist/esm/enums.js +4 -0
- package/dist/esm/enums.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metaProvider.d.ts +8 -0
- package/dist/esm/metaProvider.d.ts.map +1 -1
- package/dist/esm/metaProvider.js.map +1 -1
- package/dist/esm/referral.d.ts +237 -0
- package/dist/esm/referral.d.ts.map +1 -0
- package/dist/esm/referral.js +46 -0
- package/dist/esm/referral.js.map +1 -0
- package/dist/types/account.d.ts +40 -11
- package/dist/types/account.d.ts.map +1 -1
- package/dist/types/action.d.ts +3 -0
- package/dist/types/action.d.ts.map +1 -1
- package/dist/types/enums.d.ts +5 -1
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/metaProvider.d.ts +8 -0
- package/dist/types/metaProvider.d.ts.map +1 -1
- package/dist/types/referral.d.ts +237 -0
- package/dist/types/referral.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/account.ts +41 -11
- package/src/action.ts +3 -0
- package/src/enums.ts +4 -0
- package/src/index.ts +1 -0
- package/src/metaProvider.ts +13 -0
- package/src/referral.ts +266 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActionType } from './enums.js';
|
|
1
2
|
/**
|
|
2
3
|
* Sentinel sent in the `provider` field for provider-independent actions
|
|
3
4
|
* (e.g. {@link "./enums.js".ActionType.META_ACCEPT_TERMS}). The backend
|
|
@@ -7,4 +8,11 @@
|
|
|
7
8
|
export declare const META_PROVIDER = "meta";
|
|
8
9
|
/** Type alias for the {@link META_PROVIDER} provider-independent sentinel. @public */
|
|
9
10
|
export type MetaProvider = typeof META_PROVIDER;
|
|
11
|
+
/**
|
|
12
|
+
* The provider-independent actions dispatched with the {@link META_PROVIDER}
|
|
13
|
+
* sentinel. They carry no venue plugin and no `ProviderAction` descriptor, so
|
|
14
|
+
* they are signed as EIP-712 typed data with the end-user's wallet.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type MetaActionType = ActionType.META_ACCEPT_TERMS | ActionType.META_ONBOARD | ActionType.META_CREATE_REFERRAL_CODE;
|
|
10
18
|
//# sourceMappingURL=metaProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaProvider.d.ts","sourceRoot":"","sources":["../../src/metaProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"metaProvider.d.ts","sourceRoot":"","sources":["../../src/metaProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,UAAU,CAAC,iBAAiB,GAC5B,UAAU,CAAC,YAAY,GACvB,UAAU,CAAC,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { Pagination } from './account.js';
|
|
2
|
+
import type { Address } from './primitives.js';
|
|
3
|
+
import type { PerpsTypedData, TypedDataParameter } from './typedData.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reason the backend will not attach a candidate internal referral code to an
|
|
6
|
+
* address. The backend decides; the SDK relays the verdict.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ReferralCodeRejection {
|
|
10
|
+
/** The candidate does not match the accepted code format. */
|
|
11
|
+
MALFORMED = "MALFORMED",
|
|
12
|
+
/** No internal referral code matches the candidate. */
|
|
13
|
+
NOT_FOUND = "NOT_FOUND",
|
|
14
|
+
/** The code exists but the backend has disabled it. */
|
|
15
|
+
INACTIVE = "INACTIVE",
|
|
16
|
+
/** The candidate is the queried address's own code. */
|
|
17
|
+
SELF_REFERRAL = "SELF_REFERRAL",
|
|
18
|
+
/** The address already has an attached code; attachment is first-touch. */
|
|
19
|
+
ALREADY_ATTACHED = "ALREADY_ATTACHED",
|
|
20
|
+
/** The address no longer meets the backend's conditions for attachment. */
|
|
21
|
+
NOT_ELIGIBLE = "NOT_ELIGIBLE"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Backend verdict for a candidate internal referral code.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface ReferralCodeValidation {
|
|
28
|
+
/** The candidate exactly as submitted. */
|
|
29
|
+
code: string;
|
|
30
|
+
valid: boolean;
|
|
31
|
+
/** Backend-normalized form of `code`; absent when `valid` is false. */
|
|
32
|
+
normalizedCode?: string;
|
|
33
|
+
/** Present only when `valid` is false. */
|
|
34
|
+
rejection?: ReferralCodeRejection;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The internal referral code attached to an address. Attachment is first-touch:
|
|
38
|
+
* once the backend records it, it does not change.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export interface AttachedReferralCode {
|
|
42
|
+
/** Normalized code this address is attached to. */
|
|
43
|
+
code: string;
|
|
44
|
+
/** Unix epoch milliseconds the attachment was recorded. */
|
|
45
|
+
attachedAt: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The shareable internal referral code an address owns.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export interface OwnedReferralCode {
|
|
52
|
+
code: string;
|
|
53
|
+
/** Unix epoch milliseconds the code was created. */
|
|
54
|
+
createdAt: number;
|
|
55
|
+
/** Number of addresses attached to this code. */
|
|
56
|
+
attachedCount: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether an address may create an owned internal referral code. The backend
|
|
60
|
+
* owns both the threshold and the decision.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export interface OwnedReferralCodeEligibility {
|
|
64
|
+
eligible: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Executed notional the address must reach, as a decimal string in the
|
|
67
|
+
* backend's reporting currency. Absent when the backend does not disclose it.
|
|
68
|
+
*/
|
|
69
|
+
requiredNotional?: string;
|
|
70
|
+
/** The address's executed notional so far, in the same units as `requiredNotional`. */
|
|
71
|
+
currentNotional?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* What the one pending onboarding signature would commit for an address. A
|
|
75
|
+
* present field is carried by the step; an absent field is not part of it.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export interface OnboardingRequirement {
|
|
79
|
+
/** Terms version the step accepts; absent when the address already accepted the current version. */
|
|
80
|
+
termsVersion?: string;
|
|
81
|
+
/** Normalized code the step attaches; absent when the step attaches none. */
|
|
82
|
+
referralCode?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Address-scoped onboarding and internal-referral state, served by
|
|
86
|
+
* `GET /v1/perps/meta/referral?address=`.
|
|
87
|
+
*
|
|
88
|
+
* An address the backend holds no record for still resolves to a well-formed
|
|
89
|
+
* payload: `termsAccepted` is `false` and every optional state field is absent.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export interface ReferralStatus {
|
|
93
|
+
address: Address;
|
|
94
|
+
/** Backend-owned version identifier for the current terms. */
|
|
95
|
+
termsVersion: string;
|
|
96
|
+
termsAccepted: boolean;
|
|
97
|
+
attachedCode?: AttachedReferralCode;
|
|
98
|
+
ownedCode?: OwnedReferralCode;
|
|
99
|
+
ownedCodeEligibility: OwnedReferralCodeEligibility;
|
|
100
|
+
/** Verdict for the request's candidate code; absent when the request passed none. */
|
|
101
|
+
candidate?: ReferralCodeValidation;
|
|
102
|
+
/**
|
|
103
|
+
* The one onboarding step to sign next; absent when the backend requires no
|
|
104
|
+
* consent from this address.
|
|
105
|
+
*/
|
|
106
|
+
onboarding?: OnboardingRequirement;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* One address attached to the queried address's owned internal referral code.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export interface ReferralActivityItem {
|
|
113
|
+
address: Address;
|
|
114
|
+
/** Unix epoch milliseconds the attachment was recorded. */
|
|
115
|
+
attachedAt: number;
|
|
116
|
+
/**
|
|
117
|
+
* Executed notional recorded against this attachment, as a decimal string in
|
|
118
|
+
* the backend's reporting currency.
|
|
119
|
+
*/
|
|
120
|
+
notional: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Paginated attachment records for an address's owned internal referral code,
|
|
124
|
+
* served by `GET /v1/perps/meta/referral/activity?address=`.
|
|
125
|
+
*
|
|
126
|
+
* An address that owns no code resolves to `items: []` with `hasMore: false`
|
|
127
|
+
* and no cursor.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export interface ReferralActivityResponse {
|
|
131
|
+
items: ReferralActivityItem[];
|
|
132
|
+
pagination: Pagination;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Params for an {@link "./enums.js".ActionType.META_ONBOARD} action: the terms
|
|
136
|
+
* version to accept and the candidate internal referral code to attach.
|
|
137
|
+
*
|
|
138
|
+
* Both fields are requests, not commitments. The backend decides what the step
|
|
139
|
+
* it returns actually carries, and returns no step when it needs no consent.
|
|
140
|
+
*
|
|
141
|
+
* Provider-independent: sent with the {@link "./metaProvider.js".META_PROVIDER}
|
|
142
|
+
* sentinel in the transport `provider` field.
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
export interface OnboardParams {
|
|
146
|
+
/** Terms-of-Service version being accepted; backend-owned, relayed verbatim. */
|
|
147
|
+
termsVersion?: string;
|
|
148
|
+
/** Candidate code as the client captured it; the backend normalizes it. */
|
|
149
|
+
referralCode?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* EIP-712 message body for an `Onboard`. Field order matches
|
|
153
|
+
* {@link onboardTypeFields}.
|
|
154
|
+
*
|
|
155
|
+
* Every mutable field is bound into the digest, so a term the signature does
|
|
156
|
+
* not commit is carried as the empty string rather than dropped.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export interface OnboardMessage {
|
|
160
|
+
/** Human-readable action, e.g. `"Accept LI.FI Perps Terms of Service v3"`. */
|
|
161
|
+
action: string;
|
|
162
|
+
account: Address;
|
|
163
|
+
/** Terms version accepted, or `''` when the signature accepts no terms. */
|
|
164
|
+
termsVersion: string;
|
|
165
|
+
/** Normalized code attached, or `''` when the signature attaches none. */
|
|
166
|
+
referralCode: string;
|
|
167
|
+
/** Replay-protection nonce as a decimal string (uint256). */
|
|
168
|
+
nonce: string;
|
|
169
|
+
/** Unix timestamp in milliseconds after which the signature is stale. */
|
|
170
|
+
deadline: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* EIP-712 type member list for the `Onboard` primary type. Field order is part
|
|
174
|
+
* of the signed digest and must match the backend's encoder.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
export declare const onboardTypeFields: readonly TypedDataParameter[];
|
|
178
|
+
/**
|
|
179
|
+
* EIP-712 typed data for a composite onboarding consent, as returned by
|
|
180
|
+
* `createAction` and signed client-side. `primaryType` is always `'Onboard'`.
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
export interface OnboardTypedData extends PerpsTypedData {
|
|
184
|
+
primaryType: 'Onboard';
|
|
185
|
+
types: {
|
|
186
|
+
Onboard: readonly TypedDataParameter[];
|
|
187
|
+
} & PerpsTypedData['types'];
|
|
188
|
+
message: OnboardMessage;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Params for an
|
|
192
|
+
* {@link "./enums.js".ActionType.META_CREATE_REFERRAL_CODE} action.
|
|
193
|
+
*
|
|
194
|
+
* Provider-independent: sent with the {@link "./metaProvider.js".META_PROVIDER}
|
|
195
|
+
* sentinel in the transport `provider` field.
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export interface CreateReferralCodeParams {
|
|
199
|
+
/** Desired code; omit to let the backend generate one. */
|
|
200
|
+
code?: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* EIP-712 message body for a `CreateReferralCode`. Field order matches
|
|
204
|
+
* {@link createReferralCodeTypeFields}.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export interface CreateReferralCodeMessage {
|
|
208
|
+
/** Human-readable action, e.g. `"Create LI.FI Perps referral code ABC123"`. */
|
|
209
|
+
action: string;
|
|
210
|
+
account: Address;
|
|
211
|
+
/** Normalized code the signature reserves. */
|
|
212
|
+
code: string;
|
|
213
|
+
/** Replay-protection nonce as a decimal string (uint256). */
|
|
214
|
+
nonce: string;
|
|
215
|
+
/** Unix timestamp in milliseconds after which the signature is stale. */
|
|
216
|
+
deadline: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* EIP-712 type member list for the `CreateReferralCode` primary type. Field
|
|
220
|
+
* order is part of the signed digest and must match the backend's encoder.
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export declare const createReferralCodeTypeFields: readonly TypedDataParameter[];
|
|
224
|
+
/**
|
|
225
|
+
* EIP-712 typed data for reserving an owned internal referral code, as
|
|
226
|
+
* returned by `createAction` and signed client-side. `primaryType` is always
|
|
227
|
+
* `'CreateReferralCode'`.
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export interface CreateReferralCodeTypedData extends PerpsTypedData {
|
|
231
|
+
primaryType: 'CreateReferralCode';
|
|
232
|
+
types: {
|
|
233
|
+
CreateReferralCode: readonly TypedDataParameter[];
|
|
234
|
+
} & PerpsTypedData['types'];
|
|
235
|
+
message: CreateReferralCodeMessage;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=referral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referral.d.ts","sourceRoot":"","sources":["../../src/referral.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExE;;;;GAIG;AACH,oBAAY,qBAAqB;IAC/B,6DAA6D;IAC7D,SAAS,cAAc;IACvB,uDAAuD;IACvD,SAAS,cAAc;IACvB,uDAAuD;IAC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AAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,kBAAkB,EAMrE,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,2BAA4B,SAAQ,cAAc;IACjE,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,EAAE;QACL,kBAAkB,EAAE,SAAS,kBAAkB,EAAE,CAAA;KAClD,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IAC3B,OAAO,EAAE,yBAAyB,CAAA;CACnC"}
|
package/package.json
CHANGED
package/src/account.ts
CHANGED
|
@@ -218,6 +218,25 @@ export interface OrdersResponse {
|
|
|
218
218
|
pagination: Pagination
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Fee a venue charged, in the asset the venue charged it in. A venue does not
|
|
223
|
+
* always charge a fee in the asset the record is otherwise denominated in, so
|
|
224
|
+
* a consumer must format the amount against `asset` and never against the
|
|
225
|
+
* fill's quote asset or the activity's own `asset`.
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
export interface Fee {
|
|
230
|
+
/** Decimal string in `asset`'s units. */
|
|
231
|
+
amount: string
|
|
232
|
+
/**
|
|
233
|
+
* Display symbol the fee is denominated in, resolved by the provider
|
|
234
|
+
* adapter. Falls back to the venue's own asset id when the registry knows no
|
|
235
|
+
* symbol.
|
|
236
|
+
*/
|
|
237
|
+
asset: string
|
|
238
|
+
}
|
|
239
|
+
|
|
221
240
|
/**
|
|
222
241
|
* Normalized execution/fill record for an order.
|
|
223
242
|
*
|
|
@@ -239,7 +258,8 @@ export interface Fill {
|
|
|
239
258
|
status: FillStatus
|
|
240
259
|
liquidity: LiquidityRole
|
|
241
260
|
filledSize?: string
|
|
242
|
-
fee
|
|
261
|
+
/** Absent when the venue reports no fee for the fill. */
|
|
262
|
+
fee?: Fee
|
|
243
263
|
realizedPnl?: string | null
|
|
244
264
|
startPosition?: string
|
|
245
265
|
classification: FillClassification
|
|
@@ -304,9 +324,8 @@ export interface DepositActivity extends BaseActivity {
|
|
|
304
324
|
}
|
|
305
325
|
|
|
306
326
|
/**
|
|
307
|
-
* Account activity representing a completed withdrawal. `amount`
|
|
308
|
-
*
|
|
309
|
-
* denominated in the withdrawn asset.
|
|
327
|
+
* Account activity representing a completed withdrawal. `amount` is a decimal
|
|
328
|
+
* string in `asset`'s units.
|
|
310
329
|
*
|
|
311
330
|
* @public
|
|
312
331
|
*/
|
|
@@ -319,7 +338,7 @@ export interface WithdrawalActivity extends BaseActivity {
|
|
|
319
338
|
asset: string
|
|
320
339
|
amount: string
|
|
321
340
|
/** Absent when the venue reports no fee for the withdrawal. */
|
|
322
|
-
fee?:
|
|
341
|
+
fee?: Fee
|
|
323
342
|
/** Fully-resolved block-explorer URL for the on-chain withdrawal tx. */
|
|
324
343
|
explorerLink?: string
|
|
325
344
|
}
|
|
@@ -336,11 +355,10 @@ export interface LiquidatedPosition {
|
|
|
336
355
|
}
|
|
337
356
|
|
|
338
357
|
/**
|
|
339
|
-
* Account activity representing a liquidation event.
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* must never group activities by timestamp.
|
|
358
|
+
* Account activity representing a liquidation event. A venue that liquidates
|
|
359
|
+
* several cross-margin positions in one cascade reports them as one activity
|
|
360
|
+
* with several entries, so consumers must never group activities by
|
|
361
|
+
* timestamp.
|
|
344
362
|
*
|
|
345
363
|
* @public
|
|
346
364
|
*/
|
|
@@ -357,7 +375,11 @@ export interface LiquidationActivity extends BaseActivity {
|
|
|
357
375
|
* liquidation row.
|
|
358
376
|
*/
|
|
359
377
|
leverageType?: string
|
|
360
|
-
|
|
378
|
+
/**
|
|
379
|
+
* At least one entry is guaranteed — a provider adapter drops any
|
|
380
|
+
* liquidation record whose positions it cannot resolve to a known market.
|
|
381
|
+
*/
|
|
382
|
+
liquidatedPositions: [LiquidatedPosition, ...LiquidatedPosition[]]
|
|
361
383
|
}
|
|
362
384
|
|
|
363
385
|
/**
|
|
@@ -393,6 +415,14 @@ export type TransferActivity = BaseActivity & {
|
|
|
393
415
|
direction: 'IN' | 'OUT'
|
|
394
416
|
asset: string
|
|
395
417
|
amount: string
|
|
418
|
+
/**
|
|
419
|
+
* Every fee the venue charged for the transfer, in the order the venue
|
|
420
|
+
* reports them. A venue may charge several fees for one transfer, each in a
|
|
421
|
+
* different asset — a transfer fee plus a separate gas fee in the chain's
|
|
422
|
+
* native token — so this is a list and not a single amount. Absent when the
|
|
423
|
+
* venue reports no fee.
|
|
424
|
+
*/
|
|
425
|
+
fees?: Fee[]
|
|
396
426
|
meta?: Record<string, unknown>
|
|
397
427
|
/** Fully-resolved block-explorer URL for the on-chain transfer tx. */
|
|
398
428
|
explorerLink?: string
|
package/src/action.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from './enums.js'
|
|
13
13
|
import type { MarketDisplay, MarketRef } from './market.js'
|
|
14
14
|
import type { Address, Hex } from './primitives.js'
|
|
15
|
+
import type { CreateReferralCodeParams, OnboardParams } from './referral.js'
|
|
15
16
|
import type { PerpsTypedData } from './typedData.js'
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -616,6 +617,8 @@ export interface ActionParamsMap {
|
|
|
616
617
|
[ActionType.ACCEPT_PROVIDER_TERMS]: Record<string, never>
|
|
617
618
|
[ActionType.DEPOSIT]: DepositParams
|
|
618
619
|
[ActionType.META_ACCEPT_TERMS]: AcceptTermsParams
|
|
620
|
+
[ActionType.META_ONBOARD]: OnboardParams
|
|
621
|
+
[ActionType.META_CREATE_REFERRAL_CODE]: CreateReferralCodeParams
|
|
619
622
|
}
|
|
620
623
|
|
|
621
624
|
/**
|
package/src/enums.ts
CHANGED
|
@@ -173,6 +173,10 @@ export enum ActionType {
|
|
|
173
173
|
DEPOSIT = 'deposit',
|
|
174
174
|
/** Provider-independent: sent with the `META_PROVIDER` sentinel, not a real provider key. */
|
|
175
175
|
META_ACCEPT_TERMS = 'metaAcceptTerms',
|
|
176
|
+
/** Provider-independent composite onboarding consent: the current app-wide terms plus an optional internal referral code, in one signature. */
|
|
177
|
+
META_ONBOARD = 'metaOnboard',
|
|
178
|
+
/** Provider-independent: reserves the shareable internal referral code an address owns. */
|
|
179
|
+
META_CREATE_REFERRAL_CODE = 'metaCreateReferralCode',
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
/** Price relation that activates a trigger order. @public */
|
package/src/index.ts
CHANGED
package/src/metaProvider.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ActionType } from './enums.js'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Sentinel sent in the `provider` field for provider-independent actions
|
|
3
5
|
* (e.g. {@link "./enums.js".ActionType.META_ACCEPT_TERMS}). The backend
|
|
@@ -8,3 +10,14 @@ export const META_PROVIDER = 'meta'
|
|
|
8
10
|
|
|
9
11
|
/** Type alias for the {@link META_PROVIDER} provider-independent sentinel. @public */
|
|
10
12
|
export type MetaProvider = typeof META_PROVIDER
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The provider-independent actions dispatched with the {@link META_PROVIDER}
|
|
16
|
+
* sentinel. They carry no venue plugin and no `ProviderAction` descriptor, so
|
|
17
|
+
* they are signed as EIP-712 typed data with the end-user's wallet.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type MetaActionType =
|
|
21
|
+
| ActionType.META_ACCEPT_TERMS
|
|
22
|
+
| ActionType.META_ONBOARD
|
|
23
|
+
| ActionType.META_CREATE_REFERRAL_CODE
|