@pear-protocol/exchanges-sdk 0.19.0 → 0.19.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/README.md CHANGED
@@ -413,9 +413,9 @@ await tracker.disconnect(); // closes the WebSocket opened by start()
413
413
 
414
414
  Credentials and the trade account are fetched automatically on `connect`; Hyperliquid and Lighter account identifiers come from `connection.account.exchangeIdentifier`.
415
415
 
416
- Pear returns the public trader identity only while its owner enables `sharingEnabled` in
417
- trade account settings. Disabling it hides future Pear reads; the exchange public APIs
418
- remain address-based and independent of Pear consent.
416
+ Pear exposes public trader reads for active accounts without separate sharing or copying
417
+ settings. The default leaderboard requires a linked X account; hiding X omits the identity
418
+ without removing the rank. Exchange public APIs remain address-based.
419
419
 
420
420
  ## Hyperliquid subaccount funding
421
421
 
package/dist/index.d.ts CHANGED
@@ -1449,10 +1449,13 @@ declare class LighterAccountSyncer extends BaseAccountSyncer<RawFill$1> {
1449
1449
  protected listExternalFunding({ since, instruments, }: ListExternalFundingParams): Promise<HttpTypes.FundingPaymentEntry[]>;
1450
1450
  protected isReduceOnly(rawFill: RawFill$1): boolean;
1451
1451
  private getAccountSide;
1452
+ /** The client order id on our side of the fill, or null when Lighter reports none. */
1452
1453
  private getClientOrderId;
1453
1454
  private isMaker;
1454
1455
  private getPositionSizeBefore;
1456
+ /** Signed like the rate: positive is a cost, a negative rate a maker rebate (#748). */
1455
1457
  private getTradeFee;
1458
+ /** The integrator's cut, which the wire carries unsigned. */
1456
1459
  private getIntegratorFee;
1457
1460
  /** Prevents testnet reads from silently minting a mainnet auth token. */
1458
1461
  private assertAuthenticatedSyncAvailable;
@@ -1,6 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { fetchAllPositionRisk, fetchUserTradesSince, fetchAllOrdersSince } from '../../client/binance/rest';
3
3
  import { BaseAccountSyncer } from '../base';
4
+ import { toSignedTradeFee } from '../trade-fee';
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -66,7 +67,7 @@ class BinanceAccountSyncer extends BaseAccountSyncer {
66
67
  side: rawFill.side,
67
68
  reduceOnly: this.isReduceOnly(rawFill),
68
69
  timestamp: rawFill.time,
69
- tradeFee: new BigNumber(rawFill.commission || 0).abs().toFixed(),
70
+ tradeFee: toSignedTradeFee("binance", rawFill.commission),
70
71
  builderFee: "0",
71
72
  liquidation: null
72
73
  });
@@ -1,6 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { fetchPositions, fetchExecutionsSince } from '../../client/bybit/rest';
3
3
  import { BaseAccountSyncer } from '../base';
4
+ import { toSignedTradeFee } from '../trade-fee';
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -36,6 +37,9 @@ class BybitAccountSyncer extends BaseAccountSyncer {
36
37
  async listExternalFills({ since }) {
37
38
  const executions = await fetchExecutionsSince(this.creds, since, this.demo);
38
39
  return executions.reduce((fills, rawFill) => {
40
+ if (rawFill.execType === "Funding") {
41
+ return fills;
42
+ }
39
43
  fills.push({
40
44
  connector: "bybit",
41
45
  exchangeFillId: rawFill.execId,
@@ -46,7 +50,7 @@ class BybitAccountSyncer extends BaseAccountSyncer {
46
50
  side: rawFill.side === "Buy" ? "BUY" : "SELL",
47
51
  reduceOnly: this.isReduceOnly(rawFill),
48
52
  timestamp: Number(rawFill.execTime),
49
- tradeFee: new BigNumber(rawFill.execFee || 0).abs().toFixed(),
53
+ tradeFee: toSignedTradeFee("bybit", rawFill.execFee),
50
54
  builderFee: "0",
51
55
  liquidation: null
52
56
  });
@@ -119,8 +119,10 @@ class LighterAccountSyncer extends BaseAccountSyncer {
119
119
  if (rawFill.bid_account_id === this.accountIndex) return "bid";
120
120
  return null;
121
121
  }
122
+ /** The client order id on our side of the fill, or null when Lighter reports none. */
122
123
  getClientOrderId(rawFill, side) {
123
- return (side === "ask" ? rawFill.ask_client_id_str : rawFill.bid_client_id_str) || null;
124
+ const clientOrderId = side === "ask" ? rawFill.ask_client_id_str : rawFill.bid_client_id_str;
125
+ return clientOrderId && clientOrderId !== "0" ? clientOrderId : null;
124
126
  }
125
127
  isMaker(rawFill, side) {
126
128
  return side === "ask" ? rawFill.is_maker_ask : !rawFill.is_maker_ask;
@@ -129,13 +131,15 @@ class LighterAccountSyncer extends BaseAccountSyncer {
129
131
  const value = this.isMaker(rawFill, side) ? rawFill.maker_position_size_before : rawFill.taker_position_size_before;
130
132
  return new BigNumber(value ?? 0);
131
133
  }
134
+ /** Signed like the rate: positive is a cost, a negative rate a maker rebate (#748). */
132
135
  getTradeFee(rawFill, side) {
133
136
  const rateTick = this.isMaker(rawFill, side) ? rawFill.maker_fee : rawFill.taker_fee;
134
- return this.feeTickToAmount(rateTick, rawFill.usd_amount);
137
+ return this.feeTickToAmount(rateTick, rawFill.usd_amount).toFixed();
135
138
  }
139
+ /** The integrator's cut, which the wire carries unsigned. */
136
140
  getIntegratorFee(rawFill, side) {
137
141
  const rateTick = this.isMaker(rawFill, side) ? rawFill.integrator_maker_fee : rawFill.integrator_taker_fee;
138
- return this.feeTickToAmount(rateTick, rawFill.usd_amount);
142
+ return this.feeTickToAmount(rateTick, rawFill.usd_amount).abs().toFixed();
139
143
  }
140
144
  /** Prevents testnet reads from silently minting a mainnet auth token. */
141
145
  assertAuthenticatedSyncAvailable() {
@@ -145,8 +149,8 @@ class LighterAccountSyncer extends BaseAccountSyncer {
145
149
  }
146
150
  // Lighter fees come as ppm rates (÷1e6), not amounts — the charged fee is that rate times the trade's USD notional.
147
151
  feeTickToAmount(rateTick, usdAmount) {
148
- const rate = new BigNumber(rateTick ?? 0).abs().div(LIGHTER_FEE_TICK_DENOMINATOR);
149
- return rate.times(usdAmount).toFixed();
152
+ const rate = new BigNumber(rateTick ?? 0).div(LIGHTER_FEE_TICK_DENOMINATOR);
153
+ return rate.times(usdAmount);
150
154
  }
151
155
  }
152
156
 
@@ -1,6 +1,7 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { fetchPositions, fetchFillsHistorySince } from '../../client/okx/rest';
3
3
  import { BaseAccountSyncer } from '../base';
4
+ import { toSignedTradeFee } from '../trade-fee';
4
5
 
5
6
  var __defProp = Object.defineProperty;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -51,7 +52,7 @@ class OkxAccountSyncer extends BaseAccountSyncer {
51
52
  side: rawFill.side === "buy" ? "BUY" : "SELL",
52
53
  reduceOnly: this.isReduceOnly(rawFill),
53
54
  timestamp: Number(rawFill.fillTime || rawFill.ts),
54
- tradeFee: new BigNumber(rawFill.fee || 0).abs().toFixed(),
55
+ tradeFee: toSignedTradeFee("okx", rawFill.fee),
55
56
  builderFee: "0",
56
57
  liquidation: null
57
58
  });
@@ -0,0 +1,21 @@
1
+ import { parse, negate } from '@pear-protocol/utils';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function toSignedTradeFee(connector, rawFee) {
6
+ const fee = parse(rawFee || "0");
7
+ switch (connector) {
8
+ // Binance `userTrades.commission`: a charge is positive. The docs do not state a rebate's sign; it is
9
+ // taken to be negative, the same convention as ours.
10
+ case "binance":
11
+ // Bybit `execution/list.execFee`: positive is an expense, negative a rebate (v5 transaction-log docs).
12
+ case "bybit":
13
+ return fee.toFixed();
14
+ // OKX `fills-history.fee`: a deduction is negative, a rebate positive (v5 docs), the opposite of ours.
15
+ case "okx":
16
+ return negate(fee).toFixed();
17
+ }
18
+ }
19
+ __name(toSignedTradeFee, "toSignedTradeFee");
20
+
21
+ export { toSignedTradeFee };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/exchanges-sdk",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Pear Protocol Exchanges SDK",
5
5
  "private": false,
6
6
  "type": "module",
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@nktkas/hyperliquid": "0.33.2",
31
- "@pear-protocol/core-sdk": "^2.8.0",
32
- "@pear-protocol/types": "^2.15.0",
33
- "@pear-protocol/utils": "^1.3.0",
31
+ "@pear-protocol/core-sdk": "^2.12.0",
32
+ "@pear-protocol/types": "^2.19.0",
33
+ "@pear-protocol/utils": "^1.4.0",
34
34
  "bignumber.js": "^11.1.1",
35
35
  "partysocket": "^1.0.3",
36
36
  "viem": "^2.48.8",