/
expected_keepers.go
114 lines (95 loc) · 3.59 KB
/
expected_keepers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/osmomath"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
// AccountI defines the account contract that must be fulfilled when
// creating a x/gamm keeper.
type AccountI interface {
GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI
NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
SetAccount(ctx sdk.Context, acc authtypes.AccountI)
}
// BankI defines the banking contract that must be fulfilled when
// creating a x/gamm keeper.
type BankI interface {
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata)
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}
// CommunityPoolI defines the contract needed to be fulfilled for distribution keeper.
type CommunityPoolI interface {
FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}
// PoolModuleI is the interface that must be fulfillled by the module
// storing and containing the pools.
type PoolModuleI interface {
InitializePool(ctx sdk.Context, pool PoolI, creatorAddress sdk.AccAddress) error
GetPool(ctx sdk.Context, poolId uint64) (PoolI, error)
GetPools(ctx sdk.Context) ([]PoolI, error)
GetPoolDenoms(ctx sdk.Context, poolId uint64) (denoms []string, err error)
CalculateSpotPrice(
ctx sdk.Context,
poolId uint64,
quoteAssetDenom string,
baseAssetDenom string,
) (price osmomath.BigDec, err error)
SwapExactAmountIn(
ctx sdk.Context,
sender sdk.AccAddress,
pool PoolI,
tokenIn sdk.Coin,
tokenOutDenom string,
tokenOutMinAmount osmomath.Int,
spreadFactor osmomath.Dec,
) (osmomath.Int, error)
// CalcOutAmtGivenIn calculates the amount of tokenOut given tokenIn and the pool's current state.
// Returns error if the given pool is not a CFMM pool. Returns error on internal calculations.
CalcOutAmtGivenIn(
ctx sdk.Context,
poolI PoolI,
tokenIn sdk.Coin,
tokenOutDenom string,
spreadFactor osmomath.Dec,
) (tokenOut sdk.Coin, err error)
SwapExactAmountOut(
ctx sdk.Context,
sender sdk.AccAddress,
pool PoolI,
tokenInDenom string,
tokenInMaxAmount osmomath.Int,
tokenOut sdk.Coin,
spreadFactor osmomath.Dec,
) (tokenInAmount osmomath.Int, err error)
// CalcInAmtGivenOut calculates the amount of tokenIn given tokenOut and the pool's current state.
// Returns error if the given pool is not a CFMM pool. Returns error on internal calculations.
CalcInAmtGivenOut(
ctx sdk.Context,
poolI PoolI,
tokenOut sdk.Coin,
tokenInDenom string,
spreadFactor osmomath.Dec,
) (tokenIn sdk.Coin, err error)
// GetTotalPoolLiquidity returns the coins in the pool owned by all LPs
GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error)
// GetTotalLiquidity returns the total liquidity of all the pools in the module.
GetTotalLiquidity(ctx sdk.Context) (sdk.Coins, error)
}
type PoolIncentivesKeeperI interface {
IsPoolIncentivized(ctx sdk.Context, poolId uint64) (bool, error)
}
type MultihopRoute interface {
Length() int
PoolIds() []uint64
IntermediateDenoms() []string
}
type StakingKeeper interface {
BondDenom(ctx sdk.Context) string
}
type ProtorevKeeper interface {
GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error)
}