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:
@@ -1,5 +1,7 @@
|
||||
# How to launch the App
|
||||
|
||||
## Requirements
|
||||
|
||||
- NET .Core framework
|
||||
- MongoDb
|
||||
- Node.JS
|
||||
@@ -8,18 +10,20 @@
|
||||
|
||||
# First setup
|
||||
|
||||
|
||||
## Generate dev certificate
|
||||
|
||||
- ```dotnet dev-certs https -ep \.aspnet\https\aspnetapp.pfx -p password```
|
||||
- ```dotnet dev-certs https --trust```
|
||||
|
||||
## Setup docker
|
||||
|
||||
- Update ```apps\src\Managing.Api\appsettings.MYNAME.json``` with your configuration settings
|
||||
- Update ```apps\src\Managing.Api.Workers\appsettings.MYNAME.json``` with your configuration settings
|
||||
- Then execute from the root of the project : ```.\scripts\docker-deploy-sandbox.cmd```
|
||||
- At this point, only Managing.Api.Workers should be NOT running. It because we didn't create an account.
|
||||
|
||||
## Setup an account
|
||||
|
||||
- ```cd src/Managing.WebApp```
|
||||
- ```npm run dev```
|
||||
|
||||
@@ -30,6 +34,7 @@
|
||||
- On Account page : Create an EVM account for trading (Not necessary if you don't want to trade)
|
||||
|
||||
## Setup InfluxDb
|
||||
|
||||
- Go to http://localhost:8086/
|
||||
- Then initialize InfluxDb
|
||||
|
||||
@@ -38,9 +43,11 @@
|
||||
- Go to api keys
|
||||
|
||||

|
||||
|
||||
- Create an apikey and update the ```apps\src\Managing.Api.Workers\appsettings.MYNAME.json``` file with the api key
|
||||
|
||||

|
||||
|
||||
- Then redeploy by executing : ```.\scripts\docker-deploy-sandbox.cmd```
|
||||
- Check influxdb > buckets > prices-bucket > if there is data
|
||||
|
||||
@@ -50,12 +57,17 @@
|
||||
- It may take some time to see the candles in the front-end
|
||||
|
||||
## Setup default strategies, scenario and money management
|
||||
|
||||
- Go to Managing.Api swagger ```https://localhost/index.html```
|
||||
- Execute ```POST /settings```
|
||||

|
||||

|
||||
|
||||
# Dev
|
||||
|
||||
## Generate Api Client
|
||||
|
||||
- Use [NSwag](https://github.com/RicoSuter/NSwag)
|
||||
- Generate a Typescript client with Fetch template
|
||||
- Deposit the file in ```Managing.WebApp\src\generated\```
|
||||
- Generatet ABI
|
||||
service ```Nethereum.Generator.Console generate from-abi -abi ./DataStore/DataStore.abi -o . -ns Managing.Tools```
|
||||
@@ -21,6 +21,7 @@ It contains bot management, backtesting, scenario management and money managemen
|
||||
- [x] Adaptive trading
|
||||
- [x] Account management
|
||||
- [x] Workers (prices, backtests, volumes)
|
||||
- [x] Bot backup
|
||||
|
||||
## v2 - The custody back
|
||||
|
||||
@@ -39,6 +40,7 @@ It contains bot management, backtesting, scenario management and money managemen
|
||||
- [ ] Address tracking
|
||||
- [ ] Trading desk
|
||||
- [ ] Metrics (backtests, portofolio)
|
||||
- [ ] Account Abstraction Layer
|
||||
- [ ] Enhance performances
|
||||
- [ ] Dockerize everything
|
||||
|
||||
|
||||
1
src/Managing.ABI.GmxV2/Contracts/DataStore.abi
Normal file
1
src/Managing.ABI.GmxV2/Contracts/DataStore.abi
Normal file
File diff suppressed because one or more lines are too long
1
src/Managing.ABI.GmxV2/Contracts/DataStore.bin
Normal file
1
src/Managing.ABI.GmxV2/Contracts/DataStore.bin
Normal file
File diff suppressed because one or more lines are too long
1
src/Managing.ABI.GmxV2/Contracts/Multicall3.abi
Normal file
1
src/Managing.ABI.GmxV2/Contracts/Multicall3.abi
Normal file
File diff suppressed because one or more lines are too long
1
src/Managing.ABI.GmxV2/Contracts/Multicall3.bin
Normal file
1
src/Managing.ABI.GmxV2/Contracts/Multicall3.bin
Normal file
File diff suppressed because one or more lines are too long
1
src/Managing.ABI.GmxV2/Contracts/Reader.abi
Normal file
1
src/Managing.ABI.GmxV2/Contracts/Reader.abi
Normal file
File diff suppressed because one or more lines are too long
1
src/Managing.ABI.GmxV2/Contracts/Reader.bin
Normal file
1
src/Managing.ABI.GmxV2/Contracts/Reader.bin
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1655
src/Managing.ABI.GmxV2/DataStore/DataStoreService.cs
Normal file
1655
src/Managing.ABI.GmxV2/DataStore/DataStoreService.cs
Normal file
File diff suppressed because it is too large
Load Diff
15
src/Managing.ABI.GmxV2/Managing.ABI.GmxV2.csproj
Normal file
15
src/Managing.ABI.GmxV2/Managing.ABI.GmxV2.csproj
Normal file
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nethereum.Contracts" Version="4.21.3"/>
|
||||
<PackageReference Include="Nethereum.Web3" Version="4.21.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
14
src/Managing.ABI.GmxV2/Multicall3/ContractDefinition/Call.cs
Normal file
14
src/Managing.ABI.GmxV2/Multicall3/ContractDefinition/Call.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Multicall3.ContractDefinition
|
||||
{
|
||||
public partial class Call : CallBase
|
||||
{
|
||||
}
|
||||
|
||||
public class CallBase
|
||||
{
|
||||
[Parameter("address", "target", 1)] public virtual string Target { get; set; }
|
||||
[Parameter("bytes", "callData", 2)] public virtual byte[] CallData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Multicall3.ContractDefinition
|
||||
{
|
||||
public partial class Call3 : Call3Base
|
||||
{
|
||||
}
|
||||
|
||||
public class Call3Base
|
||||
{
|
||||
[Parameter("address", "target", 1)] public virtual string Target { get; set; }
|
||||
[Parameter("bool", "allowFailure", 2)] public virtual bool AllowFailure { get; set; }
|
||||
[Parameter("bytes", "callData", 3)] public virtual byte[] CallData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Multicall3.ContractDefinition
|
||||
{
|
||||
public partial class Call3Value : Call3ValueBase
|
||||
{
|
||||
}
|
||||
|
||||
public class Call3ValueBase
|
||||
{
|
||||
[Parameter("address", "target", 1)] public virtual string Target { get; set; }
|
||||
[Parameter("bool", "allowFailure", 2)] public virtual bool AllowFailure { get; set; }
|
||||
[Parameter("uint256", "value", 3)] public virtual BigInteger Value { get; set; }
|
||||
[Parameter("bytes", "callData", 4)] public virtual byte[] CallData { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,14 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Multicall3.ContractDefinition
|
||||
{
|
||||
public partial class Result : ResultBase
|
||||
{
|
||||
}
|
||||
|
||||
public class ResultBase
|
||||
{
|
||||
[Parameter("bool", "success", 1)] public virtual bool Success { get; set; }
|
||||
[Parameter("bytes", "returnData", 2)] public virtual byte[] ReturnData { get; set; }
|
||||
}
|
||||
}
|
||||
362
src/Managing.ABI.GmxV2/Multicall3/Multicall3Service.cs
Normal file
362
src/Managing.ABI.GmxV2/Multicall3/Multicall3Service.cs
Normal file
@@ -0,0 +1,362 @@
|
||||
using System.Numerics;
|
||||
using Managing.ABI.GmxV2.Multicall3.ContractDefinition;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Multicall3
|
||||
{
|
||||
public partial class Multicall3Service : ContractWeb3ServiceBase
|
||||
{
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.IWeb3 web3,
|
||||
Multicall3Deployment multicall3Deployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<Multicall3Deployment>()
|
||||
.SendRequestAndWaitForReceiptAsync(multicall3Deployment, cancellationTokenSource);
|
||||
}
|
||||
|
||||
public static Task<string> DeployContractAsync(Nethereum.Web3.IWeb3 web3,
|
||||
Multicall3Deployment multicall3Deployment)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<Multicall3Deployment>().SendRequestAsync(multicall3Deployment);
|
||||
}
|
||||
|
||||
public static async Task<Multicall3Service> DeployContractAndGetServiceAsync(Nethereum.Web3.IWeb3 web3,
|
||||
Multicall3Deployment multicall3Deployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
var receipt =
|
||||
await DeployContractAndWaitForReceiptAsync(web3, multicall3Deployment, cancellationTokenSource);
|
||||
return new Multicall3Service(web3, receipt.ContractAddress);
|
||||
}
|
||||
|
||||
public Multicall3Service(Nethereum.Web3.IWeb3 web3, string contractAddress) : base(web3, contractAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public Task<string> AggregateRequestAsync(AggregateFunction aggregateFunction)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(aggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> AggregateRequestAndWaitForReceiptAsync(AggregateFunction aggregateFunction,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> AggregateRequestAsync(List<Call> calls)
|
||||
{
|
||||
var aggregateFunction = new AggregateFunction();
|
||||
aggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(aggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> AggregateRequestAndWaitForReceiptAsync(List<Call> calls,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var aggregateFunction = new AggregateFunction();
|
||||
aggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> Aggregate3RequestAsync(Aggregate3Function aggregate3Function)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(aggregate3Function);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> Aggregate3RequestAndWaitForReceiptAsync(Aggregate3Function aggregate3Function,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregate3Function, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> Aggregate3RequestAsync(List<Call3> calls)
|
||||
{
|
||||
var aggregate3Function = new Aggregate3Function();
|
||||
aggregate3Function.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(aggregate3Function);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> Aggregate3RequestAndWaitForReceiptAsync(List<Call3> calls,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var aggregate3Function = new Aggregate3Function();
|
||||
aggregate3Function.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregate3Function, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> Aggregate3ValueRequestAsync(Aggregate3ValueFunction aggregate3ValueFunction)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(aggregate3ValueFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> Aggregate3ValueRequestAndWaitForReceiptAsync(
|
||||
Aggregate3ValueFunction aggregate3ValueFunction, CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregate3ValueFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> Aggregate3ValueRequestAsync(List<Call3Value> calls)
|
||||
{
|
||||
var aggregate3ValueFunction = new Aggregate3ValueFunction();
|
||||
aggregate3ValueFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(aggregate3ValueFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> Aggregate3ValueRequestAndWaitForReceiptAsync(List<Call3Value> calls,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var aggregate3ValueFunction = new Aggregate3ValueFunction();
|
||||
aggregate3ValueFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(aggregate3ValueFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> BlockAndAggregateRequestAsync(BlockAndAggregateFunction blockAndAggregateFunction)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(blockAndAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> BlockAndAggregateRequestAndWaitForReceiptAsync(
|
||||
BlockAndAggregateFunction blockAndAggregateFunction, CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(blockAndAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> BlockAndAggregateRequestAsync(List<Call> calls)
|
||||
{
|
||||
var blockAndAggregateFunction = new BlockAndAggregateFunction();
|
||||
blockAndAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(blockAndAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> BlockAndAggregateRequestAndWaitForReceiptAsync(List<Call> calls,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var blockAndAggregateFunction = new BlockAndAggregateFunction();
|
||||
blockAndAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(blockAndAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetBasefeeQueryAsync(GetBasefeeFunction getBasefeeFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetBasefeeFunction, BigInteger>(getBasefeeFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetBasefeeQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetBasefeeFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<byte[]> GetBlockHashQueryAsync(GetBlockHashFunction getBlockHashFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetBlockHashFunction, byte[]>(getBlockHashFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<byte[]> GetBlockHashQueryAsync(BigInteger blockNumber, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getBlockHashFunction = new GetBlockHashFunction();
|
||||
getBlockHashFunction.BlockNumber = blockNumber;
|
||||
|
||||
return ContractHandler.QueryAsync<GetBlockHashFunction, byte[]>(getBlockHashFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetBlockNumberQueryAsync(GetBlockNumberFunction getBlockNumberFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetBlockNumberFunction, BigInteger>(getBlockNumberFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetBlockNumberQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetBlockNumberFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetChainIdQueryAsync(GetChainIdFunction getChainIdFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetChainIdFunction, BigInteger>(getChainIdFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetChainIdQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetChainIdFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<string> GetCurrentBlockCoinbaseQueryAsync(
|
||||
GetCurrentBlockCoinbaseFunction getCurrentBlockCoinbaseFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockCoinbaseFunction, string>(getCurrentBlockCoinbaseFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<string> GetCurrentBlockCoinbaseQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockCoinbaseFunction, string>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockGasLimitQueryAsync(
|
||||
GetCurrentBlockGasLimitFunction getCurrentBlockGasLimitFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockGasLimitFunction, BigInteger>(
|
||||
getCurrentBlockGasLimitFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockGasLimitQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockGasLimitFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockTimestampQueryAsync(
|
||||
GetCurrentBlockTimestampFunction getCurrentBlockTimestampFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockTimestampFunction, BigInteger>(
|
||||
getCurrentBlockTimestampFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockTimestampQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockTimestampFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetEthBalanceQueryAsync(GetEthBalanceFunction getEthBalanceFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetEthBalanceFunction, BigInteger>(getEthBalanceFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetEthBalanceQueryAsync(string addr, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getEthBalanceFunction = new GetEthBalanceFunction();
|
||||
getEthBalanceFunction.Addr = addr;
|
||||
|
||||
return ContractHandler.QueryAsync<GetEthBalanceFunction, BigInteger>(getEthBalanceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<byte[]> GetLastBlockHashQueryAsync(GetLastBlockHashFunction getLastBlockHashFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetLastBlockHashFunction, byte[]>(getLastBlockHashFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<byte[]> GetLastBlockHashQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetLastBlockHashFunction, byte[]>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<string> TryAggregateRequestAsync(TryAggregateFunction tryAggregateFunction)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(tryAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> TryAggregateRequestAndWaitForReceiptAsync(
|
||||
TryAggregateFunction tryAggregateFunction, CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(tryAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> TryAggregateRequestAsync(bool requireSuccess, List<Call> calls)
|
||||
{
|
||||
var tryAggregateFunction = new TryAggregateFunction();
|
||||
tryAggregateFunction.RequireSuccess = requireSuccess;
|
||||
tryAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(tryAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> TryAggregateRequestAndWaitForReceiptAsync(bool requireSuccess, List<Call> calls,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var tryAggregateFunction = new TryAggregateFunction();
|
||||
tryAggregateFunction.RequireSuccess = requireSuccess;
|
||||
tryAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(tryAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> TryBlockAndAggregateRequestAsync(TryBlockAndAggregateFunction tryBlockAndAggregateFunction)
|
||||
{
|
||||
return ContractHandler.SendRequestAsync(tryBlockAndAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> TryBlockAndAggregateRequestAndWaitForReceiptAsync(
|
||||
TryBlockAndAggregateFunction tryBlockAndAggregateFunction, CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(tryBlockAndAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<string> TryBlockAndAggregateRequestAsync(bool requireSuccess, List<Call> calls)
|
||||
{
|
||||
var tryBlockAndAggregateFunction = new TryBlockAndAggregateFunction();
|
||||
tryBlockAndAggregateFunction.RequireSuccess = requireSuccess;
|
||||
tryBlockAndAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAsync(tryBlockAndAggregateFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> TryBlockAndAggregateRequestAndWaitForReceiptAsync(bool requireSuccess,
|
||||
List<Call> calls, CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var tryBlockAndAggregateFunction = new TryBlockAndAggregateFunction();
|
||||
tryBlockAndAggregateFunction.RequireSuccess = requireSuccess;
|
||||
tryBlockAndAggregateFunction.Calls = calls;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(tryBlockAndAggregateFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public override List<Type> GetAllFunctionTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
typeof(AggregateFunction),
|
||||
typeof(Aggregate3Function),
|
||||
typeof(Aggregate3ValueFunction),
|
||||
typeof(BlockAndAggregateFunction),
|
||||
typeof(GetBasefeeFunction),
|
||||
typeof(GetBlockHashFunction),
|
||||
typeof(GetBlockNumberFunction),
|
||||
typeof(GetChainIdFunction),
|
||||
typeof(GetCurrentBlockCoinbaseFunction),
|
||||
typeof(GetCurrentBlockGasLimitFunction),
|
||||
typeof(GetCurrentBlockTimestampFunction),
|
||||
typeof(GetEthBalanceFunction),
|
||||
typeof(GetLastBlockHashFunction),
|
||||
typeof(TryAggregateFunction),
|
||||
typeof(TryBlockAndAggregateFunction)
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllEventTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllErrorTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
3
src/Managing.ABI.GmxV2/Program.cs
Normal file
3
src/Managing.ABI.GmxV2/Program.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
@@ -0,0 +1,31 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class Addresses : AddressesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class AddressesBase
|
||||
{
|
||||
[Parameter("address", "account", 1)] public virtual string Account { get; set; }
|
||||
[Parameter("address", "receiver", 2)] public virtual string Receiver { get; set; }
|
||||
|
||||
[Parameter("address", "cancellationReceiver", 3)]
|
||||
public virtual string CancellationReceiver { get; set; }
|
||||
|
||||
[Parameter("address", "callbackContract", 4)]
|
||||
public virtual string CallbackContract { get; set; }
|
||||
|
||||
[Parameter("address", "uiFeeReceiver", 5)]
|
||||
public virtual string UiFeeReceiver { get; set; }
|
||||
|
||||
[Parameter("address", "market", 6)] public virtual string Market { get; set; }
|
||||
|
||||
[Parameter("address", "initialCollateralToken", 7)]
|
||||
public virtual string InitialCollateralToken { get; set; }
|
||||
|
||||
[Parameter("address[]", "swapPath", 8)]
|
||||
public virtual List<string> SwapPath { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class BaseFundingValues : BaseFundingValuesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class BaseFundingValuesBase
|
||||
{
|
||||
[Parameter("tuple", "fundingFeeAmountPerSize", 1)]
|
||||
public virtual PositionType FundingFeeAmountPerSize { get; set; }
|
||||
|
||||
[Parameter("tuple", "claimableFundingAmountPerSize", 2)]
|
||||
public virtual PositionType ClaimableFundingAmountPerSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class CollateralType : CollateralTypeBase
|
||||
{
|
||||
}
|
||||
|
||||
public class CollateralTypeBase
|
||||
{
|
||||
[Parameter("uint256", "longToken", 1)] public virtual BigInteger LongToken { get; set; }
|
||||
|
||||
[Parameter("uint256", "shortToken", 2)]
|
||||
public virtual BigInteger ShortToken { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class ExecutionPriceResult : ExecutionPriceResultBase
|
||||
{
|
||||
}
|
||||
|
||||
public class ExecutionPriceResultBase
|
||||
{
|
||||
[Parameter("int256", "priceImpactUsd", 1)]
|
||||
public virtual BigInteger PriceImpactUsd { get; set; }
|
||||
|
||||
[Parameter("uint256", "priceImpactDiffUsd", 2)]
|
||||
public virtual BigInteger PriceImpactDiffUsd { get; set; }
|
||||
|
||||
[Parameter("uint256", "executionPrice", 3)]
|
||||
public virtual BigInteger ExecutionPrice { get; set; }
|
||||
}
|
||||
}
|
||||
19
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Flags.cs
Normal file
19
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Flags.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class Flags : FlagsBase
|
||||
{
|
||||
}
|
||||
|
||||
public class FlagsBase
|
||||
{
|
||||
[Parameter("bool", "isLong", 1)] public virtual bool IsLong { get; set; }
|
||||
|
||||
[Parameter("bool", "shouldUnwrapNativeToken", 2)]
|
||||
public virtual bool ShouldUnwrapNativeToken { get; set; }
|
||||
|
||||
[Parameter("bool", "isFrozen", 3)] public virtual bool IsFrozen { get; set; }
|
||||
[Parameter("bool", "autoCancel", 4)] public virtual bool AutoCancel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class GetNextFundingAmountPerSizeResult : GetNextFundingAmountPerSizeResultBase
|
||||
{
|
||||
}
|
||||
|
||||
public class GetNextFundingAmountPerSizeResultBase
|
||||
{
|
||||
[Parameter("bool", "longsPayShorts", 1)]
|
||||
public virtual bool LongsPayShorts { get; set; }
|
||||
|
||||
[Parameter("uint256", "fundingFactorPerSecond", 2)]
|
||||
public virtual BigInteger FundingFactorPerSecond { get; set; }
|
||||
|
||||
[Parameter("int256", "nextSavedFundingFactorPerSecond", 3)]
|
||||
public virtual BigInteger NextSavedFundingFactorPerSecond { get; set; }
|
||||
|
||||
[Parameter("tuple", "fundingFeeAmountPerSizeDelta", 4)]
|
||||
public virtual PositionType FundingFeeAmountPerSizeDelta { get; set; }
|
||||
|
||||
[Parameter("tuple", "claimableFundingAmountPerSizeDelta", 5)]
|
||||
public virtual PositionType ClaimableFundingAmountPerSizeDelta { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class MarketInfo : MarketInfoBase
|
||||
{
|
||||
}
|
||||
|
||||
public class MarketInfoBase
|
||||
{
|
||||
[Parameter("tuple", "market", 1)] public virtual MarketsProps Market { get; set; }
|
||||
|
||||
[Parameter("uint256", "borrowingFactorPerSecondForLongs", 2)]
|
||||
public virtual BigInteger BorrowingFactorPerSecondForLongs { get; set; }
|
||||
|
||||
[Parameter("uint256", "borrowingFactorPerSecondForShorts", 3)]
|
||||
public virtual BigInteger BorrowingFactorPerSecondForShorts { get; set; }
|
||||
|
||||
[Parameter("tuple", "baseFunding", 4)] public virtual BaseFundingValues BaseFunding { get; set; }
|
||||
|
||||
[Parameter("tuple", "nextFunding", 5)]
|
||||
public virtual GetNextFundingAmountPerSizeResult NextFunding { get; set; }
|
||||
|
||||
[Parameter("tuple", "virtualInventory", 6)]
|
||||
public virtual VirtualInventory VirtualInventory { get; set; }
|
||||
|
||||
[Parameter("bool", "isDisabled", 7)] public virtual bool IsDisabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class MarketPrices : MarketPricesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class MarketPricesBase
|
||||
{
|
||||
[Parameter("tuple", "indexTokenPrice", 1)]
|
||||
public virtual MarketPrice IndexTokenPrice { get; set; }
|
||||
|
||||
[Parameter("tuple", "longTokenPrice", 2)]
|
||||
public virtual MarketPrice LongTokenPrice { get; set; }
|
||||
|
||||
[Parameter("tuple", "shortTokenPrice", 3)]
|
||||
public virtual MarketPrice ShortTokenPrice { get; set; }
|
||||
}
|
||||
|
||||
public class MarketPrice
|
||||
{
|
||||
[Parameter("uint256", "min", 1)] public BigInteger Min { get; set; }
|
||||
[Parameter("uint256", "max", 2)] public BigInteger Max { get; set; }
|
||||
}
|
||||
}
|
||||
44
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Numbers.cs
Normal file
44
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Numbers.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class Numbers : NumbersBase
|
||||
{
|
||||
}
|
||||
|
||||
public class NumbersBase
|
||||
{
|
||||
[Parameter("uint8", "orderType", 1)] public virtual byte OrderType { get; set; }
|
||||
|
||||
[Parameter("uint8", "decreasePositionSwapType", 2)]
|
||||
public virtual byte DecreasePositionSwapType { get; set; }
|
||||
|
||||
[Parameter("uint256", "sizeDeltaUsd", 3)]
|
||||
public virtual BigInteger SizeDeltaUsd { get; set; }
|
||||
|
||||
[Parameter("uint256", "initialCollateralDeltaAmount", 4)]
|
||||
public virtual BigInteger InitialCollateralDeltaAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "triggerPrice", 5)]
|
||||
public virtual BigInteger TriggerPrice { get; set; }
|
||||
|
||||
[Parameter("uint256", "acceptablePrice", 6)]
|
||||
public virtual BigInteger AcceptablePrice { get; set; }
|
||||
|
||||
[Parameter("uint256", "executionFee", 7)]
|
||||
public virtual BigInteger ExecutionFee { get; set; }
|
||||
|
||||
[Parameter("uint256", "callbackGasLimit", 8)]
|
||||
public virtual BigInteger CallbackGasLimit { get; set; }
|
||||
|
||||
[Parameter("uint256", "minOutputAmount", 9)]
|
||||
public virtual BigInteger MinOutputAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "updatedAtBlock", 10)]
|
||||
public virtual BigInteger UpdatedAtBlock { get; set; }
|
||||
|
||||
[Parameter("uint256", "updatedAtTime", 11)]
|
||||
public virtual BigInteger UpdatedAtTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionBorrowingFees : PositionBorrowingFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionBorrowingFeesBase
|
||||
{
|
||||
[Parameter("uint256", "borrowingFeeUsd", 1)]
|
||||
public virtual BigInteger BorrowingFeeUsd { get; set; }
|
||||
|
||||
[Parameter("uint256", "borrowingFeeAmount", 2)]
|
||||
public virtual BigInteger BorrowingFeeAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "borrowingFeeReceiverFactor", 3)]
|
||||
public virtual BigInteger BorrowingFeeReceiverFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "borrowingFeeAmountForFeeReceiver", 4)]
|
||||
public virtual BigInteger BorrowingFeeAmountForFeeReceiver { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionFees : PositionFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionFeesBase
|
||||
{
|
||||
[Parameter("tuple", "referral", 1)] public virtual PositionReferralFees Referral { get; set; }
|
||||
[Parameter("tuple", "funding", 2)] public virtual PositionFundingFees Funding { get; set; }
|
||||
[Parameter("tuple", "borrowing", 3)] public virtual PositionBorrowingFees Borrowing { get; set; }
|
||||
[Parameter("tuple", "ui", 4)] public virtual PositionUiFees Ui { get; set; }
|
||||
|
||||
[Parameter("tuple", "collateralTokenPrice", 5)]
|
||||
public virtual Props CollateralTokenPrice { get; set; }
|
||||
|
||||
[Parameter("uint256", "positionFeeFactor", 6)]
|
||||
public virtual BigInteger PositionFeeFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "protocolFeeAmount", 7)]
|
||||
public virtual BigInteger ProtocolFeeAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "positionFeeReceiverFactor", 8)]
|
||||
public virtual BigInteger PositionFeeReceiverFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "feeReceiverAmount", 9)]
|
||||
public virtual BigInteger FeeReceiverAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "feeAmountForPool", 10)]
|
||||
public virtual BigInteger FeeAmountForPool { get; set; }
|
||||
|
||||
[Parameter("uint256", "positionFeeAmountForPool", 11)]
|
||||
public virtual BigInteger PositionFeeAmountForPool { get; set; }
|
||||
|
||||
[Parameter("uint256", "positionFeeAmount", 12)]
|
||||
public virtual BigInteger PositionFeeAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "totalCostAmountExcludingFunding", 13)]
|
||||
public virtual BigInteger TotalCostAmountExcludingFunding { get; set; }
|
||||
|
||||
[Parameter("uint256", "totalCostAmount", 14)]
|
||||
public virtual BigInteger TotalCostAmount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionFundingFees : PositionFundingFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionFundingFeesBase
|
||||
{
|
||||
[Parameter("uint256", "fundingFeeAmount", 1)]
|
||||
public virtual BigInteger FundingFeeAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "claimableLongTokenAmount", 2)]
|
||||
public virtual BigInteger ClaimableLongTokenAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "claimableShortTokenAmount", 3)]
|
||||
public virtual BigInteger ClaimableShortTokenAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "latestFundingFeeAmountPerSize", 4)]
|
||||
public virtual BigInteger LatestFundingFeeAmountPerSize { get; set; }
|
||||
|
||||
[Parameter("uint256", "latestLongTokenClaimableFundingAmountPerSize", 5)]
|
||||
public virtual BigInteger LatestLongTokenClaimableFundingAmountPerSize { get; set; }
|
||||
|
||||
[Parameter("uint256", "latestShortTokenClaimableFundingAmountPerSize", 6)]
|
||||
public virtual BigInteger LatestShortTokenClaimableFundingAmountPerSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionInfo : PositionInfoBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionInfoBase
|
||||
{
|
||||
[Parameter("tuple", "position", 1)] public virtual Props Position { get; set; }
|
||||
[Parameter("tuple", "fees", 2)] public virtual PositionFees Fees { get; set; }
|
||||
|
||||
[Parameter("tuple", "executionPriceResult", 3)]
|
||||
public virtual ExecutionPriceResult ExecutionPriceResult { get; set; }
|
||||
|
||||
[Parameter("int256", "basePnlUsd", 4)] public virtual BigInteger BasePnlUsd { get; set; }
|
||||
|
||||
[Parameter("int256", "uncappedBasePnlUsd", 5)]
|
||||
public virtual BigInteger UncappedBasePnlUsd { get; set; }
|
||||
|
||||
[Parameter("int256", "pnlAfterPriceImpactUsd", 6)]
|
||||
public virtual BigInteger PnlAfterPriceImpactUsd { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionReferralFees : PositionReferralFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionReferralFeesBase
|
||||
{
|
||||
[Parameter("bytes32", "referralCode", 1)]
|
||||
public virtual byte[] ReferralCode { get; set; }
|
||||
|
||||
[Parameter("address", "affiliate", 2)] public virtual string Affiliate { get; set; }
|
||||
[Parameter("address", "trader", 3)] public virtual string Trader { get; set; }
|
||||
|
||||
[Parameter("uint256", "totalRebateFactor", 4)]
|
||||
public virtual BigInteger TotalRebateFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "traderDiscountFactor", 5)]
|
||||
public virtual BigInteger TraderDiscountFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "totalRebateAmount", 6)]
|
||||
public virtual BigInteger TotalRebateAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "traderDiscountAmount", 7)]
|
||||
public virtual BigInteger TraderDiscountAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "affiliateRewardAmount", 8)]
|
||||
public virtual BigInteger AffiliateRewardAmount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionType : PositionTypeBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionTypeBase
|
||||
{
|
||||
[Parameter("tuple", "long", 1)] public virtual CollateralType Long { get; set; }
|
||||
[Parameter("tuple", "short", 2)] public virtual CollateralType Short { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class PositionUiFees : PositionUiFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PositionUiFeesBase
|
||||
{
|
||||
[Parameter("address", "uiFeeReceiver", 1)]
|
||||
public virtual string UiFeeReceiver { get; set; }
|
||||
|
||||
[Parameter("uint256", "uiFeeReceiverFactor", 2)]
|
||||
public virtual BigInteger UiFeeReceiverFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "uiFeeAmount", 3)]
|
||||
public virtual BigInteger UiFeeAmount { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Props.cs
Normal file
15
src/Managing.ABI.GmxV2/Reader/ContractDefinition/Props.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class Props : PropsBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PropsBase
|
||||
{
|
||||
[Parameter("tuple", "addresses", 1)] public virtual Addresses Addresses { get; set; }
|
||||
[Parameter("tuple", "numbers", 2)] public virtual Numbers Numbers { get; set; }
|
||||
[Parameter("tuple", "flags", 3)] public virtual Flags Flags { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
30
src/Managing.ABI.GmxV2/Reader/ContractDefinition/SwapFees.cs
Normal file
30
src/Managing.ABI.GmxV2/Reader/ContractDefinition/SwapFees.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class SwapFees : SwapFeesBase
|
||||
{
|
||||
}
|
||||
|
||||
public class SwapFeesBase
|
||||
{
|
||||
[Parameter("uint256", "feeReceiverAmount", 1)]
|
||||
public virtual BigInteger FeeReceiverAmount { get; set; }
|
||||
|
||||
[Parameter("uint256", "feeAmountForPool", 2)]
|
||||
public virtual BigInteger FeeAmountForPool { get; set; }
|
||||
|
||||
[Parameter("uint256", "amountAfterFees", 3)]
|
||||
public virtual BigInteger AmountAfterFees { get; set; }
|
||||
|
||||
[Parameter("address", "uiFeeReceiver", 4)]
|
||||
public virtual string UiFeeReceiver { get; set; }
|
||||
|
||||
[Parameter("uint256", "uiFeeReceiverFactor", 5)]
|
||||
public virtual BigInteger UiFeeReceiverFactor { get; set; }
|
||||
|
||||
[Parameter("uint256", "uiFeeAmount", 6)]
|
||||
public virtual BigInteger UiFeeAmount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader.ContractDefinition
|
||||
{
|
||||
public partial class VirtualInventory : VirtualInventoryBase
|
||||
{
|
||||
}
|
||||
|
||||
public class VirtualInventoryBase
|
||||
{
|
||||
[Parameter("uint256", "virtualPoolAmountForLongToken", 1)]
|
||||
public virtual BigInteger VirtualPoolAmountForLongToken { get; set; }
|
||||
|
||||
[Parameter("uint256", "virtualPoolAmountForShortToken", 2)]
|
||||
public virtual BigInteger VirtualPoolAmountForShortToken { get; set; }
|
||||
|
||||
[Parameter("int256", "virtualInventoryForPositions", 3)]
|
||||
public virtual BigInteger VirtualInventoryForPositions { get; set; }
|
||||
}
|
||||
}
|
||||
636
src/Managing.ABI.GmxV2/Reader/ReaderService.cs
Normal file
636
src/Managing.ABI.GmxV2/Reader/ReaderService.cs
Normal file
@@ -0,0 +1,636 @@
|
||||
using System.Numerics;
|
||||
using Managing.ABI.GmxV2.Reader.ContractDefinition;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace Managing.ABI.GmxV2.Reader
|
||||
{
|
||||
public partial class ReaderService : ContractWeb3ServiceBase
|
||||
{
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.IWeb3 web3,
|
||||
ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>()
|
||||
.SendRequestAndWaitForReceiptAsync(readerDeployment, cancellationTokenSource);
|
||||
}
|
||||
|
||||
public static Task<string> DeployContractAsync(Nethereum.Web3.IWeb3 web3, ReaderDeployment readerDeployment)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>().SendRequestAsync(readerDeployment);
|
||||
}
|
||||
|
||||
public static async Task<ReaderService> DeployContractAndGetServiceAsync(Nethereum.Web3.IWeb3 web3,
|
||||
ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
var receipt = await DeployContractAndWaitForReceiptAsync(web3, readerDeployment, cancellationTokenSource);
|
||||
return new ReaderService(web3, receipt.ContractAddress);
|
||||
}
|
||||
|
||||
public ReaderService(Nethereum.Web3.IWeb3 web3, string contractAddress) : base(web3, contractAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public Task<GetAccountOrdersOutputDTO> GetAccountOrdersQueryAsync(
|
||||
GetAccountOrdersFunction getAccountOrdersFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAccountOrdersFunction, GetAccountOrdersOutputDTO>(
|
||||
getAccountOrdersFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAccountOrdersOutputDTO> GetAccountOrdersQueryAsync(string dataStore, string account,
|
||||
BigInteger start, BigInteger end, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getAccountOrdersFunction = new GetAccountOrdersFunction();
|
||||
getAccountOrdersFunction.DataStore = dataStore;
|
||||
getAccountOrdersFunction.Account = account;
|
||||
getAccountOrdersFunction.Start = start;
|
||||
getAccountOrdersFunction.End = end;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAccountOrdersFunction, GetAccountOrdersOutputDTO>(
|
||||
getAccountOrdersFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAccountPositionInfoListOutputDTO> GetAccountPositionInfoListQueryAsync(
|
||||
GetAccountPositionInfoListFunction getAccountPositionInfoListFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetAccountPositionInfoListFunction,
|
||||
GetAccountPositionInfoListOutputDTO>(getAccountPositionInfoListFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAccountPositionInfoListOutputDTO> GetAccountPositionInfoListQueryAsync(string dataStore,
|
||||
string referralStorage, List<byte[]> positionKeys, List<MarketPrices> prices, string uiFeeReceiver,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getAccountPositionInfoListFunction = new GetAccountPositionInfoListFunction();
|
||||
getAccountPositionInfoListFunction.DataStore = dataStore;
|
||||
getAccountPositionInfoListFunction.ReferralStorage = referralStorage;
|
||||
getAccountPositionInfoListFunction.PositionKeys = positionKeys;
|
||||
getAccountPositionInfoListFunction.Prices = prices;
|
||||
getAccountPositionInfoListFunction.UiFeeReceiver = uiFeeReceiver;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetAccountPositionInfoListFunction,
|
||||
GetAccountPositionInfoListOutputDTO>(getAccountPositionInfoListFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAccountPositionsOutputDTO> GetAccountPositionsQueryAsync(
|
||||
GetAccountPositionsFunction getAccountPositionsFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetAccountPositionsFunction, GetAccountPositionsOutputDTO>(
|
||||
getAccountPositionsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAccountPositionsOutputDTO> GetAccountPositionsQueryAsync(string dataStore, string account,
|
||||
BigInteger start, BigInteger end, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getAccountPositionsFunction = new GetAccountPositionsFunction();
|
||||
getAccountPositionsFunction.DataStore = dataStore;
|
||||
getAccountPositionsFunction.Account = account;
|
||||
getAccountPositionsFunction.Start = start;
|
||||
getAccountPositionsFunction.End = end;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetAccountPositionsFunction, GetAccountPositionsOutputDTO>(
|
||||
getAccountPositionsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAdlStateOutputDTO> GetAdlStateQueryAsync(GetAdlStateFunction getAdlStateFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAdlStateFunction, GetAdlStateOutputDTO>(
|
||||
getAdlStateFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAdlStateOutputDTO> GetAdlStateQueryAsync(string dataStore, string market, bool isLong,
|
||||
MarketPrices prices, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getAdlStateFunction = new GetAdlStateFunction();
|
||||
getAdlStateFunction.DataStore = dataStore;
|
||||
getAdlStateFunction.Market = market;
|
||||
getAdlStateFunction.IsLong = isLong;
|
||||
getAdlStateFunction.Prices = prices;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAdlStateFunction, GetAdlStateOutputDTO>(
|
||||
getAdlStateFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetDepositOutputDTO> GetDepositQueryAsync(GetDepositFunction getDepositFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetDepositFunction, GetDepositOutputDTO>(
|
||||
getDepositFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetDepositOutputDTO> GetDepositQueryAsync(string dataStore, byte[] key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getDepositFunction = new GetDepositFunction();
|
||||
getDepositFunction.DataStore = dataStore;
|
||||
getDepositFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetDepositFunction, GetDepositOutputDTO>(
|
||||
getDepositFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetDepositAmountOutQueryAsync(GetDepositAmountOutFunction getDepositAmountOutFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetDepositAmountOutFunction, BigInteger>(getDepositAmountOutFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetDepositAmountOutQueryAsync(string dataStore, Props market, MarketPrices prices,
|
||||
BigInteger longTokenAmount, BigInteger shortTokenAmount, string uiFeeReceiver, byte swapPricingType,
|
||||
bool includeVirtualInventoryImpact, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getDepositAmountOutFunction = new GetDepositAmountOutFunction();
|
||||
getDepositAmountOutFunction.DataStore = dataStore;
|
||||
getDepositAmountOutFunction.Market = market;
|
||||
getDepositAmountOutFunction.Prices = prices;
|
||||
getDepositAmountOutFunction.LongTokenAmount = longTokenAmount;
|
||||
getDepositAmountOutFunction.ShortTokenAmount = shortTokenAmount;
|
||||
getDepositAmountOutFunction.UiFeeReceiver = uiFeeReceiver;
|
||||
getDepositAmountOutFunction.SwapPricingType = swapPricingType;
|
||||
getDepositAmountOutFunction.IncludeVirtualInventoryImpact = includeVirtualInventoryImpact;
|
||||
|
||||
return ContractHandler.QueryAsync<GetDepositAmountOutFunction, BigInteger>(getDepositAmountOutFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetExecutionPriceOutputDTO> GetExecutionPriceQueryAsync(
|
||||
GetExecutionPriceFunction getExecutionPriceFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetExecutionPriceFunction, GetExecutionPriceOutputDTO>(
|
||||
getExecutionPriceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetExecutionPriceOutputDTO> GetExecutionPriceQueryAsync(string dataStore, string marketKey,
|
||||
Props indexTokenPrice, BigInteger positionSizeInUsd, BigInteger positionSizeInTokens,
|
||||
BigInteger sizeDeltaUsd, bool isLong, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getExecutionPriceFunction = new GetExecutionPriceFunction();
|
||||
getExecutionPriceFunction.DataStore = dataStore;
|
||||
getExecutionPriceFunction.MarketKey = marketKey;
|
||||
getExecutionPriceFunction.IndexTokenPrice = indexTokenPrice;
|
||||
getExecutionPriceFunction.PositionSizeInUsd = positionSizeInUsd;
|
||||
getExecutionPriceFunction.PositionSizeInTokens = positionSizeInTokens;
|
||||
getExecutionPriceFunction.SizeDeltaUsd = sizeDeltaUsd;
|
||||
getExecutionPriceFunction.IsLong = isLong;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetExecutionPriceFunction, GetExecutionPriceOutputDTO>(
|
||||
getExecutionPriceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketOutputDTO> GetMarketQueryAsync(GetMarketFunction getMarketFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketFunction, GetMarketOutputDTO>(
|
||||
getMarketFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketOutputDTO> GetMarketQueryAsync(string dataStore, string key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketFunction = new GetMarketFunction();
|
||||
getMarketFunction.DataStore = dataStore;
|
||||
getMarketFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketFunction, GetMarketOutputDTO>(
|
||||
getMarketFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketBySaltOutputDTO> GetMarketBySaltQueryAsync(GetMarketBySaltFunction getMarketBySaltFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketBySaltFunction, GetMarketBySaltOutputDTO>(
|
||||
getMarketBySaltFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketBySaltOutputDTO> GetMarketBySaltQueryAsync(string dataStore, byte[] salt,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketBySaltFunction = new GetMarketBySaltFunction();
|
||||
getMarketBySaltFunction.DataStore = dataStore;
|
||||
getMarketBySaltFunction.Salt = salt;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketBySaltFunction, GetMarketBySaltOutputDTO>(
|
||||
getMarketBySaltFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketInfoOutputDTO> GetMarketInfoQueryAsync(GetMarketInfoFunction getMarketInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketInfoFunction, GetMarketInfoOutputDTO>(
|
||||
getMarketInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketInfoOutputDTO> GetMarketInfoQueryAsync(string dataStore, MarketPrices prices,
|
||||
string marketKey, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketInfoFunction = new GetMarketInfoFunction();
|
||||
getMarketInfoFunction.DataStore = dataStore;
|
||||
getMarketInfoFunction.Prices = prices;
|
||||
getMarketInfoFunction.MarketKey = marketKey;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketInfoFunction, GetMarketInfoOutputDTO>(
|
||||
getMarketInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketInfoListOutputDTO> GetMarketInfoListQueryAsync(
|
||||
GetMarketInfoListFunction getMarketInfoListFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetMarketInfoListFunction, GetMarketInfoListOutputDTO>(
|
||||
getMarketInfoListFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketInfoListOutputDTO> GetMarketInfoListQueryAsync(string dataStore,
|
||||
List<MarketPrices> marketPricesList, BigInteger start, BigInteger end, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketInfoListFunction = new GetMarketInfoListFunction();
|
||||
getMarketInfoListFunction.DataStore = dataStore;
|
||||
getMarketInfoListFunction.MarketPricesList = marketPricesList;
|
||||
getMarketInfoListFunction.Start = start;
|
||||
getMarketInfoListFunction.End = end;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetMarketInfoListFunction, GetMarketInfoListOutputDTO>(
|
||||
getMarketInfoListFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketTokenPriceOutputDTO> GetMarketTokenPriceQueryAsync(
|
||||
GetMarketTokenPriceFunction getMarketTokenPriceFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetMarketTokenPriceFunction, GetMarketTokenPriceOutputDTO>(
|
||||
getMarketTokenPriceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketTokenPriceOutputDTO> GetMarketTokenPriceQueryAsync(string dataStore, MarketsProps market,
|
||||
MarketPrice indexTokenPrice, MarketPrice longTokenPrice, MarketPrice shortTokenPrice, byte[] pnlFactorType,
|
||||
bool maximize,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketTokenPriceFunction = new GetMarketTokenPriceFunction();
|
||||
getMarketTokenPriceFunction.DataStore = dataStore;
|
||||
getMarketTokenPriceFunction.Market = market;
|
||||
getMarketTokenPriceFunction.IndexTokenPrice = indexTokenPrice;
|
||||
getMarketTokenPriceFunction.LongTokenPrice = longTokenPrice;
|
||||
getMarketTokenPriceFunction.ShortTokenPrice = shortTokenPrice;
|
||||
getMarketTokenPriceFunction.PnlFactorType = pnlFactorType;
|
||||
getMarketTokenPriceFunction.Maximize = maximize;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetMarketTokenPriceFunction, GetMarketTokenPriceOutputDTO>(
|
||||
getMarketTokenPriceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketsOutputDTO> GetMarketsQueryAsync(GetMarketsFunction getMarketsFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketsFunction, GetMarketsOutputDTO>(
|
||||
getMarketsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetMarketsOutputDTO> GetMarketsQueryAsync(string dataStore, BigInteger start, BigInteger end,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMarketsFunction = new GetMarketsFunction();
|
||||
getMarketsFunction.DataStore = dataStore;
|
||||
getMarketsFunction.Start = start;
|
||||
getMarketsFunction.End = end;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetMarketsFunction, GetMarketsOutputDTO>(
|
||||
getMarketsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetNetPnlQueryAsync(GetNetPnlFunction getNetPnlFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetNetPnlFunction, BigInteger>(getNetPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetNetPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice,
|
||||
bool maximize, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getNetPnlFunction = new GetNetPnlFunction();
|
||||
getNetPnlFunction.DataStore = dataStore;
|
||||
getNetPnlFunction.Market = market;
|
||||
getNetPnlFunction.IndexTokenPrice = indexTokenPrice;
|
||||
getNetPnlFunction.Maximize = maximize;
|
||||
|
||||
return ContractHandler.QueryAsync<GetNetPnlFunction, BigInteger>(getNetPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetOpenInterestWithPnlQueryAsync(
|
||||
GetOpenInterestWithPnlFunction getOpenInterestWithPnlFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetOpenInterestWithPnlFunction, BigInteger>(
|
||||
getOpenInterestWithPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetOpenInterestWithPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice,
|
||||
bool isLong, bool maximize, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getOpenInterestWithPnlFunction = new GetOpenInterestWithPnlFunction();
|
||||
getOpenInterestWithPnlFunction.DataStore = dataStore;
|
||||
getOpenInterestWithPnlFunction.Market = market;
|
||||
getOpenInterestWithPnlFunction.IndexTokenPrice = indexTokenPrice;
|
||||
getOpenInterestWithPnlFunction.IsLong = isLong;
|
||||
getOpenInterestWithPnlFunction.Maximize = maximize;
|
||||
|
||||
return ContractHandler.QueryAsync<GetOpenInterestWithPnlFunction, BigInteger>(
|
||||
getOpenInterestWithPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetOrderOutputDTO> GetOrderQueryAsync(GetOrderFunction getOrderFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetOrderFunction, GetOrderOutputDTO>(
|
||||
getOrderFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetOrderOutputDTO> GetOrderQueryAsync(string dataStore, byte[] key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getOrderFunction = new GetOrderFunction();
|
||||
getOrderFunction.DataStore = dataStore;
|
||||
getOrderFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetOrderFunction, GetOrderOutputDTO>(
|
||||
getOrderFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetPnlQueryAsync(GetPnlFunction getPnlFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetPnlFunction, BigInteger>(getPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetPnlQueryAsync(string dataStore, Props market, Props indexTokenPrice, bool isLong,
|
||||
bool maximize, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPnlFunction = new GetPnlFunction();
|
||||
getPnlFunction.DataStore = dataStore;
|
||||
getPnlFunction.Market = market;
|
||||
getPnlFunction.IndexTokenPrice = indexTokenPrice;
|
||||
getPnlFunction.IsLong = isLong;
|
||||
getPnlFunction.Maximize = maximize;
|
||||
|
||||
return ContractHandler.QueryAsync<GetPnlFunction, BigInteger>(getPnlFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetPnlToPoolFactorQueryAsync(GetPnlToPoolFactorFunction getPnlToPoolFactorFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetPnlToPoolFactorFunction, BigInteger>(getPnlToPoolFactorFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetPnlToPoolFactorQueryAsync(string dataStore, string marketAddress,
|
||||
MarketPrices prices, bool isLong, bool maximize, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPnlToPoolFactorFunction = new GetPnlToPoolFactorFunction();
|
||||
getPnlToPoolFactorFunction.DataStore = dataStore;
|
||||
getPnlToPoolFactorFunction.MarketAddress = marketAddress;
|
||||
getPnlToPoolFactorFunction.Prices = prices;
|
||||
getPnlToPoolFactorFunction.IsLong = isLong;
|
||||
getPnlToPoolFactorFunction.Maximize = maximize;
|
||||
|
||||
return ContractHandler.QueryAsync<GetPnlToPoolFactorFunction, BigInteger>(getPnlToPoolFactorFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionOutputDTO> GetPositionQueryAsync(GetPositionFunction getPositionFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetPositionFunction, GetPositionOutputDTO>(
|
||||
getPositionFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionOutputDTO> GetPositionQueryAsync(string dataStore, byte[] key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPositionFunction = new GetPositionFunction();
|
||||
getPositionFunction.DataStore = dataStore;
|
||||
getPositionFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetPositionFunction, GetPositionOutputDTO>(
|
||||
getPositionFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionInfoOutputDTO> GetPositionInfoQueryAsync(GetPositionInfoFunction getPositionInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetPositionInfoFunction, GetPositionInfoOutputDTO>(
|
||||
getPositionInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionInfoOutputDTO> GetPositionInfoQueryAsync(string dataStore, string referralStorage,
|
||||
byte[] positionKey, MarketPrices prices, BigInteger sizeDeltaUsd, string uiFeeReceiver,
|
||||
bool usePositionSizeAsSizeDeltaUsd, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPositionInfoFunction = new GetPositionInfoFunction();
|
||||
getPositionInfoFunction.DataStore = dataStore;
|
||||
getPositionInfoFunction.ReferralStorage = referralStorage;
|
||||
getPositionInfoFunction.PositionKey = positionKey;
|
||||
getPositionInfoFunction.Prices = prices;
|
||||
getPositionInfoFunction.SizeDeltaUsd = sizeDeltaUsd;
|
||||
getPositionInfoFunction.UiFeeReceiver = uiFeeReceiver;
|
||||
getPositionInfoFunction.UsePositionSizeAsSizeDeltaUsd = usePositionSizeAsSizeDeltaUsd;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetPositionInfoFunction, GetPositionInfoOutputDTO>(
|
||||
getPositionInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionPnlUsdOutputDTO> GetPositionPnlUsdQueryAsync(
|
||||
GetPositionPnlUsdFunction getPositionPnlUsdFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetPositionPnlUsdFunction, GetPositionPnlUsdOutputDTO>(
|
||||
getPositionPnlUsdFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetPositionPnlUsdOutputDTO> GetPositionPnlUsdQueryAsync(string dataStore, Props market,
|
||||
MarketPrices prices, byte[] positionKey, BigInteger sizeDeltaUsd, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPositionPnlUsdFunction = new GetPositionPnlUsdFunction();
|
||||
getPositionPnlUsdFunction.DataStore = dataStore;
|
||||
getPositionPnlUsdFunction.Market = market;
|
||||
getPositionPnlUsdFunction.Prices = prices;
|
||||
getPositionPnlUsdFunction.PositionKey = positionKey;
|
||||
getPositionPnlUsdFunction.SizeDeltaUsd = sizeDeltaUsd;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetPositionPnlUsdFunction, GetPositionPnlUsdOutputDTO>(
|
||||
getPositionPnlUsdFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetShiftOutputDTO> GetShiftQueryAsync(GetShiftFunction getShiftFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetShiftFunction, GetShiftOutputDTO>(
|
||||
getShiftFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetShiftOutputDTO> GetShiftQueryAsync(string dataStore, byte[] key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getShiftFunction = new GetShiftFunction();
|
||||
getShiftFunction.DataStore = dataStore;
|
||||
getShiftFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetShiftFunction, GetShiftOutputDTO>(
|
||||
getShiftFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetSwapAmountOutOutputDTO> GetSwapAmountOutQueryAsync(
|
||||
GetSwapAmountOutFunction getSwapAmountOutFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetSwapAmountOutFunction, GetSwapAmountOutOutputDTO>(
|
||||
getSwapAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetSwapAmountOutOutputDTO> GetSwapAmountOutQueryAsync(string dataStore, Props market,
|
||||
MarketPrices prices, string tokenIn, BigInteger amountIn, string uiFeeReceiver,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getSwapAmountOutFunction = new GetSwapAmountOutFunction();
|
||||
getSwapAmountOutFunction.DataStore = dataStore;
|
||||
getSwapAmountOutFunction.Market = market;
|
||||
getSwapAmountOutFunction.Prices = prices;
|
||||
getSwapAmountOutFunction.TokenIn = tokenIn;
|
||||
getSwapAmountOutFunction.AmountIn = amountIn;
|
||||
getSwapAmountOutFunction.UiFeeReceiver = uiFeeReceiver;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetSwapAmountOutFunction, GetSwapAmountOutOutputDTO>(
|
||||
getSwapAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetSwapPriceImpactOutputDTO> GetSwapPriceImpactQueryAsync(
|
||||
GetSwapPriceImpactFunction getSwapPriceImpactFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetSwapPriceImpactFunction, GetSwapPriceImpactOutputDTO>(
|
||||
getSwapPriceImpactFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetSwapPriceImpactOutputDTO> GetSwapPriceImpactQueryAsync(string dataStore, string marketKey,
|
||||
string tokenIn, string tokenOut, BigInteger amountIn, Props tokenInPrice, Props tokenOutPrice,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getSwapPriceImpactFunction = new GetSwapPriceImpactFunction();
|
||||
getSwapPriceImpactFunction.DataStore = dataStore;
|
||||
getSwapPriceImpactFunction.MarketKey = marketKey;
|
||||
getSwapPriceImpactFunction.TokenIn = tokenIn;
|
||||
getSwapPriceImpactFunction.TokenOut = tokenOut;
|
||||
getSwapPriceImpactFunction.AmountIn = amountIn;
|
||||
getSwapPriceImpactFunction.TokenInPrice = tokenInPrice;
|
||||
getSwapPriceImpactFunction.TokenOutPrice = tokenOutPrice;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetSwapPriceImpactFunction, GetSwapPriceImpactOutputDTO>(
|
||||
getSwapPriceImpactFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetWithdrawalOutputDTO> GetWithdrawalQueryAsync(GetWithdrawalFunction getWithdrawalFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetWithdrawalFunction, GetWithdrawalOutputDTO>(
|
||||
getWithdrawalFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetWithdrawalOutputDTO> GetWithdrawalQueryAsync(string dataStore, byte[] key,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getWithdrawalFunction = new GetWithdrawalFunction();
|
||||
getWithdrawalFunction.DataStore = dataStore;
|
||||
getWithdrawalFunction.Key = key;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetWithdrawalFunction, GetWithdrawalOutputDTO>(
|
||||
getWithdrawalFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetWithdrawalAmountOutOutputDTO> GetWithdrawalAmountOutQueryAsync(
|
||||
GetWithdrawalAmountOutFunction getWithdrawalAmountOutFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetWithdrawalAmountOutFunction, GetWithdrawalAmountOutOutputDTO>(
|
||||
getWithdrawalAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetWithdrawalAmountOutOutputDTO> GetWithdrawalAmountOutQueryAsync(string dataStore, Props market,
|
||||
MarketPrices prices, BigInteger marketTokenAmount, string uiFeeReceiver, byte swapPricingType,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getWithdrawalAmountOutFunction = new GetWithdrawalAmountOutFunction();
|
||||
getWithdrawalAmountOutFunction.DataStore = dataStore;
|
||||
getWithdrawalAmountOutFunction.Market = market;
|
||||
getWithdrawalAmountOutFunction.Prices = prices;
|
||||
getWithdrawalAmountOutFunction.MarketTokenAmount = marketTokenAmount;
|
||||
getWithdrawalAmountOutFunction.UiFeeReceiver = uiFeeReceiver;
|
||||
getWithdrawalAmountOutFunction.SwapPricingType = swapPricingType;
|
||||
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetWithdrawalAmountOutFunction, GetWithdrawalAmountOutOutputDTO>(
|
||||
getWithdrawalAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public override List<Type> GetAllFunctionTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
typeof(GetAccountOrdersFunction),
|
||||
typeof(GetAccountPositionInfoListFunction),
|
||||
typeof(GetAccountPositionsFunction),
|
||||
typeof(GetAdlStateFunction),
|
||||
typeof(GetDepositFunction),
|
||||
typeof(GetDepositAmountOutFunction),
|
||||
typeof(GetExecutionPriceFunction),
|
||||
typeof(GetMarketFunction),
|
||||
typeof(GetMarketBySaltFunction),
|
||||
typeof(GetMarketInfoFunction),
|
||||
typeof(GetMarketInfoListFunction),
|
||||
typeof(GetMarketTokenPriceFunction),
|
||||
typeof(GetMarketsFunction),
|
||||
typeof(GetNetPnlFunction),
|
||||
typeof(GetOpenInterestWithPnlFunction),
|
||||
typeof(GetOrderFunction),
|
||||
typeof(GetPnlFunction),
|
||||
typeof(GetPnlToPoolFactorFunction),
|
||||
typeof(GetPositionFunction),
|
||||
typeof(GetPositionInfoFunction),
|
||||
typeof(GetPositionPnlUsdFunction),
|
||||
typeof(GetShiftFunction),
|
||||
typeof(GetSwapAmountOutFunction),
|
||||
typeof(GetSwapPriceImpactFunction),
|
||||
typeof(GetWithdrawalFunction),
|
||||
typeof(GetWithdrawalAmountOutFunction)
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllEventTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllErrorTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
typeof(DisabledMarketError),
|
||||
typeof(EmptyMarketError)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,17 +102,17 @@ builder.Services.AddSwaggerGen(options =>
|
||||
});
|
||||
|
||||
builder.WebHost.SetupDiscordBot();
|
||||
builder.Services.AddHostedService<FeeWorker>();
|
||||
// builder.Services.AddHostedService<PositionManagerWorker>();
|
||||
// builder.Services.AddHostedService<PositionFetcher>();
|
||||
// builder.Services.AddHostedService<PricesFiveMinutesWorker>();
|
||||
builder.Services.AddHostedService<PricesFifteenMinutesWorker>();
|
||||
builder.Services.AddHostedService<PricesOneHourWorker>();
|
||||
// builder.Services.AddHostedService<PricesFourHoursWorker>();
|
||||
builder.Services.AddHostedService<PricesOneDayWorker>();
|
||||
// builder.Services.AddHostedService<SpotlightWorker>();
|
||||
builder.Services.AddHostedService<TraderWatcher>();
|
||||
builder.Services.AddHostedService<LeaderboardWorker>();
|
||||
// builder.Services.AddHostedService<FeeWorker>();
|
||||
// // builder.Services.AddHostedService<PositionManagerWorker>();
|
||||
// // builder.Services.AddHostedService<PositionFetcher>();
|
||||
// // builder.Services.AddHostedService<PricesFiveMinutesWorker>();
|
||||
// builder.Services.AddHostedService<PricesFifteenMinutesWorker>();
|
||||
// builder.Services.AddHostedService<PricesOneHourWorker>();
|
||||
// // builder.Services.AddHostedService<PricesFourHoursWorker>();
|
||||
// builder.Services.AddHostedService<PricesOneDayWorker>();
|
||||
// // builder.Services.AddHostedService<SpotlightWorker>();
|
||||
// builder.Services.AddHostedService<TraderWatcher>();
|
||||
// builder.Services.AddHostedService<LeaderboardWorker>();
|
||||
builder.Services.AddHostedService<FundingRatesWatcher>();
|
||||
|
||||
// App
|
||||
|
||||
@@ -94,9 +94,8 @@ public class StatisticService : IStatisticService
|
||||
{
|
||||
// Get fundingRate from database
|
||||
var previousFundingRate = await GetFundingRates();
|
||||
// var fundingRates = await .GetFundingRates();
|
||||
var newFundingRates = await _evmManager.GetFundingRates();
|
||||
|
||||
var newFundingRates = await _tradaoService.GetFundingRates();
|
||||
var topRates = newFundingRates
|
||||
.Where(fr => fr.Direction == TradeDirection.Short && fr.Rate > 0)
|
||||
.OrderByDescending(fr => fr.Rate)
|
||||
@@ -132,7 +131,7 @@ public class StatisticService : IStatisticService
|
||||
else if (previousFundingRate.Any(tr => SameFundingRate(tr, newRate)))
|
||||
{
|
||||
var oldRate = previousFundingRate.FirstOrDefault(tr => SameFundingRate(tr, newRate));
|
||||
if (oldRate != null && Math.Abs(oldRate.Rate - newRate.Rate) > 1m)
|
||||
if (oldRate != null && Math.Abs(oldRate.Rate - newRate.Rate) > 5m)
|
||||
{
|
||||
await _messengerService.SendFundingRateUpdate(oldRate, newRate);
|
||||
_statisticRepository.UpdateFundingRate(oldRate, newRate);
|
||||
|
||||
@@ -36,5 +36,77 @@
|
||||
public const string Usd = "USD";
|
||||
public const string Usdt = "USDT";
|
||||
}
|
||||
|
||||
public class GMX
|
||||
{
|
||||
public const string OPEN_INTEREST = "OPEN_INTEREST";
|
||||
public const string LONG_INTEREST_USD_KEY = "MAX_OPEN_INTEREST";
|
||||
public const string POOL_AMOUNT_KEY = "POOL_AMOUNT";
|
||||
public const string MARKET_DISABLED_KEY = "IS_MARKET_DISABLED";
|
||||
public const string MAX_PNL_FACTOR_FOR_TRADERS = "MAX_PNL_FACTOR_FOR_TRADERS";
|
||||
|
||||
public class TokenAddress
|
||||
{
|
||||
public const string WETH = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
||||
public const string WSTETH = "0x5979D7b546E38E414F7E9822514be443A4800529";
|
||||
public const string WBTC = "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f";
|
||||
public const string ARB = "0x912CE59144191C1204E64559FE8253a0e49E6548";
|
||||
public const string SOL = "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07";
|
||||
public const string LINK = "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4";
|
||||
public const string UNI = "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0";
|
||||
public const string USDCE = "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8";
|
||||
public const string USDC = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
||||
public const string USDT = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9";
|
||||
public const string DAI = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1";
|
||||
public const string USDE = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34";
|
||||
public const string FRAX = "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F";
|
||||
public const string MIM = "0xFEa7a6a0B346362BF88A9e4A88416B77a57D6c2A";
|
||||
public const string BTC = "0x47904963fc8b2340414262125aF798B9655E58Cd";
|
||||
public const string DOGE = "0xC4da4c24fd591125c3F47b340b6f4f76111883d8";
|
||||
public const string LTC = "0xB46A094Bc4B0adBD801E14b9DB95e05E28962764";
|
||||
public const string XRP = "0xc14e065b0067dE91534e032868f5Ac6ecf2c6868";
|
||||
public const string GMX = "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a";
|
||||
public const string WBNB = "0xa9004A5421372E1D83fB1f85b0fc986c912f91f3";
|
||||
public const string ATOM = "0x7D7F1765aCbaF847b9A1f7137FE8Ed4931FbfEbA";
|
||||
public const string AAVE = "0xba5DdD1f9d7F570dc94a51479a000E3BCE967196";
|
||||
public const string AVAX = "0x565609fAF65B92F7be02468acF86f8979423e514";
|
||||
public const string OP = "0xaC800FD6159c2a2CB8fC31EF74621eB430287a5A";
|
||||
public const string PEPE = "0x25d887Ce7a35172C62FeBFD67a1856F20FaEbB00";
|
||||
public const string WIF = "0xA1b91fe9FD52141Ff8cac388Ce3F10BFDc1dE79d";
|
||||
public const string SHIB = "0x3E57D02f9d196873e55727382974b02EdebE6bfd";
|
||||
public const string APE = "0x74885b4D524d497261259B38900f54e6dbAd2210";
|
||||
public const string NEAR = "0x1FF7F3EFBb9481Cbd7db4F932cBCD4467144237C";
|
||||
public const string STX = "0xBaf07cF91D413C0aCB2b7444B9Bf13b4e03c9D71";
|
||||
public const string ORDI = "0x1E15d08f3CA46853B692EE28AE9C7a0b88a9c994";
|
||||
}
|
||||
|
||||
public class Markets
|
||||
{
|
||||
public const string BTCUSDC = "0x47c031236e19d024b42f8AE6780E44A573170703";
|
||||
public const string ETHUSDC = "0x70d95587d40A2caf56bd97485aB3Eec10Bee6336";
|
||||
public const string SOLUSD = "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9";
|
||||
public const string LINKUSD = "0x7f1fa204bb700853D36994DA19F830b6Ad18455C";
|
||||
public const string UNIUSD = "0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50";
|
||||
public const string DOGEUSD = "0x6853EA96FF216fAb11D2d930CE3C508556A4bdc4";
|
||||
public const string LTCUSD = "0xD9535bB5f58A1a75032416F2dFe7880C30575a41";
|
||||
public const string XRPUSD = "0x0CCB4fAa6f1F1B30911619f1184082aB4E25813c";
|
||||
public const string GMXUSD = "0x55391D178Ce46e7AC8eaAEa50A72D1A5a8A622Da";
|
||||
public const string BNBUSD = "0x2d340912Aa47e33c90Efb078e69E70EFe2B34b9B";
|
||||
public const string ATOMUSD = "0x248C35760068cE009a13076D573ed3497A47bCD4";
|
||||
public const string AAVEUSD = "0x1CbBa6346F110c8A5ea739ef2d1eb182990e4EB2";
|
||||
public const string AVAXUSD = "0x7BbBf946883a5701350007320F525c5379B8178A";
|
||||
public const string OPUSD = "0x4fDd333FF9cA409df583f306B6F5a7fFdE790739";
|
||||
public const string PEPEUSD = "0x2b477989A149B17073D9C9C82eC9cB03591e20c6";
|
||||
public const string WIFUSD = "0x0418643F94Ef14917f1345cE5C460C37dE463ef7";
|
||||
public const string SHIBUSD = "0xB62369752D8Ad08392572db6d0cc872127888beD";
|
||||
public const string APEUSD = "0x74885b4D524d497261259B38900f54e6dbAd2210";
|
||||
public const string NEARUSD = "0x63Dc80EE90F26363B3FCD609007CC9e14c8991BE";
|
||||
public const string ARBUSD = "0xC25cEf6061Cf5dE5eb761b50E4743c1F5D7E5407";
|
||||
public const string BTCUSD = "0x7C11F78Ce78768518D743E81Fdfa2F860C6b9A77";
|
||||
public const string ETHUSD = "0x450bb6774Dd8a756274E0ab4107953259d2ac541";
|
||||
public const string STXUSD = "0xD9377d9B9a2327C7778867203deeA73AB8a68b6B";
|
||||
public const string ORDIUSD = "0x93385F7C646A3048051914BDFaC25F4d620aeDF1";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,6 +299,10 @@ public static class Enums
|
||||
XMR,
|
||||
XRP,
|
||||
XTZ,
|
||||
SHIB,
|
||||
STX,
|
||||
ORDI,
|
||||
Unknown
|
||||
}
|
||||
|
||||
public enum WorkerType
|
||||
|
||||
@@ -5,4 +5,5 @@ public class Chain
|
||||
public string Id { get; set; }
|
||||
public string RpcUrl { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int ChainId { get; set; }
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace Managing.Infrastructure.Messengers.Discord
|
||||
catch (ApplicationCommandException exception)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(exception, Formatting.Indented);
|
||||
Console.WriteLine(json);
|
||||
_logger.LogError(exception, json);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
121
src/Managing.Infrastructure.Tests/GmxServiceV2Tests.cs
Normal file
121
src/Managing.Infrastructure.Tests/GmxServiceV2Tests.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Managing.Common;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
using Managing.Infrastructure.Evm.Services;
|
||||
using Managing.Infrastructure.Evm.Services.Gmx;
|
||||
using Nethereum.Web3;
|
||||
using Xunit;
|
||||
|
||||
namespace Managing.Infrastructure.Tests;
|
||||
|
||||
public class GmxV2ServiceTests
|
||||
{
|
||||
private readonly GmxV2Service _service;
|
||||
private readonly Web3 _web3;
|
||||
|
||||
public GmxV2ServiceTests()
|
||||
{
|
||||
var defaultChain = ChainService.GetArbitrum();
|
||||
_web3 = new Web3(defaultChain.RpcUrl);
|
||||
_service = new GmxV2Service();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Multiple_Markets_With_MultiCall()
|
||||
{
|
||||
// Act
|
||||
var result = await _service.GetMarketsAsync(_web3);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.NotEmpty(result);
|
||||
Assert.All(result, r =>
|
||||
{
|
||||
Assert.NotNull(r.MarketToken);
|
||||
Assert.NotNull(r.IndexToken);
|
||||
Assert.NotNull(r.LongToken);
|
||||
Assert.NotNull(r.ShortToken);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Multiple_Markets()
|
||||
{
|
||||
var result = await _service.GetMarkets(_web3);
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Multiple_MarketsInfos_With_Multicall()
|
||||
{
|
||||
// Act
|
||||
var result = await _service.GetMarketInfosAsync(_web3);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.NotEmpty(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Single_MarketInfos()
|
||||
{
|
||||
var result = await _service.GetMarketInfo(_web3);
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Single_FundingRate()
|
||||
{
|
||||
var result = await _service.GetFundingRate(_web3);
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Market_Token_Price()
|
||||
{
|
||||
var result = await _service.GetMarketTokenPrice(_web3);
|
||||
var resultMaximized = await _service.GetMarketTokenPrice(_web3, false);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(resultMaximized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_IsMarket_Disabled()
|
||||
{
|
||||
var result = await _service.GetIsMarketDisabled(_web3);
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_Long_Interest_Amount()
|
||||
{
|
||||
var result = await _service.GetLongInterestAmount(_web3);
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_FundigRates()
|
||||
{
|
||||
var result = await _service.GetFundingRates(_web3);
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Helpers_Should_Validate_Exact_Same_Address()
|
||||
{
|
||||
var address = "0x47904963Fc8b2340414262125aF798B9655E58Cd";
|
||||
var address2 = "0x47904963fc8b2340414262125aF798B9655E58Cd";
|
||||
|
||||
Assert.True(GmxV2Helpers.SameAddress(address, address2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Return_Correct_Long_Key()
|
||||
{
|
||||
var expectedKey = "0xaaf79028722fd65633cdf994a4a10b0bd349761062506c4bb6a0489956ba5d3f";
|
||||
var keys = GmxKeysService.GetMarketKeys(Constants.GMX.Markets.BTCUSDC);
|
||||
|
||||
Assert.NotNull(keys);
|
||||
Assert.Equal(expectedKey, keys.LongInterestUsingLongToken);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,9 @@ public class EvmManager : IEvmManager
|
||||
_web3 = new Web3(defaultChain.RpcUrl);
|
||||
_httpClient = new HttpClient();
|
||||
_subgraphs = subgraphs;
|
||||
_geckoPrices = _geckoPrices != null && _geckoPrices.Any() ? _geckoPrices : new Dictionary<string, Dictionary<string, decimal>>();
|
||||
_geckoPrices = _geckoPrices != null && _geckoPrices.Any()
|
||||
? _geckoPrices
|
||||
: new Dictionary<string, Dictionary<string, decimal>>();
|
||||
SetupPrices();
|
||||
}
|
||||
|
||||
@@ -131,7 +133,8 @@ public class EvmManager : IEvmManager
|
||||
return holders;
|
||||
}
|
||||
|
||||
public async Task<List<EventLog<Nethereum.Contracts.Standards.ERC721.ContractDefinition.TransferEventDTO>>> GetNftEvent(string contractAddress, string tokenOwner)
|
||||
public async Task<List<EventLog<Nethereum.Contracts.Standards.ERC721.ContractDefinition.TransferEventDTO>>>
|
||||
GetNftEvent(string contractAddress, string tokenOwner)
|
||||
{
|
||||
return await NftService.GetNftEvent(_web3, tokenOwner, contractAddress);
|
||||
}
|
||||
@@ -186,9 +189,10 @@ public class EvmManager : IEvmManager
|
||||
{
|
||||
var web3 = new Web3(chain.RpcUrl);
|
||||
var etherBalance = Web3.Convert.FromWei(await web3.Eth.GetBalance.SendRequestAsync(account));
|
||||
var etherPrice = (await GetPrices(new List<string> { "ethereum"}))["ethereum"]["usd"];
|
||||
var etherPrice = (await GetPrices(new List<string> { "ethereum" }))["ethereum"]["usd"];
|
||||
|
||||
return new EvmBalance() { Balance = etherBalance, Price = etherPrice, TokenName = "ETH", Value = etherBalance * etherPrice };
|
||||
return new EvmBalance()
|
||||
{ Balance = etherBalance, Price = etherPrice, TokenName = "ETH", Value = etherBalance * etherPrice };
|
||||
}
|
||||
|
||||
public async Task<List<EvmBalance>> GetAllBalances(Domain.Evm.Chain chain, string publicAddress)
|
||||
@@ -213,6 +217,7 @@ public class EvmManager : IEvmManager
|
||||
// TODO : handle exception
|
||||
}
|
||||
}
|
||||
|
||||
var etherBalance = await GetEtherBalance(chain, publicAddress);
|
||||
etherBalance.Chain = chain;
|
||||
balances.Add(etherBalance);
|
||||
@@ -267,7 +272,8 @@ public class EvmManager : IEvmManager
|
||||
return evmBalance;
|
||||
}
|
||||
|
||||
public async Task<List<EvmBalance>> GetBalances(Domain.Evm.Chain chain, int page, int pageSize, string publicAddress)
|
||||
public async Task<List<EvmBalance>> GetBalances(Domain.Evm.Chain chain, int page, int pageSize,
|
||||
string publicAddress)
|
||||
{
|
||||
var callList = new List<IMulticallInputOutput>();
|
||||
var startItem = (page * pageSize);
|
||||
@@ -281,6 +287,7 @@ public class EvmManager : IEvmManager
|
||||
tokens[i].Address);
|
||||
callList.Add(call);
|
||||
}
|
||||
|
||||
var evmTokens = new List<(EvmBalance Balance, GeckoToken GeckoToken)>();
|
||||
|
||||
try
|
||||
@@ -292,7 +299,8 @@ public class EvmManager : IEvmManager
|
||||
|
||||
for (int i = startItem; i < totaItemsToFetch; i++)
|
||||
{
|
||||
var balance = ((MulticallInputOutput<BalanceOfFunction, BalanceOfOutputDTO>)callList[i - startItem]).Output.Balance;
|
||||
var balance = ((MulticallInputOutput<BalanceOfFunction, BalanceOfOutputDTO>)callList[i - startItem])
|
||||
.Output.Balance;
|
||||
if (balance > 0)
|
||||
{
|
||||
var tokenBalance = new EvmBalance()
|
||||
@@ -303,7 +311,8 @@ public class EvmManager : IEvmManager
|
||||
Chain = chain
|
||||
};
|
||||
|
||||
var geckoToken = geckoTokens.FirstOrDefault(x => string.Equals(x.Symbol, tokens[i].Symbol, StringComparison.InvariantCultureIgnoreCase));
|
||||
var geckoToken = geckoTokens.FirstOrDefault(x =>
|
||||
string.Equals(x.Symbol, tokens[i].Symbol, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
evmTokens.Add((tokenBalance, geckoToken));
|
||||
}
|
||||
@@ -324,7 +333,6 @@ public class EvmManager : IEvmManager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -338,7 +346,8 @@ public class EvmManager : IEvmManager
|
||||
public async Task<Dictionary<string, Dictionary<string, decimal>>> GetPrices(List<string> geckoIds)
|
||||
{
|
||||
var idsCombined = string.Join(",", geckoIds);
|
||||
return await _httpClient.GetFromJsonAsync<Dictionary<string, Dictionary<string, decimal>>>("https://api.coingecko.com/api/v3/simple/price?ids=" + idsCombined + "&vs_currencies=usd");
|
||||
return await _httpClient.GetFromJsonAsync<Dictionary<string, Dictionary<string, decimal>>>(
|
||||
"https://api.coingecko.com/api/v3/simple/price?ids=" + idsCombined + "&vs_currencies=usd");
|
||||
}
|
||||
|
||||
public async Task<List<EvmBalance>> GetAllBalancesOnAllChain(string publicAddress)
|
||||
@@ -354,11 +363,12 @@ public class EvmManager : IEvmManager
|
||||
return chainBalances;
|
||||
}
|
||||
|
||||
public async Task<List<Candle>> GetCandles(SubgraphProvider subgraphProvider, Ticker ticker, DateTime startDate, Timeframe timeframe)
|
||||
public async Task<List<Candle>> GetCandles(SubgraphProvider subgraphProvider, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe)
|
||||
{
|
||||
|
||||
string gmxTimeframe = GmxHelpers.GeTimeframe(timeframe);
|
||||
var gmxPrices = await _httpClient.GetFromJsonAsync<GmxPrices>($"https://stats.gmx.io/api/candles/{ticker}?preferableChainId=42161&period={gmxTimeframe}&from={startDate.ToUnixTimestamp()}&preferableSource=fast");
|
||||
var gmxPrices = await _httpClient.GetFromJsonAsync<GmxPrices>(
|
||||
$"https://stats.gmx.io/api/candles/{ticker}?preferableChainId=42161&period={gmxTimeframe}&from={startDate.ToUnixTimestamp()}&preferableSource=fast");
|
||||
//var subgraph = _subgraphs.First(s => s.GetProvider() == subgraphProvider);
|
||||
//var prices = await subgraph.GetPrices(ticker, startDate, timeframe);
|
||||
|
||||
@@ -401,7 +411,8 @@ public class EvmManager : IEvmManager
|
||||
|
||||
public async Task<Candle> GetCandle(SubgraphProvider subgraphProvider, Ticker ticker)
|
||||
{
|
||||
var lastPrices = await GetCandles(subgraphProvider, ticker, DateTime.UtcNow.AddMinutes(-15), Timeframe.FiveMinutes);
|
||||
var lastPrices = await GetCandles(subgraphProvider, ticker, DateTime.UtcNow.AddMinutes(-15),
|
||||
Timeframe.FiveMinutes);
|
||||
return lastPrices.Last();
|
||||
}
|
||||
|
||||
@@ -482,7 +493,6 @@ public class EvmManager : IEvmManager
|
||||
string receiverAddress,
|
||||
Web3 web3)
|
||||
{
|
||||
|
||||
var contractAddress = TokenService.GetContractAddress(ticker);
|
||||
var transactionMessage = new TransferFunction
|
||||
{
|
||||
@@ -495,7 +505,8 @@ public class EvmManager : IEvmManager
|
||||
var transferReceipt =
|
||||
await transferHandler.SendRequestAndWaitForReceiptAsync(contractAddress, transactionMessage);
|
||||
|
||||
var transaction = await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(transferReceipt.TransactionHash);
|
||||
var transaction =
|
||||
await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(transferReceipt.TransactionHash);
|
||||
return transaction != null;
|
||||
}
|
||||
|
||||
@@ -523,7 +534,6 @@ public class EvmManager : IEvmManager
|
||||
try
|
||||
{
|
||||
trade = await GmxService.IncreasePosition(web3, account.Key, ticker, direction, price, quantity, leverage);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -558,9 +568,9 @@ public class EvmManager : IEvmManager
|
||||
return trade;
|
||||
}
|
||||
|
||||
public async Task<Trade> DecreaseOrder(Account account, TradeType tradeType, Ticker ticker, TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
public async Task<Trade> DecreaseOrder(Account account, TradeType tradeType, Ticker ticker,
|
||||
TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
{
|
||||
|
||||
var wallet = new Wallet(account.Secret, _password).GetAccount(account.Key);
|
||||
var chain = ChainService.GetChain(Constants.Chains.Arbitrum);
|
||||
var web3 = new Web3(wallet, chain.RpcUrl);
|
||||
@@ -568,7 +578,8 @@ public class EvmManager : IEvmManager
|
||||
Trade trade = null;
|
||||
try
|
||||
{
|
||||
trade = await GmxService.DecreaseOrder(web3, tradeType, account.Key, ticker, direction, price, quantity, leverage);
|
||||
trade = await GmxService.DecreaseOrder(web3, tradeType, account.Key, ticker, direction, price, quantity,
|
||||
leverage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -591,13 +602,14 @@ public class EvmManager : IEvmManager
|
||||
return await GmxService.GetTrade(web3, reference, ticker);
|
||||
}
|
||||
|
||||
public Task<List<FundingRate>> GetFundingRates()
|
||||
public async Task<List<FundingRate>> GetFundingRates()
|
||||
{
|
||||
// Call GMX v2
|
||||
// Call hyperliquid
|
||||
var chain = ChainService.GetChain(Constants.Chains.Arbitrum);
|
||||
var web3 = new Web3(chain.RpcUrl);
|
||||
var service = new GmxV2Service();
|
||||
var fundingRates = await service.GetFundingRates(web3);
|
||||
|
||||
// Map the results
|
||||
return Task.FromResult(new List<FundingRate>());
|
||||
return fundingRates;
|
||||
}
|
||||
|
||||
public async Task<decimal> QuantityInPosition(string chainName, string publicAddress, Ticker ticker)
|
||||
@@ -626,5 +638,4 @@ public class EvmManager : IEvmManager
|
||||
|
||||
return GmxHelpers.Map(orders, ticker);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,20 +7,23 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GraphQL.Client" Version="6.0.5" />
|
||||
<PackageReference Include="GraphQL.Client.Abstractions" Version="6.0.5" />
|
||||
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="6.0.5" />
|
||||
<PackageReference Include="GraphQL.Query.Builder" Version="2.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="NBitcoin" Version="7.0.36" />
|
||||
<PackageReference Include="Nethereum.HdWallet" Version="4.20.0" />
|
||||
<PackageReference Include="Nethereum.StandardTokenEIP20" Version="4.20.0" />
|
||||
<PackageReference Include="Nethereum.Web3" Version="4.20.0" />
|
||||
<PackageReference Include="GraphQL.Client" Version="6.0.5"/>
|
||||
<PackageReference Include="GraphQL.Client.Abstractions" Version="6.0.5"/>
|
||||
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="6.0.5"/>
|
||||
<PackageReference Include="GraphQL.Query.Builder" Version="2.0.2"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1"/>
|
||||
<PackageReference Include="NBitcoin" Version="7.0.36"/>
|
||||
<PackageReference Include="Nethereum.HdWallet" Version="4.20.0"/>
|
||||
<PackageReference Include="Nethereum.Hex" Version="4.21.3"/>
|
||||
<PackageReference Include="Nethereum.StandardTokenEIP20" Version="4.20.0"/>
|
||||
<PackageReference Include="Nethereum.Web3" Version="4.21.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Managing.Application.Abstractions\Managing.Application.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\Managing.Tools.ABI\Managing.Tools.ABI.csproj" />
|
||||
<ProjectReference Include="..\Managing.ABI.GmxV2\Managing.ABI.GmxV2.csproj"/>
|
||||
<ProjectReference Include="..\Managing.Application.Abstractions\Managing.Application.Abstractions.csproj"/>
|
||||
<ProjectReference Include="..\Managing.Tools.ABI\Managing.Tools.ABI.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
17
src/Managing.Infrastructure.Web3/Models/Gmx/v2/GmxMarket.cs
Normal file
17
src/Managing.Infrastructure.Web3/Models/Gmx/v2/GmxMarket.cs
Normal 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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
110
src/Managing.Infrastructure.Web3/Models/Gmx/v2/GmxMarketInfos.cs
Normal file
110
src/Managing.Infrastructure.Web3/Models/Gmx/v2/GmxMarketInfos.cs
Normal 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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
|
||||
public class GmxTokenBalances
|
||||
{
|
||||
public Dictionary<string, BigInteger> Balances { get; set; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -54,4 +54,18 @@ public class Arbitrum
|
||||
|
||||
public static string Zero = "0x0000000000000000000000000000000000000000";
|
||||
}
|
||||
|
||||
public class AddressV2
|
||||
{
|
||||
public const string DataStore = "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8";
|
||||
public const string EventEmitter = "0xC8ee91A54287DB53897056e12D9819156D3822Fb";
|
||||
public const string SubaccountRouter = "0x9F48160eDc3Ad78F4cA0E3FDF54A75D8FB228452";
|
||||
public const string ExchangeRouter = "0x69C527fC77291722b52649E45c838e41be8Bf5d5";
|
||||
public const string DepositVault = "0xF89e77e8Dc11691C9e8757e84aaFbCD8A67d7A55";
|
||||
public const string WithdrawalVault = "0x0628D46b5D145f183AdB6Ef1f2c97eD1C4701C55";
|
||||
public const string OrderVault = "0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5";
|
||||
public const string Reader = "0x5Ca84c34a381434786738735265b9f3FD814b824";
|
||||
public const string SyntheticsRouter = "0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6";
|
||||
public const string Multicall = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,8 @@ public static class ChainService
|
||||
return new Chain()
|
||||
{
|
||||
Name = Constants.Chains.Arbitrum,
|
||||
RpcUrl = RPC_ARBITRUM
|
||||
RpcUrl = RPC_ARBITRUM,
|
||||
ChainId = 42161
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,7 +47,8 @@ public static class ChainService
|
||||
return new Chain()
|
||||
{
|
||||
Name = Constants.Chains.Ethereum,
|
||||
RpcUrl = RPC_ETHEREUM
|
||||
RpcUrl = RPC_ETHEREUM,
|
||||
ChainId = 1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx;
|
||||
using Managing.Infrastructure.Evm.Referentials;
|
||||
using Nethereum.Web3;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Managing.ABI.GmxV2.Reader.ContractDefinition;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
using Managing.Infrastructure.Evm.Referentials;
|
||||
using Nethereum.Hex.HexConvertors.Extensions;
|
||||
using Nethereum.Web3;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Services.Gmx;
|
||||
|
||||
public static class GmxHelpers
|
||||
{
|
||||
|
||||
public static decimal GetQuantityForLeverage(decimal quantity, decimal? leverage)
|
||||
{
|
||||
return leverage.HasValue ? leverage.Value * quantity : quantity;
|
||||
}
|
||||
|
||||
public static (List<string> CollateralTokens, List<string> IndexTokens, List<bool> IsLong) GetPositionQueryData(List<string> contractAddress)
|
||||
public static (List<string> CollateralTokens, List<string> IndexTokens, List<bool> IsLong) GetPositionQueryData(
|
||||
List<string> contractAddress)
|
||||
{
|
||||
var collateralToken = new List<string>();
|
||||
var indexTokens = new List<string>();
|
||||
@@ -68,6 +73,7 @@ public static class GmxHelpers
|
||||
{
|
||||
priceBasisPoints = basisPointDivisor + allowedSlippage;
|
||||
}
|
||||
|
||||
var test = Web3.Convert.ToWei(price, toDecimal) * new BigInteger(priceBasisPoints);
|
||||
|
||||
var priceLimit = test / Web3.Convert.ToWei(basisPointDivisor, 0);
|
||||
@@ -83,8 +89,8 @@ public static class GmxHelpers
|
||||
internal static List<Trade> Map(List<GmxOrder> orders, Ticker ticker)
|
||||
{
|
||||
return orders.ConvertAll(order => Map(order, ticker));
|
||||
|
||||
}
|
||||
|
||||
private static Trade Map(GmxOrder order, Ticker ticker)
|
||||
{
|
||||
var trade = new Trade(DateTime.UtcNow,
|
||||
@@ -136,4 +142,119 @@ public static class GmxHelpers
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetRandomAddress()
|
||||
{
|
||||
var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
|
||||
var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
|
||||
var account = new Nethereum.Signer.EthECKey(privateKey).GetPublicAddress();
|
||||
return account;
|
||||
}
|
||||
|
||||
internal static MarketPrices GetContractMarketPrices(List<GmxTokenData> tokens, GmxMarket market)
|
||||
{
|
||||
var indexToken = tokens.First(t => GmxV2Helpers.SameAddress(t.Address, market.IndexToken));
|
||||
var longToken = tokens.First(t => GmxV2Helpers.SameAddress(t.Address, market.LongToken));
|
||||
var shortToken = tokens.First(t => GmxV2Helpers.SameAddress(t.Address, market.ShortToken));
|
||||
|
||||
return new MarketPrices()
|
||||
{
|
||||
IndexTokenPrice = ConvertToContractTokenPrice(indexToken.Price, indexToken.Decimals),
|
||||
LongTokenPrice = ConvertToContractTokenPrice(longToken.Price, longToken.Decimals),
|
||||
ShortTokenPrice = ConvertToContractTokenPrice(shortToken.Price, shortToken.Decimals)
|
||||
};
|
||||
}
|
||||
|
||||
private static MarketPrice ConvertToContractTokenPrice(MarketPrice marketPrice, int tokenDecimals)
|
||||
{
|
||||
var price = new MarketPrice();
|
||||
price.Min = ConvertToContractPrice(tokenDecimals, marketPrice.Min);
|
||||
price.Max = ConvertToContractPrice(tokenDecimals, marketPrice.Max);
|
||||
return price;
|
||||
}
|
||||
|
||||
private static BigInteger ConvertToContractPrice(decimal price, BigInteger tokenDecimals)
|
||||
{
|
||||
// Convert the decimal price to a BigInteger, scaling it up to maintain precision.
|
||||
BigInteger scaledPrice = new BigInteger(price * (decimal)Math.Pow(10, (double)tokenDecimals));
|
||||
|
||||
// Return the scaled price directly since it's already adjusted for token decimals.
|
||||
return scaledPrice;
|
||||
}
|
||||
|
||||
public static Ticker GetTicker(string marketName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var indexToken = marketName.Split(' ')[0];
|
||||
var ticker = MiscExtensions.ParseEnum<Ticker>(indexToken);
|
||||
return ticker;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Ticker.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public static decimal FormatAmount(BigInteger? amount, int tokenDecimals, int? displayDecimals = null,
|
||||
bool useCommas = false, string defaultValue = "...")
|
||||
{
|
||||
if (amount == null || amount == BigInteger.Zero)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (displayDecimals == null)
|
||||
{
|
||||
displayDecimals = 4;
|
||||
}
|
||||
|
||||
var amountStr = Web3.Convert.FromWei(amount.Value, tokenDecimals).ToString(CultureInfo.InvariantCulture);
|
||||
amountStr = LimitDecimals(amountStr, displayDecimals.Value);
|
||||
|
||||
if (displayDecimals != 0)
|
||||
{
|
||||
amountStr = PadDecimals(amountStr, displayDecimals.Value);
|
||||
}
|
||||
|
||||
if (useCommas)
|
||||
{
|
||||
amountStr = NumberWithCommas(amountStr);
|
||||
}
|
||||
|
||||
return decimal.Parse(amountStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private static string LimitDecimals(string amountStr, int displayDecimals)
|
||||
{
|
||||
var parts = amountStr.Split('.');
|
||||
if (parts.Length == 2 && parts[1].Length > displayDecimals)
|
||||
{
|
||||
parts[1] = parts[1].Substring(0, displayDecimals);
|
||||
}
|
||||
|
||||
return string.Join(".", parts);
|
||||
}
|
||||
|
||||
private static string PadDecimals(string amountStr, int displayDecimals)
|
||||
{
|
||||
var parts = amountStr.Split('.');
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
return amountStr + "." + new string('0', displayDecimals);
|
||||
}
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
return parts[0] + "." + parts[1].PadRight(displayDecimals, '0');
|
||||
}
|
||||
|
||||
return amountStr;
|
||||
}
|
||||
|
||||
private static string NumberWithCommas(string amountStr)
|
||||
{
|
||||
var parts = amountStr.Split('.');
|
||||
parts[0] = int.Parse(parts[0]).ToString("N0", CultureInfo.InvariantCulture);
|
||||
return string.Join(".", parts);
|
||||
}
|
||||
}
|
||||
112
src/Managing.Infrastructure.Web3/Services/Gmx/GmxKeysService.cs
Normal file
112
src/Managing.Infrastructure.Web3/Services/Gmx/GmxKeysService.cs
Normal file
File diff suppressed because one or more lines are too long
@@ -1,10 +1,12 @@
|
||||
using Managing.Core;
|
||||
using System.Numerics;
|
||||
using Managing.ABI.GmxV2.Reader.ContractDefinition;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
using Managing.Infrastructure.Evm.Referentials;
|
||||
using Nethereum.Web3;
|
||||
using System.Numerics;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Services.Gmx;
|
||||
@@ -174,4 +176,73 @@ public static class GmxMappers
|
||||
Timeframe = timeframe
|
||||
};
|
||||
}
|
||||
|
||||
internal static GmxMarket Map(MarketInfo infos)
|
||||
{
|
||||
var indexToken =
|
||||
TokenV2Service.GetTokenByAddress(TokenV2Service.ConvertTokenAddress(infos.Market.IndexToken, "native"));
|
||||
var longToken = TokenV2Service.GetTokenByAddress(infos.Market.LongToken);
|
||||
var shortToken = TokenV2Service.GetTokenByAddress(infos.Market.ShortToken);
|
||||
var isSameCollaterals = infos.Market.LongToken == infos.Market.ShortToken;
|
||||
var isSpotOnly = infos.Market.IndexToken == Nethereum.Util.AddressUtil.ZERO_ADDRESS;
|
||||
var name = TokenV2Service.GetMarketFullName(indexToken.Address, longToken.Address, shortToken.Address,
|
||||
isSpotOnly);
|
||||
var symbol = indexToken.Symbol;
|
||||
|
||||
return new GmxMarket
|
||||
{
|
||||
MarketToken = infos.Market.MarketToken,
|
||||
IndexToken = infos.Market.IndexToken,
|
||||
LongToken = infos.Market.LongToken,
|
||||
ShortToken = infos.Market.ShortToken,
|
||||
Name = name,
|
||||
Symbol = symbol,
|
||||
IsSpotOnly = isSpotOnly,
|
||||
IsSameCollaterals = isSameCollaterals,
|
||||
FundingFactorPerSecond = infos.NextFunding.FundingFactorPerSecond,
|
||||
LongsPayShorts = infos.NextFunding.LongsPayShorts
|
||||
};
|
||||
}
|
||||
|
||||
public static GmxMarket MapInfos(MarketsProps infos)
|
||||
{
|
||||
var indexToken =
|
||||
TokenV2Service.GetTokenByAddress(TokenV2Service.ConvertTokenAddress(infos.IndexToken, "native"));
|
||||
var longToken = TokenV2Service.GetTokenByAddress(infos.LongToken);
|
||||
var shortToken = TokenV2Service.GetTokenByAddress(infos.ShortToken);
|
||||
var isSameCollaterals = infos.LongToken == infos.ShortToken;
|
||||
var isSpotOnly = infos.IndexToken == Nethereum.Util.AddressUtil.ZERO_ADDRESS;
|
||||
var name = TokenV2Service.GetMarketFullName(indexToken.Address, longToken.Address, shortToken.Address,
|
||||
isSpotOnly);
|
||||
|
||||
return new GmxMarket
|
||||
{
|
||||
MarketToken = infos.MarketToken,
|
||||
IndexToken = infos.IndexToken,
|
||||
LongToken = infos.LongToken,
|
||||
ShortToken = infos.ShortToken,
|
||||
Name = name,
|
||||
Symbol = indexToken.Symbol,
|
||||
IsSpotOnly = isSpotOnly,
|
||||
IsSameCollaterals = isSameCollaterals,
|
||||
};
|
||||
}
|
||||
|
||||
public static GmxMarketTokenPrice Map(GetMarketTokenPriceOutputDTO response)
|
||||
{
|
||||
return new GmxMarketTokenPrice
|
||||
{
|
||||
LongTokenAmount = response.ReturnValue2.LongTokenAmount,
|
||||
ShortTokenAmount = response.ReturnValue2.ShortTokenAmount,
|
||||
LongTokenUsd = response.ReturnValue2.LongTokenUsd,
|
||||
ShortTokenUsd = response.ReturnValue2.ShortTokenUsd,
|
||||
PoolValue = response.ReturnValue2.PoolValue,
|
||||
LongPnl = response.ReturnValue2.LongPnl,
|
||||
ShortPnl = response.ReturnValue2.ShortPnl,
|
||||
NetPnl = response.ReturnValue2.NetPnl,
|
||||
TotalBorrowingFees = response.ReturnValue2.TotalBorrowingFees,
|
||||
BorrowingFeePoolFactor = response.ReturnValue2.BorrowingFeePoolFactor,
|
||||
ImpactPoolAmount = response.ReturnValue2.ImpactPoolAmount
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
using Managing.Domain.Trades;
|
||||
using System.Numerics;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx;
|
||||
using Managing.Infrastructure.Evm.Referentials;
|
||||
using Managing.Tools.ABI.Reader;
|
||||
using Managing.Tools.ABI.Reader.ContractDefinition;
|
||||
using Managing.Tools.OrderBook;
|
||||
using Managing.Tools.OrderBook.ContractDefinition;
|
||||
using Managing.Tools.OrderBookReader;
|
||||
using Managing.Tools.OrderBookReader.ContractDefinition;
|
||||
using Managing.Tools.PositionRouter;
|
||||
using Managing.Tools.PositionRouter.ContractDefinition;
|
||||
using Managing.Tools.Reader;
|
||||
using Managing.Tools.Reader.ContractDefinition;
|
||||
using Managing.Tools.Router;
|
||||
using Managing.Tools.Router.ContractDefinition;
|
||||
using Nethereum.Contracts.Standards.ERC20;
|
||||
using Nethereum.Contracts.Standards.ERC20.ContractDefinition;
|
||||
using Nethereum.Util;
|
||||
using Nethereum.Web3;
|
||||
using System.Numerics;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Services.Gmx;
|
||||
@@ -98,7 +98,8 @@ public static class GmxService
|
||||
return true;
|
||||
}
|
||||
|
||||
public async static Task<Trade> IncreasePosition(Web3 web3, string publicAddress, Ticker ticker, TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
public async static Task<Trade> IncreasePosition(Web3 web3, string publicAddress, Ticker ticker,
|
||||
TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
{
|
||||
var quantityLeveraged = GmxHelpers.GetQuantityForLeverage(quantity, leverage);
|
||||
var orderBook = new OrderBookService(web3, Arbitrum.Address.OrderBook);
|
||||
@@ -149,7 +150,8 @@ public static class GmxService
|
||||
return trade;
|
||||
}
|
||||
|
||||
public async static Task<Trade> DecreasePosition(Web3 web3, string publicAddress, Ticker ticker, TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
public async static Task<Trade> DecreasePosition(Web3 web3, string publicAddress, Ticker ticker,
|
||||
TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
{
|
||||
var trade = new Trade(DateTime.UtcNow,
|
||||
direction,
|
||||
@@ -212,7 +214,8 @@ public static class GmxService
|
||||
return trade;
|
||||
}
|
||||
|
||||
public static async Task<Trade> DecreaseOrder(Web3 web3, TradeType tradeType, string publicAddress, Ticker ticker, TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
public static async Task<Trade> DecreaseOrder(Web3 web3, TradeType tradeType, string publicAddress, Ticker ticker,
|
||||
TradeDirection direction, decimal price, decimal quantity, decimal? leverage)
|
||||
{
|
||||
var trade = new Trade(DateTime.UtcNow,
|
||||
direction,
|
||||
@@ -318,12 +321,14 @@ public static class GmxService
|
||||
orders.AddRange(increaseOrders);
|
||||
orders.AddRange(decreaseOrders);
|
||||
var contractAddress = TokenService.GetContractAddress(ticker);
|
||||
var ordersFiltered = orders.Where(o => string.Equals(o.IndexToken, contractAddress, StringComparison.CurrentCultureIgnoreCase));
|
||||
var ordersFiltered = orders.Where(o =>
|
||||
string.Equals(o.IndexToken, contractAddress, StringComparison.CurrentCultureIgnoreCase));
|
||||
|
||||
return ordersFiltered.ToList();
|
||||
}
|
||||
|
||||
private static async Task<List<GmxOrder>> GetIncreaseOrders(OrderBookReaderService orderBookReader, string publicAddress, int lastIndex)
|
||||
private static async Task<List<GmxOrder>> GetIncreaseOrders(OrderBookReaderService orderBookReader,
|
||||
string publicAddress, int lastIndex)
|
||||
{
|
||||
var increaseIndex = GmxHelpers.GetIndexesRange(lastIndex);
|
||||
var increaseOrdersFunction = new GetIncreaseOrdersFunction
|
||||
@@ -338,7 +343,8 @@ public static class GmxService
|
||||
return GmxMappers.MapIncrease(increaseOrders.ReturnValue1, increaseOrders.ReturnValue2, increaseIndex);
|
||||
}
|
||||
|
||||
private static async Task<List<GmxOrder>> GetDecreaseOrders(OrderBookReaderService orderBookReader, string publicAddress, int lastIndex)
|
||||
private static async Task<List<GmxOrder>> GetDecreaseOrders(OrderBookReaderService orderBookReader,
|
||||
string publicAddress, int lastIndex)
|
||||
{
|
||||
var increaseIndex = GmxHelpers.GetIndexesRange(lastIndex);
|
||||
var increaseOrdersFunction = new GetDecreaseOrdersFunction
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Numerics;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Nethereum.ABI;
|
||||
using Nethereum.Util;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
|
||||
public class GmxV2Helpers
|
||||
{
|
||||
private readonly MemoryCache _dataCache = new MemoryCache(new MemoryCacheOptions { SizeLimit = 10000 });
|
||||
private readonly MemoryCache _stringCache = new MemoryCache(new MemoryCacheOptions { SizeLimit = 10000 });
|
||||
private readonly ABIEncode _abiEncode = new ABIEncode();
|
||||
private readonly MemoryCacheEntryOptions _absoluteExpiration = new MemoryCacheEntryOptions { Size = 1 };
|
||||
|
||||
|
||||
public byte[] HashData(string[] dataTypes, object[] dataValues)
|
||||
{
|
||||
var key = GenerateKey(dataTypes, dataValues);
|
||||
|
||||
if (_dataCache.TryGetValue(key, out byte[] cachedHash))
|
||||
{
|
||||
return cachedHash;
|
||||
}
|
||||
|
||||
var abiValues = new List<ABIValue>();
|
||||
foreach (var dataType in dataTypes)
|
||||
{
|
||||
var abiValue = new ABIValue(dataType, dataValues[dataTypes.ToList().IndexOf(dataType)]);
|
||||
abiValues.Add(abiValue);
|
||||
}
|
||||
|
||||
var abiEncode = new ABIEncode();
|
||||
var encoded = abiEncode.GetABIEncoded(abiValues.ToArray());
|
||||
var hash = new Sha3Keccack().CalculateHash(encoded);
|
||||
_dataCache.Set(key, hash, _absoluteExpiration);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
public byte[] HashString(string input)
|
||||
{
|
||||
if (_stringCache.TryGetValue(input, out byte[] cachedHash))
|
||||
{
|
||||
return cachedHash;
|
||||
}
|
||||
|
||||
// Adjusted to directly work with byte arrays
|
||||
var hash = HashData(new[] { "string" }, new string[] { input });
|
||||
_stringCache.Set(input, hash, _absoluteExpiration);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
private string GenerateKey(string[] dataTypes, object[] dataValues)
|
||||
{
|
||||
var combined = new List<string>();
|
||||
for (int i = 0; i < dataTypes.Length; i++)
|
||||
{
|
||||
combined.Add($"{dataTypes[i]}:{(dataValues[i] is BigInteger bigInt ? bigInt.ToString() : dataValues[i])}");
|
||||
}
|
||||
|
||||
return string.Join(",", combined);
|
||||
}
|
||||
|
||||
public static bool SameAddress(string address, string address2)
|
||||
{
|
||||
return address.ToLower() == address2.ToLower();
|
||||
}
|
||||
}
|
||||
531
src/Managing.Infrastructure.Web3/Services/Gmx/GmxV2Service.cs
Normal file
531
src/Managing.Infrastructure.Web3/Services/Gmx/GmxV2Service.cs
Normal file
@@ -0,0 +1,531 @@
|
||||
using System.Numerics;
|
||||
using Managing.ABI.GmxV2.DataStore;
|
||||
using Managing.ABI.GmxV2.DataStore.ContractDefinition;
|
||||
using Managing.ABI.GmxV2.Multicall3.ContractDefinition;
|
||||
using Managing.ABI.GmxV2.Reader;
|
||||
using Managing.ABI.GmxV2.Reader.ContractDefinition;
|
||||
using Managing.Common;
|
||||
using Managing.Domain.Statistics;
|
||||
using Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
using Managing.Infrastructure.Evm.Referentials;
|
||||
using Managing.Infrastructure.Evm.Services.Gmx;
|
||||
using Nethereum.Contracts;
|
||||
using Nethereum.Contracts.Standards.ERC20.ContractDefinition;
|
||||
using Nethereum.Hex.HexConvertors.Extensions;
|
||||
using Nethereum.Web3;
|
||||
|
||||
public class GmxV2Service
|
||||
{
|
||||
private readonly GmxV2Helpers _helpers = new GmxV2Helpers();
|
||||
|
||||
public GmxV2Service()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<object> GetMarkets(Web3 web3)
|
||||
{
|
||||
var reader = new ReaderService(web3, Arbitrum.AddressV2.Reader);
|
||||
var result = await reader.GetMarketsQueryAsync(Arbitrum.AddressV2.DataStore, 0, 100);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<GmxMarket>> GetMarketsAsync(Web3 web3)
|
||||
{
|
||||
var getMarketCallData = new GetMarketsFunction
|
||||
{
|
||||
DataStore = Arbitrum.AddressV2.DataStore,
|
||||
Start = 0,
|
||||
End = 100
|
||||
}.GetCallData();
|
||||
|
||||
var call1 = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.Reader,
|
||||
CallData = getMarketCallData
|
||||
};
|
||||
|
||||
var aggregateFunction = new AggregateFunction();
|
||||
aggregateFunction.Calls = new List<Call>();
|
||||
aggregateFunction.Calls.Add(call1);
|
||||
|
||||
var queryHandler = web3.Eth.GetContractQueryHandler<AggregateFunction>();
|
||||
var returnCalls = await queryHandler
|
||||
.QueryDeserializingToObjectAsync<AggregateOutputDTO>(aggregateFunction, Arbitrum.AddressV2.Multicall)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var markets = new GetMarketsOutputDTO().DecodeOutput(returnCalls.ReturnData[0].ToHex());
|
||||
var result = new List<GmxMarket>();
|
||||
foreach (var market in markets.ReturnValue1)
|
||||
{
|
||||
try
|
||||
{
|
||||
result.Add(GmxMappers.MapInfos(market));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<GmxMarketInfo> GetMarketInfo(Web3 web3)
|
||||
{
|
||||
var reader = new ReaderService(web3, Arbitrum.AddressV2.Reader);
|
||||
var market = (await GetMarketsAsync(web3)).First();
|
||||
var tokensData = await GetTokensData(web3);
|
||||
var marketPrices = GmxHelpers.GetContractMarketPrices(tokensData, market);
|
||||
var response =
|
||||
await reader.GetMarketInfoQueryAsync(Arbitrum.AddressV2.DataStore, marketPrices, market.MarketToken);
|
||||
|
||||
// Get hashed key to call datastore
|
||||
var marketKeys = GmxKeysService.GetMarketKeys(market.MarketToken);
|
||||
var longInterestUsingLongTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.LongInterestUsingLongToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var longInterestUsingLongTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = longInterestUsingLongTokenCallData
|
||||
};
|
||||
var longInterestUsingShortTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.LongInterestUsingShortToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var longInterestUsingShortTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = longInterestUsingShortTokenCallData
|
||||
};
|
||||
var shortInterestUsingLongTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.ShortInterestUsingLongToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var shortInterestUsingLongTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = shortInterestUsingLongTokenCallData
|
||||
};
|
||||
var shortInterestUsingShortTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.ShortInterestUsingShortToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var shortInterestUsingShortTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = shortInterestUsingShortTokenCallData
|
||||
};
|
||||
|
||||
var dataStoreMulticall = new AggregateFunction();
|
||||
dataStoreMulticall.Calls = new List<Call>();
|
||||
dataStoreMulticall.Calls.Add(longInterestUsingLongTokenCall);
|
||||
dataStoreMulticall.Calls.Add(longInterestUsingShortTokenCall);
|
||||
dataStoreMulticall.Calls.Add(shortInterestUsingLongTokenCall);
|
||||
dataStoreMulticall.Calls.Add(shortInterestUsingShortTokenCall);
|
||||
var queryHandler = web3.Eth.GetContractQueryHandler<AggregateFunction>();
|
||||
var returnCalls = await queryHandler
|
||||
.QueryDeserializingToObjectAsync<AggregateOutputDTO>(dataStoreMulticall, Arbitrum.AddressV2.Multicall)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var marketInfos = GmxMappers.Map(response.ReturnValue1);
|
||||
var result = new GmxMarketInfo()
|
||||
{
|
||||
Market = marketInfos,
|
||||
Infos = DecodeFundingRateOutput(returnCalls, marketInfos.IsSameCollaterals)
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<GmxMarketTokenPrice> GetMarketTokenPrice(Web3 web3, bool maximize = true)
|
||||
{
|
||||
var reader = new ReaderService(web3, Arbitrum.AddressV2.Reader);
|
||||
var market = (await GetMarketsAsync(web3)).First();
|
||||
var tokensData = await GetTokensData(web3);
|
||||
var marketPrices = GmxHelpers.GetContractMarketPrices(tokensData, market);
|
||||
var marketProps = new MarketsProps()
|
||||
{
|
||||
MarketToken = market.MarketToken,
|
||||
IndexToken = market.IndexToken,
|
||||
LongToken = market.LongToken,
|
||||
ShortToken = market.ShortToken
|
||||
};
|
||||
|
||||
var response = await reader.GetMarketTokenPriceQueryAsync(Arbitrum.AddressV2.DataStore, marketProps,
|
||||
marketPrices.IndexTokenPrice, marketPrices.LongTokenPrice, marketPrices.ShortTokenPrice,
|
||||
_helpers.HashString(Constants.GMX.MAX_PNL_FACTOR_FOR_TRADERS), maximize);
|
||||
|
||||
return GmxMappers.Map(response);
|
||||
}
|
||||
|
||||
public async Task<bool> GetIsMarketDisabled(Web3 web3)
|
||||
{
|
||||
var dataStoreService = new DataStoreService(web3, Arbitrum.AddressV2.DataStore);
|
||||
var market = (await GetMarketsAsync(web3)).First();
|
||||
var hashString = _helpers.HashString(Constants.GMX.MARKET_DISABLED_KEY);
|
||||
var response = await dataStoreService.GetBoolQueryAsync(_helpers.HashData(
|
||||
new[] { "bytes32", "address" },
|
||||
new object[] { hashString, market.MarketToken }));
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<BigInteger> GetLongInterestAmount(Web3 web3)
|
||||
{
|
||||
var dataStoreService = new DataStoreService(web3, Arbitrum.AddressV2.DataStore);
|
||||
var market = (await GetMarketsAsync(web3)).First();
|
||||
var keys = GmxKeysService.GetMarketKeys(market.MarketToken);
|
||||
var response = await dataStoreService.GetUintQueryAsync(keys.LongInterestUsingLongToken.HexToByteArray());
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<List<GmxMarketInfo>> GetMarketInfosAsync(Web3 web3)
|
||||
{
|
||||
var markets = await GetMarketsAsync(web3);
|
||||
var readerResult = new List<GmxMarketInfo>();
|
||||
foreach (var market in markets)
|
||||
{
|
||||
var tokensData = await GetTokensData(web3);
|
||||
var marketPrices = GmxHelpers.GetContractMarketPrices(tokensData, market);
|
||||
var marketProps = new MarketsProps()
|
||||
{
|
||||
MarketToken = market.MarketToken,
|
||||
IndexToken = market.IndexToken,
|
||||
LongToken = market.LongToken,
|
||||
ShortToken = market.ShortToken
|
||||
};
|
||||
var getMarketInfoCallData = new GetMarketInfoFunction
|
||||
{
|
||||
DataStore = Arbitrum.AddressV2.DataStore,
|
||||
Prices = marketPrices,
|
||||
MarketKey = market.MarketToken
|
||||
}.GetCallData();
|
||||
var getMarketInfoCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.Reader,
|
||||
CallData = getMarketInfoCallData
|
||||
};
|
||||
var getMarketTokenPriceCallData = new GetMarketTokenPriceFunction
|
||||
{
|
||||
DataStore = Arbitrum.AddressV2.DataStore,
|
||||
Market = marketProps,
|
||||
IndexTokenPrice = marketPrices.IndexTokenPrice,
|
||||
LongTokenPrice = marketPrices.LongTokenPrice,
|
||||
ShortTokenPrice = marketPrices.ShortTokenPrice,
|
||||
PnlFactorType = _helpers.HashString(Constants.GMX.MAX_PNL_FACTOR_FOR_TRADERS),
|
||||
Maximize = true
|
||||
}.GetCallData();
|
||||
var getMarketTokenPriceCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.Reader,
|
||||
CallData = getMarketTokenPriceCallData
|
||||
};
|
||||
var getMarketTokenPriceMinCallData = new GetMarketTokenPriceFunction
|
||||
{
|
||||
DataStore = Arbitrum.AddressV2.DataStore,
|
||||
Market = marketProps,
|
||||
IndexTokenPrice = marketPrices.IndexTokenPrice,
|
||||
LongTokenPrice = marketPrices.LongTokenPrice,
|
||||
ShortTokenPrice = marketPrices.ShortTokenPrice,
|
||||
PnlFactorType = _helpers.HashString(Constants.GMX.MAX_PNL_FACTOR_FOR_TRADERS),
|
||||
Maximize = false
|
||||
}.GetCallData();
|
||||
var getMarketTokenPriceMinCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.Reader,
|
||||
CallData = getMarketTokenPriceMinCallData
|
||||
};
|
||||
|
||||
var readerMulticall = new AggregateFunction();
|
||||
readerMulticall.Calls = new List<Call>();
|
||||
readerMulticall.Calls.Add(getMarketInfoCall);
|
||||
readerMulticall.Calls.Add(getMarketTokenPriceCall);
|
||||
readerMulticall.Calls.Add(getMarketTokenPriceMinCall);
|
||||
|
||||
var queryHandler = web3.Eth.GetContractQueryHandler<AggregateFunction>();
|
||||
var readerCallResults = await queryHandler
|
||||
.QueryDeserializingToObjectAsync<AggregateOutputDTO>(readerMulticall, Arbitrum.AddressV2.Multicall)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var marketInfo = new GetMarketInfoOutputDTO().DecodeOutput(readerCallResults.ReturnData[0].ToHex());
|
||||
var marketTokenPriceMax =
|
||||
new GetMarketTokenPriceOutputDTO().DecodeOutput(readerCallResults.ReturnData[1].ToHex());
|
||||
var marketTokenPriceMin =
|
||||
new GetMarketTokenPriceOutputDTO().DecodeOutput(readerCallResults.ReturnData[2].ToHex());
|
||||
|
||||
// Get hashed key to call datastore
|
||||
var marketKeys = GmxKeysService.GetMarketKeys(market.MarketToken);
|
||||
if (marketKeys == null)
|
||||
continue;
|
||||
|
||||
var longInterestUsingLongTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.LongInterestUsingLongToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var longInterestUsingLongTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = longInterestUsingLongTokenCallData
|
||||
};
|
||||
var longInterestUsingShortTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.LongInterestUsingShortToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var longInterestUsingShortTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = longInterestUsingShortTokenCallData
|
||||
};
|
||||
var shortInterestUsingLongTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.ShortInterestUsingLongToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var shortInterestUsingLongTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = shortInterestUsingLongTokenCallData
|
||||
};
|
||||
var shortInterestUsingShortTokenCallData = new GetUintFunction()
|
||||
{
|
||||
Key = marketKeys.ShortInterestUsingShortToken.HexToByteArray()
|
||||
}.GetCallData();
|
||||
var shortInterestUsingShortTokenCall = new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.DataStore,
|
||||
CallData = shortInterestUsingShortTokenCallData
|
||||
};
|
||||
|
||||
var dataStoreMulticall = new AggregateFunction();
|
||||
dataStoreMulticall.Calls = new List<Call>();
|
||||
dataStoreMulticall.Calls.Add(longInterestUsingLongTokenCall);
|
||||
dataStoreMulticall.Calls.Add(longInterestUsingShortTokenCall);
|
||||
dataStoreMulticall.Calls.Add(shortInterestUsingLongTokenCall);
|
||||
dataStoreMulticall.Calls.Add(shortInterestUsingShortTokenCall);
|
||||
|
||||
// Call datastore to get market info
|
||||
var dataStoreQueryHandler = web3.Eth.GetContractQueryHandler<AggregateFunction>();
|
||||
var dataStoreCallResults = await dataStoreQueryHandler
|
||||
.QueryDeserializingToObjectAsync<AggregateOutputDTO>(dataStoreMulticall, Arbitrum.AddressV2.Multicall)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var marketInfos = GmxMappers.Map(marketInfo.ReturnValue1);
|
||||
readerResult.Add(new GmxMarketInfo()
|
||||
{
|
||||
Market = marketInfos,
|
||||
Infos = DecodeFundingRateOutput(dataStoreCallResults, marketInfos.IsSameCollaterals),
|
||||
MarketTokenPriceMax = GmxMappers.Map(marketTokenPriceMax),
|
||||
MarketTokenPriceMin = GmxMappers.Map(marketTokenPriceMin)
|
||||
});
|
||||
}
|
||||
|
||||
return readerResult;
|
||||
}
|
||||
|
||||
private GmxMarketInfos DecodeFundingRateOutput(AggregateOutputDTO results, bool isSameCollaterals)
|
||||
{
|
||||
var marketDivisor = new BigInteger(isSameCollaterals ? 2 : 1);
|
||||
var longInterestUsingLongToken =
|
||||
new GetUintOutputDTO().DecodeOutput(results.ReturnData[0].ToHex()).ReturnValue1 / marketDivisor;
|
||||
var longInterestUsingShortToken =
|
||||
new GetUintOutputDTO().DecodeOutput(results.ReturnData[1].ToHex()).ReturnValue1 / marketDivisor;
|
||||
var shortInterestUsingLongToken =
|
||||
new GetUintOutputDTO().DecodeOutput(results.ReturnData[2].ToHex()).ReturnValue1 / marketDivisor;
|
||||
var shortInterestUsingShortToken =
|
||||
new GetUintOutputDTO().DecodeOutput(results.ReturnData[3].ToHex()).ReturnValue1 / marketDivisor;
|
||||
|
||||
var longInterestUsd = longInterestUsingLongToken + longInterestUsingShortToken;
|
||||
var shortInterestUsd = shortInterestUsingLongToken + shortInterestUsingShortToken;
|
||||
|
||||
var marketInfos = new GmxMarketInfos()
|
||||
{
|
||||
LongInterestUsd = longInterestUsd,
|
||||
ShortInterestUsd = shortInterestUsd
|
||||
};
|
||||
return marketInfos;
|
||||
}
|
||||
|
||||
public async Task<List<GmxTokenData>> GetTokensData(Web3 web3)
|
||||
{
|
||||
var tokens = TokenV2Service.GetTokens().ToList();
|
||||
var balances = await GetTokenBalances(web3, tokens);
|
||||
var prices = GetTokenPrices(web3, tokens);
|
||||
var result = new List<GmxTokenData>();
|
||||
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
BigInteger? balance = null;
|
||||
if (balances.Balances != null && balances.Balances.ContainsKey(token.Address))
|
||||
{
|
||||
balance = balances.Balances[token.Address];
|
||||
}
|
||||
|
||||
var price = prices[token.Address].Price;
|
||||
|
||||
var data = new GmxTokenData()
|
||||
{
|
||||
Address = token.Address,
|
||||
Name = token.Name,
|
||||
Symbol = token.Symbol,
|
||||
Decimals = token.Decimals,
|
||||
Price = price,
|
||||
Balance = balance
|
||||
};
|
||||
result.Add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Dictionary<string, GmxTokenPriceData> GetTokenPrices(Web3 web3, List<GmxToken> tokens)
|
||||
{
|
||||
var result = new Dictionary<string, GmxTokenPriceData>();
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
// TODO fetch token price from oracle
|
||||
result.Add(token.Address, new GmxTokenPriceData()
|
||||
{
|
||||
Price = new MarketPrice()
|
||||
{
|
||||
Min = 0,
|
||||
Max = 0
|
||||
},
|
||||
Balance = 0,
|
||||
TotalSupply = 0
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<GmxTokenBalances> GetTokenBalances(Web3 web3, List<GmxToken> tokens, string? account = null)
|
||||
{
|
||||
var result = new GmxTokenBalances();
|
||||
result.Balances = new Dictionary<string, BigInteger>();
|
||||
var aggregateFunction = new AggregateFunction();
|
||||
aggregateFunction.Calls = new List<Call>();
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (token.IsNative)
|
||||
{
|
||||
var nativeBalanceCallData = new GetEthBalanceFunction()
|
||||
{
|
||||
Addr = account ?? Nethereum.Util.AddressUtil.ZERO_ADDRESS
|
||||
}.GetCallData();
|
||||
aggregateFunction.Calls.Add(new Call
|
||||
{
|
||||
Target = Arbitrum.AddressV2.Multicall,
|
||||
CallData = nativeBalanceCallData
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var balanceCallData = new BalanceOfFunction()
|
||||
{
|
||||
Owner = account ?? GmxHelpers.GetRandomAddress()
|
||||
}.GetCallData();
|
||||
aggregateFunction.Calls.Add(new Call
|
||||
{
|
||||
Target = token.Address,
|
||||
CallData = balanceCallData
|
||||
});
|
||||
}
|
||||
|
||||
var queryHandler = web3.Eth.GetContractQueryHandler<AggregateFunction>();
|
||||
var returnCalls = await queryHandler
|
||||
.QueryDeserializingToObjectAsync<AggregateOutputDTO>(aggregateFunction, Arbitrum.AddressV2.Multicall)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var balances = new BalanceOfOutputDTOBase().DecodeOutput(returnCalls.ReturnData[0].ToHex());
|
||||
result.Balances.Add(token.Address, balances.Balance);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<FundingRate>> GetFundingRate(Web3 web3)
|
||||
{
|
||||
var market = await GetMarketInfo(web3);
|
||||
return Map(market);
|
||||
}
|
||||
|
||||
private List<FundingRate> Map(GmxMarketInfo market)
|
||||
{
|
||||
var longApr = GetFundingFactorPerPeriod(market, true, Periods[Enums.Timeframe.OneHour]) * 100;
|
||||
var shortApr = GetFundingFactorPerPeriod(market, false, Periods[Enums.Timeframe.OneHour]) * 100;
|
||||
var longFundingRate = new FundingRate()
|
||||
{
|
||||
Ticker = GmxHelpers.GetTicker(market.Market.Symbol),
|
||||
Rate = GmxHelpers.FormatAmount(longApr, 30, 4),
|
||||
Direction = Enums.TradeDirection.Long
|
||||
};
|
||||
var shortFundingRate = new FundingRate()
|
||||
{
|
||||
Ticker = GmxHelpers.GetTicker(market.Market.Symbol),
|
||||
Rate = GmxHelpers.FormatAmount(shortApr, 30, 4),
|
||||
Direction = Enums.TradeDirection.Short
|
||||
};
|
||||
return new List<FundingRate>() { longFundingRate, shortFundingRate };
|
||||
}
|
||||
|
||||
public async Task<List<FundingRate>> GetFundingRates(Web3 web3)
|
||||
{
|
||||
var fundingRates = new List<FundingRate>();
|
||||
var marketDatas = await GetMarketInfosAsync(web3);
|
||||
foreach (var gmxMarketInfo in marketDatas)
|
||||
{
|
||||
var rates = Map(gmxMarketInfo);
|
||||
fundingRates.AddRange(rates);
|
||||
}
|
||||
|
||||
return fundingRates;
|
||||
}
|
||||
|
||||
private BigInteger GetFundingFactorPerPeriod(GmxMarketInfo marketInfo, bool isLong, int periodInSeconds)
|
||||
{
|
||||
var fundingFactorPerSecond = marketInfo.Market.FundingFactorPerSecond;
|
||||
var longsPayShorts = marketInfo.Market.LongsPayShorts;
|
||||
var longInterestUsd = marketInfo.Infos.LongInterestUsd;
|
||||
var shortInterestUsd = marketInfo.Infos.ShortInterestUsd;
|
||||
|
||||
var isLargerSide = isLong ? longsPayShorts : !longsPayShorts;
|
||||
|
||||
BigInteger factorPerSecond;
|
||||
|
||||
if (isLargerSide)
|
||||
{
|
||||
factorPerSecond = fundingFactorPerSecond * -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var largerInterestUsd = longsPayShorts ? longInterestUsd : shortInterestUsd;
|
||||
var smallerInterestUsd = longsPayShorts ? shortInterestUsd : longInterestUsd;
|
||||
|
||||
var ratio = smallerInterestUsd > 0
|
||||
? BigInteger.Multiply(largerInterestUsd, PRECISION) / smallerInterestUsd
|
||||
: 0;
|
||||
|
||||
factorPerSecond = ApplyFactor(ratio, fundingFactorPerSecond);
|
||||
}
|
||||
|
||||
return factorPerSecond * periodInSeconds;
|
||||
}
|
||||
|
||||
private BigInteger ApplyFactor(BigInteger ratio, BigInteger fundingFactorPerSecond)
|
||||
{
|
||||
// Implement the logic for applying the factor based on the ratio
|
||||
// This is a placeholder implementation
|
||||
return BigInteger.Multiply(ratio, fundingFactorPerSecond) / PRECISION;
|
||||
}
|
||||
|
||||
private static readonly BigInteger PRECISION = BigInteger.Pow(10, 18);
|
||||
|
||||
private Dictionary<Enums.Timeframe, int> Periods = new Dictionary<Enums.Timeframe, int>()
|
||||
{
|
||||
{ Enums.Timeframe.FiveMinutes, 300 },
|
||||
{ Enums.Timeframe.FifteenMinutes, 900 },
|
||||
{ Enums.Timeframe.OneHour, 3600 },
|
||||
{ Enums.Timeframe.FourHour, 14400 },
|
||||
{ Enums.Timeframe.OneDay, 86400 }
|
||||
};
|
||||
}
|
||||
447
src/Managing.Infrastructure.Web3/Services/Gmx/TokenV2Service.cs
Normal file
447
src/Managing.Infrastructure.Web3/Services/Gmx/TokenV2Service.cs
Normal file
@@ -0,0 +1,447 @@
|
||||
using Managing.Common;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Models.Gmx.v2;
|
||||
|
||||
public static class TokenV2Service
|
||||
{
|
||||
public static List<GmxToken> TOKENS { get; set; } = new List<GmxToken>
|
||||
{
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Ethereum",
|
||||
Symbol = "ETH",
|
||||
Decimals = 18,
|
||||
Address = Nethereum.Util.AddressUtil.ZERO_ADDRESS,
|
||||
IsNative = true,
|
||||
IsShortable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/279/small/ethereum.png?1595348880",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/ethereum",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Wrapped Ethereum",
|
||||
Symbol = "WETH",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.WETH,
|
||||
IsWrapped = true,
|
||||
BaseSymbol = "ETH",
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/2518/thumb/weth.png?1628852295",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/ethereum",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Wrapped Stacked Ethereum",
|
||||
Symbol = "WSTETH",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.WSTETH,
|
||||
IsWrapped = true,
|
||||
BaseSymbol = "wstETH",
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/2518/thumb/wsteth.png?1628852295",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/ethereum",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Bitcoin (WBTC)",
|
||||
Symbol = "BTC",
|
||||
AssetSymbol = "WBTC",
|
||||
Decimals = 8,
|
||||
Address = Constants.GMX.TokenAddress.WBTC,
|
||||
IsShortable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/26115/thumb/btcb.png?1655921693",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/wrapped-bitcoin",
|
||||
ExplorerUrl = "https://arbiscan.io/address/0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Arbitrum",
|
||||
Symbol = "ARB",
|
||||
Decimals = 18,
|
||||
PriceDecimals = 3,
|
||||
Address = Constants.GMX.TokenAddress.ARB,
|
||||
ImageUrl =
|
||||
"https://assets.coingecko.com/coins/images/16547/small/photo_2023-03-29_21.47.00.jpeg?1680097630",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/arbitrum",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0x912ce59144191c1204e64559fe8253a0e49e6548"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Wrapped SOL (Wormhole)",
|
||||
Symbol = "SOL",
|
||||
AssetSymbol = "WSOL (Wormhole)",
|
||||
Decimals = 9,
|
||||
Address = Constants.GMX.TokenAddress.SOL,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/4128/small/solana.png?1640133422",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/solana",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0x2bCc6D6CdBbDC0a4071e48bb3B969b06B3330c07",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Chainlink",
|
||||
Symbol = "LINK",
|
||||
Decimals = 18,
|
||||
PriceDecimals = 3,
|
||||
Address = Constants.GMX.TokenAddress.LINK,
|
||||
IsStable = false,
|
||||
IsShortable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/877/thumb/chainlink-new-logo.png?1547034700",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/chainlink",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xf97f4df75117a78c1a5a0dbb814af92458539fb4",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Uniswap",
|
||||
Symbol = "UNI",
|
||||
Decimals = 18,
|
||||
PriceDecimals = 3,
|
||||
Address = Constants.GMX.TokenAddress.UNI,
|
||||
IsStable = false,
|
||||
IsShortable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/12504/thumb/uniswap-uni.png?1600306604",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/uniswap",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Bridged USDC (USDC.e)",
|
||||
Symbol = "USDC.e",
|
||||
Decimals = 6,
|
||||
Address = Constants.GMX.TokenAddress.USDCE,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/6319/thumb/USD_Coin_icon.png?1547042389",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/bridged-usdc-arbitrum",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "USD Coin",
|
||||
Symbol = "USDC",
|
||||
Decimals = 6,
|
||||
Address = Constants.GMX.TokenAddress.USDC,
|
||||
IsStable = true,
|
||||
IsV1Available = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/6319/thumb/USD_Coin_icon.png?1547042389",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/usd-coin",
|
||||
ExplorerUrl = "https://arbiscan.io/address/0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Tether",
|
||||
Symbol = "USDT",
|
||||
Decimals = 6,
|
||||
Address = Constants.GMX.TokenAddress.USDT,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/325/thumb/Tether-logo.png?1598003707",
|
||||
ExplorerUrl = "https://arbiscan.io/address/0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/tether",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Dai",
|
||||
Symbol = "DAI",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.DAI,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/9956/thumb/4943.png?1636636734",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/dai",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "USDe",
|
||||
Symbol = "USDe",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.USDE,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/9956/thumb/4943.png?1636636734",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/usde",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Frax",
|
||||
Symbol = "FRAX",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.FRAX,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/13422/small/frax_logo.png?1608476506",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/frax",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0x17fc002b466eec40dae837fc4be5c67993ddbd6f",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Magic Internet Money",
|
||||
Symbol = "MIM",
|
||||
Decimals = 18,
|
||||
Address = Constants.GMX.TokenAddress.MIM,
|
||||
IsStable = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/16786/thumb/mimlogopng.png?1624979612",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/magic-internet-money",
|
||||
ExplorerUrl = "https://arbiscan.io/token/0xFEa7a6a0B346362BF88A9e4A88416B77a57D6c2A",
|
||||
IsV1Available = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Bitcoin",
|
||||
Symbol = "BTC",
|
||||
Decimals = 8,
|
||||
Address = Constants.GMX.TokenAddress.BTC,
|
||||
IsSynthetic = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/1/small/bitcoin.png?1547033579",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/bitcoin",
|
||||
},
|
||||
new GmxToken()
|
||||
{
|
||||
Name = "DogeCoin",
|
||||
Symbol = "DOGE",
|
||||
Decimals = 8,
|
||||
PriceDecimals = 4,
|
||||
Address = Constants.GMX.TokenAddress.DOGE,
|
||||
IsSynthetic = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/5/small/dogecoin.png?1547792256",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/dogecoin",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Litecoin",
|
||||
Symbol = "LTC",
|
||||
Decimals = 8,
|
||||
Address = Constants.GMX.TokenAddress.LTC,
|
||||
IsSynthetic = true,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/2/small/litecoin.png?1547033580",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/litecoin",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "XRP",
|
||||
Symbol = "XRP",
|
||||
Decimals = 6,
|
||||
PriceDecimals = 4,
|
||||
Address = Constants.GMX.TokenAddress.XRP,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/44/small/xrp-symbol-white-128.png?1605778731",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/xrp",
|
||||
IsSynthetic = true,
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "GMX",
|
||||
Symbol = "GMX",
|
||||
Address =
|
||||
Constants.GMX.TokenAddress.GMX,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/18323/small/arbit.png?1631532468",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/gmx",
|
||||
ExplorerUrl = "https://arbiscan.io/address/0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",
|
||||
IsPlatform = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Wrapped BNB (LayerZero)",
|
||||
Symbol = "BNB",
|
||||
AssetSymbol = "WBNB (LayerZero)",
|
||||
Address = Constants.GMX.TokenAddress.WBNB,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/bnb",
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Cosmos",
|
||||
Symbol = "ATOM",
|
||||
AssetSymbol = "ATOM",
|
||||
Address = Constants.GMX.TokenAddress.ATOM,
|
||||
Decimals = 6,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/1481/standard/cosmos_hub.png?1696502525",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/cosmos-hub",
|
||||
IsSynthetic = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Near",
|
||||
Symbol = "NEAR",
|
||||
AssetSymbol = "NEAR",
|
||||
Address = Constants.GMX.TokenAddress.NEAR,
|
||||
Decimals = 24,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/10365/standard/near.jpg?1696510367",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/near",
|
||||
IsSynthetic = true
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Aave",
|
||||
Symbol = "AAVE",
|
||||
AssetSymbol = "AAVE",
|
||||
Address = Constants.GMX.TokenAddress.AAVE,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/12645/standard/AAVE.png?1696512452",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/aave"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Wrapped AVAX (Wormhole)",
|
||||
Symbol = "AVAX",
|
||||
AssetSymbol = "WAVAX (Wormhole)",
|
||||
Address = Constants.GMX.TokenAddress.AVAX,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/12559/small/coin-round-red.png?1604021818",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/avalanche"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Optimism",
|
||||
Symbol = "OP",
|
||||
Address = Constants.GMX.TokenAddress.OP,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/25244/standard/Optimism.png?1696524385",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/optimism"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Pepe",
|
||||
Symbol = "PEPE",
|
||||
Address = Constants.GMX.TokenAddress.PEPE,
|
||||
Decimals = 18,
|
||||
PriceDecimals = 8,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/29850/standard/pepe-token.jpeg?1696528776",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/pepe"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "dogwifhat",
|
||||
Symbol = "WIF",
|
||||
Address = Constants.GMX.TokenAddress.WIF,
|
||||
Decimals = 6,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/33566/standard/dogwifhat.jpg?1702499428",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/dogwifhat"
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Shiba Inu",
|
||||
Symbol = "SHIB",
|
||||
Address = Constants.GMX.TokenAddress.SHIB,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/11939/standard/shiba.png?1696511800",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/shiba-inu",
|
||||
IsSynthetic = true,
|
||||
PriceDecimals = 8
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "APE Coin",
|
||||
Symbol = "APE",
|
||||
Address = Constants.GMX.TokenAddress.APE,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/11939/standard/shiba.png?1696511800",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/shiba-inu",
|
||||
IsSynthetic = true,
|
||||
PriceDecimals = 8
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "Stacks",
|
||||
Symbol = "STX",
|
||||
Address = Constants.GMX.TokenAddress.STX,
|
||||
Decimals = 6,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/2069/standard/Stacks_Logo_png.png?1709979332",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/stacks",
|
||||
IsSynthetic = true,
|
||||
},
|
||||
new GmxToken
|
||||
{
|
||||
Name = "ORDI",
|
||||
Symbol = "ORDI",
|
||||
Address = Constants.GMX.TokenAddress.ORDI,
|
||||
Decimals = 18,
|
||||
ImageUrl = "https://assets.coingecko.com/coins/images/30162/standard/ordi.png?1696529082",
|
||||
CoingeckoUrl = "https://www.coingecko.com/en/coins/ordi",
|
||||
IsSynthetic = true,
|
||||
},
|
||||
};
|
||||
|
||||
public static GmxToken NATIVE_TOKEN = TOKENS.First(t => t.IsNative);
|
||||
public static GmxToken WRAPPRED_NATIVE_TOKEN = TOKENS.First(t => t.IsWrapped);
|
||||
|
||||
public static List<GmxToken> GetTokens()
|
||||
{
|
||||
return TOKENS;
|
||||
}
|
||||
|
||||
public static GmxToken GetTokenByAddress(string address)
|
||||
{
|
||||
var token = TOKENS.FirstOrDefault(t => GmxV2Helpers.SameAddress(t.Address, address));
|
||||
if (token == null)
|
||||
throw new Exception($"Token with address '{address}' not found");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public static string ConvertTokenAddress(string address, string convertTo = null)
|
||||
{
|
||||
if (convertTo == "wrapped" && address == NATIVE_TOKEN.Address)
|
||||
{
|
||||
return WRAPPRED_NATIVE_TOKEN.Address;
|
||||
}
|
||||
|
||||
if (convertTo == "native" && address == WRAPPRED_NATIVE_TOKEN.Address)
|
||||
{
|
||||
return NATIVE_TOKEN.Address;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
public static string GetMarketFullName(string indexToken, string longToken, string shortToken, bool isSpotOnly)
|
||||
{
|
||||
return $"{GetMarketIndexName(indexToken, isSpotOnly)} [{GetMarketPoolName(longToken, shortToken)}]";
|
||||
}
|
||||
|
||||
|
||||
public static string GetMarketIndexName(string indexToken, bool isSpotOnly)
|
||||
{
|
||||
if (isSpotOnly)
|
||||
{
|
||||
return "SPOT-ONLY";
|
||||
}
|
||||
|
||||
return indexToken;
|
||||
}
|
||||
|
||||
public static string GetMarketPoolName(string longToken, string shortToken)
|
||||
{
|
||||
if (longToken == shortToken)
|
||||
{
|
||||
return longToken;
|
||||
}
|
||||
|
||||
return $"{longToken}-{shortToken}";
|
||||
}
|
||||
}
|
||||
|
||||
public class GmxToken
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Symbol { get; set; }
|
||||
public int Decimals { get; set; }
|
||||
public string Address { get; set; }
|
||||
public bool IsNative { get; set; }
|
||||
public bool IsShortable { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
public string CoingeckoUrl { get; set; }
|
||||
public bool IsV1Available { get; set; }
|
||||
public bool IsStable { get; set; }
|
||||
public string ExplorerUrl { get; set; }
|
||||
public string BaseSymbol { get; set; }
|
||||
public string AssetSymbol { get; set; }
|
||||
public bool IsWrapped { get; set; }
|
||||
public int PriceDecimals { get; set; }
|
||||
public bool IsSynthetic { get; set; }
|
||||
public bool IsPlatform { get; set; }
|
||||
}
|
||||
@@ -8,7 +8,22 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nethereum.Web3" Version="4.20.0" />
|
||||
<PackageReference Include="Nethereum.Web3" Version="4.21.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="DataStore\ContractDefinition\VirtualInventory.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\SwapFees.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\Props.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\PositionType.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\PositionFundingFees.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\PositionFees.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\PositionBorrowingFees.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\MarketInfo.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\ExecutionPriceResult.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\DataStoreDefinition.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\CollateralType.cs"/>
|
||||
<Compile Remove="DataStore\ContractDefinition\BaseFundingValues.cs"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,48 +1,40 @@
|
||||
using System.Numerics;
|
||||
using Nethereum.Web3;
|
||||
using Managing.Tools.ABI.Reader.ContractDefinition;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using Nethereum.Contracts.ContractHandlers;
|
||||
using Managing.Tools.Reader.ContractDefinition;
|
||||
using Nethereum.Web3;
|
||||
|
||||
namespace Managing.Tools.Reader
|
||||
namespace Managing.Tools.ABI.Reader
|
||||
{
|
||||
public partial class ReaderService
|
||||
public partial class ReaderService : ContractWeb3ServiceBase
|
||||
{
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Web3 web3, ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.IWeb3 web3,
|
||||
ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>().SendRequestAndWaitForReceiptAsync(readerDeployment, cancellationTokenSource);
|
||||
return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>()
|
||||
.SendRequestAndWaitForReceiptAsync(readerDeployment, cancellationTokenSource);
|
||||
}
|
||||
|
||||
public static Task<string> DeployContractAsync(Web3 web3, ReaderDeployment readerDeployment)
|
||||
public static Task<string> DeployContractAsync(Nethereum.Web3.IWeb3 web3, ReaderDeployment readerDeployment)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<ReaderDeployment>().SendRequestAsync(readerDeployment);
|
||||
}
|
||||
|
||||
public static async Task<ReaderService> DeployContractAndGetServiceAsync(Web3 web3, ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
public static async Task<ReaderService> DeployContractAndGetServiceAsync(Nethereum.Web3.IWeb3 web3,
|
||||
ReaderDeployment readerDeployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
var receipt = await DeployContractAndWaitForReceiptAsync(web3, readerDeployment, cancellationTokenSource);
|
||||
return new ReaderService(web3, receipt.ContractAddress);
|
||||
}
|
||||
|
||||
protected IWeb3 Web3 { get; }
|
||||
|
||||
public ContractHandler ContractHandler { get; }
|
||||
|
||||
public ReaderService(Web3 web3, string contractAddress)
|
||||
public ReaderService(Nethereum.Web3.IWeb3 web3, string contractAddress) : base(web3, contractAddress)
|
||||
{
|
||||
Web3 = web3;
|
||||
ContractHandler = web3.Eth.GetContractHandler(contractAddress);
|
||||
}
|
||||
|
||||
public ReaderService(IWeb3 web3, string contractAddress)
|
||||
public Task<BigInteger> BasisPointsDivisorQueryAsync(BasisPointsDivisorFunction basisPointsDivisorFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
Web3 = web3;
|
||||
ContractHandler = web3.Eth.GetContractHandler(contractAddress);
|
||||
}
|
||||
|
||||
public Task<BigInteger> BasisPointsDivisorQueryAsync(BasisPointsDivisorFunction basisPointsDivisorFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<BasisPointsDivisorFunction, BigInteger>(basisPointsDivisorFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<BasisPointsDivisorFunction, BigInteger>(basisPointsDivisorFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +43,11 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<BasisPointsDivisorFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> PositionPropsLengthQueryAsync(PositionPropsLengthFunction positionPropsLengthFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> PositionPropsLengthQueryAsync(PositionPropsLengthFunction positionPropsLengthFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<PositionPropsLengthFunction, BigInteger>(positionPropsLengthFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<PositionPropsLengthFunction, BigInteger>(positionPropsLengthFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +56,11 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<PositionPropsLengthFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> PricePrecisionQueryAsync(PricePrecisionFunction pricePrecisionFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> PricePrecisionQueryAsync(PricePrecisionFunction pricePrecisionFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<PricePrecisionFunction, BigInteger>(pricePrecisionFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<PricePrecisionFunction, BigInteger>(pricePrecisionFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +69,8 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<PricePrecisionFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> UsdgDecimalsQueryAsync(UsdgDecimalsFunction usdgDecimalsFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> UsdgDecimalsQueryAsync(UsdgDecimalsFunction usdgDecimalsFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<UsdgDecimalsFunction, BigInteger>(usdgDecimalsFunction, blockParameter);
|
||||
}
|
||||
@@ -84,12 +81,15 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<UsdgDecimalsFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAmountOutOutputDTO> GetAmountOutQueryAsync(GetAmountOutFunction getAmountOutFunction, BlockParameter blockParameter = null)
|
||||
public Task<GetAmountOutOutputDTO> GetAmountOutQueryAsync(GetAmountOutFunction getAmountOutFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAmountOutFunction, GetAmountOutOutputDTO>(getAmountOutFunction, blockParameter);
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAmountOutFunction, GetAmountOutOutputDTO>(
|
||||
getAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetAmountOutOutputDTO> GetAmountOutQueryAsync(string vault, string tokenIn, string tokenOut, BigInteger amountIn, BlockParameter blockParameter = null)
|
||||
public Task<GetAmountOutOutputDTO> GetAmountOutQueryAsync(string vault, string tokenIn, string tokenOut,
|
||||
BigInteger amountIn, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getAmountOutFunction = new GetAmountOutFunction();
|
||||
getAmountOutFunction.Vault = vault;
|
||||
@@ -97,15 +97,20 @@ namespace Managing.Tools.Reader
|
||||
getAmountOutFunction.TokenOut = tokenOut;
|
||||
getAmountOutFunction.AmountIn = amountIn;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAmountOutFunction, GetAmountOutOutputDTO>(getAmountOutFunction, blockParameter);
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetAmountOutFunction, GetAmountOutOutputDTO>(
|
||||
getAmountOutFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetFeeBasisPointsOutputDTO> GetFeeBasisPointsQueryAsync(GetFeeBasisPointsFunction getFeeBasisPointsFunction, BlockParameter blockParameter = null)
|
||||
public Task<GetFeeBasisPointsOutputDTO> GetFeeBasisPointsQueryAsync(
|
||||
GetFeeBasisPointsFunction getFeeBasisPointsFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetFeeBasisPointsFunction, GetFeeBasisPointsOutputDTO>(getFeeBasisPointsFunction, blockParameter);
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetFeeBasisPointsFunction, GetFeeBasisPointsOutputDTO>(
|
||||
getFeeBasisPointsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<GetFeeBasisPointsOutputDTO> GetFeeBasisPointsQueryAsync(string vault, string tokenIn, string tokenOut, BigInteger amountIn, BlockParameter blockParameter = null)
|
||||
public Task<GetFeeBasisPointsOutputDTO> GetFeeBasisPointsQueryAsync(string vault, string tokenIn,
|
||||
string tokenOut, BigInteger amountIn, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getFeeBasisPointsFunction = new GetFeeBasisPointsFunction();
|
||||
getFeeBasisPointsFunction.Vault = vault;
|
||||
@@ -113,16 +118,20 @@ namespace Managing.Tools.Reader
|
||||
getFeeBasisPointsFunction.TokenOut = tokenOut;
|
||||
getFeeBasisPointsFunction.AmountIn = amountIn;
|
||||
|
||||
return ContractHandler.QueryDeserializingToObjectAsync<GetFeeBasisPointsFunction, GetFeeBasisPointsOutputDTO>(getFeeBasisPointsFunction, blockParameter);
|
||||
return ContractHandler
|
||||
.QueryDeserializingToObjectAsync<GetFeeBasisPointsFunction, GetFeeBasisPointsOutputDTO>(
|
||||
getFeeBasisPointsFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetFeesQueryAsync(GetFeesFunction getFeesFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFeesQueryAsync(GetFeesFunction getFeesFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetFeesFunction, List<BigInteger>>(getFeesFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetFeesQueryAsync(string vault, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFeesQueryAsync(string vault, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getFeesFunction = new GetFeesFunction();
|
||||
getFeesFunction.Vault = vault;
|
||||
@@ -131,13 +140,16 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<GetFeesFunction, List<BigInteger>>(getFeesFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetFullVaultTokenInfoQueryAsync(GetFullVaultTokenInfoFunction getFullVaultTokenInfoFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFullVaultTokenInfoQueryAsync(
|
||||
GetFullVaultTokenInfoFunction getFullVaultTokenInfoFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetFullVaultTokenInfoFunction, List<BigInteger>>(getFullVaultTokenInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetFullVaultTokenInfoFunction, List<BigInteger>>(
|
||||
getFullVaultTokenInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetFullVaultTokenInfoQueryAsync(string vault, string weth, BigInteger usdgAmount, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFullVaultTokenInfoQueryAsync(string vault, string weth, BigInteger usdgAmount,
|
||||
List<string> tokens, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getFullVaultTokenInfoFunction = new GetFullVaultTokenInfoFunction();
|
||||
getFullVaultTokenInfoFunction.Vault = vault;
|
||||
@@ -145,63 +157,80 @@ namespace Managing.Tools.Reader
|
||||
getFullVaultTokenInfoFunction.UsdgAmount = usdgAmount;
|
||||
getFullVaultTokenInfoFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetFullVaultTokenInfoFunction, List<BigInteger>>(getFullVaultTokenInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetFullVaultTokenInfoFunction, List<BigInteger>>(
|
||||
getFullVaultTokenInfoFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetFundingRatesQueryAsync(GetFundingRatesFunction getFundingRatesFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFundingRatesQueryAsync(GetFundingRatesFunction getFundingRatesFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetFundingRatesFunction, List<BigInteger>>(getFundingRatesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetFundingRatesFunction, List<BigInteger>>(getFundingRatesFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetFundingRatesQueryAsync(string vault, string weth, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetFundingRatesQueryAsync(string vault, string weth, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getFundingRatesFunction = new GetFundingRatesFunction();
|
||||
getFundingRatesFunction.Vault = vault;
|
||||
getFundingRatesFunction.Weth = weth;
|
||||
getFundingRatesFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetFundingRatesFunction, List<BigInteger>>(getFundingRatesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetFundingRatesFunction, List<BigInteger>>(getFundingRatesFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetMaxAmountInQueryAsync(GetMaxAmountInFunction getMaxAmountInFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetMaxAmountInQueryAsync(GetMaxAmountInFunction getMaxAmountInFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetMaxAmountInFunction, BigInteger>(getMaxAmountInFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetMaxAmountInFunction, BigInteger>(getMaxAmountInFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetMaxAmountInQueryAsync(string vault, string tokenIn, string tokenOut, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetMaxAmountInQueryAsync(string vault, string tokenIn, string tokenOut,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getMaxAmountInFunction = new GetMaxAmountInFunction();
|
||||
getMaxAmountInFunction.Vault = vault;
|
||||
getMaxAmountInFunction.TokenIn = tokenIn;
|
||||
getMaxAmountInFunction.TokenOut = tokenOut;
|
||||
|
||||
return ContractHandler.QueryAsync<GetMaxAmountInFunction, BigInteger>(getMaxAmountInFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetMaxAmountInFunction, BigInteger>(getMaxAmountInFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetPairInfoQueryAsync(GetPairInfoFunction getPairInfoFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPairInfoQueryAsync(GetPairInfoFunction getPairInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetPairInfoFunction, List<BigInteger>>(getPairInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetPairInfoFunction, List<BigInteger>>(getPairInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetPairInfoQueryAsync(string factory, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPairInfoQueryAsync(string factory, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPairInfoFunction = new GetPairInfoFunction();
|
||||
getPairInfoFunction.Factory = factory;
|
||||
getPairInfoFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetPairInfoFunction, List<BigInteger>>(getPairInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetPairInfoFunction, List<BigInteger>>(getPairInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetPositionsQueryAsync(GetPositionsFunction getPositionsFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPositionsQueryAsync(GetPositionsFunction getPositionsFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetPositionsFunction, List<BigInteger>>(getPositionsFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetPositionsFunction, List<BigInteger>>(getPositionsFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetPositionsQueryAsync(string vault, string account, List<string> collateralTokens, List<string> indexTokens, List<bool> isLong, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPositionsQueryAsync(string vault, string account,
|
||||
List<string> collateralTokens, List<string> indexTokens, List<bool> isLong,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPositionsFunction = new GetPositionsFunction();
|
||||
getPositionsFunction.Vault = vault;
|
||||
@@ -210,16 +239,19 @@ namespace Managing.Tools.Reader
|
||||
getPositionsFunction.IndexTokens = indexTokens;
|
||||
getPositionsFunction.IsLong = isLong;
|
||||
|
||||
return ContractHandler.QueryAsync<GetPositionsFunction, List<BigInteger>>(getPositionsFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetPositionsFunction, List<BigInteger>>(getPositionsFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetPricesQueryAsync(GetPricesFunction getPricesFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPricesQueryAsync(GetPricesFunction getPricesFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetPricesFunction, List<BigInteger>>(getPricesFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetPricesQueryAsync(string priceFeed, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetPricesQueryAsync(string priceFeed, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getPricesFunction = new GetPricesFunction();
|
||||
getPricesFunction.PriceFeed = priceFeed;
|
||||
@@ -228,102 +260,130 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<GetPricesFunction, List<BigInteger>>(getPricesFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetStakingInfoQueryAsync(GetStakingInfoFunction getStakingInfoFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetStakingInfoQueryAsync(GetStakingInfoFunction getStakingInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetStakingInfoFunction, List<BigInteger>>(getStakingInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetStakingInfoFunction, List<BigInteger>>(getStakingInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetStakingInfoQueryAsync(string account, List<string> yieldTrackers, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetStakingInfoQueryAsync(string account, List<string> yieldTrackers,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getStakingInfoFunction = new GetStakingInfoFunction();
|
||||
getStakingInfoFunction.Account = account;
|
||||
getStakingInfoFunction.YieldTrackers = yieldTrackers;
|
||||
|
||||
return ContractHandler.QueryAsync<GetStakingInfoFunction, List<BigInteger>>(getStakingInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetStakingInfoFunction, List<BigInteger>>(getStakingInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetTokenBalancesQueryAsync(GetTokenBalancesFunction getTokenBalancesFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTokenBalancesQueryAsync(GetTokenBalancesFunction getTokenBalancesFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesFunction, List<BigInteger>>(getTokenBalancesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesFunction, List<BigInteger>>(getTokenBalancesFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetTokenBalancesQueryAsync(string account, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTokenBalancesQueryAsync(string account, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getTokenBalancesFunction = new GetTokenBalancesFunction();
|
||||
getTokenBalancesFunction.Account = account;
|
||||
getTokenBalancesFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesFunction, List<BigInteger>>(getTokenBalancesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesFunction, List<BigInteger>>(getTokenBalancesFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetTokenBalancesWithSuppliesQueryAsync(GetTokenBalancesWithSuppliesFunction getTokenBalancesWithSuppliesFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTokenBalancesWithSuppliesQueryAsync(
|
||||
GetTokenBalancesWithSuppliesFunction getTokenBalancesWithSuppliesFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesWithSuppliesFunction, List<BigInteger>>(getTokenBalancesWithSuppliesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesWithSuppliesFunction, List<BigInteger>>(
|
||||
getTokenBalancesWithSuppliesFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetTokenBalancesWithSuppliesQueryAsync(string account, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTokenBalancesWithSuppliesQueryAsync(string account, List<string> tokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getTokenBalancesWithSuppliesFunction = new GetTokenBalancesWithSuppliesFunction();
|
||||
getTokenBalancesWithSuppliesFunction.Account = account;
|
||||
getTokenBalancesWithSuppliesFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesWithSuppliesFunction, List<BigInteger>>(getTokenBalancesWithSuppliesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenBalancesWithSuppliesFunction, List<BigInteger>>(
|
||||
getTokenBalancesWithSuppliesFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetTokenSupplyQueryAsync(GetTokenSupplyFunction getTokenSupplyFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetTokenSupplyQueryAsync(GetTokenSupplyFunction getTokenSupplyFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetTokenSupplyFunction, BigInteger>(getTokenSupplyFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenSupplyFunction, BigInteger>(getTokenSupplyFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetTokenSupplyQueryAsync(string token, List<string> excludedAccounts, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetTokenSupplyQueryAsync(string token, List<string> excludedAccounts,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getTokenSupplyFunction = new GetTokenSupplyFunction();
|
||||
getTokenSupplyFunction.Token = token;
|
||||
getTokenSupplyFunction.ExcludedAccounts = excludedAccounts;
|
||||
|
||||
return ContractHandler.QueryAsync<GetTokenSupplyFunction, BigInteger>(getTokenSupplyFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTokenSupplyFunction, BigInteger>(getTokenSupplyFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetTotalBalanceQueryAsync(GetTotalBalanceFunction getTotalBalanceFunction, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetTotalBalanceQueryAsync(GetTotalBalanceFunction getTotalBalanceFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetTotalBalanceFunction, BigInteger>(getTotalBalanceFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTotalBalanceFunction, BigInteger>(getTotalBalanceFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetTotalBalanceQueryAsync(string token, List<string> accounts, BlockParameter blockParameter = null)
|
||||
public Task<BigInteger> GetTotalBalanceQueryAsync(string token, List<string> accounts,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getTotalBalanceFunction = new GetTotalBalanceFunction();
|
||||
getTotalBalanceFunction.Token = token;
|
||||
getTotalBalanceFunction.Accounts = accounts;
|
||||
|
||||
return ContractHandler.QueryAsync<GetTotalBalanceFunction, BigInteger>(getTotalBalanceFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTotalBalanceFunction, BigInteger>(getTotalBalanceFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetTotalStakedQueryAsync(GetTotalStakedFunction getTotalStakedFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTotalStakedQueryAsync(GetTotalStakedFunction getTotalStakedFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetTotalStakedFunction, List<BigInteger>>(getTotalStakedFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTotalStakedFunction, List<BigInteger>>(getTotalStakedFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetTotalStakedQueryAsync(List<string> yieldTokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetTotalStakedQueryAsync(List<string> yieldTokens,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getTotalStakedFunction = new GetTotalStakedFunction();
|
||||
getTotalStakedFunction.YieldTokens = yieldTokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetTotalStakedFunction, List<BigInteger>>(getTotalStakedFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetTotalStakedFunction, List<BigInteger>>(getTotalStakedFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoQueryAsync(GetVaultTokenInfoFunction getVaultTokenInfoFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoQueryAsync(GetVaultTokenInfoFunction getVaultTokenInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoFunction, List<BigInteger>>(getVaultTokenInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoFunction, List<BigInteger>>(getVaultTokenInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoQueryAsync(string vault, string weth, BigInteger usdgAmount, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoQueryAsync(string vault, string weth, BigInteger usdgAmount,
|
||||
List<string> tokens, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getVaultTokenInfoFunction = new GetVaultTokenInfoFunction();
|
||||
getVaultTokenInfoFunction.Vault = vault;
|
||||
@@ -331,16 +391,20 @@ namespace Managing.Tools.Reader
|
||||
getVaultTokenInfoFunction.UsdgAmount = usdgAmount;
|
||||
getVaultTokenInfoFunction.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoFunction, List<BigInteger>>(getVaultTokenInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoFunction, List<BigInteger>>(getVaultTokenInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoV2QueryAsync(GetVaultTokenInfoV2Function getVaultTokenInfoV2Function, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoV2QueryAsync(
|
||||
GetVaultTokenInfoV2Function getVaultTokenInfoV2Function, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoV2Function, List<BigInteger>>(getVaultTokenInfoV2Function, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoV2Function, List<BigInteger>>(
|
||||
getVaultTokenInfoV2Function, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoV2QueryAsync(string vault, string weth, BigInteger usdgAmount, List<string> tokens, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVaultTokenInfoV2QueryAsync(string vault, string weth, BigInteger usdgAmount,
|
||||
List<string> tokens, BlockParameter blockParameter = null)
|
||||
{
|
||||
var getVaultTokenInfoV2Function = new GetVaultTokenInfoV2Function();
|
||||
getVaultTokenInfoV2Function.Vault = vault;
|
||||
@@ -348,22 +412,27 @@ namespace Managing.Tools.Reader
|
||||
getVaultTokenInfoV2Function.UsdgAmount = usdgAmount;
|
||||
getVaultTokenInfoV2Function.Tokens = tokens;
|
||||
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoV2Function, List<BigInteger>>(getVaultTokenInfoV2Function, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVaultTokenInfoV2Function, List<BigInteger>>(
|
||||
getVaultTokenInfoV2Function, blockParameter);
|
||||
}
|
||||
|
||||
public Task<List<BigInteger>> GetVestingInfoQueryAsync(GetVestingInfoFunction getVestingInfoFunction, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVestingInfoQueryAsync(GetVestingInfoFunction getVestingInfoFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetVestingInfoFunction, List<BigInteger>>(getVestingInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVestingInfoFunction, List<BigInteger>>(getVestingInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<List<BigInteger>> GetVestingInfoQueryAsync(string account, List<string> vesters, BlockParameter blockParameter = null)
|
||||
public Task<List<BigInteger>> GetVestingInfoQueryAsync(string account, List<string> vesters,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
var getVestingInfoFunction = new GetVestingInfoFunction();
|
||||
getVestingInfoFunction.Account = account;
|
||||
getVestingInfoFunction.Vesters = vesters;
|
||||
|
||||
return ContractHandler.QueryAsync<GetVestingInfoFunction, List<BigInteger>>(getVestingInfoFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<GetVestingInfoFunction, List<BigInteger>>(getVestingInfoFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
public Task<string> GovQueryAsync(GovFunction govFunction, BlockParameter blockParameter = null)
|
||||
@@ -377,9 +446,11 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.QueryAsync<GovFunction, string>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<bool> HasMaxGlobalShortSizesQueryAsync(HasMaxGlobalShortSizesFunction hasMaxGlobalShortSizesFunction, BlockParameter blockParameter = null)
|
||||
public Task<bool> HasMaxGlobalShortSizesQueryAsync(
|
||||
HasMaxGlobalShortSizesFunction hasMaxGlobalShortSizesFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<HasMaxGlobalShortSizesFunction, bool>(hasMaxGlobalShortSizesFunction, blockParameter);
|
||||
return ContractHandler.QueryAsync<HasMaxGlobalShortSizesFunction, bool>(hasMaxGlobalShortSizesFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +464,8 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.SendRequestAsync(setConfigFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> SetConfigRequestAndWaitForReceiptAsync(SetConfigFunction setConfigFunction, CancellationTokenSource cancellationToken = null)
|
||||
public Task<TransactionReceipt> SetConfigRequestAndWaitForReceiptAsync(SetConfigFunction setConfigFunction,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(setConfigFunction, cancellationToken);
|
||||
}
|
||||
@@ -406,7 +478,8 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.SendRequestAsync(setConfigFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> SetConfigRequestAndWaitForReceiptAsync(bool hasMaxGlobalShortSizes, CancellationTokenSource cancellationToken = null)
|
||||
public Task<TransactionReceipt> SetConfigRequestAndWaitForReceiptAsync(bool hasMaxGlobalShortSizes,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var setConfigFunction = new SetConfigFunction();
|
||||
setConfigFunction.HasMaxGlobalShortSizes = hasMaxGlobalShortSizes;
|
||||
@@ -419,7 +492,8 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.SendRequestAsync(setGovFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(SetGovFunction setGovFunction, CancellationTokenSource cancellationToken = null)
|
||||
public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(SetGovFunction setGovFunction,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(setGovFunction, cancellationToken);
|
||||
}
|
||||
@@ -432,12 +506,60 @@ namespace Managing.Tools.Reader
|
||||
return ContractHandler.SendRequestAsync(setGovFunction);
|
||||
}
|
||||
|
||||
public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(string gov, CancellationTokenSource cancellationToken = null)
|
||||
public Task<TransactionReceipt> SetGovRequestAndWaitForReceiptAsync(string gov,
|
||||
CancellationTokenSource cancellationToken = null)
|
||||
{
|
||||
var setGovFunction = new SetGovFunction();
|
||||
setGovFunction.Gov = gov;
|
||||
|
||||
return ContractHandler.SendRequestAndWaitForReceiptAsync(setGovFunction, cancellationToken);
|
||||
}
|
||||
|
||||
public override List<Type> GetAllFunctionTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
typeof(BasisPointsDivisorFunction),
|
||||
typeof(PositionPropsLengthFunction),
|
||||
typeof(PricePrecisionFunction),
|
||||
typeof(UsdgDecimalsFunction),
|
||||
typeof(GetAmountOutFunction),
|
||||
typeof(GetFeeBasisPointsFunction),
|
||||
typeof(GetFeesFunction),
|
||||
typeof(GetFullVaultTokenInfoFunction),
|
||||
typeof(GetFundingRatesFunction),
|
||||
typeof(GetMaxAmountInFunction),
|
||||
typeof(GetPairInfoFunction),
|
||||
typeof(GetPositionsFunction),
|
||||
typeof(GetPricesFunction),
|
||||
typeof(GetStakingInfoFunction),
|
||||
typeof(GetTokenBalancesFunction),
|
||||
typeof(GetTokenBalancesWithSuppliesFunction),
|
||||
typeof(GetTokenSupplyFunction),
|
||||
typeof(GetTotalBalanceFunction),
|
||||
typeof(GetTotalStakedFunction),
|
||||
typeof(GetVaultTokenInfoFunction),
|
||||
typeof(GetVaultTokenInfoV2Function),
|
||||
typeof(GetVestingInfoFunction),
|
||||
typeof(GovFunction),
|
||||
typeof(HasMaxGlobalShortSizesFunction),
|
||||
typeof(SetConfigFunction),
|
||||
typeof(SetGovFunction)
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllEventTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
public override List<Type> GetAllErrorTypes()
|
||||
{
|
||||
return new List<Type>
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
826
src/Managing.WebApp/src/pages/web3Page/GetMarketInfoGmxV2.tsx
Normal file
826
src/Managing.WebApp/src/pages/web3Page/GetMarketInfoGmxV2.tsx
Normal file
@@ -0,0 +1,826 @@
|
||||
import {useAccount} from "wagmi";
|
||||
|
||||
import {getContract} from "config/contracts";
|
||||
import {
|
||||
BORROWING_EXPONENT_FACTOR_KEY,
|
||||
BORROWING_FACTOR_KEY,
|
||||
CLAIMABLE_FUNDING_AMOUNT,
|
||||
FUNDING_DECREASE_FACTOR_PER_SECOND,
|
||||
FUNDING_EXPONENT_FACTOR_KEY,
|
||||
FUNDING_FACTOR_KEY,
|
||||
FUNDING_INCREASE_FACTOR_PER_SECOND,
|
||||
IS_MARKET_DISABLED_KEY,
|
||||
MAX_FUNDING_FACTOR_PER_SECOND,
|
||||
MAX_OPEN_INTEREST_KEY,
|
||||
MAX_PNL_FACTOR_FOR_TRADERS_KEY,
|
||||
MAX_PNL_FACTOR_KEY,
|
||||
MAX_POOL_AMOUNT_KEY,
|
||||
MAX_POOL_USD_FOR_DEPOSIT_KEY,
|
||||
MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY,
|
||||
MAX_POSITION_IMPACT_FACTOR_KEY,
|
||||
MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY,
|
||||
MIN_COLLATERAL_FACTOR_KEY,
|
||||
MIN_FUNDING_FACTOR_PER_SECOND,
|
||||
MIN_POSITION_IMPACT_POOL_AMOUNT_KEY,
|
||||
OPEN_INTEREST_IN_TOKENS_KEY,
|
||||
OPEN_INTEREST_KEY,
|
||||
OPEN_INTEREST_RESERVE_FACTOR_KEY,
|
||||
POOL_AMOUNT_ADJUSTMENT_KEY,
|
||||
POOL_AMOUNT_KEY,
|
||||
POSITION_FEE_FACTOR_KEY,
|
||||
POSITION_IMPACT_EXPONENT_FACTOR_KEY,
|
||||
POSITION_IMPACT_FACTOR_KEY,
|
||||
POSITION_IMPACT_POOL_AMOUNT_KEY,
|
||||
POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY,
|
||||
RESERVE_FACTOR_KEY,
|
||||
SWAP_FEE_FACTOR_KEY,
|
||||
SWAP_IMPACT_EXPONENT_FACTOR_KEY,
|
||||
SWAP_IMPACT_FACTOR_KEY,
|
||||
SWAP_IMPACT_POOL_AMOUNT_KEY,
|
||||
THRESHOLD_FOR_DECREASE_FUNDING,
|
||||
THRESHOLD_FOR_STABLE_FUNDING,
|
||||
VIRTUAL_MARKET_ID_KEY,
|
||||
VIRTUAL_TOKEN_ID_KEY,
|
||||
} from "config/dataStore";
|
||||
import {convertTokenAddress} from "config/tokens";
|
||||
import {useMulticall} from "lib/multicall";
|
||||
import {hashDataMapAsync} from "lib/multicall/hashDataAsync";
|
||||
import {BN_ONE} from "lib/numbers";
|
||||
import {getByKey} from "lib/objects";
|
||||
import {TokensData, useTokensDataRequest} from "../tokens";
|
||||
import {MarketsInfoData} from "./types";
|
||||
import {useMarkets} from "./useMarkets";
|
||||
import {getContractMarketPrices} from "./utils";
|
||||
|
||||
import DataStore from "abis/DataStore.json";
|
||||
import SyntheticsReader from "abis/SyntheticsReader.json";
|
||||
|
||||
export type MarketsInfoResult = {
|
||||
marketsInfoData?: MarketsInfoData;
|
||||
tokensData?: TokensData;
|
||||
pricesUpdatedAt?: number;
|
||||
};
|
||||
|
||||
export function useMarketsInfoRequest(chainId: number): MarketsInfoResult {
|
||||
const {address: account} = useAccount();
|
||||
const {marketsData, marketsAddresses} = useMarkets(chainId);
|
||||
const {tokensData, pricesUpdatedAt} = useTokensDataRequest(chainId);
|
||||
const dataStoreAddress = getContract(chainId, "DataStore");
|
||||
|
||||
const isDepencenciesLoading = !marketsAddresses || !tokensData;
|
||||
|
||||
const {data} = useMulticall(chainId, "useMarketsInfo", {
|
||||
inWorker: true,
|
||||
key: !isDepencenciesLoading &&
|
||||
marketsAddresses.length > 0 && [marketsAddresses.join("-"), dataStoreAddress, account, pricesUpdatedAt],
|
||||
|
||||
// Refreshed on every prices update
|
||||
refreshInterval: null,
|
||||
clearUnusedKeys: true,
|
||||
keepPreviousData: true,
|
||||
|
||||
request: async () => {
|
||||
const request = {};
|
||||
const promises = (marketsAddresses || []).map(async (marketAddress) => {
|
||||
const market = getByKey(marketsData, marketAddress)!;
|
||||
const marketPrices = getContractMarketPrices(tokensData!, market)!;
|
||||
|
||||
if (!marketPrices) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn("missed market prices", market);
|
||||
return;
|
||||
}
|
||||
|
||||
const marketProps = {
|
||||
marketToken: market.marketTokenAddress,
|
||||
indexToken: market.indexTokenAddress,
|
||||
longToken: market.longTokenAddress,
|
||||
shortToken: market.shortTokenAddress,
|
||||
};
|
||||
|
||||
request[`${marketAddress}-reader`] = {
|
||||
contractAddress: getContract(chainId, "SyntheticsReader"),
|
||||
abi: SyntheticsReader.abi,
|
||||
calls: {
|
||||
marketInfo: {
|
||||
methodName: "getMarketInfo",
|
||||
params: [dataStoreAddress, marketPrices, marketAddress],
|
||||
},
|
||||
marketTokenPriceMax: {
|
||||
methodName: "getMarketTokenPrice",
|
||||
params: [
|
||||
dataStoreAddress,
|
||||
marketProps,
|
||||
marketPrices.indexTokenPrice,
|
||||
marketPrices.longTokenPrice,
|
||||
marketPrices.shortTokenPrice,
|
||||
MAX_PNL_FACTOR_FOR_TRADERS_KEY,
|
||||
true,
|
||||
],
|
||||
},
|
||||
marketTokenPriceMin: {
|
||||
methodName: "getMarketTokenPrice",
|
||||
params: [
|
||||
dataStoreAddress,
|
||||
marketProps,
|
||||
marketPrices.indexTokenPrice,
|
||||
marketPrices.longTokenPrice,
|
||||
marketPrices.shortTokenPrice,
|
||||
MAX_PNL_FACTOR_FOR_TRADERS_KEY,
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const hashedKeys = await hashDataMapAsync({
|
||||
isDisabled: [
|
||||
["bytes32", "address"],
|
||||
[IS_MARKET_DISABLED_KEY, marketAddress],
|
||||
],
|
||||
longPoolAmount: [
|
||||
["bytes32", "address", "address"],
|
||||
[POOL_AMOUNT_KEY, marketAddress, market.longTokenAddress],
|
||||
],
|
||||
shortPoolAmount: [
|
||||
["bytes32", "address", "address"],
|
||||
[POOL_AMOUNT_KEY, marketAddress, market.shortTokenAddress],
|
||||
],
|
||||
maxLongPoolAmount: [
|
||||
["bytes32", "address", "address"],
|
||||
[MAX_POOL_AMOUNT_KEY, marketAddress, market.longTokenAddress],
|
||||
],
|
||||
maxShortPoolAmount: [
|
||||
["bytes32", "address", "address"],
|
||||
[MAX_POOL_AMOUNT_KEY, marketAddress, market.shortTokenAddress],
|
||||
],
|
||||
maxLongPoolUsdForDeposit: [
|
||||
["bytes32", "address", "address"],
|
||||
[MAX_POOL_USD_FOR_DEPOSIT_KEY, marketAddress, market.longTokenAddress],
|
||||
],
|
||||
maxShortPoolUsdForDeposit: [
|
||||
["bytes32", "address", "address"],
|
||||
[MAX_POOL_USD_FOR_DEPOSIT_KEY, marketAddress, market.shortTokenAddress],
|
||||
],
|
||||
longPoolAmountAdjustment: [
|
||||
["bytes32", "address", "address"],
|
||||
[POOL_AMOUNT_ADJUSTMENT_KEY, marketAddress, market.longTokenAddress],
|
||||
],
|
||||
shortPoolAmountAdjustment: [
|
||||
["bytes32", "address", "address"],
|
||||
[POOL_AMOUNT_ADJUSTMENT_KEY, marketAddress, market.shortTokenAddress],
|
||||
],
|
||||
reserveFactorLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[RESERVE_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
reserveFactorShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[RESERVE_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
openInterestReserveFactorLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[OPEN_INTEREST_RESERVE_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
openInterestReserveFactorShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[OPEN_INTEREST_RESERVE_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
maxOpenInterestLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MAX_OPEN_INTEREST_KEY, marketAddress, true],
|
||||
],
|
||||
maxOpenInterestShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MAX_OPEN_INTEREST_KEY, marketAddress, false],
|
||||
],
|
||||
positionImpactPoolAmount: [
|
||||
["bytes32", "address"],
|
||||
[POSITION_IMPACT_POOL_AMOUNT_KEY, marketAddress],
|
||||
],
|
||||
minPositionImpactPoolAmount: [
|
||||
["bytes32", "address"],
|
||||
[MIN_POSITION_IMPACT_POOL_AMOUNT_KEY, marketAddress],
|
||||
],
|
||||
positionImpactPoolDistributionRate: [
|
||||
["bytes32", "address"],
|
||||
[POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY, marketAddress],
|
||||
],
|
||||
swapImpactPoolAmountLong: [
|
||||
["bytes32", "address", "address"],
|
||||
[SWAP_IMPACT_POOL_AMOUNT_KEY, marketAddress, market.longTokenAddress],
|
||||
],
|
||||
swapImpactPoolAmountShort: [
|
||||
["bytes32", "address", "address"],
|
||||
[SWAP_IMPACT_POOL_AMOUNT_KEY, marketAddress, market.shortTokenAddress],
|
||||
],
|
||||
borrowingFactorLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[BORROWING_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
borrowingFactorShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[BORROWING_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
borrowingExponentFactorLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[BORROWING_EXPONENT_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
borrowingExponentFactorShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[BORROWING_EXPONENT_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
fundingFactor: [
|
||||
["bytes32", "address"],
|
||||
[FUNDING_FACTOR_KEY, marketAddress],
|
||||
],
|
||||
fundingExponentFactor: [
|
||||
["bytes32", "address"],
|
||||
[FUNDING_EXPONENT_FACTOR_KEY, marketAddress],
|
||||
],
|
||||
fundingIncreaseFactorPerSecond: [
|
||||
["bytes32", "address"],
|
||||
[FUNDING_INCREASE_FACTOR_PER_SECOND, marketAddress],
|
||||
],
|
||||
fundingDecreaseFactorPerSecond: [
|
||||
["bytes32", "address"],
|
||||
[FUNDING_DECREASE_FACTOR_PER_SECOND, marketAddress],
|
||||
],
|
||||
thresholdForStableFunding: [
|
||||
["bytes32", "address"],
|
||||
[THRESHOLD_FOR_STABLE_FUNDING, marketAddress],
|
||||
],
|
||||
thresholdForDecreaseFunding: [
|
||||
["bytes32", "address"],
|
||||
[THRESHOLD_FOR_DECREASE_FUNDING, marketAddress],
|
||||
],
|
||||
minFundingFactorPerSecond: [
|
||||
["bytes32", "address"],
|
||||
[MIN_FUNDING_FACTOR_PER_SECOND, marketAddress],
|
||||
],
|
||||
maxFundingFactorPerSecond: [
|
||||
["bytes32", "address"],
|
||||
[MAX_FUNDING_FACTOR_PER_SECOND, marketAddress],
|
||||
],
|
||||
maxPnlFactorForTradersLong: [
|
||||
["bytes32", "bytes32", "address", "bool"],
|
||||
[MAX_PNL_FACTOR_KEY, MAX_PNL_FACTOR_FOR_TRADERS_KEY, marketAddress, true],
|
||||
],
|
||||
maxPnlFactorForTradersShort: [
|
||||
["bytes32", "bytes32", "address", "bool"],
|
||||
[MAX_PNL_FACTOR_KEY, MAX_PNL_FACTOR_FOR_TRADERS_KEY, marketAddress, false],
|
||||
],
|
||||
claimableFundingAmountLong: account
|
||||
? [
|
||||
["bytes32", "address", "address", "address"],
|
||||
[CLAIMABLE_FUNDING_AMOUNT, marketAddress, market.longTokenAddress, account],
|
||||
]
|
||||
: undefined,
|
||||
claimableFundingAmountShort: account
|
||||
? [
|
||||
["bytes32", "address", "address", "address"],
|
||||
[CLAIMABLE_FUNDING_AMOUNT, marketAddress, market.shortTokenAddress, account],
|
||||
]
|
||||
: undefined,
|
||||
positionFeeFactorForPositiveImpact: [
|
||||
["bytes32", "address", "bool"],
|
||||
[POSITION_FEE_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
positionFeeFactorForNegativeImpact: [
|
||||
["bytes32", "address", "bool"],
|
||||
[POSITION_FEE_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
positionImpactFactorPositive: [
|
||||
["bytes32", "address", "bool"],
|
||||
[POSITION_IMPACT_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
positionImpactFactorNegative: [
|
||||
["bytes32", "address", "bool"],
|
||||
[POSITION_IMPACT_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
maxPositionImpactFactorPositive: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MAX_POSITION_IMPACT_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
maxPositionImpactFactorNegative: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MAX_POSITION_IMPACT_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
maxPositionImpactFactorForLiquidations: [
|
||||
["bytes32", "address"],
|
||||
[MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY, marketAddress],
|
||||
],
|
||||
minCollateralFactor: [
|
||||
["bytes32", "address"],
|
||||
[MIN_COLLATERAL_FACTOR_KEY, marketAddress],
|
||||
],
|
||||
minCollateralFactorForOpenInterestLong: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY, marketAddress, true],
|
||||
],
|
||||
minCollateralFactorForOpenInterestShort: [
|
||||
["bytes32", "address", "bool"],
|
||||
[MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY, marketAddress, false],
|
||||
],
|
||||
positionImpactExponentFactor: [
|
||||
["bytes32", "address"],
|
||||
[POSITION_IMPACT_EXPONENT_FACTOR_KEY, marketAddress],
|
||||
],
|
||||
swapFeeFactorForPositiveImpact: [
|
||||
["bytes32", "address", "bool"],
|
||||
[SWAP_FEE_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
swapFeeFactorForNegativeImpact: [
|
||||
["bytes32", "address", "bool"],
|
||||
[SWAP_FEE_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
swapImpactFactorPositive: [
|
||||
["bytes32", "address", "bool"],
|
||||
[SWAP_IMPACT_FACTOR_KEY, marketAddress, true],
|
||||
],
|
||||
swapImpactFactorNegative: [
|
||||
["bytes32", "address", "bool"],
|
||||
[SWAP_IMPACT_FACTOR_KEY, marketAddress, false],
|
||||
],
|
||||
swapImpactExponentFactor: [
|
||||
["bytes32", "address"],
|
||||
[SWAP_IMPACT_EXPONENT_FACTOR_KEY, marketAddress],
|
||||
],
|
||||
longInterestUsingLongToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_KEY, marketAddress, market.longTokenAddress, true],
|
||||
],
|
||||
longInterestUsingShortToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_KEY, marketAddress, market.shortTokenAddress, true],
|
||||
],
|
||||
shortInterestUsingLongToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_KEY, marketAddress, market.longTokenAddress, false],
|
||||
],
|
||||
shortInterestUsingShortToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_KEY, marketAddress, market.shortTokenAddress, false],
|
||||
],
|
||||
longInterestInTokensUsingLongToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_IN_TOKENS_KEY, marketAddress, market.longTokenAddress, true],
|
||||
],
|
||||
longInterestInTokensUsingShortToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_IN_TOKENS_KEY, marketAddress, market.shortTokenAddress, true],
|
||||
],
|
||||
shortInterestInTokensUsingLongToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_IN_TOKENS_KEY, marketAddress, market.longTokenAddress, false],
|
||||
],
|
||||
shortInterestInTokensUsingShortToken: [
|
||||
["bytes32", "address", "address", "bool"],
|
||||
[OPEN_INTEREST_IN_TOKENS_KEY, marketAddress, market.shortTokenAddress, false],
|
||||
],
|
||||
virtualMarketId: [
|
||||
["bytes32", "address"],
|
||||
[VIRTUAL_MARKET_ID_KEY, marketAddress],
|
||||
],
|
||||
virtualLongTokenId: [
|
||||
["bytes32", "address"],
|
||||
[VIRTUAL_TOKEN_ID_KEY, market.longTokenAddress],
|
||||
],
|
||||
virtualShortTokenId: [
|
||||
["bytes32", "address"],
|
||||
[VIRTUAL_TOKEN_ID_KEY, market.shortTokenAddress],
|
||||
],
|
||||
});
|
||||
|
||||
request[`${marketAddress}-dataStore`] = {
|
||||
contractAddress: dataStoreAddress,
|
||||
abi: DataStore.abi,
|
||||
calls: {
|
||||
isDisabled: {
|
||||
methodName: "getBool",
|
||||
params: [hashedKeys.isDisabled],
|
||||
},
|
||||
longPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longPoolAmount],
|
||||
},
|
||||
shortPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortPoolAmount],
|
||||
},
|
||||
maxLongPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxLongPoolAmount],
|
||||
},
|
||||
maxShortPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxShortPoolAmount],
|
||||
},
|
||||
maxLongPoolUsdForDeposit: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxLongPoolUsdForDeposit],
|
||||
},
|
||||
maxShortPoolUsdForDeposit: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxShortPoolUsdForDeposit],
|
||||
},
|
||||
longPoolAmountAdjustment: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longPoolAmountAdjustment],
|
||||
},
|
||||
shortPoolAmountAdjustment: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortPoolAmountAdjustment],
|
||||
},
|
||||
reserveFactorLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.reserveFactorLong],
|
||||
},
|
||||
reserveFactorShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.reserveFactorShort],
|
||||
},
|
||||
openInterestReserveFactorLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.openInterestReserveFactorLong],
|
||||
},
|
||||
openInterestReserveFactorShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.openInterestReserveFactorShort],
|
||||
},
|
||||
maxOpenInterestLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxOpenInterestLong],
|
||||
},
|
||||
maxOpenInterestShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxOpenInterestShort],
|
||||
},
|
||||
positionImpactPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionImpactPoolAmount],
|
||||
},
|
||||
minPositionImpactPoolAmount: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.minPositionImpactPoolAmount],
|
||||
},
|
||||
positionImpactPoolDistributionRate: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionImpactPoolDistributionRate],
|
||||
},
|
||||
swapImpactPoolAmountLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapImpactPoolAmountLong],
|
||||
},
|
||||
swapImpactPoolAmountShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapImpactPoolAmountShort],
|
||||
},
|
||||
borrowingFactorLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.borrowingFactorLong],
|
||||
},
|
||||
borrowingFactorShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.borrowingFactorShort],
|
||||
},
|
||||
borrowingExponentFactorLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.borrowingExponentFactorLong],
|
||||
},
|
||||
borrowingExponentFactorShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.borrowingExponentFactorShort],
|
||||
},
|
||||
fundingFactor: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.fundingFactor],
|
||||
},
|
||||
fundingExponentFactor: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.fundingExponentFactor],
|
||||
},
|
||||
fundingIncreaseFactorPerSecond: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.fundingIncreaseFactorPerSecond],
|
||||
},
|
||||
fundingDecreaseFactorPerSecond: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.fundingDecreaseFactorPerSecond],
|
||||
},
|
||||
thresholdForStableFunding: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.thresholdForStableFunding],
|
||||
},
|
||||
thresholdForDecreaseFunding: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.thresholdForDecreaseFunding],
|
||||
},
|
||||
minFundingFactorPerSecond: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.minFundingFactorPerSecond],
|
||||
},
|
||||
maxFundingFactorPerSecond: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxFundingFactorPerSecond],
|
||||
},
|
||||
maxPnlFactorForTradersLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxPnlFactorForTradersLong],
|
||||
},
|
||||
maxPnlFactorForTradersShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxPnlFactorForTradersShort],
|
||||
},
|
||||
claimableFundingAmountLong: account
|
||||
? {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.claimableFundingAmountLong],
|
||||
}
|
||||
: undefined,
|
||||
claimableFundingAmountShort: account
|
||||
? {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.claimableFundingAmountShort],
|
||||
}
|
||||
: undefined,
|
||||
positionFeeFactorForPositiveImpact: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionFeeFactorForPositiveImpact],
|
||||
},
|
||||
positionFeeFactorForNegativeImpact: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionFeeFactorForNegativeImpact],
|
||||
},
|
||||
positionImpactFactorPositive: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionImpactFactorPositive],
|
||||
},
|
||||
positionImpactFactorNegative: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionImpactFactorNegative],
|
||||
},
|
||||
maxPositionImpactFactorPositive: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxPositionImpactFactorPositive],
|
||||
},
|
||||
maxPositionImpactFactorNegative: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxPositionImpactFactorNegative],
|
||||
},
|
||||
maxPositionImpactFactorForLiquidations: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.maxPositionImpactFactorForLiquidations],
|
||||
},
|
||||
minCollateralFactor: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.minCollateralFactor],
|
||||
},
|
||||
minCollateralFactorForOpenInterestLong: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.minCollateralFactorForOpenInterestLong],
|
||||
},
|
||||
minCollateralFactorForOpenInterestShort: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.minCollateralFactorForOpenInterestShort],
|
||||
},
|
||||
positionImpactExponentFactor: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.positionImpactExponentFactor],
|
||||
},
|
||||
swapFeeFactorForPositiveImpact: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapFeeFactorForPositiveImpact],
|
||||
},
|
||||
swapFeeFactorForNegativeImpact: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapFeeFactorForNegativeImpact],
|
||||
},
|
||||
swapImpactFactorPositive: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapImpactFactorPositive],
|
||||
},
|
||||
swapImpactFactorNegative: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapImpactFactorNegative],
|
||||
},
|
||||
swapImpactExponentFactor: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.swapImpactExponentFactor],
|
||||
},
|
||||
longInterestUsingLongToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longInterestUsingLongToken],
|
||||
},
|
||||
longInterestUsingShortToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longInterestUsingShortToken],
|
||||
},
|
||||
shortInterestUsingLongToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortInterestUsingLongToken],
|
||||
},
|
||||
shortInterestUsingShortToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortInterestUsingShortToken],
|
||||
},
|
||||
longInterestInTokensUsingLongToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longInterestInTokensUsingLongToken],
|
||||
},
|
||||
longInterestInTokensUsingShortToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.longInterestInTokensUsingShortToken],
|
||||
},
|
||||
shortInterestInTokensUsingLongToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortInterestInTokensUsingLongToken],
|
||||
},
|
||||
shortInterestInTokensUsingShortToken: {
|
||||
methodName: "getUint",
|
||||
params: [hashedKeys.shortInterestInTokensUsingShortToken],
|
||||
},
|
||||
virtualMarketId: {
|
||||
methodName: "getBytes32",
|
||||
params: [hashedKeys.virtualMarketId],
|
||||
},
|
||||
virtualLongTokenId: {
|
||||
methodName: "getBytes32",
|
||||
params: [hashedKeys.virtualLongTokenId],
|
||||
},
|
||||
virtualShortTokenId: {
|
||||
methodName: "getBytes32",
|
||||
params: [hashedKeys.virtualShortTokenId],
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
return request;
|
||||
},
|
||||
parseResponse: (res) => {
|
||||
const result = marketsAddresses!.reduce((acc: MarketsInfoData, marketAddress) => {
|
||||
const readerErrors = res.errors[`${marketAddress}-reader`];
|
||||
const dataStoreErrors = res.errors[`${marketAddress}-dataStore`];
|
||||
|
||||
const readerValues = res.data[`${marketAddress}-reader`];
|
||||
const dataStoreValues = res.data[`${marketAddress}-dataStore`];
|
||||
|
||||
// Skip invalid market
|
||||
if (!readerValues || !dataStoreValues || readerErrors || dataStoreErrors) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("market info error", marketAddress, readerErrors, dataStoreErrors, dataStoreValues);
|
||||
return acc;
|
||||
}
|
||||
const market = getByKey(marketsData, marketAddress)!;
|
||||
const marketDivisor = market.isSameCollaterals ? BigInt(2) : BN_ONE;
|
||||
|
||||
const longInterestUsingLongToken =
|
||||
BigInt(dataStoreValues.longInterestUsingLongToken.returnValues[0]) / marketDivisor;
|
||||
const longInterestUsingShortToken =
|
||||
BigInt(dataStoreValues.longInterestUsingShortToken.returnValues[0]) / marketDivisor;
|
||||
const shortInterestUsingLongToken =
|
||||
BigInt(dataStoreValues.shortInterestUsingLongToken.returnValues[0]) / marketDivisor;
|
||||
const shortInterestUsingShortToken =
|
||||
BigInt(dataStoreValues.shortInterestUsingShortToken.returnValues[0]) / marketDivisor;
|
||||
|
||||
const longInterestUsd = longInterestUsingLongToken + longInterestUsingShortToken;
|
||||
const shortInterestUsd = shortInterestUsingLongToken + shortInterestUsingShortToken;
|
||||
|
||||
const longInterestInTokensUsingLongToken =
|
||||
BigInt(dataStoreValues.longInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
|
||||
const longInterestInTokensUsingShortToken =
|
||||
BigInt(dataStoreValues.longInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
|
||||
const shortInterestInTokensUsingLongToken =
|
||||
BigInt(dataStoreValues.shortInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
|
||||
const shortInterestInTokensUsingShortToken =
|
||||
BigInt(dataStoreValues.shortInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
|
||||
|
||||
const longInterestInTokens = longInterestInTokensUsingLongToken + longInterestInTokensUsingShortToken;
|
||||
const shortInterestInTokens = shortInterestInTokensUsingLongToken + shortInterestInTokensUsingShortToken;
|
||||
|
||||
const {nextFunding, virtualInventory} = readerValues.marketInfo.returnValues;
|
||||
|
||||
const [, poolValueInfoMin] = readerValues.marketTokenPriceMin.returnValues;
|
||||
|
||||
const [, poolValueInfoMax] = readerValues.marketTokenPriceMax.returnValues;
|
||||
|
||||
const longToken = getByKey(tokensData!, market.longTokenAddress)!;
|
||||
const shortToken = getByKey(tokensData!, market.shortTokenAddress)!;
|
||||
const indexToken = getByKey(tokensData!, convertTokenAddress(chainId, market.indexTokenAddress, "native"))!;
|
||||
|
||||
acc[marketAddress] = {
|
||||
...market,
|
||||
isDisabled: dataStoreValues.isDisabled.returnValues[0],
|
||||
longToken,
|
||||
shortToken,
|
||||
indexToken,
|
||||
longInterestUsd,
|
||||
shortInterestUsd,
|
||||
longInterestInTokens,
|
||||
shortInterestInTokens,
|
||||
longPoolAmount: dataStoreValues.longPoolAmount.returnValues[0] / marketDivisor,
|
||||
shortPoolAmount: dataStoreValues.shortPoolAmount.returnValues[0] / marketDivisor,
|
||||
maxLongPoolUsdForDeposit: dataStoreValues.maxLongPoolUsdForDeposit.returnValues[0],
|
||||
maxShortPoolUsdForDeposit: dataStoreValues.maxShortPoolUsdForDeposit.returnValues[0],
|
||||
maxLongPoolAmount: dataStoreValues.maxLongPoolAmount.returnValues[0],
|
||||
maxShortPoolAmount: dataStoreValues.maxShortPoolAmount.returnValues[0],
|
||||
longPoolAmountAdjustment: dataStoreValues.longPoolAmountAdjustment.returnValues[0],
|
||||
shortPoolAmountAdjustment: dataStoreValues.shortPoolAmountAdjustment.returnValues[0],
|
||||
poolValueMin: poolValueInfoMin.poolValue,
|
||||
poolValueMax: poolValueInfoMax.poolValue,
|
||||
reserveFactorLong: dataStoreValues.reserveFactorLong.returnValues[0],
|
||||
reserveFactorShort: dataStoreValues.reserveFactorShort.returnValues[0],
|
||||
openInterestReserveFactorLong: dataStoreValues.openInterestReserveFactorLong.returnValues[0],
|
||||
openInterestReserveFactorShort: dataStoreValues.openInterestReserveFactorShort.returnValues[0],
|
||||
maxOpenInterestLong: dataStoreValues.maxOpenInterestLong.returnValues[0],
|
||||
maxOpenInterestShort: dataStoreValues.maxOpenInterestShort.returnValues[0],
|
||||
totalBorrowingFees: poolValueInfoMax.totalBorrowingFees,
|
||||
positionImpactPoolAmount: dataStoreValues.positionImpactPoolAmount.returnValues[0],
|
||||
minPositionImpactPoolAmount: dataStoreValues.minPositionImpactPoolAmount.returnValues[0],
|
||||
positionImpactPoolDistributionRate: dataStoreValues.positionImpactPoolDistributionRate.returnValues[0],
|
||||
swapImpactPoolAmountLong: dataStoreValues.swapImpactPoolAmountLong.returnValues[0],
|
||||
swapImpactPoolAmountShort: dataStoreValues.swapImpactPoolAmountShort.returnValues[0],
|
||||
borrowingFactorLong: dataStoreValues.borrowingFactorLong.returnValues[0],
|
||||
borrowingFactorShort: dataStoreValues.borrowingFactorShort.returnValues[0],
|
||||
borrowingExponentFactorLong: dataStoreValues.borrowingExponentFactorLong.returnValues[0],
|
||||
borrowingExponentFactorShort: dataStoreValues.borrowingExponentFactorShort.returnValues[0],
|
||||
fundingFactor: dataStoreValues.fundingFactor.returnValues[0],
|
||||
fundingExponentFactor: dataStoreValues.fundingExponentFactor.returnValues[0],
|
||||
fundingIncreaseFactorPerSecond: dataStoreValues.fundingIncreaseFactorPerSecond.returnValues[0],
|
||||
fundingDecreaseFactorPerSecond: dataStoreValues.fundingDecreaseFactorPerSecond.returnValues[0],
|
||||
thresholdForDecreaseFunding: dataStoreValues.thresholdForDecreaseFunding.returnValues[0],
|
||||
thresholdForStableFunding: dataStoreValues.thresholdForStableFunding.returnValues[0],
|
||||
minFundingFactorPerSecond: dataStoreValues.minFundingFactorPerSecond.returnValues[0],
|
||||
maxFundingFactorPerSecond: dataStoreValues.maxFundingFactorPerSecond.returnValues[0],
|
||||
pnlLongMax: poolValueInfoMax.longPnl,
|
||||
pnlLongMin: poolValueInfoMin.longPnl,
|
||||
pnlShortMax: poolValueInfoMax.shortPnl,
|
||||
pnlShortMin: poolValueInfoMin.shortPnl,
|
||||
netPnlMax: poolValueInfoMax.netPnl,
|
||||
netPnlMin: poolValueInfoMin.netPnl,
|
||||
|
||||
maxPnlFactorForTradersLong: dataStoreValues.maxPnlFactorForTradersLong.returnValues[0],
|
||||
maxPnlFactorForTradersShort: dataStoreValues.maxPnlFactorForTradersShort.returnValues[0],
|
||||
|
||||
minCollateralFactor: dataStoreValues.minCollateralFactor.returnValues[0],
|
||||
minCollateralFactorForOpenInterestLong:
|
||||
dataStoreValues.minCollateralFactorForOpenInterestLong.returnValues[0],
|
||||
|
||||
minCollateralFactorForOpenInterestShort:
|
||||
dataStoreValues.minCollateralFactorForOpenInterestShort.returnValues[0],
|
||||
|
||||
claimableFundingAmountLong: dataStoreValues.claimableFundingAmountLong
|
||||
? dataStoreValues.claimableFundingAmountLong?.returnValues[0] / marketDivisor
|
||||
: undefined,
|
||||
|
||||
claimableFundingAmountShort: dataStoreValues.claimableFundingAmountShort
|
||||
? dataStoreValues.claimableFundingAmountShort?.returnValues[0] / marketDivisor
|
||||
: undefined,
|
||||
|
||||
positionFeeFactorForPositiveImpact: dataStoreValues.positionFeeFactorForPositiveImpact.returnValues[0],
|
||||
positionFeeFactorForNegativeImpact: dataStoreValues.positionFeeFactorForNegativeImpact.returnValues[0],
|
||||
positionImpactFactorPositive: dataStoreValues.positionImpactFactorPositive.returnValues[0],
|
||||
positionImpactFactorNegative: dataStoreValues.positionImpactFactorNegative.returnValues[0],
|
||||
maxPositionImpactFactorPositive: dataStoreValues.maxPositionImpactFactorPositive.returnValues[0],
|
||||
maxPositionImpactFactorNegative: dataStoreValues.maxPositionImpactFactorNegative.returnValues[0],
|
||||
maxPositionImpactFactorForLiquidations:
|
||||
dataStoreValues.maxPositionImpactFactorForLiquidations.returnValues[0],
|
||||
positionImpactExponentFactor: dataStoreValues.positionImpactExponentFactor.returnValues[0],
|
||||
swapFeeFactorForPositiveImpact: dataStoreValues.swapFeeFactorForPositiveImpact.returnValues[0],
|
||||
swapFeeFactorForNegativeImpact: dataStoreValues.swapFeeFactorForNegativeImpact.returnValues[0],
|
||||
swapImpactFactorPositive: dataStoreValues.swapImpactFactorPositive.returnValues[0],
|
||||
swapImpactFactorNegative: dataStoreValues.swapImpactFactorNegative.returnValues[0],
|
||||
swapImpactExponentFactor: dataStoreValues.swapImpactExponentFactor.returnValues[0],
|
||||
|
||||
borrowingFactorPerSecondForLongs: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForLongs,
|
||||
|
||||
borrowingFactorPerSecondForShorts: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForShorts,
|
||||
|
||||
fundingFactorPerSecond: nextFunding.fundingFactorPerSecond,
|
||||
longsPayShorts: nextFunding.longsPayShorts,
|
||||
|
||||
virtualPoolAmountForLongToken: virtualInventory.virtualPoolAmountForLongToken,
|
||||
virtualPoolAmountForShortToken: virtualInventory.virtualPoolAmountForShortToken,
|
||||
virtualInventoryForPositions: virtualInventory.virtualInventoryForPositions,
|
||||
|
||||
virtualMarketId: dataStoreValues.virtualMarketId.returnValues[0],
|
||||
virtualLongTokenId: dataStoreValues.virtualLongTokenId.returnValues[0],
|
||||
virtualShortTokenId: dataStoreValues.virtualShortTokenId.returnValues[0],
|
||||
};
|
||||
|
||||
return acc;
|
||||
}, {} as MarketsInfoData);
|
||||
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
marketsInfoData: isDepencenciesLoading ? undefined : data,
|
||||
tokensData,
|
||||
pricesUpdatedAt,
|
||||
};
|
||||
}
|
||||
@@ -64,6 +64,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managing.ABI.GmxV2", "Managing.ABI.GmxV2\Managing.ABI.GmxV2.csproj", "{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -216,6 +218,14 @@ Global
|
||||
{A1D88DC3-1CF6-4C03-AEEC-30AA37420CE1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A1D88DC3-1CF6-4C03-AEEC-30AA37420CE1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A1D88DC3-1CF6-4C03-AEEC-30AA37420CE1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -238,6 +248,7 @@ Global
|
||||
{283AC491-97C3-49E0-AB17-272EFB4E5A9C} = {F6774DB0-DF13-4077-BC94-0E67EE105C4C}
|
||||
{CDDF92D4-9D2E-4134-BD44-3064D6EF462D} = {E453D33B-5C2B-4AA1-834D-2C916EC95FC6}
|
||||
{A1D88DC3-1CF6-4C03-AEEC-30AA37420CE1} = {D6711C71-A263-4398-8DFF-28E2CD1FE0CE}
|
||||
{4521E1A9-AF81-4CA8-8B4D-30C261ECE977} = {D6711C71-A263-4398-8DFF-28E2CD1FE0CE}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BD7CA081-CE52-4824-9777-C0562E54F3EA}
|
||||
|
||||
Reference in New Issue
Block a user