clp

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

README

Changelog

  • 2020/10/22 Initial version
Summary

For the Sifchain MVP ,CLP module provides the following functionalities

  • Create New Liquidity Pool
  • Add Liquidity to an Existing Liquidity pool
  • Remove Liquidity from an Existing Liquidity pool
  • Swap tokens
    -Swap an External token for Native or vice versa (single swap)
    -Swap an External token for another External Token (double swap)
  • Decommission an Existing Liquidity pool
Data structures

-Asset : An asset is most basic unit of a CLP . It Contains source chain, symbol and ticker to identify a token .

SourceChain: ETHEREUM
Symbol: ETH
Ticker: ceth

SourceChain: SIFCHAIN
Symbol: RWN
Ticker: rwn

-Pool : Every Liquidity pool for CLP is created by pairing an External asset with the Native asset .

ExternalAsset: SourceChain: ETHEREUM
              Symbol: ETH
              Ticker: ceth
ExternalAssetBalance: 1000
NativeAssetBalance: 1000
PoolUnits : 1000
PoolAddress :sif1vdjxzumgtae8wmstpv9skzctpv9skzct72zwra

-Liquidity provider : Any user adding liquidity to a pool becomes a liquidity provider for that pool.

ExternalAsset: SourceChain: ETHEREUM
               Symbol: ETH
               Ticker: ceth
LiquidityProviderUnits: 1000
liquidityProviderAddress: sif15tyrwghfcjszj7sckxvqh0qpzprup9mhksmuzm 

Trasactions supported

  • Create new liquidity pool

    • Creating a pool has a minimum threshold for the amount of liquidity provided. This is a genensis parameter and can be tweaked later.
    • The user who creates a new pool automatically becomes its first liquidity provider.
  • Decommission a liquidity pool

    • Decommission requires the net balance of the pool to be under the minimum threshold .
    • If successful a decommission transaction returns balances to its liquidity providers and deletes the liquidity pool.
  • Add Liquidity to a pool

    • User can add liquidity to the native and external tokens
  • Remove liquidity

    • Remove liquidity consists of a composition of withdraw , and a swap if required

    • Liquidity can be removed in three ways

      -Native and external - Withdraw to native and external tokens .
      -Only Native - Withdraw to native and external tokens ,and then a swap from external to native.
      -Only External - Withdraw to native and external tokens ,and then a swap from native to external.

    • For asymmetric removal , (option 2 and 3), the user incurs a tradeslip and liquidity fee similar to a swap.

  • Swap

    • The system supports two types of swaps
      -Swap between external and native tokens - This is a single swap
      -Swap between external and external tokens - This swap is combination of two single swaps.

    • A double swap also includes a transfer between the two pools to maintain pool balances.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportGenesis

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

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) (res []abci.ValidatorUpdate)

func NewHandler

func NewHandler(k keeper.Keeper) sdk.Handler

NewHandler creates an sdk.Handler for all the clp type messages

func ValidateGenesis

func ValidateGenesis(data types.GenesisState) error

ValidateGenesis validates the clp genesis parameters

Types

type AppModule

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

AppModule implements an application module for the clp module.

func NewAppModule

func NewAppModule(k keeper.Keeper, bankKeeper types.BankKeeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

func (AppModule) EndBlock

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

func (AppModule) ExportGenesis

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

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

func (AppModule) InitGenesis

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

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

func (AppModule) LegacyQuerierHandler

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

LegacyQuerierHandler returns the staking module sdk.Querier.

func (AppModule) Name

func (AppModule) Name() string

Name returns the clp module's name.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the clp module's querier route name.

func (AppModule) RegisterInvariants

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

RegisterInvariants registers the clp module invariants.

func (AppModule) RegisterServices

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

RegisterServices registers module services.

func (AppModule) Route

func (am AppModule) Route() sdk.Route

Route returns the message routing key for the staking module.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the clp module.

func (AppModuleBasic) DefaultGenesis

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

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

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns no root query command for the clp module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns the root tx command for the clp module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the clp module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

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

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the clp module.

func (AppModuleBasic) RegisterInterfaces

func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

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

RegisterLegacyAminoCodec registers the clp module's types on the given LegacyAmino codec.

func (AppModuleBasic) RegisterRESTRoutes

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

RegisterRESTRoutes registers the REST routes for the clp module.

func (AppModuleBasic) ValidateGenesis

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

ValidateGenesis performs genesis state validation for the clp module.

Directories

Path Synopsis
client
cli
legacy
v39
v42
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