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

Patch/csv parsers various message types 2 #528

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
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: 31 additions & 0 deletions csv/parsers/accointing/accointing.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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"
)

Expand Down Expand Up @@ -253,6 +255,10 @@ 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)
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
Expand Down Expand Up @@ -460,3 +466,28 @@ 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
}

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
}
28 changes: 28 additions & 0 deletions csv/parsers/cointracker/cointracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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"
)

Expand Down Expand Up @@ -215,6 +217,10 @@ 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)
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
Expand Down Expand Up @@ -443,3 +449,25 @@ 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
}

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
}
29 changes: 29 additions & 0 deletions csv/parsers/cryptotaxcalculator/cryptotaxcalculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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"
)

Expand Down Expand Up @@ -216,6 +218,10 @@ 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)
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
Expand Down Expand Up @@ -426,3 +432,26 @@ 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
}

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
}
30 changes: 30 additions & 0 deletions csv/parsers/koinly/koinly.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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"
)

Expand Down Expand Up @@ -319,6 +321,10 @@ 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)
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
Expand Down Expand Up @@ -526,3 +532,27 @@ 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
}

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
}
30 changes: 30 additions & 0 deletions csv/parsers/taxbit/taxbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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"
)

func (p *Parser) TimeLayout() string {
Expand Down Expand Up @@ -246,6 +248,10 @@ 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)
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
Expand Down Expand Up @@ -377,3 +383,27 @@ 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
}

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
}
Loading