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

Auto-swap non-osmo tx fees to osmo #1145

Merged
merged 84 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
98eed0b
migrate deductfeesdecorator to txfees module & set up second module a…
AlpinYukseloglu Mar 24, 2022
bb1857c
add second module account to supported module accounts in app
AlpinYukseloglu Mar 25, 2022
88b4401
set up txFeesKeeper with new keeper interface in app
AlpinYukseloglu Mar 25, 2022
2b7f32f
add hook receiver to epoch hooks for txfees module
AlpinYukseloglu Mar 25, 2022
0becf2a
set up AfterEpochEnd hook to swap all non-OSMO fees to OSMO
AlpinYukseloglu Mar 25, 2022
ad8bd35
clean up feedecorator comments
AlpinYukseloglu Mar 25, 2022
c2c848e
add relevant keepers to TxFeeKeeper struct
AlpinYukseloglu Mar 25, 2022
6467af6
revert accidental file changes due to branch mixup
AlpinYukseloglu Mar 25, 2022
e5d46e1
revert accidental file changes due to branch mixup
AlpinYukseloglu Mar 25, 2022
cfae2f0
add rudimentary swapping logic
AlpinYukseloglu Mar 25, 2022
528edfd
clean up comments and spacing
AlpinYukseloglu Mar 25, 2022
9db3006
add gammkeeper and move swap calls under it
AlpinYukseloglu Mar 25, 2022
8850485
comments for intended feedecorator tests
AlpinYukseloglu Mar 25, 2022
26c3316
fix swap parameters to get correct pool id and minimum output
AlpinYukseloglu Mar 25, 2022
3f40623
set up feegrantkeeper in suite app for testing
AlpinYukseloglu Mar 25, 2022
2d1ceb2
Update x/txfees/keeper/feedecorator.go
AlpinYukseloglu Mar 27, 2022
081d9a7
Update x/txfees/keeper/feedecorator.go
AlpinYukseloglu Mar 27, 2022
aa5775e
Update x/txfees/keeper/feedecorator.go
AlpinYukseloglu Mar 27, 2022
184b939
Update x/txfees/keeper/feedecorator.go
AlpinYukseloglu Mar 27, 2022
4bce525
Update x/txfees/keeper/feedecorator.go
AlpinYukseloglu Mar 27, 2022
5032ca1
Apply suggestions from code review
AlpinYukseloglu Mar 27, 2022
9719f75
Merge branch 'auto-fee-swaps' of https://github.com/osmosis-labs/osmo…
AlpinYukseloglu Mar 27, 2022
b9026d1
update comments
AlpinYukseloglu Mar 27, 2022
349bc70
attempt to migrate test from legacytx to txbuilder
AlpinYukseloglu Mar 28, 2022
d8fbd81
updates
alexanderbez Mar 28, 2022
8002532
update txbuilder setup
AlpinYukseloglu Mar 28, 2022
5371229
update feedecorator test for sanity check on dfd
AlpinYukseloglu Mar 28, 2022
4f1fded
working second module acc tx tests
AlpinYukseloglu Mar 29, 2022
b1b02cf
clean up debugging and comments
AlpinYukseloglu Mar 29, 2022
2ddddd2
remove superfluous comments
AlpinYukseloglu Mar 29, 2022
634c2b8
add tests for hooks.go
AlpinYukseloglu Mar 29, 2022
573f48c
complete fee swap and distribution tests
AlpinYukseloglu Mar 29, 2022
a611c28
clean up comments
AlpinYukseloglu Mar 29, 2022
5ffcf27
remove import comments app/keepers.go
AlpinYukseloglu Mar 29, 2022
38a9609
Apply suggestions from code review
AlpinYukseloglu Mar 30, 2022
f03ca7e
change name for second module account to AltFeeCollector
AlpinYukseloglu Mar 30, 2022
5cda003
go docs for CalcOutGivenIn function
AlpinYukseloglu Mar 30, 2022
dccb1dd
updates
alexanderbez Mar 30, 2022
7355d76
updates
alexanderbez Mar 30, 2022
495be0a
updates
alexanderbez Mar 30, 2022
7a41952
Apply suggestions from code review
AlpinYukseloglu Apr 4, 2022
d483612
Apply suggestions from code review
AlpinYukseloglu Apr 6, 2022
82454dd
update second module name
AlpinYukseloglu Apr 6, 2022
0c001f4
add error check for swaps
AlpinYukseloglu Apr 6, 2022
5c8ec96
Apply comment suggestions from code review
AlpinYukseloglu Apr 6, 2022
3cb4fc7
add minTokenOut comments
AlpinYukseloglu Apr 6, 2022
d33ae10
update swap error checking logic
AlpinYukseloglu Apr 6, 2022
213d32e
set up changes for hook tests
AlpinYukseloglu Apr 7, 2022
d9609d5
resolve merge conflicts
AlpinYukseloglu Apr 7, 2022
e415a51
merge related fixes
AlpinYukseloglu Apr 7, 2022
3fe3b63
merge related updates
AlpinYukseloglu Apr 7, 2022
637b75c
gofmt updates
AlpinYukseloglu Apr 7, 2022
f803faa
Fix feekeeper test setup
ValarDragon Apr 7, 2022
273fc3b
switch tests to cleaner approach for resetting
AlpinYukseloglu Apr 9, 2022
d710ad0
refactor tx building into test suite
AlpinYukseloglu Apr 9, 2022
b6da360
add error checks and run linters
AlpinYukseloglu Apr 9, 2022
8bdea1f
formatting
AlpinYukseloglu Apr 9, 2022
903b2a2
fix linting related issues
AlpinYukseloglu Apr 9, 2022
691dce4
Apply suggestions from code review
AlpinYukseloglu Apr 13, 2022
6eec713
apply suggestions from review
AlpinYukseloglu Apr 13, 2022
68d2ad2
Merge branch 'main' into auto-fee-swaps
AlpinYukseloglu Apr 13, 2022
193f832
run linter
AlpinYukseloglu Apr 13, 2022
5b5749d
run linter
AlpinYukseloglu Apr 13, 2022
87bd397
fix import-related issues
AlpinYukseloglu Apr 13, 2022
342761c
fix merge conflicts
AlpinYukseloglu Apr 13, 2022
c1228c3
Delete math.go
AlpinYukseloglu Apr 14, 2022
02056ae
Merge branch 'main' into auto-fee-swaps
AlpinYukseloglu Apr 14, 2022
1e43f4e
Fix build error
ValarDragon Apr 15, 2022
b60e0a0
Merge branch 'main' into auto-fee-swaps
ValarDragon Apr 15, 2022
709bceb
Fix formatting
ValarDragon Apr 15, 2022
05b3fbc
Not sure why make format didn't catch this
ValarDragon Apr 15, 2022
3d8e7dc
import fixes
AlpinYukseloglu Apr 15, 2022
2b8140d
Delete fee grant keeper
ValarDragon Apr 15, 2022
dbc7cb1
Merge branch 'auto-fee-swaps' of https://github.com/osmosis-labs/osmo…
AlpinYukseloglu Apr 16, 2022
c152510
gerge branch 'auto-fee-swaps' of https://github.com/osmosis-labs/osmo…
AlpinYukseloglu Apr 18, 2022
faf48a5
fix tests to accommodate removal of fee grant keeper
AlpinYukseloglu Apr 18, 2022
ab34ca3
remove panic errors at epoch end and remove potential for unbounded d…
AlpinYukseloglu Apr 18, 2022
366da35
Apply suggestions from code review
AlpinYukseloglu Apr 18, 2022
84ab533
Update epoch code + DRY some of the test
ValarDragon Apr 18, 2022
08c4a8f
Merge branch 'main' into auto-fee-swaps
ValarDragon Apr 21, 2022
f3c0eee
formatting
AlpinYukseloglu Apr 21, 2022
85d215b
formatting
AlpinYukseloglu Apr 21, 2022
2c22499
Fix build & keeper import
ValarDragon Apr 22, 2022
f341152
Apply suggestions from code review
ValarDragon Apr 22, 2022
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
4 changes: 3 additions & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewAnteHandler(
) sdk.AnteHandler {
mempoolFeeOptions := txfeestypes.NewMempoolFeeOptions(appOpts)
mempoolFeeDecorator := txfeeskeeper.NewMempoolFeeDecorator(*txFeesKeeper, mempoolFeeOptions)
deductFeeDecorator := txfeeskeeper.NewDeductFeeDecorator(*txFeesKeeper, ak, bankKeeper, nil)
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(wasmConfig.SimulationGasLimit),
Expand All @@ -43,7 +44,8 @@ func NewAnteHandler(
ante.TxTimeoutHeightDecorator{},
ante.NewValidateMemoDecorator(ak),
ante.NewConsumeGasForTxSizeDecorator(ak),
ante.NewDeductFeeDecorator(ak, bankKeeper, nil),
// Replaced with version from our txfees module from auth (previously "ante.NewDeductFeeDecorator(ak, bankKeeper, nil)")"
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
deductFeeDecorator,
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(ak),
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
Expand Down
12 changes: 11 additions & 1 deletion app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ func (app *OsmosisApp) InitNormalKeepers(
)
app.MintKeeper = &mintKeeper



poolIncentivesKeeper := poolincentiveskeeper.NewKeeper(
appCodec,
keys[poolincentivestypes.StoreKey],
Expand All @@ -358,10 +360,16 @@ func (app *OsmosisApp) InitNormalKeepers(
)
app.PoolIncentivesKeeper = &poolIncentivesKeeper

// Note: gammKeeper is expected to satisfy the SpotPriceCalculator interface parameter
txFeesKeeper := txfeeskeeper.NewKeeper(
appCodec,
app.AccountKeeper,
app.BankKeeper,
app.EpochsKeeper,
keys[txfeestypes.StoreKey],
app.GAMMKeeper,
gammKeeper,
txfeestypes.FeeCollectorName,
txfeestypes.FooCollectorName,
)
app.TxFeesKeeper = &txFeesKeeper

Expand Down Expand Up @@ -465,6 +473,8 @@ func (app *OsmosisApp) SetupHooks() {
app.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
// insert epoch hooks receivers here
// TO DO: add TxFeesKeeper.Hooks() for auto fee swaps
app.TxFeesKeeper.Hooks(),
app.SuperfluidKeeper.Hooks(),
app.IncentivesKeeper.Hooks(),
app.MintKeeper.Hooks(),
Expand Down
1 change: 1 addition & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var moduleAaccountPermissions = map[string][]string{
poolincentivestypes.ModuleName: nil,
superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
txfeestypes.ModuleName: nil,
txfeestypes.FooCollectorName: nil,
wasm.ModuleName: {authtypes.Burner},
}

Expand Down
123 changes: 123 additions & 0 deletions x/txfees/keeper/feedecorator.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package keeper

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/osmosis-labs/osmosis/v7/x/txfees/keeper/txfee_filters"
"github.com/osmosis-labs/osmosis/v7/x/txfees/types"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// MempoolFeeDecorator will check if the transaction's fee is at least as large
Expand Down Expand Up @@ -119,3 +123,122 @@ func (mfd MempoolFeeDecorator) GetMinBaseGasPriceForTx(ctx sdk.Context, baseDeno
}
return cfgMinGasPrice
}

// DeductFeeDecorator deducts fees from the first signer of the tx
// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error
// Call next AnteHandler if fees successfully deducted
// CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
type DeductFeeDecorator struct {
ak types.AccountKeeper
bankKeeper types.BankKeeper
feegrantKeeper types.FeegrantKeeper
txFeesKeeper Keeper
}

func NewDeductFeeDecorator(tk Keeper, ak types.AccountKeeper, bk types.BankKeeper, fk types.FeegrantKeeper) DeductFeeDecorator {
return DeductFeeDecorator{
ak: ak,
bankKeeper: bk,
feegrantKeeper: fk,
txFeesKeeper: tk,
}
}

func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {

AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
// checks to make sure feeTx is of the right type
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
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 OSMO
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
if addr := dfd.ak.GetModuleAddress(types.FeeCollectorName); addr == nil {
return ctx, fmt.Errorf("Fee collector module account (%s) has not been set", types.FeeCollectorName)
}

// checks to make sure a separate module account has been set to collect fees not in OSMO
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
if addrFoo := dfd.ak.GetModuleAddress(types.FooCollectorName); addrFoo == nil {
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
return ctx, fmt.Errorf("Foo collector module account (%s) has not been set", types.FooCollectorName)
}

// fee can be in any denom (checked for validity later)
fee := feeTx.GetFee()
feePayer := feeTx.FeePayer()
feeGranter := feeTx.FeeGranter()

// set the fee payer as the default address to deduct fees from
deductFeesFrom := feePayer

// if feegranter set deduct fee from feegranter account.
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
// this works with only when feegrant enabled.
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
if feeGranter != nil {
if dfd.feegrantKeeper == nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee grants are not enabled")
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
} else if !feeGranter.Equals(feePayer) {
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, tx.GetMsgs())

if err != nil {
return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer)
}
}

// if no errors, change the account that is charged for fees to the fee granter
deductFeesFrom = feeGranter
}

// pulls account from address and makes sure it exists
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
deductFeesFromAcc := dfd.ak.GetAccount(ctx, deductFeesFrom)
if deductFeesFromAcc == nil {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom)
}

// deducts the fees and transfer them to the module account
if !feeTx.GetFee().IsZero() {
err = DeductFees(dfd.txFeesKeeper, dfd.bankKeeper, ctx, deductFeesFromAcc, feeTx.GetFee())
if err != nil {
return ctx, err
}
} // no additional action/else statment needed if the fee is zero since zero-gas transactions are allowed
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved

events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx,
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()),
)}
ctx.EventManager().EmitEvents(events)

return next(ctx, tx, simulate)
}

// DeductFees deducts fees from the given account and transfers them to the set module account
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
func DeductFees(txFeesKeeper types.TxFeesKeeper, bankKeeper types.BankKeeper, ctx sdk.Context, acc authtypes.AccountI, fees sdk.Coins) error {

AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
// Checks the validity of the fee tokens (sorted, have positive amount, valid and unique denomination)
if !fees.IsValid() {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
}

// pulls base denom from TxFeesKeeper (should be uOSMO)
baseDenom, err := txFeesKeeper.GetBaseDenom(ctx)
if err != nil {
return err
}

// checks if input fee is uOSMO (assumes only one fee token exists in the fees array (as per the check in mempoolFeeDecorator))
if fees[0].Denom == baseDenom {
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved

// sends to FeeCollectorName module account
err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
}
} else {

// sends to FooCollectorName module account
err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FooCollectorName, fees)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
}
}

return nil
}
78 changes: 78 additions & 0 deletions x/txfees/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package keeper

import (
// "fmt"

// "github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"
)

func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
}
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved

// at the end of each epoch, swap all non-OSMO fees into OSMO and transfer to fee module account
func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {

// get module address for FooCollectorName
addrFoo := k.accountKeeper.GetModuleAddress(txfeestypes.FooCollectorName)

// get balances for all denoms in the module account
fooAccountBalances := k.bankKeeper.GetAllBalances(ctx, addrFoo)

// pulls base denom from TxFeesKeeper (should be uOSMO)
baseDenom, _ := k.GetBaseDenom(ctx)

// iterate through the resulting array and swap each denom into OSMO using the GAMM module
for _, coin := range fooAccountBalances {

AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
if coin.Denom == baseDenom {
continue
} else {
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved

// TO DO: figure out how to cast this or get the pool ID for the main OSMO paired pool
feetoken := coin.(txfeestypes.FeeToken)

// calculate spot price to determine minimum out for swap
// question: is the order of input denom and output denom correct?
spotPrice, _ := k.spotPriceCalculator.CalculateSpotPrice(ctx, feetoken.GetPoolID(), coin.Denom, baseDenom)

// swap into OSMO
// question: is spotPrice really the minimum out for the swap?
k.spotPriceCalculator.SwapExactAmountIn(ctx, addrFoo, feetoken.GetPoolId(), coin.Denom, baseDenom, k.spotPriceCalculator)
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
}
}

// PLACEHOLDER – addrFee := k.accountKeeper.GetModuleAddress(txfeestypes.FeeCollectorName)

// Potential error to test for: do swaps to OSMO consolidate into a single denom in fooAccountBalances? Should be yes but keep an eye out

// send all OSMO to fee module account to be distributed in the next block
k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.FooCollectorName, txfeestypes.FeeCollectorName, fooAccountBalances)

// Should events be emitted at the end here?
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
}

// ___________________________________________________________________________________________________
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved

// Hooks wrapper struct for incentives keeper
type Hooks struct {
k Keeper
}

var _ epochstypes.EpochHooks = Hooks{}

// Return the wrapper struct
func (k Keeper) Hooks() Hooks {
return Hooks{k}
}

// epochs hooks
func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber)
}

func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
h.k.AfterEpochEnd(ctx, epochIdentifier, epochNumber)
}
19 changes: 19 additions & 0 deletions x/txfees/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

"github.com/osmosis-labs/osmosis/v7/x/txfees/types"
)

Expand All @@ -17,19 +19,36 @@ type (
cdc codec.Codec
storeKey sdk.StoreKey

accountKeeper types.AccountKeeper
bankKeeper *bankkeeper.BaseKeeper
epochKeeper types.EpochKeeper

spotPriceCalculator types.SpotPriceCalculator

feeCollectorName string
fooCollectorName string
}
)

func NewKeeper(
cdc codec.Codec,
accountKeeper types.AccountKeeper,
bankKeeper *bankkeeper.BaseKeeper,
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

reminder: Should use bank keeper from expected_keepers, instead of using it in a direct import form!

epochKeeper types.EpochKeeper,
storeKey sdk.StoreKey,
spotPriceCalculator types.SpotPriceCalculator,
feeCollectorName string,
fooCollectorName string,
) Keeper {
return Keeper{
cdc: cdc,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
epochKeeper: epochKeeper,
storeKey: storeKey,
spotPriceCalculator: spotPriceCalculator,
feeCollectorName: feeCollectorName,
fooCollectorName: fooCollectorName,
}
}

Expand Down
41 changes: 41 additions & 0 deletions x/txfees/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,51 @@ package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
)

// SpotPriceCalculator defines the contract that must be fulfilled by a spot price calculator
// The x/gamm keeper is expected to satisfy this interface
type SpotPriceCalculator interface {
CalculateSpotPrice(ctx sdk.Context, poolId uint64, tokenInDenom, tokenOutDenom string) (sdk.Dec, error)
SwapExactAmountIn(
ctx sdk.Context,
sender sdk.AccAddress,
poolId uint64,
tokenIn sdk.Coin,
tokenOutDenom string,
tokenOutMinAmount sdk.Int,
) (tokenOutAmount sdk.Int, spotPriceAfter sdk.Dec, err error)
}

// AccountKeeper defines the contract needed for AccountKeeper related APIs.
// Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators.
type AccountKeeper interface {
GetParams(ctx sdk.Context) (params authtypes.Params)
AlpinYukseloglu marked this conversation as resolved.
Show resolved Hide resolved
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
SetAccount(ctx sdk.Context, acc authtypes.AccountI)
GetModuleAddress(moduleName string) sdk.AccAddress
}

// FeegrantKeeper defines the expected feegrant keeper.
type FeegrantKeeper interface {
UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error
}

// BankKeeper defines the contract needed for supply related APIs (noalias)
type BankKeeper interface {
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

// TxFeesKeeper defines the expected transaction fee keeper
type TxFeesKeeper interface {
ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin, error)
GetBaseDenom(ctx sdk.Context) (denom string, err error)
GetFeeToken(ctx sdk.Context, denom string) (FeeToken, error)
}

// EpochKeeper defines the contract needed to be fulfilled for epochs keeper
type EpochKeeper interface {
GetEpochInfo(ctx sdk.Context, identifier string) epochstypes.EpochInfo
}
Loading