gamm

package
v6.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

GAMM Module

This document introduces the Queries and Transactions of the Generalized Automated Market Maker (GAMM) module. The GAMM module provides the logic to create and interact with liquidity pools on the Osmosis DEX.

Queries

The Query submodule of the GAMM module provides the logic to request information from the liquidity pools. It contains the following functions:

Estimate Swap Exact Amount In

Query the estimated result of the Swap Exact Amount In transaction. Note that the flags swap-route-pool and swap-route-denoms are required.

Usage
osmosisd query gamm estimate-swap-exact-amount-in <poolID> <sender> <tokenIn> [flags]
Example

Query the amount of ATOM the sender would receive for swapping 1 OSMO in pool 1.

osmosisd query gamm estimate-swap-exact-amount-in 1 osmo123nfq6m8f88m4g3sky570unsnk4zng4uqv7cm8 1000000uosmo --swap-route-pool-ids 1 --swap-route-denoms ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 

Estimate Swap Exact Amount Out

Query the estimated result of the Swap Exact Amount Out transaction. Note that the flags swap-route-pool and swap-route-denoms are required.

Usage
osmosisd query gamm estimate-swap-exact-amount-out <poolID> <sender> <tokenOut> [flags]
Example

Query the amount of OSMO the sender would require to swap 1 ATOM out of pool 1.

osmosisd query gamm estimate-swap-exact-amount-out 1 osmo123nfq6m8f88m4g3sky570unsnk4zng4uqv7cm8 1000000ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --swap-route-pool-ids 1 --swap-route-denoms uosmo

Num Pools

Query the number of active pools.

Usage
osmosisd query gamm num-pools

Pool

Query the parameter and assets of a specific pool.

Usage
osmosisd query gamm pool <poolID> [flags]
Example

Query parameters and assets from pool 1.

osmosisd query gamm pool 1

Pool Assets

Query the assets of a specific pool. This query is a reduced form of the Pool query.

Usage
osmosisd query gamm pool-assets <poolID> [flags]

Query the assets from pool 1.

Example
osmosisd query gamm pool-assets 1

Pool Params

Query the parameters of a specific pool. This query is a reduced form of the Pool query.

Usage
osmosisd query gamm pool-params <poolID> [flags]

Query the parameters from pool 1.

Example
osmosisd query gamm pool-params 1

Pools

Query parameters and assets of all active pools.

Usage
osmosisd query gamm pools

Spot Price

Query the spot price of a pool asset based on a specific pool it is in.

Usage
osmosisd query gamm spot-price <poolID> <tokenInDenom> <tokenOutDenom> [flags]
Example

Query the price of OSMO based on the price of ATOM in pool 1.

osmosisd query gamm spot-price 1 uosmo ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2

Total Liquidity

Query the total liquidity of all active pools.

Usage
osmosisd query gamm total-liquidity

Total Share

Query the total amount of GAMM shares of a specific pool.

Usage
osmosisd query gamm total-share <poolID> [flags]
Example

Query the total amount of GAMM shares of pool 1.

osmosisd query gamm total-share 1

Transactions

The Transaction submodule of the GAMM module provides the logic to create and interact with the liquidity pools. It contains the following functions:

Create Pool

Create a new liquidity pool and provide the initial liquidity to it. Pool initialization parameters must be provided through a JSON file using the flag pool-file.

Usage
osmosisd tx gamm create-pool [flags]

The configuration file config.json must specify the following parameters.

{
	"weights": [list weighted denoms],
	"initial-deposit": [list of denoms with initial deposit amount],
	"swap-fee": [swap fee in percentage],
	"exit-fee": [exit fee in percentage],
	"future-governor": [number of hours]
}
Example

Create a new ATOM-OSMO liquidity pool with a swap and exit fee of 1%.

tx gamm create-pool --pool-file ../public/config.json --from myKeyringWallet

The configuration file contains the following parameters.

{
	"weights": "5uatom,5uosmo",
	"initial-deposit": "100uatom,100uosmo",
	"swap-fee": "0.01",
	"exit-fee": "0.01",
	"future-governor": "168h"
}

Join Pool

Join a specific pool with a custom amount of tokens. Note that the flags pool-id, max-amounts-in and share-amount-out are required.

Usage
osmosisd tx gamm join-pool [flags]
Example

Join pool 1 with 1 OSMO and the respective amount of ATOM, using myKeyringWallet.

osmosisd tx gamm join-pool --pool-id 2 --max-amounts-in 1000000uosmo --max-amounts-in 1000000uion --share-amount-out 1000000 --from myKeyringWallet

Exit Pool

Exit a specific pool with a custom amount of tokens. Note that the flags pool-id, min-amounts-out and share-amount-in are required.

Usage
osmosisd tx gamm exit-pool [flags]
Example

Exit pool one with 1 OSMO and the respective amount of ATOM using myKeyringWallet.

osmosisd tx gamm exit-pool --pool-id 1 --min-amounts-out 1000000uosmo --share-amount-in 1000000 --from myKeyringWallet

Join Swap Extern Amount In

Note that the flags pool-id is required.

Usage
osmosisd tx gamm join-swap-extern-amount-in [token-in] [share-out-min-amount] [flags]
Example
osmosisd tx gamm join-swap-extern-amount-in 1000000uosmo 1000000 --pool-id 1 --from myKeyringWallet

Exit Swap Extern Amount Out

Note that the flag pool-id is required.

Usage
osmosisd tx gamm exit-swap-extern-amount-out [token-out] [share-in-max-amount] [flags]
Example
osmosisd tx gamm exit-swap-extern-amount-out 1000000uosmo 1000000 --pool-id 1 --from myKeyringWallet

Join Swap Share Amount Out

Note that the flag pool-id is required.

Usage
osmosisd tx gamm join-swap-share-amount-out [token-in-denom] [token-in-max-amount] [share-out-amount] [flags]
Example
osmosisd tx gamm join-swap-share-amount-out uosmo 1000000 1000000 --pool-id 1 --from myKeyringWallet

Exit Swap Share Amount In

Note that the flag pool-id is required.

Usage
osmosisd tx gamm exit-swap-share-amount-in [token-out-denom] [share-in-amount] [token-out-min-amount] [flags]
Example
osmosisd tx gamm exit-swap-share-amount-in uosmo 1000000 1000000 --pool-id 1 --from myKeyringWallet

Swap Exact Amount In

Swap an exact amount of tokens into a specific pool. Note that the flags swap-route-pool-ids and swap-route-denoms are required.

Usage
osmosisd tx gamm swap-exact-amount-in [token-in] [token-out-min-amount] [flags]
Example

Swap 1 OSMO through pool 1 into at least 0.3 ATOM using MyKeyringWallet.

osmosisd tx gamm swap-exact-amount-in 1000000uosmo 300000 --swap-route-pool-ids 1 --swap-route-denoms ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --from MyKeyringWallet

Swap Exact Amount Out

Swap an exact amount of tokens out of a specific pool. Note that the flags swap-route-pool-ids and swap-route-denoms are required.

Usage
osmosisd tx gamm swap-exact-amount-out [token-out] [token-out-max-amount] [flags]
Example

Swap 1 ATOM through pool 1 into at most 2.5 OSMO using MyKeyringWallet.

osmosisd tx gamm swap-exact-amount-out 1000000ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 250000 --swap-route-pool-ids 1 --swap-route-denoms uosmo --from MyKeyringWallet

Other resources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

ExportGenesis returns the capability module's exported genesis.

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState, unpacker codectypes.AnyUnpacker)

InitGenesis initializes the capability module's state from a provided genesis state.

func NewHandler

func NewHandler(k keeper.Keeper) sdk.Handler

NewHandler returns a handler for "gamm" type messages.

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

func NewAppModule

func NewAppModule(cdc codec.Codec, keeper keeper.Keeper,
	accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) AppModule

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

BeginBlock performs a no-op.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) EndBlock

EndBlock returns the end blocker for the gamm module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the gamm module.

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the gamm module. However, at launch the gamm module has no state, hence this is a no-op

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the gamm module. It returns no validator updates.

func (AppModule) LegacyQuerierHandler

func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

LegacyQuerierHandler returns the gamm module sdk.Querier.

func (AppModule) ProposalContents

func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent

ProposalContents doesn't return any content functions for governance proposals.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the gamm module's querier route name.

func (AppModule) RandomizedParams

func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange

RandomizedParams creates randomized gamm param changes for the simulator. There are no params that we view as sensible to randomize at the moment.

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)

RegisterInvariants registers the gamm module invariants.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for supply module's types

func (AppModule) Route

func (am AppModule) Route() sdk.Route

Route returns the message routing key for the gamm module.

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns all the simulation operations with their respective weights.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the gamm module.

func (AppModuleBasic) GetQueryCmd

func (b AppModuleBasic) GetQueryCmd() *cobra.Command

func (AppModuleBasic) GetTxCmd

func (b AppModuleBasic) GetTxCmd() *cobra.Command

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the gamm module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

func (AppModuleBasic) RegisterInterfaces

func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers interfaces and implementations of the gamm module.

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the gamm module's types on the LegacyAmino codec.

func (AppModuleBasic) RegisterRESTRoutes

func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router)

--------------------------------------- Interfaces

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the gamm module.

Directories

Path Synopsis
client
cli
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL