@lifi/perps-sdk-provider-ondo 0.0.0-preview-e466cdc → 0.0.0-preview-e0d34a1
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 +9 -0
- package/dist/cjs/OndoProvider.d.ts.map +1 -1
- package/dist/cjs/OndoProvider.js +14 -9
- package/dist/cjs/OndoProvider.js.map +1 -1
- package/dist/cjs/types/wire.d.ts +15 -5
- package/dist/cjs/types/wire.d.ts.map +1 -1
- package/dist/cjs/utils/mapActivity.d.ts +1 -1
- package/dist/cjs/utils/mapActivity.d.ts.map +1 -1
- package/dist/cjs/utils/mapActivity.js +18 -11
- package/dist/cjs/utils/mapActivity.js.map +1 -1
- package/dist/cjs/utils/mapOrder.d.ts.map +1 -1
- package/dist/cjs/utils/mapOrder.js +2 -1
- package/dist/cjs/utils/mapOrder.js.map +1 -1
- package/dist/cjs/utils/mapPosition.d.ts.map +1 -1
- package/dist/cjs/utils/mapPosition.js +1 -0
- package/dist/cjs/utils/mapPosition.js.map +1 -1
- package/dist/cjs/utils/mapTwap.d.ts.map +1 -1
- package/dist/cjs/utils/mapTwap.js +4 -7
- package/dist/cjs/utils/mapTwap.js.map +1 -1
- package/dist/esm/OndoProvider.d.ts.map +1 -1
- package/dist/esm/OndoProvider.js +25 -9
- package/dist/esm/OndoProvider.js.map +1 -1
- package/dist/esm/types/wire.d.ts +27 -6
- package/dist/esm/types/wire.d.ts.map +1 -1
- package/dist/esm/utils/mapActivity.d.ts +7 -4
- package/dist/esm/utils/mapActivity.d.ts.map +1 -1
- package/dist/esm/utils/mapActivity.js +24 -14
- package/dist/esm/utils/mapActivity.js.map +1 -1
- package/dist/esm/utils/mapOrder.d.ts +5 -1
- package/dist/esm/utils/mapOrder.d.ts.map +1 -1
- package/dist/esm/utils/mapOrder.js +7 -2
- package/dist/esm/utils/mapOrder.js.map +1 -1
- package/dist/esm/utils/mapPosition.d.ts.map +1 -1
- package/dist/esm/utils/mapPosition.js +1 -0
- package/dist/esm/utils/mapPosition.js.map +1 -1
- package/dist/esm/utils/mapTwap.d.ts.map +1 -1
- package/dist/esm/utils/mapTwap.js +6 -7
- package/dist/esm/utils/mapTwap.js.map +1 -1
- package/dist/types/OndoProvider.d.ts.map +1 -1
- package/dist/types/types/wire.d.ts +27 -6
- package/dist/types/types/wire.d.ts.map +1 -1
- package/dist/types/utils/mapActivity.d.ts +7 -4
- package/dist/types/utils/mapActivity.d.ts.map +1 -1
- package/dist/types/utils/mapOrder.d.ts +5 -1
- package/dist/types/utils/mapOrder.d.ts.map +1 -1
- package/dist/types/utils/mapPosition.d.ts.map +1 -1
- package/dist/types/utils/mapTwap.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/OndoProvider.ts +31 -13
- package/src/types/wire.ts +27 -6
- package/src/utils/mapActivity.ts +24 -14
- package/src/utils/mapOrder.ts +7 -2
- package/src/utils/mapPosition.ts +1 -0
- package/src/utils/mapTwap.ts +6 -7
package/src/utils/mapActivity.ts
CHANGED
|
@@ -37,25 +37,35 @@ export const mapFundingActivity = (
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Map an Ondo liquidation event to a {@link LiquidationActivity}
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Map an Ondo liquidation event to a {@link LiquidationActivity}, or `null`
|
|
41
|
+
* when the event names no triggering position. Ondo margin accounts are
|
|
42
|
+
* cross-only, so `leverageType` is always `'cross'`. Ondo reports no account
|
|
43
|
+
* value at liquidation time, so `accountValue` stays absent. One Ondo event
|
|
44
|
+
* carries the whole cross-margin cascade in `triggeringPositions`, so every
|
|
45
|
+
* liquidated market and size reaches `liquidatedPositions`.
|
|
43
46
|
*
|
|
44
47
|
* @public
|
|
45
48
|
*/
|
|
46
49
|
export const mapLiquidationActivity = (
|
|
47
50
|
event: OndoLiquidationEvent,
|
|
48
51
|
resolveMarket: (market: string) => MarketDisplay
|
|
49
|
-
): LiquidationActivity =>
|
|
50
|
-
|
|
51
|
-
provider: ONDO_PROVIDER_KEY,
|
|
52
|
-
timestamp: new Date(event.time).toISOString(),
|
|
53
|
-
type: ActivityType.LIQUIDATION,
|
|
54
|
-
liquidatedNotionalPosition: event.filledQuoteSize ?? '0',
|
|
55
|
-
accountValue: '0',
|
|
56
|
-
leverageType: 'cross',
|
|
57
|
-
liquidatedPositions: (event.triggeringPositions ?? []).map((p) => ({
|
|
52
|
+
): LiquidationActivity | null => {
|
|
53
|
+
const liquidatedPositions = (event.triggeringPositions ?? []).map((p) => ({
|
|
58
54
|
market: resolveMarket(p.market),
|
|
59
55
|
size: p.netQuantity,
|
|
60
|
-
}))
|
|
61
|
-
|
|
56
|
+
}))
|
|
57
|
+
if (liquidatedPositions.length === 0) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
id: event.id,
|
|
62
|
+
provider: ONDO_PROVIDER_KEY,
|
|
63
|
+
timestamp: new Date(event.time).toISOString(),
|
|
64
|
+
type: ActivityType.LIQUIDATION,
|
|
65
|
+
...(event.filledQuoteSize === undefined
|
|
66
|
+
? {}
|
|
67
|
+
: { liquidatedNotionalPosition: event.filledQuoteSize }),
|
|
68
|
+
leverageType: 'cross',
|
|
69
|
+
liquidatedPositions,
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/utils/mapOrder.ts
CHANGED
|
@@ -88,7 +88,11 @@ export const isTriggerOrder = (order: OndoOrder): boolean =>
|
|
|
88
88
|
order.stopOrderType !== undefined ||
|
|
89
89
|
order.triggerPrice !== undefined
|
|
90
90
|
|
|
91
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Map an active non-trigger Ondo order to an {@link OpenOrder}. Ondo reports
|
|
93
|
+
* the submitted and filled quantities only, so `remainingSize` is derived.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
92
96
|
export const mapOrder = (
|
|
93
97
|
order: OndoOrder,
|
|
94
98
|
market: MarketDisplay
|
|
@@ -97,7 +101,8 @@ export const mapOrder = (
|
|
|
97
101
|
market,
|
|
98
102
|
side: mapSide(order.side),
|
|
99
103
|
type: mapOrderType(order.type),
|
|
100
|
-
|
|
104
|
+
originalSize: new Big(order.size).toFixed(),
|
|
105
|
+
remainingSize: new Big(order.size).minus(order.filledSize).toFixed(),
|
|
101
106
|
price: order.price,
|
|
102
107
|
filledSize: order.filledSize,
|
|
103
108
|
reduceOnly: order.reduceOnly ?? false,
|
package/src/utils/mapPosition.ts
CHANGED
|
@@ -21,6 +21,7 @@ export const mapPosition = (
|
|
|
21
21
|
markPrice: pos.markPrice,
|
|
22
22
|
liquidationPrice: pos.liquidationPrice,
|
|
23
23
|
unrealizedPnl: pos.unrealizedPnl,
|
|
24
|
+
accruedFunding: pos.netFundingSinceNeutral,
|
|
24
25
|
leverage: Number.parseFloat(pos.leverage),
|
|
25
26
|
marginUsed: pos.usedMargin,
|
|
26
27
|
initialMarginRequirement: pos.usedMargin,
|
package/src/utils/mapTwap.ts
CHANGED
|
@@ -13,19 +13,18 @@ export const mapRunningTwap = (
|
|
|
13
13
|
order: OndoTwapOrder,
|
|
14
14
|
market: Market
|
|
15
15
|
): TwapOrder => {
|
|
16
|
-
const filledSize = new Big(order.filledSize)
|
|
17
16
|
return {
|
|
18
17
|
twapId: order.twapId,
|
|
19
18
|
market: toMarketDisplay(market),
|
|
20
19
|
side: order.side === 'buy' ? OrderSide.BUY : OrderSide.SELL,
|
|
21
|
-
totalSize: order.
|
|
20
|
+
totalSize: order.totalSize,
|
|
22
21
|
filledSize: order.filledSize,
|
|
23
|
-
|
|
22
|
+
// The venue reports `avgFilledPrice: '0'` before the first child fill,
|
|
23
|
+
// where the shared model omits the field.
|
|
24
|
+
...(new Big(order.filledSize).eq(0)
|
|
24
25
|
? {}
|
|
25
|
-
: {
|
|
26
|
-
|
|
27
|
-
}),
|
|
28
|
-
startedAt: new Date(order.createdAt).toISOString(),
|
|
26
|
+
: { avgFillPrice: order.avgFilledPrice }),
|
|
27
|
+
startedAt: new Date(order.startTime).toISOString(),
|
|
29
28
|
durationSeconds: order.runningTime,
|
|
30
29
|
status: TwapOrderStatus.RUNNING,
|
|
31
30
|
}
|