Documentation ¶
Index ¶
- Variables
- func AllOperationTypesString() []string
- func FilterChangesBySubAccount(op *Operation, subAccountType SubAccountType) map[common.Address]*big.Int
- func MatchAndReconcileLogOpWithTransfer(logOp, trOp *Operation, tobinTax *TobinTax, lockedGold common.Address) bool
- func MatchChangesOnSubAccount(op1 *Operation, op2 *Operation, subAccountType SubAccountType) bool
- type Account
- type BalanceChange
- type BalanceSet
- type ChainParameters
- type Operation
- func ComputeEpochRewards(ctx context.Context, cc *client.CeloClient, db db.RosettaDBReader, ...) (*Operation, error)
- func InternalTransfersToOperations(transfers []debug.Transfer, tobinTax *TobinTax) []Operation
- func NewActiveVotes(addr common.Address, group common.Address, value *big.Int) *Operation
- func NewAuthorizeSigner(from common.Address, signer common.Address, authorizeOp OperationType) *Operation
- func NewCreateAccount(from common.Address) *Operation
- func NewEpochRewards(changes map[common.Address]*big.Int) *Operation
- func NewFee(changes map[common.Address]*big.Int) *Operation
- func NewLockGold(addr, lockedGoldAddr common.Address, value *big.Int) *Operation
- func NewRelockGold(addr common.Address, value *big.Int) *Operation
- func NewRevokeActiveVotes(addr common.Address, group common.Address, value *big.Int) *Operation
- func NewRevokePendingVotes(addr common.Address, group common.Address, value *big.Int) *Operation
- func NewSlash(slashed, slasher, communityFund, lockedGoldAddr common.Address, ...) *Operation
- func NewTransfer(from, to common.Address, value *big.Int, tobinTax *TobinTax, successful bool) *Operation
- func NewUnlockGold(addr common.Address, value *big.Int) *Operation
- func NewVote(addr common.Address, group common.Address, value *big.Int) *Operation
- func NewWithdrawGold(addr, lockedGoldAddr common.Address, value *big.Int, tobinTax *TobinTax) *Operation
- func ReconcileLogOpsWithTransfers(logOps, transferOps []Operation, tobinTax *TobinTax, lockedGold common.Address) ([]Operation, error)
- type OperationType
- type SubAccount
- type SubAccountType
- type TobinTax
- type Tracer
- func (tr *Tracer) GetRegistryAddresses(receipt *types.Receipt, contractNames ...string) (map[string]common.Address, error)
- func (tr *Tracer) GetTobinTax(blockNumber *big.Int, reserve common.Address) (*TobinTax, error)
- func (tr *Tracer) TraceTransaction(blockHeader *types.Header, tx *types.Transaction, receipt *types.Receipt) ([]Operation, error)
- func (tr *Tracer) TxGasDetails(coinbase common.Address, tx *types.Transaction, receipt *types.Receipt) (*Operation, error)
- func (tr *Tracer) TxOpsFromLogs(tx *types.Transaction, receipt *types.Receipt, tobinTax *TobinTax, ...) ([]Operation, error)
- func (tr *Tracer) TxTransfers(tx *types.Transaction, receipt *types.Receipt, tobinTax *TobinTax) ([]Operation, error)
- type Transfer
Constants ¶
This section is empty.
Variables ¶
var AllOperationTypes = []OperationType{ OpFee, OpTransfer, OpCreateAccount, OpAuthorizeValidatorSigner, OpAuthorizeAttestationSigner, OpAuthorizeVoteSigner, OpLockGold, OpUnlockGold, OpRelockGold, OpWithdrawGold, OpVote, OpActiveVotes, OpRevokePendingVotes, OpRevokeActiveVotes, OpSlash, OpEpochRewards, }
var TobinTaxDenominator *big.Int = new(big.Int).Exp(big.NewInt(10), big.NewInt(24), nil)
10^(24) == 1000000000000000000000000
Functions ¶
func AllOperationTypesString ¶
func AllOperationTypesString() []string
func MatchAndReconcileLogOpWithTransfer ¶ added in v0.6.3
func MatchAndReconcileLogOpWithTransfer(logOp, trOp *Operation, tobinTax *TobinTax, lockedGold common.Address) bool
MatchAndReconcileLogOpWithTransfer returns true if the operations match as is or when we factor in tobin tax
If the operations match with tobin tax, then we reconcile the operations into one by combining their balance changes
operations match with tobin tax iff
logOp.Type == OpLockGold && logOp.lockedGoldContractAccMain.diff == trOp.lockedGoldContractAccMain.diff && logOp.fromAccMain.diff - trOp.fromAccMain.diff == trOp.tobinRecipientAccMain.diff
Ex. lock(100 cGlD), tobinTax == 10% Transfer Operation:
fromAccMain -90 lockedGoldContractAccMain 90 fromAccMain -10 // diff == -100 tobinRecipientAccMain 10
LockedGold Operation (created from `GoldLocked(fromAccount, 90)` event):
fromAccMain -90 // diff == -90 lockedGoldContractAccMain 90 fromAccLockedNonVoting 90
Reconciled Operation:
fromAccMain -90 lockedGoldContractAccMain 90 fromAccMain -10 tobinRecipientAccMain 10 fromAccLockedNonVoting 90
func MatchChangesOnSubAccount ¶
func MatchChangesOnSubAccount(op1 *Operation, op2 *Operation, subAccountType SubAccountType) bool
Types ¶
type Account ¶
type Account struct { Address common.Address SubAccount SubAccount }
func NewAccount ¶
func NewAccount(addr common.Address, subAccount SubAccountType) Account
func NewSignerAccount ¶ added in v0.6.3
func NewVotingAccount ¶
type BalanceChange ¶
type BalanceSet ¶
type BalanceSet struct {
// contains filtered or unexported fields
}
func NewBalanceSet ¶
func NewBalanceSet() *BalanceSet
func (*BalanceSet) Add ¶
func (bs *BalanceSet) Add(addr common.Address, value *big.Int) *BalanceSet
type ChainParameters ¶
func (*ChainParameters) IsLastBlockOfEpoch ¶
func (cp *ChainParameters) IsLastBlockOfEpoch(blockNumber uint64) bool
type Operation ¶
type Operation struct { Type OperationType Changes []BalanceChange Successful bool }
func ComputeEpochRewards ¶
func ComputeEpochRewards(ctx context.Context, cc *client.CeloClient, db db.RosettaDBReader, header *types.Header) (*Operation, error)
func InternalTransfersToOperations ¶ added in v0.6.3
func NewActiveVotes ¶
func NewAuthorizeSigner ¶ added in v0.6.2
func NewCreateAccount ¶ added in v0.6.1
func NewLockGold ¶
Ex. lock(100 cGlD), tobinTax == 10% Transfer Operation:
fromAccMain -90 lockedGoldContractAccMain 90 fromAccMain -10 tobinRecipientAccMain 10
LockedGold Operation (created from `GoldLocked(fromAccount, 90)` event):
fromAccMain -90 lockedGoldContractAccMain 90 fromAccLockedNonVoting 90
Reconciled Operation:
fromAccMain -90 lockedGoldContractAccMain 90 fromAccMain -10 tobinRecipientAccMain 10 fromAccLockedNonVoting 90
func NewRevokeActiveVotes ¶
func NewRevokePendingVotes ¶
func NewSlash ¶
func NewSlash(slashed, slasher, communityFund, lockedGoldAddr common.Address, penalty, reward *big.Int, tobinTax *TobinTax) *Operation
Ex. Slash(penalty=110, reward=100 cGlD), tobinTax == 10% Transfer Operation:
lockedGoldContractAccMain -9 communityFundAccMain 9 lockedGoldContractAccMain -1 tobinRecipientAccMain 1
LockedGold Operation (created from `AccountSlashed(slashed, -100, reporter, 110)` event):
slashedAccLockedGoldNonVoting -110 reporterAccLockedGoldNonVoting 100 lockedGoldContractAccMain -9 communityFundAccMain 9 lockedGoldContractAccMain -1 tobinRecipientAccMain 1
func NewTransfer ¶
func NewWithdrawGold ¶
func NewWithdrawGold(addr, lockedGoldAddr common.Address, value *big.Int, tobinTax *TobinTax) *Operation
Ex. Withdraw(100 cGlD), tobinTax == 10% Transfer Operation:
lockedGoldContractAccMain -90 toAccMain 90 lockedGoldContractAccMain -10 tobinRecipientAccMain 10
LockedGold Operation (created from `GoldWithdraw(toAccount, 100)` event):
lockedGoldContractAccMain -90 toAccMain 90 lockedGoldContractAccMain -10 tobinRecipientAccMain 10 AccLockedPending -100
func ReconcileLogOpsWithTransfers ¶ added in v0.6.3
func ReconcileLogOpsWithTransfers(logOps, transferOps []Operation, tobinTax *TobinTax, lockedGold common.Address) ([]Operation, error)
ReconcileLogOpsWithTransfers merges operations derived from the tx logs with transfers derived from the tx tracer into one slice that contains no duplicate operations.
See NewLockGold, NewWithdrawal, NewSlash for examples.
type OperationType ¶
type OperationType string
const ( OpFee OperationType = "fee" OpTransfer OperationType = "transfer" OpCreateAccount OperationType = "createAccount" OpAuthorizeVoteSigner OperationType = "authorizeVoteSigner" OpAuthorizeValidatorSigner OperationType = "authorizeValidatorSigner" OpAuthorizeAttestationSigner OperationType = "authorizeAttestationSigner" OpLockGold OperationType = "lockGold" OpUnlockGold OperationType = "unlockGold" OpRelockGold OperationType = "relockGold" OpWithdrawGold OperationType = "withdrawGold" OpVote OperationType = "vote" OpActiveVotes OperationType = "activateVotes" OpRevokePendingVotes OperationType = "revokePendingVotes" OpRevokeActiveVotes OperationType = "revokeActiveVotes" OpSlash OperationType = "slash" OpEpochRewards OperationType = "epochRewards" )
func (OperationType) String ¶
func (ot OperationType) String() string
type SubAccount ¶
type SubAccount struct { Identifier SubAccountType Metadata map[string]interface{} }
type SubAccountType ¶
type SubAccountType string
const ( AccMain SubAccountType = "Main" AccSigner SubAccountType = "AccountsAuthorizedSigner" AccLockedGoldNonVoting SubAccountType = "LockedGoldNonVoting" AccLockedGoldVotingActive SubAccountType = "LockedGoldVotingActive" AccLockedGoldVotingPending SubAccountType = "LockedGoldVotingPending" AccLockedGoldPending SubAccountType = "LockedGoldPending" AccReleaseGoldVested SubAccountType = "ReleaseGoldVested" AccReleaseGoldUnvestedLocked SubAccountType = "ReleaseGoldUnvestedLocked" AccReleaseGoldUnvestedUnLocked SubAccountType = "ReleaseGoldUnvestedUnlocked" )
type TobinTax ¶ added in v0.6.3
func NewTobinTax ¶ added in v0.6.3
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
func NewTracer ¶
func NewTracer(ctx context.Context, cc *client.CeloClient, db db.RosettaDBReader, traceTimeout time.Duration) *Tracer