@0xmonaco/core 1.0.80 → 1.0.81
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TraderCodes API Implementation (`sdk.pitpass`)
|
|
3
3
|
*
|
|
4
|
-
* Provides methods for the
|
|
4
|
+
* Provides methods for the TraderCodes referral program: reading your wallet-derived
|
|
5
5
|
* TraderCode, a public lookup to validate a referral code at sign-up, reading
|
|
6
6
|
* your accrued rewards balance, and transferring rewards into a tradeable balance.
|
|
7
7
|
*
|
|
@@ -69,11 +69,11 @@ export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
|
|
|
69
69
|
*/
|
|
70
70
|
getTraderCodeInfo(code: string): Promise<TraderCodeInfoResponse>;
|
|
71
71
|
/**
|
|
72
|
-
* Return the caller's current
|
|
72
|
+
* Return the caller's current TraderCodes rewards-bucket balances.
|
|
73
73
|
*/
|
|
74
74
|
getRewardsBalance(): Promise<GetRewardsBalanceResponse>;
|
|
75
75
|
/**
|
|
76
|
-
* Transfer earned
|
|
76
|
+
* Transfer earned TraderCodes rewards into a trading balance.
|
|
77
77
|
*/
|
|
78
78
|
transferRewards(params: TransferRewardsParams): Promise<TransferRewardsResponse>;
|
|
79
79
|
/**
|
package/dist/api/pitpass/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TraderCodes API Implementation (`sdk.pitpass`)
|
|
3
3
|
*
|
|
4
|
-
* Provides methods for the
|
|
4
|
+
* Provides methods for the TraderCodes referral program: reading your wallet-derived
|
|
5
5
|
* TraderCode, a public lookup to validate a referral code at sign-up, reading
|
|
6
6
|
* your accrued rewards balance, and transferring rewards into a tradeable balance.
|
|
7
7
|
*
|
|
@@ -93,13 +93,13 @@ export class PitpassAPIImpl extends BaseAPI {
|
|
|
93
93
|
return await this.makePublicRequest(`/api/v1/pitpass/codes/${encoded}`, { method: "GET" });
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Return the caller's current
|
|
96
|
+
* Return the caller's current TraderCodes rewards-bucket balances.
|
|
97
97
|
*/
|
|
98
98
|
async getRewardsBalance() {
|
|
99
99
|
return await this.makeAuthenticatedRequest("/api/v1/pitpass/rewards/balance", { method: "GET" });
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* Transfer earned
|
|
102
|
+
* Transfer earned TraderCodes rewards into a trading balance.
|
|
103
103
|
*/
|
|
104
104
|
async transferRewards(params) {
|
|
105
105
|
const validated = validate(TransferRewardsParamsSchema, params);
|
|
@@ -256,6 +256,9 @@ function parsePositionEventData(raw) {
|
|
|
256
256
|
// every `>=` comparison, so the server omits the key rather than sending
|
|
257
257
|
// zero.
|
|
258
258
|
version: readOptionalSequence(data, "version"),
|
|
259
|
+
// Lifetime funding since open. Optional: an older deployment does not
|
|
260
|
+
// send it, and the server omits it when it cannot serve the whole value.
|
|
261
|
+
fundingPaid: readOptionalString(data, "fundingPaid"),
|
|
259
262
|
};
|
|
260
263
|
}
|
|
261
264
|
function parsePositionEvent(rawData) {
|
|
@@ -522,6 +525,31 @@ function parseTradeEventData(raw) {
|
|
|
522
525
|
executedAt: readString(raw, "executed_at"),
|
|
523
526
|
};
|
|
524
527
|
}
|
|
528
|
+
/**
|
|
529
|
+
* Parse one `ohlcv` snapshot row: the live candle frame's `data` body.
|
|
530
|
+
*
|
|
531
|
+
* Strict, unlike the live OHLCV handler's casts: a snapshot is delivered
|
|
532
|
+
* all-or-nothing, so a row with a missing or mistyped field must throw for
|
|
533
|
+
* {@link snapshotFrameHandler} to withhold the frame. The output is the live
|
|
534
|
+
* candlestick minus `s`; `i` is the subscription's interval, since the row
|
|
535
|
+
* carries no envelope.
|
|
536
|
+
*/
|
|
537
|
+
function parseOHLCVSnapshotCandle(raw, interval) {
|
|
538
|
+
if (!isRecord(raw)) {
|
|
539
|
+
throw new Error("Invalid ohlcv snapshot row: must be an object");
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
T: readSequence(raw, "period_start"),
|
|
543
|
+
t: readSequence(raw, "period_end"),
|
|
544
|
+
o: readString(raw, "open"),
|
|
545
|
+
h: readString(raw, "high"),
|
|
546
|
+
l: readString(raw, "low"),
|
|
547
|
+
c: readString(raw, "close"),
|
|
548
|
+
v: readString(raw, "volume"),
|
|
549
|
+
i: interval,
|
|
550
|
+
n: readSequence(raw, "trades_count"),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
525
553
|
function parseInstrumentEventData(raw) {
|
|
526
554
|
if (!isRecord(raw)) {
|
|
527
555
|
throw new Error("Invalid instrument event: data must be an object");
|
|
@@ -1468,7 +1496,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1468
1496
|
}
|
|
1469
1497
|
});
|
|
1470
1498
|
};
|
|
1471
|
-
const subscribeOHLCV = (tradingPairId, tradingMode, interval, handler, priceType) => {
|
|
1499
|
+
const subscribeOHLCV = (tradingPairId, tradingMode, interval, handler, priceType, onSnapshot) => {
|
|
1472
1500
|
// Four-token channel selects the trade-derived candles (back-compat); the
|
|
1473
1501
|
// optional fifth token selects the price series (`mark` = close-only mark
|
|
1474
1502
|
// series, `*` = both).
|
|
@@ -1514,7 +1542,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1514
1542
|
catch (err) {
|
|
1515
1543
|
console.error("WebSocket: Error processing OHLCV event", err);
|
|
1516
1544
|
}
|
|
1517
|
-
});
|
|
1545
|
+
}, onSnapshot && snapshotFrameHandler("ohlcv", (raw) => parseOHLCVSnapshotCandle(raw, interval), onSnapshot));
|
|
1518
1546
|
};
|
|
1519
1547
|
const subscribeTrades = (tradingPairId, handler, onSnapshot) => {
|
|
1520
1548
|
const channel = `trades:${tradingPairId}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.81",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://docs.0xmonaco.com/sdk/typescript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"viem": "^2.45.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@0xmonaco/contracts": "1.0.
|
|
23
|
-
"@0xmonaco/types": "1.0.
|
|
22
|
+
"@0xmonaco/contracts": "1.0.81",
|
|
23
|
+
"@0xmonaco/types": "1.0.81",
|
|
24
24
|
"@noble/curves": "^1.9.1",
|
|
25
25
|
"@noble/hashes": "^2.4.0",
|
|
26
26
|
"http-status-codes": "^2.3.0"
|