diff --git a/chainflip-insights/Feeders/Swap/SwapFeeder.cs b/chainflip-insights/Feeders/Swap/SwapFeeder.cs index 814c268..d41ec83 100644 --- a/chainflip-insights/Feeders/Swap/SwapFeeder.cs +++ b/chainflip-insights/Feeders/Swap/SwapFeeder.cs @@ -68,6 +68,9 @@ public class SwapFeeder : IFeeder } swapChannelByDepositChannelId { + blockByIssuedBlockId { + timestamp + } swapChannelBeneficiariesByDepositChannelId { nodes { brokerCommissionRateBps diff --git a/chainflip-insights/Feeders/Swap/SwapInfo.cs b/chainflip-insights/Feeders/Swap/SwapInfo.cs index 3e827d3..0467fd8 100644 --- a/chainflip-insights/Feeders/Swap/SwapInfo.cs +++ b/chainflip-insights/Feeders/Swap/SwapInfo.cs @@ -90,6 +90,7 @@ public string ProtocolDeltaUsdPercentageFormatted public double? BurnUsd { get; } + public DateTimeOffset DepositChannelIssuedTimestamp { get; } public DateTimeOffset? PreDepositTimestamp { get; } public DateTimeOffset DepositTimestamp { get; } public DateTimeOffset EgressTimestamp { get; } @@ -118,8 +119,14 @@ public TimeSpan SwapDuration { get { + var estimatedStart = PreDepositTimestamp.HasValue + ? DepositChannelIssuedTimestamp > PreDepositTimestamp.Value + ? DepositChannelIssuedTimestamp + : PreDepositTimestamp.Value + : DepositChannelIssuedTimestamp; + var offset = PreDepositTimestamp.HasValue - ? DepositTimestamp.Subtract(PreDepositTimestamp.Value) / 2 + ? DepositTimestamp.Subtract(estimatedStart) / 2 : new TimeSpan(0); return EgressTimestamp - DepositTimestamp + offset; @@ -185,7 +192,8 @@ public SwapInfo( .Sum(x => x.Data.FeeValueUsd ?? 0) + LiquidityFeesUsd; Broker = GetBroker(swap); - + + DepositChannelIssuedTimestamp = DateTimeOffset.Parse(swap.SwapChannel.Block.StateChainTimestamp); PreDepositTimestamp = string.IsNullOrWhiteSpace(swap.PreDeposit?.StateChainTimestamp) ? null : DateTimeOffset.Parse(swap.PreDeposit.StateChainTimestamp); diff --git a/chainflip-insights/Feeders/Swap/SwapsResponse.cs b/chainflip-insights/Feeders/Swap/SwapsResponse.cs index f469c9a..52eb3ab 100644 --- a/chainflip-insights/Feeders/Swap/SwapsResponse.cs +++ b/chainflip-insights/Feeders/Swap/SwapsResponse.cs @@ -140,13 +140,16 @@ public class BlockTime public class SwapChannelByDepositChannelId { + [JsonPropertyName("blockByIssuedBlockId")] + public Block Block { get; set; } + [JsonPropertyName("brokerByBrokerId")] public BrokerByBrokerId Broker { get; set; } [JsonPropertyName("swapChannelBeneficiariesByDepositChannelId")] public BeneficiariesByDepositChannelId Beneficiaries { get; set; } } - + public class BeneficiariesByDepositChannelId { [JsonPropertyName("nodes")]