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

feat: Add ability to pay tx fees with various tokens #28

Merged
merged 24 commits into from
Dec 7, 2023
Merged

Conversation

mtsitrin
Copy link
Collaborator

@mtsitrin mtsitrin commented Dec 5, 2023

consist of a few logical components:

  • feedecorator.go - the MempoolFeeDecorator and DeductFeeDecorator to allow various fee tokens for gas fees
  • hooks.go -
    • epochHooks - once an epoch, swap and burn all collected tokens
    • pool hooks - add allowed fee token whenever a pool with DYM is created

@mtsitrin mtsitrin marked this pull request as ready for review December 5, 2023 17:47
@mtsitrin mtsitrin linked an issue Dec 6, 2023 that may be closed by this pull request
4 tasks
@mtsitrin mtsitrin linked an issue Dec 6, 2023 that may be closed by this pull request
@omritoptix omritoptix changed the title feat: modified Txfees module feat: Generic tx fees Dec 7, 2023
@omritoptix omritoptix changed the title feat: Generic tx fees feat: Various tx fees Dec 7, 2023
@omritoptix omritoptix changed the title feat: Various tx fees feat: Various tokens for tx fees Dec 7, 2023
@omritoptix omritoptix changed the title feat: Various tokens for tx fees feat: Add ability to pay tx fee with multiple tokens Dec 7, 2023
@omritoptix omritoptix changed the title feat: Add ability to pay tx fee with multiple tokens feat: Add ability to pay tx fee with various tokens Dec 7, 2023
@omritoptix omritoptix changed the title feat: Add ability to pay tx fee with various tokens feat: Add ability to pay tx fees with various tokens Dec 7, 2023
x/txfees/keeper/feetokens.go Outdated Show resolved Hide resolved
return sdk.NewCoin(baseDenom, spotPrice.MulInt(inputFee.Amount).RoundInt()), nil
}

// CalcFeeSpotPrice converts the provided tx fees into their equivalent value in the base denomination.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO redundant function as the logic is just in line 46 and the arguments required for it are already provided in the calling function (ConvertToBaseToken). So just can replace line 23 with the actual call to the CalculateSpotPrice.

}

// CalcFeeSpotPrice converts the provided tx fees into their equivalent value in the base denomination.
// Spot Price Calculation: spotPrice / (1 - swapFee),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this line. the spot price is calcualted in a different way. not sure what this calculation means.

return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

// checks to make sure the module account has been set to collect fees in base token
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this comment correct? why just base token?

return ctx, fmt.Errorf("txfees module account (%s) has not been set", types.ModuleName)
}

// checks to make sure the module account has been set to collect fees in base token
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here. why just base token?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what u mean.
it checks the modules defined (txfees for non-udym, feecollector for udum)

}
_, err = k.poolManager.RouteExactAmountIn(ctx, moduleAddr, route, coinBalance, sdk.ZeroInt())
if err != nil {
return err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is an error to swap one of the tokens it will exit the loop and the rest couldn't be switched. Also the token will still stay in the txFees module to cause problem for every consecutive swap.

@mtsitrin mtsitrin merged commit fc957b9 into main-dym Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[txfee] move epochIdentifier to params generic tx fees
2 participants