Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit e84efae

Browse files
authored
Typing CLI files (#28)
* Add typing & fix issues * Add types + README.md
1 parent 91c8140 commit e84efae

File tree

5 files changed

+377
-220
lines changed

5 files changed

+377
-220
lines changed

README.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ A small CLI Typescript client is included to help you initialize and manage the
7474

7575
To initialize deployed program, run the following commands:
7676

77-
```
77+
```sh
7878
cd app
7979
npm install
8080
npm install -g npx
@@ -83,52 +83,80 @@ npx ts-node src/cli.ts -k <ADMIN_WALLET> init --min-signatures <int> <ADMIN_PUBK
8383

8484
Where `<ADMIN_WALLET>` is the file path to the wallet that was set as the upgrade authority of the program upon deployment. `<ADMIN_PUBKEY1>`, `<ADMIN_PUBKEY2>` etc., will be set as protocol admins, and `min-signatures` will be required to execute privileged instructions. To provide multiple signatures, just execute exactly the same command multiple times specifying different `<ADMIN_WALLET>` with `-k` option. The intermediate state is recorded on-chain so that commands can be executed on different computers.
8585

86-
To change protocol admins or minimum required signatures, run:
86+
To change program authority, run:
8787

88+
```sh
89+
solana program set-upgrade-authority <PROGRAM_ADDRESS> --new-upgrade-authority <NEW_UPGRADE_AUTHORITY>
8890
```
91+
92+
To change program authority back, run:
93+
94+
```sh
95+
solana program set-upgrade-authority <PROGRAM_ADDRESS> --new-upgrade-authority <NEW_UPGRADE_AUTHORITY> -k <CURRENT_AUTHORITY_KEYPAIR>
96+
```
97+
98+
To change protocol admins or minimum required signatures, run:
99+
100+
```sh
89101
npx ts-node src/cli.ts -k <ADMIN_WALLET> set-authority --min-signatures <int> <ADMIN_PUBKEY1> <ADMIN_PUBKEY2> ...
90102
```
91103

92104
To validate initialized program:
93105

94-
```
106+
```sh
95107
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-multisig
96108
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-perpetuals
97109
```
98110

99111
Before the program can accept any liquidity or open a trade, you need to create a token pool and add one or more token custodies to it:
100112

101-
```
113+
```sh
102114
npx ts-node src/cli.ts -k <ADMIN_WALLET> add-pool <POOL_NAME>
103-
npx ts-node src/cli.ts -k <ADMIN_WALLET> add-custody [-s] [-v] <POOL_NAME> <TOKEN_MINT> <TOKEN_ORACLE>
115+
npx ts-node src/cli.ts -k <ADMIN_WALLET> add-custody [-s] [-v] [-t] <POOL_NAME> <TOKEN_MINT> <TOKEN_ORACLE>
104116
```
105117

106-
Where `<POOL_NAME>` is a random name you want to assign to the pool, `<TOKEN_MINT>` is the mint address of the token, and `<TOKEN_ORACLE>` is the corresponding Pyth price account that can be found on [this page](https://pyth.network/price-feeds?cluster=devnet). `-s` flag specifies whether the custody is for a stablecoin. `-v` flag is used to create a virtual/synthetic custody. More information on the latter can be found [here](SYNTHETICS.md).
118+
Where `<POOL_NAME>` is a random name you want to assign to the pool, `<TOKEN_MINT>` is the mint address of the token, and `<TOKEN_ORACLE>` is the corresponding Pyth price account that can be found on [this page](https://pyth.network/price-feeds?cluster=devnet). `-s` flag specifies whether the custody is for a stablecoin. `-v` flag is used to create a virtual/synthetic custody. More information on the latter can be found [here](SYNTHETICS.md). `-t` flag specifies the type of the oracle to be used for the custody: `custom`, `pyth` or `none`.
107119

108120
For example:
109121

110-
```
122+
```sh
111123
npx ts-node src/cli.ts -k <ADMIN_WALLET> add-pool TestPool1
112124
npx ts-node src/cli.ts -k <ADMIN_WALLET> add-custody TestPool1 So11111111111111111111111111111111111111112 J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix
113125
```
114126

115127
To validate added pools and custodies, run:
116128

117-
```
129+
```sh
118130
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-pool <POOL_NAME>
119131
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-custody <POOL_NAME> <TOKEN_MINT>
120132
```
121133

122134
or
123135

124-
```
136+
```sh
125137
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-pools
126138
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-custodies <POOL_NAME>
127139
```
128140

129-
CLI offers other useful commands. You can get the list of all of them by running the following:
141+
To add liquidity, run:
130142

143+
```sh
144+
npx ts-node src/cli.ts -k <WALLET> add-liquidity <POOL_NAME> <TOKEN_MINT> --amount-in <AMOUNT_IN> --min-amount-out <MIN_AMOUNT_OUT>
131145
```
146+
147+
For it to work, make sure the wallet's LM token ATA is initialized and the wallet hold enough tokens to provide as liquidity.
148+
149+
To initialize wallet's token ATA, run:
150+
151+
```sh
152+
npx ts-node src/cli.ts -k <ADMIN_WALLET> get-lp-token-mint <POOL_NAME>
153+
154+
spl-token create-account <LM_TOKEN_MINT> --owner <WALLET> --fee-payer <PAYER_WALLET>
155+
```
156+
157+
CLI offers other useful commands. You can get the list of all of them by running the following:
158+
159+
```sh
132160
npx ts-node src/cli.ts --help
133161
```
134162

0 commit comments

Comments
 (0)