GMX v2 - Trading (#7)
* Move PrivateKeys.cs * Update gitignore * Update gitignore * updt * Extract GmxServiceTests.cs * Refact * update todo * Update code * Fix hashdata * Replace static token hashed datas * Set allowance * Add get orders * Add get orders tests * Add ignore * add close orders * revert * Add get gas limit * Start increasePosition. Todo: Finish GetExecutionFee and estimateGas * little refact * Update gitignore * Fix namespaces and clean repo * Add tests samples * Add execution fee * Add increase position * Handle backtest on the frontend * Add tests * Update increase * Test increase * fix increase * Fix size * Start get position * Update get positions * Fix get position * Update rpc and trade mappers * Finish close position * Fix leverage
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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
@@ -7,20 +7,19 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
{
|
||||
public partial class Multicall3Service : ContractWeb3ServiceBase
|
||||
{
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.IWeb3 web3,
|
||||
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(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)
|
||||
public static Task<string> DeployContractAsync(IWeb3 web3, Multicall3Deployment multicall3Deployment)
|
||||
{
|
||||
return web3.Eth.GetContractDeploymentHandler<Multicall3Deployment>().SendRequestAsync(multicall3Deployment);
|
||||
}
|
||||
|
||||
public static async Task<Multicall3Service> DeployContractAndGetServiceAsync(Nethereum.Web3.IWeb3 web3,
|
||||
public static async Task<Multicall3Service> DeployContractAndGetServiceAsync(IWeb3 web3,
|
||||
Multicall3Deployment multicall3Deployment, CancellationTokenSource cancellationTokenSource = null)
|
||||
{
|
||||
var receipt =
|
||||
@@ -28,7 +27,7 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
return new Multicall3Service(web3, receipt.ContractAddress);
|
||||
}
|
||||
|
||||
public Multicall3Service(Nethereum.Web3.IWeb3 web3, string contractAddress) : base(web3, contractAddress)
|
||||
public Multicall3Service(IWeb3 web3, string contractAddress) : base(web3, contractAddress)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,62 +59,6 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
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);
|
||||
@@ -144,18 +87,6 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
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)
|
||||
{
|
||||
@@ -184,18 +115,6 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
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)
|
||||
{
|
||||
@@ -209,6 +128,19 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockCoinbaseFunction, string>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockDifficultyQueryAsync(
|
||||
GetCurrentBlockDifficultyFunction getCurrentBlockDifficultyFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockDifficultyFunction, BigInteger>(
|
||||
getCurrentBlockDifficultyFunction, blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockDifficultyQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetCurrentBlockDifficultyFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetCurrentBlockGasLimitQueryAsync(
|
||||
GetCurrentBlockGasLimitFunction getCurrentBlockGasLimitFunction, BlockParameter blockParameter = null)
|
||||
{
|
||||
@@ -250,6 +182,19 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
return ContractHandler.QueryAsync<GetEthBalanceFunction, BigInteger>(getEthBalanceFunction, blockParameter);
|
||||
}
|
||||
|
||||
public Task<BigInteger> GetL1BlockNumberQueryAsync(GetL1BlockNumberFunction getL1BlockNumberFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetL1BlockNumberFunction, BigInteger>(getL1BlockNumberFunction,
|
||||
blockParameter);
|
||||
}
|
||||
|
||||
|
||||
public Task<BigInteger> GetL1BlockNumberQueryAsync(BlockParameter blockParameter = null)
|
||||
{
|
||||
return ContractHandler.QueryAsync<GetL1BlockNumberFunction, BigInteger>(null, blockParameter);
|
||||
}
|
||||
|
||||
public Task<byte[]> GetLastBlockHashQueryAsync(GetLastBlockHashFunction getLastBlockHashFunction,
|
||||
BlockParameter blockParameter = null)
|
||||
{
|
||||
@@ -328,17 +273,15 @@ namespace Managing.ABI.GmxV2.Multicall3
|
||||
return new List<Type>
|
||||
{
|
||||
typeof(AggregateFunction),
|
||||
typeof(Aggregate3Function),
|
||||
typeof(Aggregate3ValueFunction),
|
||||
typeof(BlockAndAggregateFunction),
|
||||
typeof(GetBasefeeFunction),
|
||||
typeof(GetBlockHashFunction),
|
||||
typeof(GetBlockNumberFunction),
|
||||
typeof(GetChainIdFunction),
|
||||
typeof(GetCurrentBlockCoinbaseFunction),
|
||||
typeof(GetCurrentBlockDifficultyFunction),
|
||||
typeof(GetCurrentBlockGasLimitFunction),
|
||||
typeof(GetCurrentBlockTimestampFunction),
|
||||
typeof(GetEthBalanceFunction),
|
||||
typeof(GetL1BlockNumberFunction),
|
||||
typeof(GetLastBlockHashFunction),
|
||||
typeof(TryAggregateFunction),
|
||||
typeof(TryBlockAndAggregateFunction)
|
||||
|
||||
Reference in New Issue
Block a user