diff --git a/Crypto LP Compounder/Compounder.cs b/Crypto LP Compounder/Compounder.cs
index f031611..eef2987 100644
--- a/Crypto LP Compounder/Compounder.cs
+++ b/Crypto LP Compounder/Compounder.cs
@@ -21,12 +21,8 @@ limitations under the License.
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder
{
@@ -50,7 +46,9 @@ internal class Compounder : ICompounder
private BigInteger _LastEstimateGasCostPerTxn;
private uint _LastProcessTxnCount;
- private DateTimeOffset _LastUpdate, _NextLoopTime;
+ private DateTimeOffset _LastCompoundDateTime, _LastUpdate, _NextLoopDateTime;
+ private TimeSpan _LastProcessTimeTaken;
+
private readonly ValueSymbol _EstimateGasPerTxn;
string ICompounder.Name => _Settings.Name;
@@ -64,55 +62,51 @@ internal class Compounder : ICompounder
_LastUpdate.Second,
_LastUpdate.Offset);
- string[] ICompounder.Summary
- {
- get
+ string[] ICompounder.Summary =>
+ new[]
{
- return new[] {
- $"Current APR: {_Farm.CurrentAPR.Value.ToString(_Farm.CurrentAPR.Value < 1000 ? "n3" : "n0")} {_Farm.CurrentAPR.Symbol}" +
- $" ({_Farm.CurrentDeposit.FiatValue.Value * (_Farm.CurrentAPR.Value / 100):n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
- $" {_Farm.CurrentDeposit.ChainValue.Value * (_Farm.CurrentAPR.Value / 100):n2} {_Farm.CurrentDeposit.ChainValue.Symbol})"
- ,
- $"Optimal APY: {_Farm.OptimalAPY.Value.ToString(_Farm.OptimalAPY.Value < 1000 ? "n3" : "n0")} {_Farm.OptimalAPY.Symbol}" +
- $" ({_Farm.CurrentDeposit.FiatValue.Value * (_Farm.OptimalAPY.Value / 100):n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
- $" {_Farm.CurrentDeposit.ChainValue.Value * (_Farm.OptimalAPY.Value / 100):n2} {_Farm.CurrentDeposit.ChainValue.Symbol})" +
- $" ({_Farm.OptimalCompoundsPerYear} compounds per year)"
- ,
- $"Next compound in {(_NextLoopTime - DateTimeOffset.Now).TotalDays:n0} d" +
- $" {_NextLoopTime - DateTimeOffset.Now:hh' hr 'mm' min 'ss' sec'}" +
- $" ({_NextLoopTime:yyyy-MM-ddTHH:mm:ssK})"
- ,
- $"Total liquidity:" +
- $" {_Farm.CurrentDeposit.FiatValue.Value + _Farm.CurrentPendingReward.FiatValue.Value:n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
- $" {_Farm.CurrentDeposit.ChainValue.Value + _Farm.CurrentPendingReward.ChainValue.Value:n9} {_Farm.CurrentDeposit.ChainValue.Symbol}"
- ,
- $"Pending reward: {_Farm.CurrentPendingReward.Value.Value:n9} {_Farm.CurrentPendingReward.Value.Symbol}" +
- $" ({_Farm.CurrentPendingReward.FiatValue.Value:n2} {_Farm.CurrentPendingReward.FiatValue.Symbol} /" +
- $" {_Farm.CurrentPendingReward.ChainValue.Value:n9} {_Farm.CurrentPendingReward.ChainValue.Symbol})"
- ,
- $"Current deposit: {_Farm.CurrentDeposit.Value.Value:n9} {_Farm.CurrentDeposit.Value.Symbol}" +
- $" ({_Farm.CurrentDeposit.FiatValue.Value:n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
- $" {_Farm.CurrentDeposit.ChainValue.Value:n9} {_Farm.CurrentDeposit.ChainValue.Symbol})"
- ,
- $"Underlying Token A deposit: {_Farm.UnderlyingTokenA_Deposit.Value.Value:n9} {_Farm.UnderlyingTokenA_Deposit.Value.Symbol}" +
- $" ({_Farm.UnderlyingTokenA_Deposit.FiatValue.Value:n2} {_Farm.UnderlyingTokenA_Deposit.FiatValue.Symbol} /" +
- $" {_Farm.UnderlyingTokenA_Deposit.ChainValue.Value:n9} {_Farm.UnderlyingTokenA_Deposit.ChainValue.Symbol})"
- ,
- $"Underlying Token B deposit: {_Farm.UnderlyingTokenB_Deposit.Value.Value:n9} {_Farm.UnderlyingTokenB_Deposit.Value.Symbol}" +
- $" ({_Farm.UnderlyingTokenB_Deposit.FiatValue.Value:n2} {_Farm.UnderlyingTokenB_Deposit.FiatValue.Symbol} /" +
- $" {_Farm.UnderlyingTokenB_Deposit.ChainValue.Value:n9} {_Farm.UnderlyingTokenB_Deposit.ChainValue.Symbol})"
- ,
- $"Reward value: {_Farm.Reward.FiatValue.Value:n2} {_Farm.Reward.FiatValue.Symbol} /" +
- $" {_Farm.Reward.ChainValue.Value:n9} {_Farm.Reward.ChainValue.Symbol}"
- ,
- $"Token A value: {_Farm.TokenA.FiatValue.Value:n2} {_Farm.TokenA.FiatValue.Symbol} /" +
- $" {_Farm.TokenA.ChainValue.Value:n9} {_Farm.TokenA.ChainValue.Symbol}"
- ,
- $"Token B value: {_Farm.TokenB.FiatValue.Value:n2} {_Farm.TokenB.FiatValue.Symbol} /" +
- $" {_Farm.TokenB.ChainValue.Value:n9} {_Farm.TokenB.ChainValue.Symbol}"
- };
- }
- }
+ $"Current APR: {_Farm.CurrentAPR.Value.ToString(_Farm.CurrentAPR.Value < 1000 ? "n3" : "n0")} {_Farm.CurrentAPR.Symbol}" +
+ $" ({_Farm.CurrentDeposit.FiatValue.Value * (_Farm.CurrentAPR.Value / 100):n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
+ $" {_Farm.CurrentDeposit.ChainValue.Value * (_Farm.CurrentAPR.Value / 100):n2} {_Farm.CurrentDeposit.ChainValue.Symbol})"
+ ,
+ $"Optimal APY: {_Farm.OptimalAPY.Value.ToString(_Farm.OptimalAPY.Value < 1000 ? "n3" : "n0")} {_Farm.OptimalAPY.Symbol}" +
+ $" ({_Farm.CurrentDeposit.FiatValue.Value * (_Farm.OptimalAPY.Value / 100):n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
+ $" {_Farm.CurrentDeposit.ChainValue.Value * (_Farm.OptimalAPY.Value / 100):n2} {_Farm.CurrentDeposit.ChainValue.Symbol})" +
+ $" ({_Farm.OptimalCompoundsPerYear} compounds per year)"
+ ,
+ $"Next estimated compound in {(_NextLoopDateTime - DateTimeOffset.Now).TotalDays:n0} d" +
+ $" {_NextLoopDateTime - DateTimeOffset.Now:hh' hr 'mm' min 'ss' sec'}" +
+ $" ({_NextLoopDateTime:yyyy-MM-ddTHH:mm:ssK})"
+ ,
+ $"Total liquidity:" +
+ $" {_Farm.CurrentDeposit.FiatValue.Value + _Farm.CurrentPendingReward.FiatValue.Value:n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
+ $" {_Farm.CurrentDeposit.ChainValue.Value + _Farm.CurrentPendingReward.ChainValue.Value:n9} {_Farm.CurrentDeposit.ChainValue.Symbol}"
+ ,
+ $"Pending reward: {_Farm.CurrentPendingReward.Value.Value:n9} {_Farm.CurrentPendingReward.Value.Symbol}" +
+ $" ({_Farm.CurrentPendingReward.FiatValue.Value:n2} {_Farm.CurrentPendingReward.FiatValue.Symbol} /" +
+ $" {_Farm.CurrentPendingReward.ChainValue.Value:n9} {_Farm.CurrentPendingReward.ChainValue.Symbol})"
+ ,
+ $"Current deposit: {_Farm.CurrentDeposit.Value.Value:n9} {_Farm.CurrentDeposit.Value.Symbol}" +
+ $" ({_Farm.CurrentDeposit.FiatValue.Value:n2} {_Farm.CurrentDeposit.FiatValue.Symbol} /" +
+ $" {_Farm.CurrentDeposit.ChainValue.Value:n9} {_Farm.CurrentDeposit.ChainValue.Symbol})"
+ ,
+ $"Underlying Token A deposit: {_Farm.UnderlyingTokenA_Deposit.Value.Value:n9} {_Farm.UnderlyingTokenA_Deposit.Value.Symbol}" +
+ $" ({_Farm.UnderlyingTokenA_Deposit.FiatValue.Value:n2} {_Farm.UnderlyingTokenA_Deposit.FiatValue.Symbol} /" +
+ $" {_Farm.UnderlyingTokenA_Deposit.ChainValue.Value:n9} {_Farm.UnderlyingTokenA_Deposit.ChainValue.Symbol})"
+ ,
+ $"Underlying Token B deposit: {_Farm.UnderlyingTokenB_Deposit.Value.Value:n9} {_Farm.UnderlyingTokenB_Deposit.Value.Symbol}" +
+ $" ({_Farm.UnderlyingTokenB_Deposit.FiatValue.Value:n2} {_Farm.UnderlyingTokenB_Deposit.FiatValue.Symbol} /" +
+ $" {_Farm.UnderlyingTokenB_Deposit.ChainValue.Value:n9} {_Farm.UnderlyingTokenB_Deposit.ChainValue.Symbol})"
+ ,
+ $"Reward value: {_Farm.Reward.FiatValue.Value:n2} {_Farm.Reward.FiatValue.Symbol} /" +
+ $" {_Farm.Reward.ChainValue.Value:n9} {_Farm.Reward.ChainValue.Symbol}"
+ ,
+ $"Token A value: {_Farm.TokenA.FiatValue.Value:n2} {_Farm.TokenA.FiatValue.Symbol} /" +
+ $" {_Farm.TokenA.ChainValue.Value:n9} {_Farm.TokenA.ChainValue.Symbol}"
+ ,
+ $"Token B value: {_Farm.TokenB.FiatValue.Value:n2} {_Farm.TokenB.FiatValue.Symbol} /" +
+ $" {_Farm.TokenB.ChainValue.Value:n9} {_Farm.TokenB.ChainValue.Symbol}"
+ };
ValueSymbol ICompounder.CurrentAPR => _Farm.CurrentAPR;
@@ -120,7 +114,11 @@ string[] ICompounder.Summary
int ICompounder.OptimalCompoundsPerYear => _Farm.OptimalCompoundsPerYear;
- DateTimeOffset ICompounder.NextCompoundDateTime => _NextLoopTime;
+ DateTimeOffset ICompounder.LastCompoundDateTime => _LastCompoundDateTime;
+
+ TimeSpan ICompounder.LastCompoundProcessDuration => TimeSpan.FromSeconds(Math.Round(_LastProcessTimeTaken.TotalSeconds));
+
+ DateTimeOffset ICompounder.NextEstimateCompoundDateTime => _NextLoopDateTime;
ValueSymbol ICompounder.EstimateGasPerTxn => _EstimateGasPerTxn;
@@ -142,7 +140,9 @@ string[] ICompounder.Summary
public Compounder(Settings.CompounderSettings settings)
{
- _NextLoopTime = DateTimeOffset.UnixEpoch;
+ _LastProcessTimeTaken = TimeSpan.MinValue;
+ _LastCompoundDateTime = DateTimeOffset.UnixEpoch;
+ _NextLoopDateTime = DateTimeOffset.UnixEpoch;
_Settings = settings;
Log = new(settings);
@@ -240,15 +240,13 @@ public Compounder(Settings.CompounderSettings settings)
public async Task Start()
{
int intervalSecond;
- DateTimeOffset beginLoopTime;
DateTimeOffset lastUpdate = DateTimeOffset.Now;
Stopwatch stopwatch = new();
DateTimeOffset stateDateTime = DateTimeOffset.UnixEpoch;
- TimeSpan processTimeTaken = TimeSpan.MinValue;
- string statePath = System.IO.Path.Combine(AppContext.BaseDirectory, "state_" + _Settings.Name);
- byte[] stateBytes = System.IO.File.Exists(statePath) ? System.IO.File.ReadAllBytes(statePath) : null;
+ string statePath = Path.Combine(AppContext.BaseDirectory, "state_" + _Settings.Name);
+ byte[] stateBytes = File.Exists(statePath) ? File.ReadAllBytes(statePath) : null;
if (stateBytes?.Length.Equals(sizeof(long) * 2) ?? false)
{
@@ -256,14 +254,14 @@ public async Task Start()
stateDateTime = DateTimeOffset.FromUnixTimeSeconds(state).ToOffset(DateTimeOffset.Now.Offset);
state = BitConverter.ToInt64(stateBytes.Skip(sizeof(long)).ToArray());
- processTimeTaken = TimeSpan.FromTicks(state);
+ _LastProcessTimeTaken = TimeSpan.FromTicks(state);
}
while (!Program.IsTerminate)
{
if (stateDateTime > DateTimeOffset.UnixEpoch)
{
- beginLoopTime = stateDateTime;
+ _LastCompoundDateTime = stateDateTime;
stateDateTime = DateTimeOffset.UnixEpoch;
}
else
@@ -271,37 +269,36 @@ public async Task Start()
Log.IsCompoundProcess = true;
stopwatch.Restart();
+ _LastCompoundDateTime = DateTimeOffset.Now;
await ProcessCompound();
- processTimeTaken = stopwatch.Elapsed;
+ _LastProcessTimeTaken = stopwatch.Elapsed;
- Log.WriteLine($"Time taken: {processTimeTaken.TotalHours:n0} hr {processTimeTaken:mm' min 'ss' sec'}");
+ Log.WriteLine($"Time taken: {_LastProcessTimeTaken.TotalHours:n0} hr {_LastProcessTimeTaken:mm' min 'ss' sec'}");
Log.WriteLineBreak();
- beginLoopTime = DateTimeOffset.Now;
-
stateBytes =
- BitConverter.GetBytes(beginLoopTime.ToUnixTimeSeconds()).
- Concat(BitConverter.GetBytes(processTimeTaken.Ticks)).
+ BitConverter.GetBytes(_LastCompoundDateTime.ToUnixTimeSeconds()).
+ Concat(BitConverter.GetBytes(_LastProcessTimeTaken.Ticks)).
ToArray();
- _ = System.IO.File.WriteAllBytesAsync(statePath, stateBytes);
+ _ = File.WriteAllBytesAsync(statePath, stateBytes);
Log.IsCompoundProcess = false;
}
- _NextLoopTime = beginLoopTime;
+ _NextLoopDateTime = _LastCompoundDateTime;
intervalSecond = 0;
stopwatch.Restart();
- while ((_NextLoopTime == beginLoopTime || DateTimeOffset.Now < _NextLoopTime) && !Program.IsTerminate)
+ while ((_NextLoopDateTime == _LastCompoundDateTime || DateTimeOffset.Now < _NextLoopDateTime) && !Program.IsTerminate)
{
// Update interval every 5 minutes as gas fee fluctuates
if (stopwatch.Elapsed.Seconds < 1 && stopwatch.Elapsed.Minutes % 5 == 0)
{
- if (_NextLoopTime != beginLoopTime)
+ if (_NextLoopDateTime != _LastCompoundDateTime)
{
lastUpdate = DateTimeOffset.Now;
@@ -329,15 +326,15 @@ public async Task Start()
_EstimateGasPerTxn.Value =
(decimal)UnitConversion.Convert.FromWeiToBigDecimal(_LastEstimateGasCostPerTxn, UnitConversion.EthUnit.Ether);
- intervalSecond -= (int)Math.Floor(processTimeTaken.TotalSeconds);
+ intervalSecond -= (int)Math.Floor(_LastProcessTimeTaken.TotalSeconds);
- _NextLoopTime = beginLoopTime.AddSeconds(intervalSecond);
+ _NextLoopDateTime = _LastCompoundDateTime.AddSeconds(intervalSecond);
Log.WriteLine();
Log.WriteLine(
- $"Next compound in {(_NextLoopTime - DateTimeOffset.Now).TotalDays:n0} d" +
- $" {_NextLoopTime - DateTimeOffset.Now:hh' hr 'mm' min 'ss' sec'}" +
- $" ({_NextLoopTime:yyyy-MM-dd T HH:mm:ss K})");
+ $"Next compound in {(_NextLoopDateTime - DateTimeOffset.Now).TotalDays:n0} d" +
+ $" {_NextLoopDateTime - DateTimeOffset.Now:hh' hr 'mm' min 'ss' sec'}" +
+ $" ({_NextLoopDateTime:yyyy-MM-dd T HH:mm:ss K})");
}
await Task.Delay(1000);
diff --git a/Crypto LP Compounder/Contract/ERC20.cs b/Crypto LP Compounder/Contract/ERC20.cs
index 980badb..90193a7 100644
--- a/Crypto LP Compounder/Contract/ERC20.cs
+++ b/Crypto LP Compounder/Contract/ERC20.cs
@@ -18,9 +18,7 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Util;
using Nethereum.Web3;
-using System;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract
{
diff --git a/Crypto LP Compounder/Contract/Farm/MOMA.cs b/Crypto LP Compounder/Contract/Farm/MOMA.cs
index 2c96c7e..9ab9452 100644
--- a/Crypto LP Compounder/Contract/Farm/MOMA.cs
+++ b/Crypto LP Compounder/Contract/Farm/MOMA.cs
@@ -18,7 +18,6 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.Farm
{
diff --git a/Crypto LP Compounder/Contract/Farm/MasterChef.cs b/Crypto LP Compounder/Contract/Farm/MasterChef.cs
index 5405871..056b268 100644
--- a/Crypto LP Compounder/Contract/Farm/MasterChef.cs
+++ b/Crypto LP Compounder/Contract/Farm/MasterChef.cs
@@ -20,11 +20,7 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Util;
using Nethereum.Web3;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.Farm
{
@@ -596,8 +592,8 @@ public bool CalculateOptimalApy(BigInteger gasCostAmount, ref int compoundInterv
$" % ({compoundPerYear:n0} compounds / " +
(optimalUsdPerYr < 1000 ? $"{(decimal)optimalUsdPerYr:n2}" : $"{(decimal)optimalUsdPerYr:n0}") +
$" USD / " +
- (optimalEthPerYr < 1000 ? $"{(decimal)optimalEthPerYr:n10}" : $"{_Settings.GasSymbol:n0}") +
- $" {4} per year)");
+ (optimalEthPerYr < 1000 ? $"{(decimal)optimalEthPerYr:n10}" : $"{(decimal)optimalEthPerYr:n0}") +
+ $" {_Settings.GasSymbol} per year)");
}
else
{
diff --git a/Crypto LP Compounder/Contract/Farm/TombFinance.cs b/Crypto LP Compounder/Contract/Farm/TombFinance.cs
index b36272d..32fd54d 100644
--- a/Crypto LP Compounder/Contract/Farm/TombFinance.cs
+++ b/Crypto LP Compounder/Contract/Farm/TombFinance.cs
@@ -17,7 +17,6 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.Farm
{
diff --git a/Crypto LP Compounder/Contract/Farm/YEL.cs b/Crypto LP Compounder/Contract/Farm/YEL.cs
index a9fdff8..54de36d 100644
--- a/Crypto LP Compounder/Contract/Farm/YEL.cs
+++ b/Crypto LP Compounder/Contract/Farm/YEL.cs
@@ -17,7 +17,6 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Web3;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.Farm
{
diff --git a/Crypto LP Compounder/Contract/UniswapV2/Factory.cs b/Crypto LP Compounder/Contract/UniswapV2/Factory.cs
index c9008a3..2729371 100644
--- a/Crypto LP Compounder/Contract/UniswapV2/Factory.cs
+++ b/Crypto LP Compounder/Contract/UniswapV2/Factory.cs
@@ -16,8 +16,6 @@ limitations under the License.
using Nethereum.Contracts.ContractHandlers;
using Nethereum.Web3;
-using System;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.UniswapV2
{
diff --git a/Crypto LP Compounder/Contract/UniswapV2/MlnlRouter.cs b/Crypto LP Compounder/Contract/UniswapV2/MlnlRouter.cs
index defd9b0..dbbc701 100644
--- a/Crypto LP Compounder/Contract/UniswapV2/MlnlRouter.cs
+++ b/Crypto LP Compounder/Contract/UniswapV2/MlnlRouter.cs
@@ -19,11 +19,7 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Util;
using Nethereum.Web3;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.UniswapV2
{
diff --git a/Crypto LP Compounder/Contract/UniswapV2/Router.cs b/Crypto LP Compounder/Contract/UniswapV2/Router.cs
index f6d31b1..1e740f9 100644
--- a/Crypto LP Compounder/Contract/UniswapV2/Router.cs
+++ b/Crypto LP Compounder/Contract/UniswapV2/Router.cs
@@ -19,11 +19,7 @@ limitations under the License.
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Util;
using Nethereum.Web3;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Numerics;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder.Contract.UniswapV2
{
diff --git a/Crypto LP Compounder/Crypto LP Compounder.csproj b/Crypto LP Compounder/Crypto LP Compounder.csproj
index 1e68223..a361af9 100644
--- a/Crypto LP Compounder/Crypto LP Compounder.csproj
+++ b/Crypto LP Compounder/Crypto LP Compounder.csproj
@@ -9,7 +9,7 @@
Copyright © lwYeo 2021
lwYeo@github
lwYeo
- 0.1.9
+ 0.1.10
GitHub
https://github.com/lwYeo/CryptoLP_Compounder
Crypto LP Compounder
diff --git a/Crypto LP Compounder/DTO/Uniswap/V2Router.cs b/Crypto LP Compounder/DTO/Uniswap/V2Router.cs
index 9d1b745..1853e6e 100644
--- a/Crypto LP Compounder/DTO/Uniswap/V2Router.cs
+++ b/Crypto LP Compounder/DTO/Uniswap/V2Router.cs
@@ -16,7 +16,6 @@ limitations under the License.
using Nethereum.ABI.FunctionEncoding.Attributes;
using Nethereum.Contracts;
-using System.Collections.Generic;
using System.Numerics;
namespace Crypto_LP_Compounder.DTO.Uniswap
diff --git a/Crypto LP Compounder/Json.cs b/Crypto LP Compounder/Json.cs
index 1238341..3cbf149 100644
--- a/Crypto LP Compounder/Json.cs
+++ b/Crypto LP Compounder/Json.cs
@@ -17,11 +17,6 @@ limitations under the License.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net.Http;
using System.Text;
namespace Crypto_LP_Compounder
diff --git a/Crypto LP Compounder/Log.cs b/Crypto LP Compounder/Log.cs
index b431368..acab329 100644
--- a/Crypto LP Compounder/Log.cs
+++ b/Crypto LP Compounder/Log.cs
@@ -14,11 +14,6 @@ You may obtain a copy of the License at
limitations under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading.Tasks;
-
namespace Crypto_LP_Compounder
{
internal class Log
diff --git a/Crypto LP Compounder/Program.cs b/Crypto LP Compounder/Program.cs
index e7f1e91..37818e4 100644
--- a/Crypto LP Compounder/Program.cs
+++ b/Crypto LP Compounder/Program.cs
@@ -15,14 +15,9 @@ limitations under the License.
*/
using DTO;
-using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
-using System.Threading;
-using System.Threading.Tasks;
namespace Crypto_LP_Compounder
{
diff --git a/Crypto LP Compounder/Settings/CompounderSettings.cs b/Crypto LP Compounder/Settings/CompounderSettings.cs
index 21ff0f0..5b555a0 100644
--- a/Crypto LP Compounder/Settings/CompounderSettings.cs
+++ b/Crypto LP Compounder/Settings/CompounderSettings.cs
@@ -16,10 +16,7 @@ limitations under the License.
using Nethereum.Util;
using Nethereum.Web3;
-using System;
-using System.Linq;
using System.Numerics;
-using System.Threading;
namespace Crypto_LP_Compounder.Settings
{
@@ -36,7 +33,7 @@ public static CompounderSettings LoadSettings(string filePath)
CompounderSettings settings = null;
- if (System.IO.File.Exists(filePath))
+ if (File.Exists(filePath))
{
settings = Json.DeserializeFromFile(filePath);
Program.LogLineConsole("Done!");
@@ -95,7 +92,7 @@ private static void CheckSettings(CompounderSettings settings, out bool isSettin
Program.DisableQuickEdit();
isSettingChanged = true;
}
- else if (System.IO.Path.GetInvalidFileNameChars().Any(invalidChar => settings.Name.Contains(invalidChar)))
+ else if (Path.GetInvalidFileNameChars().Any(invalidChar => settings.Name.Contains(invalidChar)))
{
Program.LogLineConsole();
Program.LogLineConsole("Instance name contains invalid character(s)!");
diff --git a/Crypto LP Compounder/Settings/MainSettings.cs b/Crypto LP Compounder/Settings/MainSettings.cs
index 3c82bed..5dc6808 100644
--- a/Crypto LP Compounder/Settings/MainSettings.cs
+++ b/Crypto LP Compounder/Settings/MainSettings.cs
@@ -14,9 +14,6 @@ You may obtain a copy of the License at
limitations under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text.Json.Serialization;
namespace Crypto_LP_Compounder.Settings
@@ -31,9 +28,9 @@ public static MainSettings LoadSettings()
Program.LogConsole("Loading main settings... ");
MainSettings settings = null;
- string filePath = System.IO.Path.Combine(AppContext.BaseDirectory, FileName);
+ string filePath = Path.Combine(AppContext.BaseDirectory, FileName);
- if (System.IO.File.Exists(filePath))
+ if (File.Exists(filePath))
{
settings = Json.DeserializeFromFile(filePath);
Program.LogLineConsole("Done!");
@@ -47,7 +44,7 @@ public static MainSettings LoadSettings()
settings.Compounders.AddRange(
settings.SettingsFileNames.Select(
fileName => CompounderSettings.LoadSettings(
- System.IO.Path.Combine(AppContext.BaseDirectory, fileName))));
+ Path.Combine(AppContext.BaseDirectory, fileName))));
if (!settings.Compounders.Any())
{
diff --git a/DTO/DTO.csproj b/DTO/DTO.csproj
index 932b386..649c726 100644
--- a/DTO/DTO.csproj
+++ b/DTO/DTO.csproj
@@ -3,7 +3,7 @@
net6.0
enable
- 0.1.0
+ 0.1.1
lwYeo
lwYeo@github
Crypto LP Compounder
diff --git a/DTO/ICompounder.cs b/DTO/ICompounder.cs
index 37774e1..b43e893 100644
--- a/DTO/ICompounder.cs
+++ b/DTO/ICompounder.cs
@@ -15,39 +15,61 @@ limitations under the License.
*/
using System;
+using System.Text.Json.Serialization;
namespace DTO
{
public interface ICompounder
{
+ [JsonPropertyOrder(0)]
string Name { get; }
+ [JsonPropertyOrder(1)]
DateTimeOffset LastUpdate { get; }
+ [JsonPropertyOrder(2)]
string[] Summary { get; }
+ [JsonPropertyOrder(3)]
ValueSymbol CurrentAPR { get; }
+ [JsonPropertyOrder(4)]
ValueSymbol OptimalAPY { get; }
+ [JsonPropertyOrder(5)]
int OptimalCompoundsPerYear { get; }
- DateTimeOffset NextCompoundDateTime { get; }
+ [JsonPropertyOrder(6)]
+ DateTimeOffset LastCompoundDateTime { get; }
+ [JsonPropertyOrder(7)]
+ TimeSpan LastCompoundProcessDuration { get; }
+
+ [JsonPropertyOrder(8)]
+ DateTimeOffset NextEstimateCompoundDateTime { get; }
+
+ [JsonPropertyOrder(9)]
ValueSymbol EstimateGasPerTxn { get; }
+ [JsonPropertyOrder(10)]
TokenValue CurrentDeposit { get; }
+ [JsonPropertyOrder(11)]
TokenValue UnderlyingTokenA_Deposit { get; }
+ [JsonPropertyOrder(12)]
TokenValue UnderlyingTokenB_Deposit { get; }
+ [JsonPropertyOrder(13)]
TokenValue CurrentPendingReward { get; }
+ [JsonPropertyOrder(14)]
TokenValue TokenA { get; }
+ [JsonPropertyOrder(15)]
TokenValue TokenB { get; }
+ [JsonPropertyOrder(16)]
TokenValue Reward { get; }
}
}
diff --git a/WebApi/Controllers/InstancesController.cs b/WebApi/Controllers/InstancesController.cs
index 191db4b..a2b6429 100644
--- a/WebApi/Controllers/InstancesController.cs
+++ b/WebApi/Controllers/InstancesController.cs
@@ -15,8 +15,6 @@ limitations under the License.
*/
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-using System.Collections.Generic;
namespace WebApi.Controllers
{
diff --git a/WebApi/Program.cs b/WebApi/Program.cs
index ebc4058..26c3686 100644
--- a/WebApi/Program.cs
+++ b/WebApi/Program.cs
@@ -15,11 +15,6 @@ limitations under the License.
*/
using DTO;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Threading.Tasks;
namespace WebApi
{
diff --git a/WebApi/Properties/launchSettings.json b/WebApi/Properties/launchSettings.json
index da8c0b4..1f1921a 100644
--- a/WebApi/Properties/launchSettings.json
+++ b/WebApi/Properties/launchSettings.json
@@ -1,27 +1,12 @@
{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:59436/",
- "sslPort": 44308
- }
- },
"profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
"WebApi": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
+ "ASPNETCORE_ENVIRONMENT": "Production"
},
- "applicationUrl": "https://localhost:5001;http://localhost:5000"
+ "applicationUrl": "http://localhost:5050"
}
}
}
\ No newline at end of file
diff --git a/WebApi/Startup.cs b/WebApi/Startup.cs
index d48b20b..b5882ec 100644
--- a/WebApi/Startup.cs
+++ b/WebApi/Startup.cs
@@ -14,12 +14,6 @@ You may obtain a copy of the License at
limitations under the License.
*/
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
namespace WebApi
{
public class Startup