Skip to content

Commit

Permalink
Fix transfer event not found in PancakeSwap
Browse files Browse the repository at this point in the history
  • Loading branch information
lwYeo committed Aug 15, 2021
1 parent 5394971 commit 48a7386
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions Crypto LP Compounder/Compounder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -689,21 +689,29 @@ private bool CheckAndTopUpGas(BigInteger gasAmount, ref BigInteger rewardHarvest
return false;
}

List<EventLog<DTO.ERC20.TransferEventDTO>> transferEvents = _Web3.Eth.
GetEvent<DTO.ERC20.TransferEventDTO>().
DecodeAllEventsForEvent(topUpGasReceipt.Logs);
List<EventLog<DTO.ERC20.TransferEventDTO>> transferEvents =
_Web3.Eth
.GetEvent<DTO.ERC20.TransferEventDTO>()
.DecodeAllEventsForEvent(topUpGasReceipt.Logs);

List<EventLog<DTO.ERC20.TransferEventDTO>> transferOutEvents = transferEvents.
Where(e => e.Event.From.Equals(_Settings.Wallet.Address, StringComparison.OrdinalIgnoreCase)).
ToList();
List<EventLog<DTO.ERC20.TransferEventDTO>> transferOutEvents =
transferEvents
.Where(e => e.Event.From.Equals(_Settings.Wallet.Address, StringComparison.OrdinalIgnoreCase))
.ToList();

List<EventLog<DTO.ERC20.TransferEventDTO>> transferInEvents = transferEvents.
Where(e => e.Event.To.Equals(BurnAddress, StringComparison.OrdinalIgnoreCase)).
ToList();
List<EventLog<DTO.ERC20.TransferEventDTO>> transferInEvents =
transferEvents
.Where(e => e.Event.To.Equals(BurnAddress, StringComparison.OrdinalIgnoreCase))
.ToList();

if (transferOutEvents.Any())
rewardHarvestAmt -= transferOutEvents.Select(l => l.Event.Value).Aggregate((currentSum, item) => currentSum + item);

if (!transferInEvents.Any())
transferInEvents.AddRange(
transferEvents
.Where(e => e.Event.From.Equals(_Settings.LiquidityPool.LP_Contract, StringComparison.OrdinalIgnoreCase)));

if (transferInEvents.Any())
{
decimal ethAmount =
Expand Down
2 changes: 1 addition & 1 deletion Crypto LP Compounder/Crypto LP Compounder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright>Copyright © lwYeo 2021</Copyright>
<Company>lwYeo@github</Company>
<Authors>lwYeo</Authors>
<Version>0.1.13</Version>
<Version>0.1.14</Version>
<RepositoryType>GitHub</RepositoryType>
<RepositoryUrl>https://github.com/lwYeo/CryptoLP_Compounder</RepositoryUrl>
<Product>Crypto LP Compounder</Product>
Expand Down

0 comments on commit 48a7386

Please sign in to comment.