Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cosmology/cli

Package Overview
Dependencies
Maintainers
2
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmology/cli

cosmology

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-95.04%
Maintainers
2
Weekly downloads
 
Created
Source

@cosmology/cli

npm install -g @cosmology/cli

Use cosmology to build web3 applications on top of Osmosis and the Cosmos. Make cryptocurrency trades, join liquidity pools, and stake rewards.

usage

CLI and user prompts

Not sure what to do? Simply type cosmology. It will prompt you with options.

$ cosmology 
? [cmd] what do you want to do? 
  keychain-del 
  keychain-get 
  keychain-set 
❯ list-apis 
  list-pools 
  list-prices 
  load-recipe 

Then once you learn the api, you can start supplying the parameters.

cosmology <commandname>

commands

rebalance

The rebalance command will make a series of swaps on your behalf. It will prompt you to choose the coins you are willing to sell to create a new balance based on the pools you want to enter.

cosmology rebalance 

Example with parameters

cosmology rebalance \
    --chainId osmosis-1 \
    --restEndpoint https://lcd-osmosis.blockapsis.com \
    --rpcEndpoint https://osmosis.validator.network \
    --slippage 1 

join

The join command will join a pool.

cosmology join 

Example with parameters

cosmology join \
    --keychain my-mnemonic-name \
    --chainId osmosis-1 \
    --restEndpoint https://lcd-osmosis.blockapsis.com \
    --poolId 601
    --max

lock

The lock command will lock your gamms tokens for staking so you can earn rewards.

cosmology lock 

Example with parameters

cosmology lock \
    --keychain my-mnemonic-name \
    --chainId osmosis-1 \
    --restEndpoint https://lcd-osmosis.blockapsis.com \
    --poolId 601 \
    --duration 14

claim

Claim rewards from staking.

cosmology claim

Example with parameters

cosmology claim \
  --keychain my-mnemonic-name \
  --chainToken CMDX \
  --minAmount 1 \
  --restEndpoint https://rest.comdex.one \
  --rpcEndpoint https://rpc.comdex.one

delegate

Stake tokens to a validator.

cosmology delegate

Example with parameters

cosmology delegate \
  --keychain my-mnemonic-name \
  --chainToken CMDX \
  --minAmount 1 \
  --restEndpoint https://rest.comdex.one \
  --rpcEndpoint https://rpc.comdex.one \
  --validatorAddress comdexvaloper1mzxzxkzajancc63gtwt9x9zw2qfv9k9ar7ka34

env vars

While everything can be done with parameters, you can also just supply env vars and cosmology won't prompt you for those values:

env varoptionaldescription
MNEMONICYescosmos mnemonic, either plain-text or encrypted
ENCRYPTED_SALTYesused for encrypting/decrypting mnemonics
KEYCHAIN_ACCOUNTYesused for storing info in OSX keychain account
CHAIN_IDYesused for getting chain info, e.g. osmosis-1
REST_ENDPOINTYesused for setting LCD endpoint
RPC_ENDPOINTYesused for setting RCP endpoint

mnemonics

There are a few methods to deal with mnemonics.

  1. plain text env var MNEMONIC
  2. encrypted key with a salt
  3. mac OSX keychain

METHOD 1 - plain text

(Not recommended) video here

export MNEMONIC="action brisk disagree just bunker design wasp hand night ghost runway fluid"
# now you can run cosmology

cosmology rebalance

METHOD 2 - encrypted salt via env var ENCRYPTED_SALT

video here

The encrypted salt is the recommended usage so that you don't store plain-text mnemonics.

1 First, generate a salt.
cosmology salt-generate --saltBytes 64
> GRHeG5r9nojio7PmCuNnLEh0Hglwvw1Bn87ipIMeyhPFVJk9i5eWtno7m7pa8FPRjbsd2LqCjEsR8/Hiyp9lLg==
2 Now encrypt this salt value

(Yes, we are encrypting a salt with a salt, or password)

cosmology salt-encrypt \
     --secret GRHeG5r9nojio7PmCuNnLEh0Hglwvw1Bn87ipIMeyhPFVJk9i5eWtno7m7pa8FPRjbsd2LqCjEsR8/Hiyp9lLg==

Now, store that value securely, and remember your password. Test the salt-encrypt and salt-decrypt commands a few times so you understand how it works.

3 Now you can use it in env var ENCRYPTED_SALT
export ENCRYPTED_SALT=U2FsdGVkX183aSMtLlWua/uig/Qqd99TBILc63iW1AsJaKGykZGPvA/DXByjYtws7drSVlipMPsMLrePajBtRyFP7tZOLrlUuL+xlhcsRAm0DcTRV+VDsnDQVykSDhSyl1RYf03SsLgUsYMvsixWFA==

# now the user will be prompted for "salt" which is the password used to decrypt the encryption key
# the mnemonic will be automatically decrypted by the system
cosmology

METHOD 3 - keychain

video here

We can leverage the Mac OSX keychain. Don't worry though, we ONLY use encryption via the encrypted salt, even if some of you happen to trust storing mnemonics in OSX keychain. We only store encrypted values, period.

1 create an encryption key and encrypt it as described in the previous step

create an ENCRYPTED_SALT and store it securely.

2 add your mnemonic to your keychain

  • name is how you'll reference
  • password is your actual mnemonic
  • salt is the salt for your encrypted salt key
$ cosmology keychain-set
? [name] name my-special-mnemonic-name-1
? [password] password [hidden]
? [salt] enter the salt [hidden]

Test it!

$ cosmology keychain-get \
 --name my-special-mnemonic-name-1

testing

first start the tests

cd ./packages/cosmology
yarn test:watch

hit "p" and then type a search string to scope to the name your test

developing the CLI

if you need to edit the CLI

cd ./packages/cosmology
export MNEMONIC="mammal wrestle hybrid cart choose flee transfer filter fly object swamp rookie"
export CHAIN_ID=osmosis-testnet-0
export RPC_ENDPOINT=http://143.244.147.126:26657

yarn run dev

RPC Docs

https://v1.cosmos.network/rpc/v0.41.4

LCD Docs

https://osmosis.stakesystems.io/static/openapi/

Validator Docs

https://api-osmosis.imperator.co/swagger

Other

https://github.com/osmosis-labs/awesome#publicly-available-endpoints

https://www.notion.so/Stake-Systems-LCD-RPC-gRPC-Instances-04a99a9a9aa14247a42944931eec7024

known issues

  • defaults to NOT using pools with less than 100k in liquidity
  • smaller tokens with volatility may need higher slippage values

Credits

🛠 Built by Cosmology — if you like our tools, please consider delegating to our validator ⚛️

Code built with the help of these related projects:

  • @cosmology/telescope a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
  • osmojs OsmosJS makes it easy to compose and broadcast Osmosis and Cosmos messages.

Disclaimer

AS DESCRIBED IN THE COSMOLOGY LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating Cosmology will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Cosmology app or Cosmology CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

FAQs

Package last updated on 30 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc