Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIP 55: Remove Tobin Tax #2029

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions core/vm/vmcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,24 @@ func TobinTransfer(evm *vm.EVM, sender, recipient common.Address, amount *big.In
defer func() { evm.SetDebug(true) }()
}

if amount.Cmp(big.NewInt(0)) != 0 {
palango marked this conversation as resolved.
Show resolved Hide resolved
caller := &SharedEVMRunner{evm}
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
if err == nil {
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
Transfer(evm.StateDB, sender, taxRecipient, tax)
return
} else {
log.Error("Failed to get tobin tax", "error", err)
// Only deduct tobin tax before the g hardfork
if evm.ChainConfig().IsGFork(evm.Context.BlockNumber) {
Transfer(evm.StateDB, sender, recipient, amount)
} else {
if amount.Cmp(big.NewInt(0)) != 0 {
caller := &SharedEVMRunner{evm}
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
if err == nil {
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
Transfer(evm.StateDB, sender, taxRecipient, tax)
return
} else {
log.Error("Failed to get tobin tax", "error", err)
}
}
}

// Complete a normal transfer if the amount is 0 or the tobin tax value is unable to be fetched and parsed.
// We transfer even when the amount is 0 because state trie clearing [EIP161] is necessary at the end of a transaction
Transfer(evm.StateDB, sender, recipient, amount)
// Complete a normal transfer if the amount is 0 or the tobin tax value is unable to be fetched and parsed.
// We transfer even when the amount is 0 because state trie clearing [EIP161] is necessary at the end of a transaction
Transfer(evm.StateDB, sender, recipient, amount)
}
}