@compass-labs/api-sdk 2.2.114 → 2.2.115

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.
Files changed (46) hide show
  1. package/dist/commonjs/models/components/index.d.ts +1 -0
  2. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  3. package/dist/commonjs/models/components/index.js +1 -0
  4. package/dist/commonjs/models/components/index.js.map +1 -1
  5. package/dist/commonjs/models/components/loopedposition.d.ts +5 -0
  6. package/dist/commonjs/models/components/loopedposition.d.ts.map +1 -1
  7. package/dist/commonjs/models/components/loopedposition.js +2 -0
  8. package/dist/commonjs/models/components/loopedposition.js.map +1 -1
  9. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts +16 -1
  10. package/dist/commonjs/models/components/loopedpositionhistoryentry.d.ts.map +1 -1
  11. package/dist/commonjs/models/components/loopedpositionhistoryentry.js +12 -1
  12. package/dist/commonjs/models/components/loopedpositionhistoryentry.js.map +1 -1
  13. package/dist/commonjs/models/components/loopedpositionpnl.d.ts +36 -0
  14. package/dist/commonjs/models/components/loopedpositionpnl.d.ts.map +1 -0
  15. package/dist/commonjs/models/components/loopedpositionpnl.js +59 -0
  16. package/dist/commonjs/models/components/loopedpositionpnl.js.map +1 -0
  17. package/dist/commonjs/models/components/swapinfo.d.ts +8 -8
  18. package/dist/esm/models/components/index.d.ts +1 -0
  19. package/dist/esm/models/components/index.d.ts.map +1 -1
  20. package/dist/esm/models/components/index.js +1 -0
  21. package/dist/esm/models/components/index.js.map +1 -1
  22. package/dist/esm/models/components/loopedposition.d.ts +5 -0
  23. package/dist/esm/models/components/loopedposition.d.ts.map +1 -1
  24. package/dist/esm/models/components/loopedposition.js +2 -0
  25. package/dist/esm/models/components/loopedposition.js.map +1 -1
  26. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts +16 -1
  27. package/dist/esm/models/components/loopedpositionhistoryentry.d.ts.map +1 -1
  28. package/dist/esm/models/components/loopedpositionhistoryentry.js +11 -0
  29. package/dist/esm/models/components/loopedpositionhistoryentry.js.map +1 -1
  30. package/dist/esm/models/components/loopedpositionpnl.d.ts +36 -0
  31. package/dist/esm/models/components/loopedpositionpnl.d.ts.map +1 -0
  32. package/dist/esm/models/components/loopedpositionpnl.js +22 -0
  33. package/dist/esm/models/components/loopedpositionpnl.js.map +1 -0
  34. package/dist/esm/models/components/swapinfo.d.ts +8 -8
  35. package/docs/models/components/flowbasis.md +15 -0
  36. package/docs/models/components/loopedposition.md +1 -0
  37. package/docs/models/components/loopedpositionhistoryentry.md +13 -11
  38. package/docs/models/components/loopedpositionpnl.md +27 -0
  39. package/docs/models/components/swapinfo.md +8 -8
  40. package/openapi_prepped_for_speakeasy.json +90 -4
  41. package/package.json +1 -1
  42. package/src/models/components/index.ts +1 -0
  43. package/src/models/components/loopedposition.ts +9 -0
  44. package/src/models/components/loopedpositionhistoryentry.ts +23 -1
  45. package/src/models/components/loopedpositionpnl.ts +66 -0
  46. package/src/models/components/swapinfo.ts +8 -8
@@ -22,6 +22,11 @@ export declare const Classification: {
22
22
  * What this transaction did to the position: loop_open / loop_increase (lever up with a swap), unwind (delever), single-sided supply/withdraw/borrow/repay, liquidation, or mixed.
23
23
  */
24
24
  export type Classification = ClosedEnum<typeof Classification>;
25
+ export declare const FlowBasis: {
26
+ readonly Swap: "swap";
27
+ readonly Oracle: "oracle";
28
+ };
29
+ export type FlowBasis = ClosedEnum<typeof FlowBasis>;
25
30
  /**
26
31
  * One transaction in a looped position's lifetime.
27
32
  */
@@ -55,17 +60,27 @@ export type LoopedPositionHistoryEntry = {
55
60
  */
56
61
  debtDelta: string;
57
62
  /**
58
- * The swap leg detected in this transaction, if any.
63
+ * The swap leg of a loop (debt sold for collateral) or an unwind (collateral sold for debt), when the transaction shows one.
59
64
  */
60
65
  swap?: SwapInfo | null | undefined;
61
66
  /**
62
67
  * The raw lending events that make up this transaction (Morpho supply_collateral maps to 'supply', withdraw_collateral to 'withdraw').
63
68
  */
64
69
  events?: Array<CreditEvent> | undefined;
70
+ /**
71
+ * Equity this transaction put into the position (positive) or took out of it (negative), in the debt token, valued when it landed. 0 for a liquidation, whose loss stays in the position's equity. Null when the transaction could not be valued.
72
+ */
73
+ equityFlowQuote?: string | null | undefined;
74
+ /**
75
+ * How equity_flow_quote was measured. 'swap': from this transaction's own swap, so the swap's cost shows up in PnL. 'oracle': from the net amounts at the market price; on a loop or unwind that folds the swap's cost into the flow instead. Null for a liquidation and for a transaction that could not be valued.
76
+ */
77
+ flowBasis?: FlowBasis | null | undefined;
65
78
  };
66
79
  /** @internal */
67
80
  export declare const Classification$inboundSchema: z.ZodNativeEnum<typeof Classification>;
68
81
  /** @internal */
82
+ export declare const FlowBasis$inboundSchema: z.ZodNativeEnum<typeof FlowBasis>;
83
+ /** @internal */
69
84
  export declare const LoopedPositionHistoryEntry$inboundSchema: z.ZodType<LoopedPositionHistoryEntry, z.ZodTypeDef, unknown>;
70
85
  export declare function loopedPositionHistoryEntryFromJSON(jsonString: string): SafeParseResult<LoopedPositionHistoryEntry, SDKValidationError>;
71
86
  //# sourceMappingURL=loopedpositionhistoryentry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loopedpositionhistoryentry.d.ts","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionhistoryentry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAA0B,MAAM,eAAe,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AACX;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,EAAE,IAAI,CAAC;IACrB;;OAEG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,EAAE,CAAC,CAAC,aAAa,CACxD,OAAO,cAAc,CACS,CAAC;AAEjC,gBAAgB;AAChB,eAAO,MAAM,wCAAwC,EAAE,CAAC,CAAC,OAAO,CAC9D,0BAA0B,EAC1B,CAAC,CAAC,UAAU,EACZ,OAAO,CAqBP,CAAC;AAEH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAMjE"}
1
+ {"version":3,"file":"loopedpositionhistoryentry.d.ts","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionhistoryentry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,WA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,wCAAwC,EAAE,CAAC,CAAC,OAAO,CAC9D,0BAA0B,EAC1B,CAAC,CAAC,UAAU,EACZ,OAAO,CAyBP,CAAC;AAEH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAMjE"}
@@ -20,9 +20,16 @@ export const Classification = {
20
20
  Liquidation: "liquidation",
21
21
  Mixed: "mixed",
22
22
  };
23
+ export const FlowBasis = {
24
+ Swap: "swap",
25
+ Oracle: "oracle",
26
+ };
23
27
  /** @internal */
24
28
  export const Classification$inboundSchema = z.nativeEnum(Classification);
25
29
  /** @internal */
30
+ export const FlowBasis$inboundSchema = z
31
+ .nativeEnum(FlowBasis);
32
+ /** @internal */
26
33
  export const LoopedPositionHistoryEntry$inboundSchema = z.object({
27
34
  transaction_hash: z.string(),
28
35
  block_number: z.number().int(),
@@ -33,6 +40,8 @@ export const LoopedPositionHistoryEntry$inboundSchema = z.object({
33
40
  debt_delta: z.string(),
34
41
  swap: z.nullable(SwapInfo$inboundSchema).optional(),
35
42
  events: z.array(CreditEvent$inboundSchema).optional(),
43
+ equity_flow_quote: z.nullable(z.string()).optional(),
44
+ flow_basis: z.nullable(FlowBasis$inboundSchema).optional(),
36
45
  }).transform((v) => {
37
46
  return remap$(v, {
38
47
  "transaction_hash": "transactionHash",
@@ -40,6 +49,8 @@ export const LoopedPositionHistoryEntry$inboundSchema = z.object({
40
49
  "block_timestamp": "blockTimestamp",
41
50
  "collateral_delta": "collateralDelta",
42
51
  "debt_delta": "debtDelta",
52
+ "equity_flow_quote": "equityFlowQuote",
53
+ "flow_basis": "flowBasis",
43
54
  });
44
55
  });
45
56
  export function loopedPositionHistoryEntryFromJSON(jsonString) {
@@ -1 +1 @@
1
- {"version":3,"file":"loopedpositionhistoryentry.js","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionhistoryentry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,M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AAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE;IACnD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,kBAAkB,EAAE,iBAAiB;QACrC,cAAc,EAAE,aAAa;QAC7B,iBAAiB,EAAE,gBAAgB;QACnC,kBAAkB,EAAE,iBAAiB;QACrC,YAAY,EAAE,WAAW;KAC1B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,kCAAkC,CAChD,UAAkB;IAElB,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,wCAAwC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACpE,wDAAwD,CACzD,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"loopedpositionhistoryentry.js","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionhistoryentry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAe,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAY,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,WAAW;IACrB,YAAY,EAAE,eAAe;IAC7B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;I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AE;CAC3D,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,kBAAkB,EAAE,iBAAiB;QACrC,cAAc,EAAE,aAAa;QAC7B,iBAAiB,EAAE,gBAAgB;QACnC,kBAAkB,EAAE,iBAAiB;QACrC,YAAY,EAAE,WAAW;QACzB,mBAAmB,EAAE,iBAAiB;QACtC,YAAY,EAAE,WAAW;KAC1B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,kCAAkC,CAChD,UAAkB;IAElB,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,wCAAwC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACpE,wDAAwD,CACzD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import * as z from "zod/v3";
2
+ import { Result as SafeParseResult } from "../../types/fp.js";
3
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
+ /**
5
+ * What a looped position has made or lost since it opened.
6
+ *
7
+ * @remarks
8
+ *
9
+ * Measured in the position's debt token (the quote), with USD alongside.
10
+ * Every transaction is an equity flow valued when it landed: a loop's
11
+ * principal goes in, an unwind's proceeds come out. PnL is what the position
12
+ * is worth now plus everything taken out, minus everything put in; each
13
+ * history entry carries its own flow in equity_flow_quote.
14
+ */
15
+ export type LoopedPositionPnl = {
16
+ /**
17
+ * Profit or loss since the position opened, in the position's debt token: what the position is worth now, plus everything taken out, minus everything put in, each valued when it happened. It includes the entry and exit swap costs, the carry (what the collateral earned minus the interest paid) and the collateral's price move against the debt token. Realized once the position is closed, unrealized while it is open. Where a loop or unwind's own swap could not be used (its history entry has flow_basis 'oracle'), that swap's cost is not counted and the figure reads higher by roughly that amount.
18
+ *
19
+ * @remarks
20
+ *
21
+ * Measured in the debt token, not USD: on a correlated loop (wstHYPE against WHYPE, wstETH against WETH) a positive figure here can still be a USD loss when the debt token itself falls. total_pnl_usd carries that.
22
+ */
23
+ totalPnlQuote: string | null;
24
+ /**
25
+ * total_pnl_quote as a percentage of the equity put in (e.g. 4.2 = 4.2%): the return on the capital contributed, not annualized.
26
+ */
27
+ totalPnlPercent?: string | null | undefined;
28
+ /**
29
+ * Profit or loss since the position opened, in USD: each flow at the debt token's USD price when it happened, the position's current value at its price now. Unlike total_pnl_quote it includes the debt token's own USD move. Null when any of those prices is unavailable.
30
+ */
31
+ totalPnlUsd?: string | null | undefined;
32
+ };
33
+ /** @internal */
34
+ export declare const LoopedPositionPnl$inboundSchema: z.ZodType<LoopedPositionPnl, z.ZodTypeDef, unknown>;
35
+ export declare function loopedPositionPnlFromJSON(jsonString: string): SafeParseResult<LoopedPositionPnl, SDKValidationError>;
36
+ //# sourceMappingURL=loopedpositionpnl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopedpositionpnl.d.ts","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionpnl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,+BAA+B,EAAE,CAAC,CAAC,OAAO,CACrD,iBAAiB,EACjB,CAAC,CAAC,UAAU,EACZ,OAAO,CAWP,CAAC;AAEH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAMxD"}
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import * as z from "zod/v3";
5
+ import { remap as remap$ } from "../../lib/primitives.js";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ /** @internal */
8
+ export const LoopedPositionPnl$inboundSchema = z.object({
9
+ total_pnl_quote: z.nullable(z.string()),
10
+ total_pnl_percent: z.nullable(z.string()).optional(),
11
+ total_pnl_usd: z.nullable(z.string()).optional(),
12
+ }).transform((v) => {
13
+ return remap$(v, {
14
+ "total_pnl_quote": "totalPnlQuote",
15
+ "total_pnl_percent": "totalPnlPercent",
16
+ "total_pnl_usd": "totalPnlUsd",
17
+ });
18
+ });
19
+ export function loopedPositionPnlFromJSON(jsonString) {
20
+ return safeParse(jsonString, (x) => LoopedPositionPnl$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LoopedPositionPnl' from JSON`);
21
+ }
22
+ //# sourceMappingURL=loopedpositionpnl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopedpositionpnl.js","sourceRoot":"","sources":["../../../../src/models/components/loopedpositionpnl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAkCjD,gBAAgB;AAChB,MAAM,CAAC,MAAM,+BAA+B,GAIxC,CAAC,CAAC,MAAM,CAAC;IACX,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,iBAAiB,EAAE,eAAe;QAClC,mBAAmB,EAAE,iBAAiB;QACtC,eAAe,EAAE,aAAa;KAC/B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,yBAAyB,CACvC,UAAkB;IAElB,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,+BAA+B,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC3D,+CAA+C,CAChD,CAAC;AACJ,CAAC"}
@@ -2,19 +2,19 @@ import * as z from "zod/v3";
2
2
  import { Result as SafeParseResult } from "../../types/fp.js";
3
3
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
4
4
  /**
5
- * The DEX swap leg detected inside a loop transaction.
5
+ * The swap leg detected inside a loop or unwind transaction.
6
6
  *
7
7
  * @remarks
8
8
  *
9
- * Evidence is token-filtered and executor-proof: the sold (debt) token left the
10
- * account to a non-protocol counterparty and the bought (collateral) token
11
- * arrived from a non-protocol counterparty. Aggregator fills often settle from an
12
- * executor contract, so the router is recorded only when it happens to be the
13
- * outbound counterparty — it is never required for detection.
9
+ * Evidence is token-filtered and executor-proof: the sold token left the
10
+ * account to a non-protocol counterparty and the bought token arrived from a
11
+ * non-protocol counterparty. Aggregator fills often settle from an executor
12
+ * contract, so the router is recorded only when it happens to be the outbound
13
+ * counterparty — it is never required for detection.
14
14
  */
15
15
  export type SwapInfo = {
16
16
  /**
17
- * Token sold in the swap (the borrowed/debt token).
17
+ * The token leaving the account: the debt token on a loop, the collateral token on an unwind.
18
18
  */
19
19
  soldToken: string;
20
20
  /**
@@ -26,7 +26,7 @@ export type SwapInfo = {
26
26
  */
27
27
  soldAmount: string;
28
28
  /**
29
- * Token bought in the swap (the collateral token).
29
+ * The token arriving in the account: the collateral token on a loop, the debt token on an unwind.
30
30
  */
31
31
  boughtToken: string;
32
32
  /**
@@ -0,0 +1,15 @@
1
+ # FlowBasis
2
+
3
+ ## Example Usage
4
+
5
+ ```typescript
6
+ import { FlowBasis } from "@compass-labs/api-sdk/models/components";
7
+
8
+ let value: FlowBasis = "oracle";
9
+ ```
10
+
11
+ ## Values
12
+
13
+ ```typescript
14
+ "swap" | "oracle"
15
+ ```
@@ -46,4 +46,5 @@ let value: LoopedPosition = {
46
46
  | `closedAt` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | :heavy_minus_sign: | Timestamp the position was fully closed; null while open. | |
47
47
  | `current` | [components.LoopedPositionCurrentState](../../models/components/loopedpositioncurrentstate.md) | :heavy_minus_sign: | Live on-chain state; null for CLOSED positions. | |
48
48
  | `totals` | [components.LoopedPositionTotals](../../models/components/loopedpositiontotals.md) | :heavy_check_mark: | Lifetime totals across all of a looped position's transactions. | |
49
+ | `pnl` | [components.LoopedPositionPnl](../../models/components/loopedpositionpnl.md) | :heavy_minus_sign: | Profit or loss since the position opened, for OPEN and CLOSED positions alike. Null when it cannot be stated honestly: the position's recorded history is incomplete (it starts after the opening, or does not add up to what the position holds now), a transaction could not be priced, the position's current value could not be read or separated from another position's, or a transaction's legs cannot be told apart from another position's. | |
49
50
  | `history` | [components.LoopedPositionHistoryEntry](../../models/components/loopedpositionhistoryentry.md)[] | :heavy_minus_sign: | All transactions for this position, chronological. | [] |
@@ -20,14 +20,16 @@ let value: LoopedPositionHistoryEntry = {
20
20
 
21
21
  ## Fields
22
22
 
23
- | Field | Type | Required | Description | Example |
24
- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
- | `transactionHash` | *string* | :heavy_check_mark: | Transaction hash. | |
26
- | `blockNumber` | *number* | :heavy_check_mark: | Block number of the transaction. | |
27
- | `blockTimestamp` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | :heavy_check_mark: | Timestamp of the transaction. | |
28
- | `classification` | [components.Classification](../../models/components/classification.md) | :heavy_check_mark: | What this transaction did to the position: loop_open / loop_increase (lever up with a swap), unwind (delever), single-sided supply/withdraw/borrow/repay, liquidation, or mixed. | |
29
- | `iterations` | *number* | :heavy_minus_sign: | Loop transactions only: number of borrow legs in this transaction (one per loop iteration). Null for non-loop transactions. | |
30
- | `collateralDelta` | *string* | :heavy_check_mark: | Signed change in collateral in this transaction (positive = added). | |
31
- | `debtDelta` | *string* | :heavy_check_mark: | Signed change in debt in this transaction (positive = borrowed). | |
32
- | `swap` | [components.SwapInfo](../../models/components/swapinfo.md) | :heavy_minus_sign: | The swap leg detected in this transaction, if any. | |
33
- | `events` | [components.CreditEvent](../../models/components/creditevent.md)[] | :heavy_minus_sign: | The raw lending events that make up this transaction (Morpho supply_collateral maps to 'supply', withdraw_collateral to 'withdraw'). | [] |
23
+ | Field | Type | Required | Description | Example |
24
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
25
+ | `transactionHash` | *string* | :heavy_check_mark: | Transaction hash. | |
26
+ | `blockNumber` | *number* | :heavy_check_mark: | Block number of the transaction. | |
27
+ | `blockTimestamp` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | :heavy_check_mark: | Timestamp of the transaction. | |
28
+ | `classification` | [components.Classification](../../models/components/classification.md) | :heavy_check_mark: | What this transaction did to the position: loop_open / loop_increase (lever up with a swap), unwind (delever), single-sided supply/withdraw/borrow/repay, liquidation, or mixed. | |
29
+ | `iterations` | *number* | :heavy_minus_sign: | Loop transactions only: number of borrow legs in this transaction (one per loop iteration). Null for non-loop transactions. | |
30
+ | `collateralDelta` | *string* | :heavy_check_mark: | Signed change in collateral in this transaction (positive = added). | |
31
+ | `debtDelta` | *string* | :heavy_check_mark: | Signed change in debt in this transaction (positive = borrowed). | |
32
+ | `swap` | [components.SwapInfo](../../models/components/swapinfo.md) | :heavy_minus_sign: | The swap leg of a loop (debt sold for collateral) or an unwind (collateral sold for debt), when the transaction shows one. | |
33
+ | `events` | [components.CreditEvent](../../models/components/creditevent.md)[] | :heavy_minus_sign: | The raw lending events that make up this transaction (Morpho supply_collateral maps to 'supply', withdraw_collateral to 'withdraw'). | [] |
34
+ | `equityFlowQuote` | *string* | :heavy_minus_sign: | Equity this transaction put into the position (positive) or took out of it (negative), in the debt token, valued when it landed. 0 for a liquidation, whose loss stays in the position's equity. Null when the transaction could not be valued. | |
35
+ | `flowBasis` | [components.FlowBasis](../../models/components/flowbasis.md) | :heavy_minus_sign: | How equity_flow_quote was measured. 'swap': from this transaction's own swap, so the swap's cost shows up in PnL. 'oracle': from the net amounts at the market price; on a loop or unwind that folds the swap's cost into the flow instead. Null for a liquidation and for a transaction that could not be valued. | |
@@ -0,0 +1,27 @@
1
+ # LoopedPositionPnl
2
+
3
+ What a looped position has made or lost since it opened.
4
+
5
+ Measured in the position's debt token (the quote), with USD alongside.
6
+ Every transaction is an equity flow valued when it landed: a loop's
7
+ principal goes in, an unwind's proceeds come out. PnL is what the position
8
+ is worth now plus everything taken out, minus everything put in; each
9
+ history entry carries its own flow in equity_flow_quote.
10
+
11
+ ## Example Usage
12
+
13
+ ```typescript
14
+ import { LoopedPositionPnl } from "@compass-labs/api-sdk/models/components";
15
+
16
+ let value: LoopedPositionPnl = {
17
+ totalPnlQuote: "<value>",
18
+ };
19
+ ```
20
+
21
+ ## Fields
22
+
23
+ | Field | Type | Required | Description |
24
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `totalPnlQuote` | *string* | :heavy_check_mark: | Profit or loss since the position opened, in the position's debt token: what the position is worth now, plus everything taken out, minus everything put in, each valued when it happened. It includes the entry and exit swap costs, the carry (what the collateral earned minus the interest paid) and the collateral's price move against the debt token. Realized once the position is closed, unrealized while it is open. Where a loop or unwind's own swap could not be used (its history entry has flow_basis 'oracle'), that swap's cost is not counted and the figure reads higher by roughly that amount.<br/><br/>Measured in the debt token, not USD: on a correlated loop (wstHYPE against WHYPE, wstETH against WETH) a positive figure here can still be a USD loss when the debt token itself falls. total_pnl_usd carries that. |
26
+ | `totalPnlPercent` | *string* | :heavy_minus_sign: | total_pnl_quote as a percentage of the equity put in (e.g. 4.2 = 4.2%): the return on the capital contributed, not annualized. |
27
+ | `totalPnlUsd` | *string* | :heavy_minus_sign: | Profit or loss since the position opened, in USD: each flow at the debt token's USD price when it happened, the position's current value at its price now. Unlike total_pnl_quote it includes the debt token's own USD move. Null when any of those prices is unavailable. |
@@ -1,12 +1,12 @@
1
1
  # SwapInfo
2
2
 
3
- The DEX swap leg detected inside a loop transaction.
3
+ The swap leg detected inside a loop or unwind transaction.
4
4
 
5
- Evidence is token-filtered and executor-proof: the sold (debt) token left the
6
- account to a non-protocol counterparty and the bought (collateral) token
7
- arrived from a non-protocol counterparty. Aggregator fills often settle from an
8
- executor contract, so the router is recorded only when it happens to be the
9
- outbound counterparty — it is never required for detection.
5
+ Evidence is token-filtered and executor-proof: the sold token left the
6
+ account to a non-protocol counterparty and the bought token arrived from a
7
+ non-protocol counterparty. Aggregator fills often settle from an executor
8
+ contract, so the router is recorded only when it happens to be the outbound
9
+ counterparty — it is never required for detection.
10
10
 
11
11
  ## Example Usage
12
12
 
@@ -27,10 +27,10 @@ let value: SwapInfo = {
27
27
 
28
28
  | Field | Type | Required | Description |
29
29
  | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
- | `soldToken` | *string* | :heavy_check_mark: | Token sold in the swap (the borrowed/debt token). |
30
+ | `soldToken` | *string* | :heavy_check_mark: | The token leaving the account: the debt token on a loop, the collateral token on an unwind. |
31
31
  | `soldSymbol` | *string* | :heavy_check_mark: | Symbol of the sold token. |
32
32
  | `soldAmount` | *string* | :heavy_check_mark: | Amount of the sold token. |
33
- | `boughtToken` | *string* | :heavy_check_mark: | Token bought in the swap (the collateral token). |
33
+ | `boughtToken` | *string* | :heavy_check_mark: | The token arriving in the account: the collateral token on a loop, the debt token on an unwind. |
34
34
  | `boughtSymbol` | *string* | :heavy_check_mark: | Symbol of the bought token. |
35
35
  | `boughtAmount` | *string* | :heavy_check_mark: | Amount of the bought token. |
36
36
  | `router` | *string* | :heavy_minus_sign: | The outbound counterparty when it is the swap router itself. Null when the swap settled from an executor contract (informational only — never required to detect the swap). |