From b069432f0e7f00d77bb7ead728a5a9e5fdb3ea2a Mon Sep 17 00:00:00 2001 From: pharr117 Date: Sun, 28 Jan 2024 16:04:36 -0500 Subject: [PATCH 1/2] Add parser for all valset reward withdrawal events --- csv/parsers/accointing/accointing.go | 18 ++++++++++++++++++ csv/parsers/cointracker/cointracker.go | 15 +++++++++++++++ .../cryptotaxcalculator/cryptotaxcalculator.go | 16 ++++++++++++++++ csv/parsers/koinly/koinly.go | 17 +++++++++++++++++ csv/parsers/taxbit/taxbit.go | 17 +++++++++++++++++ 5 files changed, 83 insertions(+) diff --git a/csv/parsers/accointing/accointing.go b/csv/parsers/accointing/accointing.go index 88ed244..a3d7b78 100644 --- a/csv/parsers/accointing/accointing.go +++ b/csv/parsers/accointing/accointing.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -253,6 +254,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParsePoolManagerSwap(event) case concentratedliquidity.MsgCollectIncentives, concentratedliquidity.MsgCollectSpreadRewards: newRow, err = ParseConcentratedLiquidityCollection(event) + case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: + newRow, err = ParseValsetPrefRewards(event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -460,3 +463,18 @@ func ParseConcentratedLiquidityCollection(event db.TaxableTransaction) (Row, err return *row, err } + +func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { + row := &Row{} + row.OperationID = event.Message.Tx.Hash + row.TransactionType = Withdraw + row.Classification = Staked + row.Date = event.Message.Tx.Block.TimeStamp.Format(TimeLayout) + + err := parseAndAddReceivedAmount(row, event) + if err != nil { + return *row, err + } + + return *row, nil +} diff --git a/csv/parsers/cointracker/cointracker.go b/csv/parsers/cointracker/cointracker.go index 53f5220..7a191d0 100644 --- a/csv/parsers/cointracker/cointracker.go +++ b/csv/parsers/cointracker/cointracker.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -215,6 +216,8 @@ func ParseTx(address string, events []db.TaxableTransaction, fees []db.Fee) (row newRow, err = ParsePoolManagerSwap(event) case concentratedliquidity.MsgCollectIncentives, concentratedliquidity.MsgCollectSpreadRewards: newRow, err = ParseConcentratedLiquidityCollection(event) + case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: + newRow, err = ParseValsetPrefRewards(event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -443,3 +446,15 @@ func ParseConcentratedLiquidityCollection(event db.TaxableTransaction) (Row, err return *row, err } + +func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { + row := &Row{} + row.Date = event.Message.Tx.Block.TimeStamp.Format(TimeLayout) + + err := parseAndAddReceivedAmount(row, event) + if err != nil { + return *row, err + } + + return *row, nil +} diff --git a/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go b/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go index c1d3bea..6914a83 100644 --- a/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go +++ b/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -216,6 +217,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParsePoolManagerSwap(address, event) case concentratedliquidity.MsgCollectIncentives, concentratedliquidity.MsgCollectSpreadRewards: newRow, err = ParseConcentratedLiquidityCollection(event) + case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: + newRow, err = ParseValsetPrefRewards(event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -426,3 +429,16 @@ func ParseConcentratedLiquidityCollection(event db.TaxableTransaction) (Row, err return *row, err } + +func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { + row := &Row{} + row.Type = Receive + row.Date = event.Message.Tx.Block.TimeStamp.Format(TimeLayout) + + err := parseAndAddReceivedAmount(row, event) + if err != nil { + return *row, err + } + + return *row, nil +} diff --git a/csv/parsers/koinly/koinly.go b/csv/parsers/koinly/koinly.go index 005fc25..b63511a 100644 --- a/csv/parsers/koinly/koinly.go +++ b/csv/parsers/koinly/koinly.go @@ -18,6 +18,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -319,6 +320,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParsePoolManagerSwap(event) case concentratedliquidity.MsgCollectIncentives, concentratedliquidity.MsgCollectSpreadRewards: newRow, err = ParseConcentratedLiquidityCollection(event) + case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: + newRow, err = ParseValsetPrefRewards(event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -526,3 +529,17 @@ func ParseConcentratedLiquidityCollection(event db.TaxableTransaction) (Row, err return *row, err } + +func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { + row := &Row{} + row.Label = Income + row.Date = event.Message.Tx.Block.TimeStamp.Format(TimeLayout) + row.TxHash = event.Message.Tx.Hash + + err := parseAndAddReceivedAmount(row, event) + if err != nil { + return *row, err + } + + return *row, nil +} diff --git a/csv/parsers/taxbit/taxbit.go b/csv/parsers/taxbit/taxbit.go index 0ad26e1..03dda77 100644 --- a/csv/parsers/taxbit/taxbit.go +++ b/csv/parsers/taxbit/taxbit.go @@ -14,6 +14,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/db" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" ) func (p *Parser) TimeLayout() string { @@ -246,6 +247,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParseMsgTransfer(address, event) case poolmanager.MsgSplitRouteSwapExactAmountIn, poolmanager.MsgSwapExactAmountIn, poolmanager.MsgSwapExactAmountOut: newRow, err = ParsePoolManagerSwap(event) + case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: + newRow, err = ParseValsetPrefRewards(event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -377,3 +380,17 @@ func ParsePoolManagerSwap(event db.TaxableTransaction) (Row, error) { } return *row, err } + +func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { + row := &Row{} + row.Date = event.Message.Tx.Block.TimeStamp.Format(TimeLayout) + row.TransactionType = Income + row.TxHash = event.Message.Tx.Hash + + err := parseAndAddReceivedAmount(row, event) + if err != nil { + return *row, err + } + + return *row, nil +} From dea949e9f6fc804220c838f96dd450879295fa3a Mon Sep 17 00:00:00 2001 From: pharr117 Date: Sun, 28 Jan 2024 16:16:28 -0500 Subject: [PATCH 2/2] Tokenfactory csv parsers --- csv/parsers/accointing/accointing.go | 13 +++++++++++++ csv/parsers/cointracker/cointracker.go | 13 +++++++++++++ .../cryptotaxcalculator/cryptotaxcalculator.go | 13 +++++++++++++ csv/parsers/koinly/koinly.go | 13 +++++++++++++ csv/parsers/taxbit/taxbit.go | 13 +++++++++++++ 5 files changed, 65 insertions(+) diff --git a/csv/parsers/accointing/accointing.go b/csv/parsers/accointing/accointing.go index a3d7b78..1eaf81f 100644 --- a/csv/parsers/accointing/accointing.go +++ b/csv/parsers/accointing/accointing.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -256,6 +257,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParseConcentratedLiquidityCollection(event) case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: newRow, err = ParseValsetPrefRewards(event) + case tokenfactory.MsgMint, tokenfactory.MsgBurn: + newRow, err = ParseTokenFactoryEvents(address, event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -478,3 +481,13 @@ func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { return *row, nil } + +func ParseTokenFactoryEvents(address string, event db.TaxableTransaction) (Row, error) { + row := &Row{} + err := row.ParseBasic(address, event) + if err != nil { + config.Log.Error("Error with ParseMsgMultiSend.", err) + } + + return *row, nil +} diff --git a/csv/parsers/cointracker/cointracker.go b/csv/parsers/cointracker/cointracker.go index 7a191d0..f55a1c6 100644 --- a/csv/parsers/cointracker/cointracker.go +++ b/csv/parsers/cointracker/cointracker.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -218,6 +219,8 @@ func ParseTx(address string, events []db.TaxableTransaction, fees []db.Fee) (row newRow, err = ParseConcentratedLiquidityCollection(event) case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: newRow, err = ParseValsetPrefRewards(event) + case tokenfactory.MsgMint, tokenfactory.MsgBurn: + newRow, err = ParseTokenFactoryEvents(address, event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -458,3 +461,13 @@ func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { return *row, nil } + +func ParseTokenFactoryEvents(address string, event db.TaxableTransaction) (Row, error) { + row := &Row{} + err := row.ParseBasic(address, event) + if err != nil { + config.Log.Error("Error with ParseMsgMultiSend.", err) + } + + return *row, nil +} diff --git a/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go b/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go index 6914a83..9e3d4ef 100644 --- a/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go +++ b/csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go @@ -16,6 +16,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -219,6 +220,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParseConcentratedLiquidityCollection(event) case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: newRow, err = ParseValsetPrefRewards(event) + case tokenfactory.MsgMint, tokenfactory.MsgBurn: + newRow, err = ParseTokenFactoryEvents(address, event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -442,3 +445,13 @@ func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { return *row, nil } + +func ParseTokenFactoryEvents(address string, event db.TaxableTransaction) (Row, error) { + row := &Row{} + err := row.ParseBasic(address, event) + if err != nil { + config.Log.Error("Error with ParseMsgMultiSend.", err) + } + + return *row, nil +} diff --git a/csv/parsers/koinly/koinly.go b/csv/parsers/koinly/koinly.go index b63511a..427052a 100644 --- a/csv/parsers/koinly/koinly.go +++ b/csv/parsers/koinly/koinly.go @@ -18,6 +18,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/concentratedliquidity" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" "github.com/DefiantLabs/cosmos-tax-cli/util" ) @@ -322,6 +323,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParseConcentratedLiquidityCollection(event) case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: newRow, err = ParseValsetPrefRewards(event) + case tokenfactory.MsgMint, tokenfactory.MsgBurn: + newRow, err = ParseTokenFactoryEvents(address, event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -543,3 +546,13 @@ func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { return *row, nil } + +func ParseTokenFactoryEvents(address string, event db.TaxableTransaction) (Row, error) { + row := &Row{} + err := row.ParseBasic(address, event) + if err != nil { + config.Log.Error("Error with ParseMsgMultiSend.", err) + } + + return *row, nil +} diff --git a/csv/parsers/taxbit/taxbit.go b/csv/parsers/taxbit/taxbit.go index 03dda77..2dfbffe 100644 --- a/csv/parsers/taxbit/taxbit.go +++ b/csv/parsers/taxbit/taxbit.go @@ -14,6 +14,7 @@ import ( "github.com/DefiantLabs/cosmos-tax-cli/db" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/gamm" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/poolmanager" + "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/tokenfactory" "github.com/DefiantLabs/cosmos-tax-cli/osmosis/modules/valsetpref" ) @@ -249,6 +250,8 @@ func ParseTx(address string, events []db.TaxableTransaction) (rows []parsers.Csv newRow, err = ParsePoolManagerSwap(event) case valsetpref.MsgDelegateBondedTokens, valsetpref.MsgUndelegateFromValidatorSet, valsetpref.MsgRedelegateValidatorSet, valsetpref.MsgWithdrawDelegationRewards, valsetpref.MsgDelegateToValidatorSet, valsetpref.MsgUndelegateFromRebalancedValidatorSet: newRow, err = ParseValsetPrefRewards(event) + case tokenfactory.MsgMint, tokenfactory.MsgBurn: + newRow, err = ParseTokenFactoryEvents(address, event) default: config.Log.Errorf("no parser for message type '%v'", event.Message.MessageType.MessageType) continue @@ -394,3 +397,13 @@ func ParseValsetPrefRewards(event db.TaxableTransaction) (Row, error) { return *row, nil } + +func ParseTokenFactoryEvents(address string, event db.TaxableTransaction) (Row, error) { + row := &Row{} + err := row.ParseBasic(address, event) + if err != nil { + config.Log.Error("Error with ParseMsgMultiSend.", err) + } + + return *row, nil +}