@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / netInternalTransfers

Function: netInternalTransfers()

netInternalTransfers(events, chainIds): PortfolioFundingEvent[]

Defined in: packages/sdk/src/unified/portfolioAnalytics.ts:137

Remove the bridge legs that move capital between an exchange's OWN chains from a funding list. A transfer from one configured chain to another leaves the account's capital where it was, so counting its origin leg as a withdrawal and its destination leg as a deposit distorts the capital base on both sides.

Details

  • Two legs with the same transferId, opposite direction, and both chainIds in chainIds are one internal transfer: both are dropped.
  • An out leg whose counterpartyChainId is in chainIds but whose in leg is absent (still in flight, or outside the window) is dropped alone: the capital is in transit and stays in the base.
  • An in leg whose counterpartyChainId is in chainIds but whose out leg is absent is dropped for the same reason — the capital was already in the base on the origin chain.
  • Every other event, including a leg to or from a chain outside chainIds, is an external movement and passes through unchanged.

Pure: returns a new array, in the input order.

Parameters

events

readonly PortfolioFundingEvent[]

chainIds

readonly number[]

Returns

PortfolioFundingEvent[]