app

package module
v0.0.0-...-2eee87b Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

README

Cosmos Swap

Swap any two tokens on the Cosmos network

An account can stake coins into a pool that is composed of ATOM and any other single token. Once a pool has been created by an account(s) staking their coins, people can than swap/trade within that pool to gain one token over another.

How many tokens an individual gets from another token is relative to how many tokens of each exist in the pool. Say you have a pool of two tokens, ATOM and CANYA. There are 20 CANYA tokens, and 50 ATOM tokens. If you swap 10 CANYA tokens, we add those to the pool (for a total of 30), see that our addition makes up for 1/3rd of the present tokens, which means we get 1/3rd of the ATOM tokens, which is 16.6666666667. This ensures that we never run out of tokens in a pool from swapping.

Development

Setup a local server

make start

See test and demo scripts for how to use the API

Test

Run tests

make test

TODO

  • Stakers gain fees when people swap tokens
  • Use real accAddresses instead of hacky made up accounts stored without this module's KVstore.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// default home directories for the application CLI
	DefaultCLIHome = os.ExpandEnv("$HOME/.sscli")

	// DefaultNodeHome sets the folder where the applcation data and configuration will be stored
	DefaultNodeHome = os.ExpandEnv("$HOME/.ssd")

	// ModuleBasicManager is in charge of setting up basic module elemnets
	ModuleBasics = module.NewBasicManager(
		genaccounts.AppModuleBasic{},
		genutil.AppModuleBasic{},
		auth.AppModuleBasic{},
		bank.AppModuleBasic{},
		params.AppModuleBasic{},
		swapservice.AppModule{},
		staking.AppModuleBasic{},
		distr.AppModuleBasic{},
		slashing.AppModuleBasic{},
	)
)

Functions

func MakeCodec

func MakeCodec() *codec.Codec

MakeCodec generates the necessary codecs for Amino

func NewSwpServiceApp

func NewSwpServiceApp(logger log.Logger, db dbm.DB) *swapServiceApp

NewSwpServiceApp is a constructor function for swapServiceApp

Types

type GenesisState

type GenesisState map[string]json.RawMessage

GenesisState represents chain state at the start of the chain. Any initial state (account balances) are stored here.

func NewDefaultGenesisState

func NewDefaultGenesisState() GenesisState

Directories

Path Synopsis
cmd
ssd
x

Jump to

Keyboard shortcuts

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