Gmx v2 - Funding rates (#6)

* Setup GMX v2

* Add get markets

* Map token with service

* Add get market info data

* Add get markets

* Add get market token prices

* Get markets infos multicall

* Try call datastore

* Add some tests to figure out why datastore call dont work

* Update funding rates

* clean
This commit is contained in:
Oda
2024-08-17 06:50:18 +07:00
committed by GitHub
parent b4087753c7
commit 68aa7fff5d
75 changed files with 8979 additions and 608 deletions

View File

@@ -0,0 +1,17 @@
using System.Numerics;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxMarket
{
public string MarketToken { get; set; }
public string IndexToken { get; set; }
public string LongToken { get; set; }
public string ShortToken { get; set; }
public string Name { get; set; }
public string Symbol { get; set; }
public bool IsSpotOnly { get; set; }
public bool IsSameCollaterals { get; set; }
public BigInteger FundingFactorPerSecond { get; set; }
public bool LongsPayShorts { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxMarketInfo
{
public GmxMarket Market { get; set; }
public GmxMarketTokenPrice MarketTokenPriceMax { get; set; }
public GmxMarketTokenPrice MarketTokenPriceMin { get; set; }
public GmxMarketInfos Infos { get; set; }
}

View File

@@ -0,0 +1,110 @@
using System.Numerics;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxMarketInfos
{
public bool IsDisabled { get; set; }
public GmxTokenData LongToken { get; set; }
public GmxTokenData ShortToken { get; set; }
public GmxTokenData IndexToken { get; set; }
public BigInteger LongPoolAmount { get; set; }
public BigInteger ShortPoolAmount { get; set; }
public BigInteger MaxLongPoolAmount { get; set; }
public BigInteger MaxShortPoolAmount { get; set; }
public BigInteger MaxLongPoolUsdForDeposit { get; set; }
public BigInteger MaxShortPoolUsdForDeposit { get; set; }
public BigInteger LongPoolAmountAdjustment { get; set; }
public BigInteger ShortPoolAmountAdjustment { get; set; }
public BigInteger PoolValueMax { get; set; }
public BigInteger PoolValueMin { get; set; }
public BigInteger ReserveFactorLong { get; set; }
public BigInteger ReserveFactorShort { get; set; }
public BigInteger OpenInterestReserveFactorLong { get; set; }
public BigInteger OpenInterestReserveFactorShort { get; set; }
public BigInteger MaxOpenInterestLong { get; set; }
public BigInteger MaxOpenInterestShort { get; set; }
public BigInteger BorrowingFactorLong { get; set; }
public BigInteger BorrowingFactorShort { get; set; }
public BigInteger BorrowingExponentFactorLong { get; set; }
public BigInteger BorrowingExponentFactorShort { get; set; }
public BigInteger FundingFactor { get; set; }
public BigInteger FundingExponentFactor { get; set; }
public BigInteger FundingIncreaseFactorPerSecond { get; set; }
public BigInteger FundingDecreaseFactorPerSecond { get; set; }
public BigInteger ThresholdForStableFunding { get; set; }
public BigInteger ThresholdForDecreaseFunding { get; set; }
public BigInteger MinFundingFactorPerSecond { get; set; }
public BigInteger MaxFundingFactorPerSecond { get; set; }
public BigInteger TotalBorrowingFees { get; set; }
public BigInteger PositionImpactPoolAmount { get; set; }
public BigInteger MinPositionImpactPoolAmount { get; set; }
public BigInteger PositionImpactPoolDistributionRate { get; set; }
public BigInteger MinCollateralFactor { get; set; }
public BigInteger MinCollateralFactorForOpenInterestLong { get; set; }
public BigInteger MinCollateralFactorForOpenInterestShort { get; set; }
public BigInteger SwapImpactPoolAmountLong { get; set; }
public BigInteger SwapImpactPoolAmountShort { get; set; }
public BigInteger MaxPnlFactorForTradersLong { get; set; }
public BigInteger MaxPnlFactorForTradersShort { get; set; }
public BigInteger PnlLongMin { get; set; }
public BigInteger PnlLongMax { get; set; }
public BigInteger PnlShortMin { get; set; }
public BigInteger PnlShortMax { get; set; }
public BigInteger NetPnlMin { get; set; }
public BigInteger NetPnlMax { get; set; }
public BigInteger? ClaimableFundingAmountLong { get; set; }
public BigInteger? ClaimableFundingAmountShort { get; set; }
public BigInteger LongInterestUsd { get; set; }
public BigInteger ShortInterestUsd { get; set; }
public BigInteger LongInterestInTokens { get; set; }
public BigInteger ShortInterestInTokens { get; set; }
public BigInteger PositionFeeFactorForPositiveImpact { get; set; }
public BigInteger PositionFeeFactorForNegativeImpact { get; set; }
public BigInteger PositionImpactFactorPositive { get; set; }
public BigInteger PositionImpactFactorNegative { get; set; }
public BigInteger MaxPositionImpactFactorPositive { get; set; }
public BigInteger MaxPositionImpactFactorNegative { get; set; }
public BigInteger MaxPositionImpactFactorForLiquidations { get; set; }
public BigInteger PositionImpactExponentFactor { get; set; }
public BigInteger SwapFeeFactorForPositiveImpact { get; set; }
public BigInteger SwapFeeFactorForNegativeImpact { get; set; }
public BigInteger SwapImpactFactorPositive { get; set; }
public BigInteger SwapImpactFactorNegative { get; set; }
public BigInteger SwapImpactExponentFactor { get; set; }
public BigInteger BorrowingFactorPerSecondForLongs { get; set; }
public BigInteger BorrowingFactorPerSecondForShorts { get; set; }
public BigInteger FundingFactorPerSecond { get; set; }
public bool LongsPayShorts { get; set; }
public BigInteger VirtualPoolAmountForLongToken { get; set; }
public BigInteger VirtualPoolAmountForShortToken { get; set; }
public BigInteger VirtualInventoryForPositions { get; set; }
public string VirtualMarketId { get; set; }
public string VirtualLongTokenId { get; set; }
public string VirtualShortTokenId { get; set; }
}

View File

@@ -0,0 +1,18 @@
using System.Numerics;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxMarketTokenPrice
{
public BigInteger PoolValue { get; set; }
public BigInteger LongPnl { get; set; }
public BigInteger ShortPnl { get; set; }
public BigInteger NetPnl { get; set; }
public BigInteger LongTokenAmount { get; set; }
public BigInteger ShortTokenAmount { get; set; }
public BigInteger LongTokenUsd { get; set; }
public BigInteger ShortTokenUsd { get; set; }
public BigInteger TotalBorrowingFees { get; set; }
public BigInteger BorrowingFeePoolFactor { get; set; }
public BigInteger ImpactPoolAmount { get; set; }
}

View File

@@ -0,0 +1,45 @@
using Newtonsoft.Json;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxStoreKeys
{
[JsonProperty("longPoolAmount", NullValueHandling = NullValueHandling.Ignore)]
public string LongPoolAmount { get; set; }
[JsonProperty("shortPoolAmount", NullValueHandling = NullValueHandling.Ignore)]
public string ShortPoolAmount { get; set; }
[JsonProperty("positionImpactPoolAmount", NullValueHandling = NullValueHandling.Ignore)]
public string PositionImpactPoolAmount { get; set; }
[JsonProperty("swapImpactPoolAmountLong", NullValueHandling = NullValueHandling.Ignore)]
public string SwapImpactPoolAmountLong { get; set; }
[JsonProperty("swapImpactPoolAmountShort", NullValueHandling = NullValueHandling.Ignore)]
public string SwapImpactPoolAmountShort { get; set; }
[JsonProperty("longInterestUsingLongToken", NullValueHandling = NullValueHandling.Ignore)]
public string LongInterestUsingLongToken { get; set; }
[JsonProperty("longInterestUsingShortToken", NullValueHandling = NullValueHandling.Ignore)]
public string LongInterestUsingShortToken { get; set; }
[JsonProperty("shortInterestUsingLongToken", NullValueHandling = NullValueHandling.Ignore)]
public string ShortInterestUsingLongToken { get; set; }
[JsonProperty("shortInterestUsingShortToken", NullValueHandling = NullValueHandling.Ignore)]
public string ShortInterestUsingShortToken { get; set; }
[JsonProperty("longInterestInTokensUsingLongToken", NullValueHandling = NullValueHandling.Ignore)]
public string LongInterestInTokensUsingLongToken { get; set; }
[JsonProperty("longInterestInTokensUsingShortToken", NullValueHandling = NullValueHandling.Ignore)]
public string LongInterestInTokensUsingShortToken { get; set; }
[JsonProperty("shortInterestInTokensUsingLongToken", NullValueHandling = NullValueHandling.Ignore)]
public string ShortInterestInTokensUsingLongToken { get; set; }
[JsonProperty("shortInterestInTokensUsingShortToken", NullValueHandling = NullValueHandling.Ignore)]
public string ShortInterestInTokensUsingShortToken { get; set; }
}

View File

@@ -0,0 +1,8 @@
using System.Numerics;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxTokenBalances
{
public Dictionary<string, BigInteger> Balances { get; set; }
}

View File

@@ -0,0 +1,10 @@
using System.Numerics;
using Managing.ABI.GmxV2.Reader.ContractDefinition;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxTokenData : GmxToken
{
public MarketPrice Price { get; set; }
public BigInteger? Balance { get; set; }
}

View File

@@ -0,0 +1,11 @@
using System.Numerics;
using Managing.ABI.GmxV2.Reader.ContractDefinition;
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class GmxTokenPriceData
{
public MarketPrice Price { get; set; }
public BigInteger? Balance { get; set; }
public BigInteger? TotalSupply { get; set; }
}

View File

@@ -0,0 +1,20 @@
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
public class MarketStats
{
public string Market { get; set; }
public decimal PoolValue { get; set; }
public decimal PoolBalance { get; set; }
public decimal PoolCapLong { get; set; }
public decimal PoolCapShort { get; set; }
public decimal PnL { get; set; }
public decimal BorrowingFees { get; set; }
public decimal FundingApr { get; set; }
public decimal OpenInterest { get; set; }
public decimal LiquidityLong { get; set; }
public decimal LiquidityShort { get; set; }
public decimal Vipositions { get; set; }
public decimal Viswaps { get; set; }
public decimal PositionImpactPool { get; set; }
public string Config { get; set; }
}