Documentation ¶
Index ¶
- func EmitBackrunEvent(ctx sdk.Context, pool SwapToBackrun, inputCoin sdk.Coin, ...)
- func NewMsgServer(keeper Keeper) types.MsgServer
- type EpochHooks
- type Hooks
- func (h Hooks) AfterCFMMPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
- func (h Hooks) AfterCFMMSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, ...)
- func (h Hooks) AfterConcentratedPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
- func (h Hooks) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, ...)
- func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, ...)
- func (h Hooks) AfterInitialPoolPositionCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
- func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, ...)
- func (h Hooks) AfterLastPoolPositionRemoved(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
- type Keeper
- func (k Keeper) AddSwapsToSwapsToBackrun(ctx sdk.Context, swaps []types.Trade) error
- func (k Keeper) AfterPoolCreatedWithCoins(ctx sdk.Context, poolId uint64)
- func (k Keeper) AnteHandleCheck(ctx sdk.Context) error
- func (k Keeper) BuildHighestLiquidityRoute(ctx sdk.Context, swapDenom types.BaseDenom, tokenIn, tokenOut string, ...) (RouteMetaData, error)
- func (k Keeper) BuildHighestLiquidityRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) ([]RouteMetaData, error)
- func (k Keeper) BuildHotRoute(ctx sdk.Context, route types.Route, poolId uint64) (RouteMetaData, error)
- func (k Keeper) BuildHotRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) ([]RouteMetaData, error)
- func (k Keeper) BuildRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) []RouteMetaData
- func (k Keeper) BuildTwoPoolRoute(ctx sdk.Context, baseDenom types.BaseDenom, tokenInDenom, tokenOutDenom string, ...) (RouteMetaData, error)
- func (k Keeper) CalculateRoutePoolPoints(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes) (uint64, error)
- func (k Keeper) CalculateUpperBoundForSearch(ctx sdk.Context, route RouteMetaData, inputDenom string) (osmomath.Int, error)
- func (k Keeper) CompareAndStorePool(ctx sdk.Context, poolId uint64, baseDenom, otherDenom string)
- func (k Keeper) ConvertProfits(ctx sdk.Context, inputCoin sdk.Coin, profit osmomath.Int) (osmomath.Int, error)
- func (k Keeper) DeleteAllEntriesForKeyPrefix(ctx sdk.Context, keyPrefix []byte)
- func (k Keeper) DeleteAllPoolsForBaseDenom(ctx sdk.Context, baseDenom string)
- func (k Keeper) DeleteAllTokenPairArbRoutes(ctx sdk.Context)
- func (k Keeper) DeleteBaseDenoms(ctx sdk.Context)
- func (k Keeper) DeleteDeveloperFees(ctx sdk.Context, denom string)deprecated
- func (k Keeper) DeleteSwapsToBackrun(ctx sdk.Context)
- func (k Keeper) EpochHooks() epochstypes.EpochHooks
- func (k Keeper) EstimateMultihopProfit(ctx sdk.Context, inputDenom string, amount osmomath.Int, ...) (sdk.Coin, osmomath.Int, error)
- func (k Keeper) ExecuteTrade(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, inputCoin sdk.Coin, ...) error
- func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
- func (k Keeper) ExtendSearchRangeIfNeeded(ctx sdk.Context, route RouteMetaData, inputDenom string, ...) (osmomath.Int, osmomath.Int, error)
- func (k Keeper) ExtractSwappedPools(ctx sdk.Context) []SwapToBackrun
- func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, ...) (sdk.Coin, osmomath.Int, error)
- func (k Keeper) GetAdminAccount(ctx sdk.Context) sdk.AccAddress
- func (k Keeper) GetAllBaseDenoms(ctx sdk.Context) ([]types.BaseDenom, error)
- func (k Keeper) GetAllDeveloperFees(ctx sdk.Context) ([]sdk.Coin, error)deprecated
- func (k Keeper) GetAllProfits(ctx sdk.Context) []sdk.Coin
- func (k Keeper) GetAllProfitsByRoute(ctx sdk.Context, route []uint64) []sdk.Coin
- func (k Keeper) GetAllProtocolRevenue(ctx sdk.Context) types.AllProtocolRevenue
- func (k Keeper) GetAllRoutes(ctx sdk.Context) ([][]uint64, error)
- func (k Keeper) GetAllTokenPairArbRoutes(ctx sdk.Context) ([]types.TokenPairArbRoutes, error)
- func (k Keeper) GetComparablePoolLiquidity(ctx sdk.Context, poolId uint64) (comparableLiquidity osmomath.Int, err error)
- func (k Keeper) GetCyclicArbProfitTrackerStartHeight(ctx sdk.Context) int64
- func (k Keeper) GetCyclicArbProfitTrackerValue(ctx sdk.Context) (currentCyclicArbProfits sdk.Coins)
- func (k Keeper) GetDaysSinceModuleGenesis(ctx sdk.Context) (uint64, error)
- func (k Keeper) GetDeveloperAccount(ctx sdk.Context) (sdk.AccAddress, error)
- func (k Keeper) GetDeveloperFees(ctx sdk.Context, denom string) (sdk.Coin, error)deprecated
- func (k Keeper) GetInfoByPoolType(ctx sdk.Context) types.InfoByPoolType
- func (k Keeper) GetLatestBlockHeight(ctx sdk.Context) (uint64, error)
- func (k Keeper) GetMaxPointsPerBlock(ctx sdk.Context) (uint64, error)
- func (k Keeper) GetMaxPointsPerTx(ctx sdk.Context) (uint64, error)
- func (k Keeper) GetNumberOfTrades(ctx sdk.Context) (osmomath.Int, error)
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPointCountForBlock(ctx sdk.Context) (uint64, error)
- func (k Keeper) GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error)
- func (k Keeper) GetPoolForDenomPairNoOrder(ctx sdk.Context, tokenA, tokenB string) (uint64, error)
- func (k Keeper) GetProfitsByDenom(ctx sdk.Context, denom string) (sdk.Coin, error)
- func (k Keeper) GetProfitsByRoute(ctx sdk.Context, route []uint64, denom string) (sdk.Coin, error)
- func (k Keeper) GetProtoRevEnabled(ctx sdk.Context) bool
- func (k Keeper) GetRemainingPoolPoints(ctx sdk.Context) (uint64, uint64, error)
- func (k Keeper) GetSwapsToBackrun(ctx sdk.Context) (types.Route, error)
- func (k Keeper) GetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string) (types.TokenPairArbRoutes, error)
- func (k Keeper) GetTradesByRoute(ctx sdk.Context, route []uint64) (osmomath.Int, error)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) IncrementNumberOfTrades(ctx sdk.Context) error
- func (k Keeper) IncrementPointCountForBlock(ctx sdk.Context, amount uint64) error
- func (k Keeper) IncrementTradesByRoute(ctx sdk.Context, route []uint64) error
- func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
- func (k Keeper) IsValidPool(ctx sdk.Context, poolID uint64) error
- func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, ...) (sdk.Coin, osmomath.Int, poolmanagertypes.SwapAmountInRoutes)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) ProtoRevTrade(ctx sdk.Context, swappedPools []SwapToBackrun) (err error)
- func (k Keeper) SendDeveloperFee(ctx sdk.Context, arbProfit sdk.Coin) error
- func (k Keeper) SendDeveloperFeesToDeveloperAccount(ctx sdk.Context) error
- func (k Keeper) SetAdminAccount(ctx sdk.Context, adminAccount sdk.AccAddress)
- func (k Keeper) SetBaseDenoms(ctx sdk.Context, baseDenoms []types.BaseDenom) error
- func (k Keeper) SetCyclicArbProfitTrackerStartHeight(ctx sdk.Context, startHeight int64)
- func (k Keeper) SetCyclicArbProfitTrackerValue(ctx sdk.Context, cyclicArbProfits sdk.Coins)
- func (k Keeper) SetDaysSinceModuleGenesis(ctx sdk.Context, daysSinceGenesis uint64)
- func (k Keeper) SetDeveloperAccount(ctx sdk.Context, developerAccount sdk.AccAddress)
- func (k Keeper) SetDeveloperFees(ctx sdk.Context, developerFees sdk.Coin) errordeprecated
- func (k Keeper) SetInfoByPoolType(ctx sdk.Context, poolWeights types.InfoByPoolType)
- func (k Keeper) SetLatestBlockHeight(ctx sdk.Context, blockHeight uint64)
- func (k Keeper) SetMaxPointsPerBlock(ctx sdk.Context, maxPoints uint64) error
- func (k Keeper) SetMaxPointsPerTx(ctx sdk.Context, maxPoints uint64) error
- func (k Keeper) SetParam(ctx sdk.Context, key []byte, value interface{})
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPointCountForBlock(ctx sdk.Context, pointCount uint64)
- func (k Keeper) SetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string, poolId uint64)
- func (k Keeper) SetProtoRevEnabled(ctx sdk.Context, enabled bool)
- func (k Keeper) SetSwapsToBackrun(ctx sdk.Context, swapsToBackrun types.Route) error
- func (k Keeper) SetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string, tokenPair types.TokenPairArbRoutes) error
- func (k Keeper) StoreJoinExitPoolSwaps(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, denom string, ...)
- func (k Keeper) StoreSwap(ctx sdk.Context, poolId uint64, tokenIn, tokenOut string)
- func (k Keeper) UpdateDeveloperFees(ctx sdk.Context, denom string, profit osmomath.Int) errordeprecated
- func (k Keeper) UpdateHighestLiquidityPools(ctx sdk.Context, baseDenomPools map[string]map[string]LiquidityPoolStruct) error
- func (k Keeper) UpdatePools(ctx sdk.Context) error
- func (k Keeper) UpdateProfitsByDenom(ctx sdk.Context, denom string, tradeProfit osmomath.Int) error
- func (k Keeper) UpdateProfitsByRoute(ctx sdk.Context, route []uint64, denom string, profit osmomath.Int) error
- func (k Keeper) UpdateSearchRangeIfNeeded(ctx sdk.Context, route RouteMetaData, inputDenom string, ...) (osmomath.Int, osmomath.Int, error)
- func (k Keeper) UpdateStatistics(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, denom string, ...) error
- type LiquidityPoolStruct
- type MsgServer
- func (m MsgServer) AdminCheck(ctx sdk.Context, admin string) error
- func (m MsgServer) SetBaseDenoms(c context.Context, msg *types.MsgSetBaseDenoms) (*types.MsgSetBaseDenomsResponse, error)
- func (m MsgServer) SetDeveloperAccount(c context.Context, msg *types.MsgSetDeveloperAccount) (*types.MsgSetDeveloperAccountResponse, error)
- func (m MsgServer) SetHotRoutes(c context.Context, msg *types.MsgSetHotRoutes) (*types.MsgSetHotRoutesResponse, error)
- func (m MsgServer) SetInfoByPoolType(c context.Context, msg *types.MsgSetInfoByPoolType) (*types.MsgSetInfoByPoolTypeResponse, error)
- func (m MsgServer) SetMaxPoolPointsPerBlock(c context.Context, msg *types.MsgSetMaxPoolPointsPerBlock) (*types.MsgSetMaxPoolPointsPerBlockResponse, error)
- func (m MsgServer) SetMaxPoolPointsPerTx(c context.Context, msg *types.MsgSetMaxPoolPointsPerTx) (*types.MsgSetMaxPoolPointsPerTxResponse, error)
- type ProtoRevDecorator
- type Querier
- func (q Querier) GetAllProtocolRevenue(c context.Context, req *types.QueryGetAllProtocolRevenueRequest) (*types.QueryGetAllProtocolRevenueResponse, error)
- func (q Querier) GetProtoRevAdminAccount(c context.Context, req *types.QueryGetProtoRevAdminAccountRequest) (*types.QueryGetProtoRevAdminAccountResponse, error)
- func (q Querier) GetProtoRevAllProfits(c context.Context, req *types.QueryGetProtoRevAllProfitsRequest) (*types.QueryGetProtoRevAllProfitsResponse, error)
- func (q Querier) GetProtoRevAllRouteStatistics(c context.Context, req *types.QueryGetProtoRevAllRouteStatisticsRequest) (*types.QueryGetProtoRevAllRouteStatisticsResponse, error)
- func (q Querier) GetProtoRevBaseDenoms(c context.Context, req *types.QueryGetProtoRevBaseDenomsRequest) (*types.QueryGetProtoRevBaseDenomsResponse, error)
- func (q Querier) GetProtoRevDeveloperAccount(c context.Context, req *types.QueryGetProtoRevDeveloperAccountRequest) (*types.QueryGetProtoRevDeveloperAccountResponse, error)
- func (q Querier) GetProtoRevEnabled(c context.Context, req *types.QueryGetProtoRevEnabledRequest) (*types.QueryGetProtoRevEnabledResponse, error)
- func (q Querier) GetProtoRevInfoByPoolType(c context.Context, req *types.QueryGetProtoRevInfoByPoolTypeRequest) (*types.QueryGetProtoRevInfoByPoolTypeResponse, error)
- func (q Querier) GetProtoRevMaxPoolPointsPerBlock(c context.Context, req *types.QueryGetProtoRevMaxPoolPointsPerBlockRequest) (*types.QueryGetProtoRevMaxPoolPointsPerBlockResponse, error)
- func (q Querier) GetProtoRevMaxPoolPointsPerTx(c context.Context, req *types.QueryGetProtoRevMaxPoolPointsPerTxRequest) (*types.QueryGetProtoRevMaxPoolPointsPerTxResponse, error)
- func (q Querier) GetProtoRevNumberOfTrades(c context.Context, req *types.QueryGetProtoRevNumberOfTradesRequest) (*types.QueryGetProtoRevNumberOfTradesResponse, error)
- func (q Querier) GetProtoRevPool(c context.Context, req *types.QueryGetProtoRevPoolRequest) (*types.QueryGetProtoRevPoolResponse, error)
- func (q Querier) GetProtoRevProfitsByDenom(c context.Context, req *types.QueryGetProtoRevProfitsByDenomRequest) (*types.QueryGetProtoRevProfitsByDenomResponse, error)
- func (q Querier) GetProtoRevStatisticsByRoute(c context.Context, req *types.QueryGetProtoRevStatisticsByRouteRequest) (*types.QueryGetProtoRevStatisticsByRouteResponse, error)
- func (q Querier) GetProtoRevTokenPairArbRoutes(c context.Context, req *types.QueryGetProtoRevTokenPairArbRoutesRequest) (*types.QueryGetProtoRevTokenPairArbRoutesResponse, error)
- func (q Querier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- type RouteMetaData
- type SwapToBackrun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitBackrunEvent ¶
func EmitBackrunEvent(ctx sdk.Context, pool SwapToBackrun, inputCoin sdk.Coin, profit, tokenOutAmount osmomath.Int, remainingTxPoolPoints, remainingBlockPoolPoints uint64)
EmitBackrunEvent updates and emits a backrunEvent
func NewMsgServer ¶
NewMsgServer returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type EpochHooks ¶
type EpochHooks struct {
// contains filtered or unexported fields
}
func (EpochHooks) AfterEpochEnd ¶
AfterEpochEnd is the epoch end hook.
func (EpochHooks) BeforeEpochStart ¶
func (h EpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error
BeforeEpochStart is the epoch start hook.
func (EpochHooks) GetModuleName ¶ added in v23.0.1
func (EpochHooks) GetModuleName() string
GetModuleName implements types.EpochHooks.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (Hooks) AfterCFMMPoolCreated ¶
AfterCFMMPoolCreated hook checks and potentially stores the pool via the highest liquidity method.
func (Hooks) AfterCFMMSwap ¶
func (h Hooks) AfterCFMMSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins)
AfterCFMMSwap stores swaps to be checked by protorev given the coins swapped in the pool.
func (Hooks) AfterConcentratedPoolCreated ¶
AfterConcentratedPoolCreated is a noop.
func (Hooks) AfterConcentratedPoolSwap ¶
func (h Hooks) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins)
AfterConcentratedPoolSwap stores swaps to be checked by protorev given the coins swapped in the pool.
func (Hooks) AfterExitPool ¶
func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins)
AfterExitPool stores swaps to be checked by protorev given the coins exited from the pool.
func (Hooks) AfterInitialPoolPositionCreated ¶
func (h Hooks) AfterInitialPoolPositionCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
AfterInitialPoolPositionCreated checks and potentially stores the pool via the highest liquidity method.
func (Hooks) AfterJoinPool ¶
func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int)
AfterJoinPool stores swaps to be checked by protorev given the coins entered into the pool.
func (Hooks) AfterLastPoolPositionRemoved ¶
AfterLastPoolPositionRemoved is a noop.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ps paramtypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, gammKeeper types.GAMMKeeper, epochKeeper types.EpochKeeper, poolmanagerKeeper types.PoolManagerKeeper, concentratedLiquidityKeeper types.ConcentratedLiquidityKeeper, ) Keeper
func (Keeper) AddSwapsToSwapsToBackrun ¶
AddSwapToSwapsToBackrun appends a swap to the swaps to backrun
func (Keeper) AfterPoolCreatedWithCoins ¶
AfterPoolCreatedWithCoins checks if the new pool should be stored as the highest liquidity pool for any of the base denoms, and stores it if so.
func (Keeper) AnteHandleCheck ¶
AnteHandleCheck checks if the module is enabled and if the number of routes to be processed per block has been reached.
func (Keeper) BuildHighestLiquidityRoute ¶
func (k Keeper) BuildHighestLiquidityRoute(ctx sdk.Context, swapDenom types.BaseDenom, tokenIn, tokenOut string, poolId uint64) (RouteMetaData, error)
BuildHighestLiquidityRoute constructs a cyclic arbitrage route that is starts/ends with swapDenom (ex. osmo) given the swap (tokenIn, tokenOut, poolId).
func (Keeper) BuildHighestLiquidityRoutes ¶
func (k Keeper) BuildHighestLiquidityRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) ([]RouteMetaData, error)
BuildHighestLiquidityRoutes builds cyclic arbitrage routes using the highest liquidity method. The base denoms are sorted by priority and routes are built in a greedy manner.
func (Keeper) BuildHotRoute ¶
func (k Keeper) BuildHotRoute(ctx sdk.Context, route types.Route, poolId uint64) (RouteMetaData, error)
BuildHotRoute constructs a cyclic arbitrage route given a hot route and swap that should be placed in the hot route.
func (Keeper) BuildHotRoutes ¶
func (k Keeper) BuildHotRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) ([]RouteMetaData, error)
BuildHotRoutes builds all of the possible arbitrage routes using the hot routes method.
func (Keeper) BuildRoutes ¶
func (k Keeper) BuildRoutes(ctx sdk.Context, tokenIn, tokenOut string, poolId uint64) []RouteMetaData
BuildRoutes builds all of the possible arbitrage routes given the tokenIn, tokenOut and poolId that were used in the swap.
func (Keeper) BuildTwoPoolRoute ¶
func (k Keeper) BuildTwoPoolRoute( ctx sdk.Context, baseDenom types.BaseDenom, tokenInDenom, tokenOutDenom string, poolId uint64, ) (RouteMetaData, error)
BuildTwoPoolRoute will attempt to create a two pool route that will rebalance pools that are paired with the base denom. This is useful for pools that contain the same assets but are imbalanced.
func (Keeper) CalculateRoutePoolPoints ¶
func (k Keeper) CalculateRoutePoolPoints(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes) (uint64, error)
CalculateRoutePoolPoints calculates the number of pool points that will be consumed by a route when simulating and executing trades. This is only added to the global pool point counter if the route simulated is minimally profitable i.e. it will make a profit.
func (Keeper) CalculateUpperBoundForSearch ¶
func (k Keeper) CalculateUpperBoundForSearch( ctx sdk.Context, route RouteMetaData, inputDenom string, ) (osmomath.Int, error)
CalculateUpperBoundForSearch returns the max amount in that can be used for the binary search respecting the max ticks moved across all concentrated liquidity pools in the route.
func (Keeper) CompareAndStorePool ¶
CompareAndStorePool compares the liquidity of the new pool with the liquidity of the stored pool, and stores the new pool if it has more liquidity.
func (Keeper) ConvertProfits ¶
func (k Keeper) ConvertProfits(ctx sdk.Context, inputCoin sdk.Coin, profit osmomath.Int) (osmomath.Int, error)
ConvertProfits converts the profit denom to uosmo to allow for a fair comparison of profits
NOTE: This does not check the underlying pool before swapping so this may go over the MaxTicksCrossed.
func (Keeper) DeleteAllEntriesForKeyPrefix ¶
DeleteAllEntriesForKeyPrefix deletes all the entries from the store for the given key prefix
func (Keeper) DeleteAllPoolsForBaseDenom ¶
DeleteAllPoolsForBaseDenom deletes all the pools for the given base denom
func (Keeper) DeleteAllTokenPairArbRoutes ¶
DeleteAllTokenPairArbRoutes deletes all the token pair arb routes
func (Keeper) DeleteBaseDenoms ¶
DeleteBaseDenoms deletes all of the base denoms
func (Keeper) DeleteDeveloperFees
deprecated
func (Keeper) DeleteSwapsToBackrun ¶
DeleteSwapsToBackrun deletes the swaps to backrun
func (Keeper) EpochHooks ¶
func (k Keeper) EpochHooks() epochstypes.EpochHooks
func (Keeper) EstimateMultihopProfit ¶
func (k Keeper) EstimateMultihopProfit(ctx sdk.Context, inputDenom string, amount osmomath.Int, route poolmanagertypes.SwapAmountInRoutes) (sdk.Coin, osmomath.Int, error)
EstimateMultihopProfit estimates the profit for a given route by estimating the amount out given the amount in for the first pool in the route and then subtracting the amount in from the amount out to get the profit
func (Keeper) ExecuteTrade ¶
func (k Keeper) ExecuteTrade(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, inputCoin sdk.Coin, pool SwapToBackrun, remainingTxPoolPoints, remainingBlockPoolPoints uint64) error
ExecuteTrade inputs a route, amount in, and rebalances the pool
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState
ExportGenesis returns the module's exported genesis. ExportGenesis intentionally ignores a few of the errors thrown by the keeper methods. This is because the keeper methods are only throwing errors if there is an issue unmarshalling or if the value had not been set yet (i.e. developer account address). In that case, we just use the default values defined in genesis.go in types.
func (Keeper) ExtendSearchRangeIfNeeded ¶
func (k Keeper) ExtendSearchRangeIfNeeded( ctx sdk.Context, route RouteMetaData, inputDenom string, curLeft, curRight, updatedMax osmomath.Int, ) (osmomath.Int, osmomath.Int, error)
Determine if the binary search range needs to be extended
func (Keeper) ExtractSwappedPools ¶
func (k Keeper) ExtractSwappedPools(ctx sdk.Context) []SwapToBackrun
ExtractSwappedPools checks if there were any swaps made on pools and if so returns a list of all the pools that were swapped on and metadata about the swap
func (Keeper) FindMaxProfitForRoute ¶
func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, osmomath.Int, error)
FindMaxProfitRoute runs a binary search to find the max profit for a given route
func (Keeper) GetAdminAccount ¶
func (k Keeper) GetAdminAccount(ctx sdk.Context) sdk.AccAddress
GetAdminAccount returns the admin account for protorev
func (Keeper) GetAllBaseDenoms ¶
GetAllBaseDenoms returns all of the base denoms (sorted by priority in descending order) used to build cyclic arbitrage routes
func (Keeper) GetAllProfits ¶
GetAllProfits returns all of the profits made by the ProtoRev module.
func (Keeper) GetAllProfitsByRoute ¶
GetAllProfitsByRoute returns all of the profits made by the ProtoRev module for the given route
func (Keeper) GetAllProtocolRevenue ¶
func (k Keeper) GetAllProtocolRevenue(ctx sdk.Context) types.AllProtocolRevenue
GetAllProtocolRevenue returns all types of protocol revenue (txfees, taker fees, and cyclic arb profits), as well as the block height from which we started accounting for each of these revenue sources.
func (Keeper) GetAllRoutes ¶
GetAllRoutes returns all of the routes that the ProtoRev module has traded on
func (Keeper) GetAllTokenPairArbRoutes ¶
GetAllTokenPairArbRoutes returns all the token pair arb routes
func (Keeper) GetComparablePoolLiquidity ¶
func (k Keeper) GetComparablePoolLiquidity(ctx sdk.Context, poolId uint64) (comparableLiquidity osmomath.Int, err error)
GetComparablePoolLiquidity gets the comparable liquidity of a pool by multiplying the amounts of the pool coins.
func (Keeper) GetCyclicArbProfitTrackerStartHeight ¶
GetCyclicArbProfitTrackerStartHeight gets the height from which we started accounting for cyclic arb profits.
func (Keeper) GetCyclicArbProfitTrackerValue ¶
func (Keeper) GetDaysSinceModuleGenesis ¶
GetDaysSinceModuleGenesis returns the number of days since the module was initialized
func (Keeper) GetDeveloperAccount ¶
GetDeveloperAccount returns the developer account for protorev
func (Keeper) GetInfoByPoolType ¶
func (k Keeper) GetInfoByPoolType(ctx sdk.Context) types.InfoByPoolType
GetInfoByPoolType retrieves the metadata about the different pool types. This is used to determine the execution costs of different pool types when calculating the optimal route (in terms of time and gas consumption).
func (Keeper) GetLatestBlockHeight ¶
GetLatestBlockHeight returns the latest block height that protorev was run on
func (Keeper) GetMaxPointsPerBlock ¶
GetMaxPointsPerBlock returns the max number of pool points that can be consumed per block. A pool point is roughly equivalent to 1 ms of simulation & execution time.
func (Keeper) GetMaxPointsPerTx ¶
GetMaxPointsPerTx returns the max number of pool points that can be consumed per transaction. A pool point is roughly equivalent to 1 ms of simulation & execution time.
func (Keeper) GetNumberOfTrades ¶
GetNumberOfTrades returns the number of trades executed by the ProtoRev module
func (Keeper) GetPointCountForBlock ¶
GetPointCountForBlock returns the number of pool points that have been consumed in the current block
func (Keeper) GetPoolForDenomPair ¶
func (k Keeper) GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error)
GetPoolForDenomPair returns the id of the highest liquidity pool between the base denom and the denom to match
func (Keeper) GetPoolForDenomPairNoOrder ¶
GetPoolForDenomPairNoOrder returns the id of the pool between the two denoms. It is order-independent. That is, tokenA can either be a base or a quote. Both cases are handled. If no pool exists, an error is returned. TODO: unit test
func (Keeper) GetProfitsByDenom ¶
GetProfitsByDenom returns the profits made by the ProtoRev module for the given denom
func (Keeper) GetProfitsByRoute ¶
GetProfitsByRoute returns the profits made by the ProtoRev module for the given route and denom
func (Keeper) GetProtoRevEnabled ¶
GetProtoRevEnabled returns whether protorev is enabled
func (Keeper) GetRemainingPoolPoints ¶
RemainingPoolPointsForTx calculates the number of pool points that can be consumed in the transaction and block. When the remaining pool points for the block is less than the remaining pool points for the transaction, then both returned values will be the same, which will be the remaining pool points for the block.
func (Keeper) GetSwapsToBackrun ¶
GetSwapsToBackrun returns the swaps to backrun, updated via hooks
func (Keeper) GetTokenPairArbRoutes ¶
func (k Keeper) GetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string) (types.TokenPairArbRoutes, error)
GetTokenPairArbRoutes returns the token pair arb routes given two denoms
func (Keeper) GetTradesByRoute ¶
GetTradesByRoute returns the number of trades executed by the ProtoRev module for the given route
func (Keeper) IncrementNumberOfTrades ¶
IncrementNumberOfTrades increments the number of trades executed by the ProtoRev module
func (Keeper) IncrementPointCountForBlock ¶
IncrementPointCountForBlock increments the number of pool points that have been consumed in the current block
func (Keeper) IncrementTradesByRoute ¶
IncrementTradesByRoute increments the number of trades executed by the ProtoRev module for the given route
func (Keeper) InitGenesis ¶
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)
InitGenesis initializes the module's state from a provided genesis state.
func (Keeper) IsValidPool ¶
IsValidPool checks if the pool is active and exists
func (Keeper) IterateRoutes ¶
func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, osmomath.Int, poolmanagertypes.SwapAmountInRoutes)
IterateRoutes checks the profitability of every single route that is passed in and returns the optimal route if there is one
func (Keeper) ProtoRevTrade ¶
func (k Keeper) ProtoRevTrade(ctx sdk.Context, swappedPools []SwapToBackrun) (err error)
ProtoRevTrade wraps around the build routes, iterate routes, and execute trade functionality to execute cyclic arbitrage trades if they exist. It returns an error if there was an issue executing any single trade.
func (Keeper) SendDeveloperFee ¶
SendDeveloperFee sends the developer fee from the module account to the developer account
func (Keeper) SendDeveloperFeesToDeveloperAccount ¶
Used in v16 upgrade, can be removed in v17 SendDeveloperFeesToDeveloperAccount sends the developer fees from the module account to the developer account
func (Keeper) SetAdminAccount ¶
func (k Keeper) SetAdminAccount(ctx sdk.Context, adminAccount sdk.AccAddress)
SetAdminAccount sets the admin account for protorev
func (Keeper) SetBaseDenoms ¶
SetBaseDenoms sets all of the base denoms used to build cyclic arbitrage routes. The base denoms priority order is going to match the order of the base denoms in the slice.
func (Keeper) SetCyclicArbProfitTrackerStartHeight ¶
SetCyclicArbProfitTrackerStartHeight sets the height from which we started accounting for cyclic arb profits.
func (Keeper) SetCyclicArbProfitTrackerValue ¶
func (Keeper) SetDaysSinceModuleGenesis ¶
SetDaysSinceModuleGenesis updates the number of days since genesis
func (Keeper) SetDeveloperAccount ¶
func (k Keeper) SetDeveloperAccount(ctx sdk.Context, developerAccount sdk.AccAddress)
SetDeveloperAccount sets the developer account for protorev that will receive a portion of arbitrage profits
func (Keeper) SetInfoByPoolType ¶
func (k Keeper) SetInfoByPoolType(ctx sdk.Context, poolWeights types.InfoByPoolType)
SetInfoByPoolType sets the pool type information.
func (Keeper) SetLatestBlockHeight ¶
SetLatestBlockHeight sets the latest block height that protorev was run on
func (Keeper) SetMaxPointsPerBlock ¶
SetMaxPointsPerBlock sets the max number of pool points that can be consumed per block. A pool point is roughly equivalent to 1 ms of simulation & execution time.
func (Keeper) SetMaxPointsPerTx ¶
SetMaxPointsPerTx sets the max number of pool points that can be consumed per transaction. A pool point is roughly equivalent to 1 ms of simulation & execution time.
func (Keeper) SetParam ¶
SetParam sets a specific protorev module's parameter with the provided parameter.
func (Keeper) SetPointCountForBlock ¶
SetPointCountForBlock sets the number of pool points that have been consumed in the current block
func (Keeper) SetPoolForDenomPair ¶
SetPoolForDenomPair sets the id of the highest liquidty pool between the base denom and the denom to match
func (Keeper) SetProtoRevEnabled ¶
SetProtoRevEnabled sets whether the protorev post handler is enabled
func (Keeper) SetSwapsToBackrun ¶
SetSwapsToBackrun sets the swaps to backrun, updated via hooks
func (Keeper) SetTokenPairArbRoutes ¶
func (k Keeper) SetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string, tokenPair types.TokenPairArbRoutes) error
SetTokenPairArbRoutes sets the token pair arb routes given two denoms
func (Keeper) StoreJoinExitPoolSwaps ¶
func (k Keeper) StoreJoinExitPoolSwaps(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, denom string, isJoin bool)
StoreJoinExitPoolSwaps stores the swaps associated with GAMM join/exit pool messages in the store, depending on if it is a join or exit.
func (Keeper) StoreSwap ¶
StoreSwap stores a swap to be checked by protorev when attempting backruns.
func (Keeper) UpdateHighestLiquidityPools ¶
func (k Keeper) UpdateHighestLiquidityPools(ctx sdk.Context, baseDenomPools map[string]map[string]LiquidityPoolStruct) error
UpdateHighestLiquidityPools updates the baseDenomPools map (passed in by reference) with the highest liquidity pools for each base denom by iterating through all pools, getting the total liquidity for each pool, and updating the highest liquidity pools based upon comparing total liquidity.
func (Keeper) UpdatePools ¶
UpdatePools first deletes all of the pools paired with any base denom in the store and then adds the highest liquidity pools that match to the store
func (Keeper) UpdateProfitsByDenom ¶
UpdateProfitsByDenom updates the profits made by the ProtoRev module for the given denom
func (Keeper) UpdateProfitsByRoute ¶
func (k Keeper) UpdateProfitsByRoute(ctx sdk.Context, route []uint64, denom string, profit osmomath.Int) error
UpdateProfitsByRoute updates the profits made by the ProtoRev module for the given route and denom
func (Keeper) UpdateSearchRangeIfNeeded ¶
func (k Keeper) UpdateSearchRangeIfNeeded( ctx sdk.Context, route RouteMetaData, inputDenom string, curLeft, curRight osmomath.Int, ) (osmomath.Int, osmomath.Int, error)
UpdateSearchRangeIfNeeded updates the search range for the binary search. First, we check if there are any concentrated liquidity pools in the route. If there are, then we may need to reduce the upper bound of the binary search since it is gas intensive to move across several ticks. Next, we determine if the current bound includes the optimal amount in. If it does not, then we can extend the search range to capture more profits.
func (Keeper) UpdateStatistics ¶
func (k Keeper) UpdateStatistics(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, denom string, profit osmomath.Int) error
UpdateStatistics updates the module statistics after each trade is executed
type LiquidityPoolStruct ¶
Struct used to track the pool with the highest liquidity
type MsgServer ¶
type MsgServer struct {
// contains filtered or unexported fields
}
func (MsgServer) AdminCheck ¶
AdminCheck ensures that the sender is the admin account.
func (MsgServer) SetBaseDenoms ¶
func (m MsgServer) SetBaseDenoms(c context.Context, msg *types.MsgSetBaseDenoms) (*types.MsgSetBaseDenomsResponse, error)
SetBaseDenoms sets the base denoms that will be used to generate cyclic arbitrage routes
func (MsgServer) SetDeveloperAccount ¶
func (m MsgServer) SetDeveloperAccount(c context.Context, msg *types.MsgSetDeveloperAccount) (*types.MsgSetDeveloperAccountResponse, error)
SetDeveloperAccount sets the developer account that will receive fees
func (MsgServer) SetHotRoutes ¶
func (m MsgServer) SetHotRoutes(c context.Context, msg *types.MsgSetHotRoutes) (*types.MsgSetHotRoutesResponse, error)
SetHotRoutes sets the hot routes for ProtoRev
func (MsgServer) SetInfoByPoolType ¶
func (m MsgServer) SetInfoByPoolType(c context.Context, msg *types.MsgSetInfoByPoolType) (*types.MsgSetInfoByPoolTypeResponse, error)
SetInfoByPoolType sets the execution time/gas consumption parameters corresponding to each pool type. This distinction is necessary because the pool types have different execution times / gas consumption.
func (MsgServer) SetMaxPoolPointsPerBlock ¶
func (m MsgServer) SetMaxPoolPointsPerBlock(c context.Context, msg *types.MsgSetMaxPoolPointsPerBlock) (*types.MsgSetMaxPoolPointsPerBlockResponse, error)
SetMaxPoolPointsPerBlock sets the maximum number of pool points that can be consumed per block
func (MsgServer) SetMaxPoolPointsPerTx ¶
func (m MsgServer) SetMaxPoolPointsPerTx(c context.Context, msg *types.MsgSetMaxPoolPointsPerTx) (*types.MsgSetMaxPoolPointsPerTxResponse, error)
SetMaxPoolPointsPerTx sets the maximum number of pool points that can be consumed per tx
type ProtoRevDecorator ¶
type ProtoRevDecorator struct {
ProtoRevKeeper Keeper
}
func NewProtoRevDecorator ¶
func NewProtoRevDecorator(protoRevDecorator Keeper) ProtoRevDecorator
func (ProtoRevDecorator) PostHandle ¶
func (protoRevDec ProtoRevDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate, success bool, next sdk.PostHandler) (sdk.Context, error)
This posthandler will first check if there were any swaps in the tx. If so, collect all of the pools, build routes for cyclic arbitrage, and then execute the optimal route if it exists.
type Querier ¶
type Querier struct {
Keeper
}
Querier defines a wrapper around the x/protorev keeper providing gRPC method handlers.
func NewQuerier ¶
func (Querier) GetAllProtocolRevenue ¶
func (q Querier) GetAllProtocolRevenue(c context.Context, req *types.QueryGetAllProtocolRevenueRequest) (*types.QueryGetAllProtocolRevenueResponse, error)
GetAllProtocolRevenue queries all types of protocol revenue (txfees, taker fees, and cyclic arbitrage profits)
func (Querier) GetProtoRevAdminAccount ¶
func (q Querier) GetProtoRevAdminAccount(c context.Context, req *types.QueryGetProtoRevAdminAccountRequest) (*types.QueryGetProtoRevAdminAccountResponse, error)
GetProtoRevAdminAccount queries the admin account that is allowed to execute admin functions
func (Querier) GetProtoRevAllProfits ¶
func (q Querier) GetProtoRevAllProfits(c context.Context, req *types.QueryGetProtoRevAllProfitsRequest) (*types.QueryGetProtoRevAllProfitsResponse, error)
GetProtoRevAllProfits queries all of the profits from the module
func (Querier) GetProtoRevAllRouteStatistics ¶
func (q Querier) GetProtoRevAllRouteStatistics(c context.Context, req *types.QueryGetProtoRevAllRouteStatisticsRequest) (*types.QueryGetProtoRevAllRouteStatisticsResponse, error)
GetProtoRevAllRouteStatistics queries all of routes that the module has arbitrage against and the number of trades executed on each route and the total profits for each route
func (Querier) GetProtoRevBaseDenoms ¶
func (q Querier) GetProtoRevBaseDenoms(c context.Context, req *types.QueryGetProtoRevBaseDenomsRequest) (*types.QueryGetProtoRevBaseDenomsResponse, error)
GetProtoRevBaseDenoms queries the base denoms that are being used for arbitrage
func (Querier) GetProtoRevDeveloperAccount ¶
func (q Querier) GetProtoRevDeveloperAccount(c context.Context, req *types.QueryGetProtoRevDeveloperAccountRequest) (*types.QueryGetProtoRevDeveloperAccountResponse, error)
GetProtoRevDeveloperAccount queries the developer account that is accumulating the profits from the module
func (Querier) GetProtoRevEnabled ¶
func (q Querier) GetProtoRevEnabled(c context.Context, req *types.QueryGetProtoRevEnabledRequest) (*types.QueryGetProtoRevEnabledResponse, error)
GetProtoRevEnabled queries whether the module is enabled or not
func (Querier) GetProtoRevInfoByPoolType ¶
func (q Querier) GetProtoRevInfoByPoolType(c context.Context, req *types.QueryGetProtoRevInfoByPoolTypeRequest) (*types.QueryGetProtoRevInfoByPoolTypeResponse, error)
GetProtoRevInfoByPoolType queries information pertaining to each pool type the module is using for arbitrage
func (Querier) GetProtoRevMaxPoolPointsPerBlock ¶
func (q Querier) GetProtoRevMaxPoolPointsPerBlock(c context.Context, req *types.QueryGetProtoRevMaxPoolPointsPerBlockRequest) (*types.QueryGetProtoRevMaxPoolPointsPerBlockResponse, error)
GetProtoRevPoolPointsPerBlock queries the maximum number of pool points that can be consumed per block
func (Querier) GetProtoRevMaxPoolPointsPerTx ¶
func (q Querier) GetProtoRevMaxPoolPointsPerTx(c context.Context, req *types.QueryGetProtoRevMaxPoolPointsPerTxRequest) (*types.QueryGetProtoRevMaxPoolPointsPerTxResponse, error)
GetProtoRevPoolPointsPerTx queries the maximum number of pool points that can be consumed per transaction
func (Querier) GetProtoRevNumberOfTrades ¶
func (q Querier) GetProtoRevNumberOfTrades(c context.Context, req *types.QueryGetProtoRevNumberOfTradesRequest) (*types.QueryGetProtoRevNumberOfTradesResponse, error)
GetProtoRevNumberOfTrades queries the number of trades the module has executed
func (Querier) GetProtoRevPool ¶
func (q Querier) GetProtoRevPool(c context.Context, req *types.QueryGetProtoRevPoolRequest) (*types.QueryGetProtoRevPoolResponse, error)
GetProtoRevPool queries the pool id for a given base denom and other denom
func (Querier) GetProtoRevProfitsByDenom ¶
func (q Querier) GetProtoRevProfitsByDenom(c context.Context, req *types.QueryGetProtoRevProfitsByDenomRequest) (*types.QueryGetProtoRevProfitsByDenomResponse, error)
GetProtoRevProfitsByDenom queries the profits of the module by denom
func (Querier) GetProtoRevStatisticsByRoute ¶
func (q Querier) GetProtoRevStatisticsByRoute(c context.Context, req *types.QueryGetProtoRevStatisticsByRouteRequest) (*types.QueryGetProtoRevStatisticsByRouteResponse, error)
GetProtoRevStatisticsByRoute queries the number of arbitrages and profits that have been executed for a given route
func (Querier) GetProtoRevTokenPairArbRoutes ¶
func (q Querier) GetProtoRevTokenPairArbRoutes(c context.Context, req *types.QueryGetProtoRevTokenPairArbRoutesRequest) (*types.QueryGetProtoRevTokenPairArbRoutesResponse, error)
GetProtoRevTokenPairArbRoutes queries the hot routes that the module is utilizing for cyclic arbitrage route generation
func (Querier) Params ¶
func (q Querier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params queries the parameters of the module.
type RouteMetaData ¶
type RouteMetaData struct { // The route that was built Route poolmanagertypes.SwapAmountInRoutes // The number of pool points that were consumed to build the route PoolPoints uint64 // The step size that should be used in the binary search for the optimal swap amount StepSize osmomath.Int }