Skip to content

Commit ed6ad5b

Browse files
authored
Update and fix documentation (#458)
* Update wallet management. Fix code examples * Fix typedocs * Fix header * Resolve comments --------- Co-authored-by: calintje <[email protected]>
1 parent 6d93632 commit ed6ad5b

File tree

10 files changed

+49
-48
lines changed

10 files changed

+49
-48
lines changed

docs/whirlpool/docs/03-Whirlpools SDK/01-Environment Setup.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,15 @@ Initialize the project as a TypeScript project:
3232
npx tsc --init
3333
```
3434

35-
## 2. Wallet Creation
35+
## 2. Wallet Management
3636

37-
You can create a wallet using `generateKeyPairSigner()` from the Solana SDK.
38-
39-
```tsx
40-
import { generateKeyPairSigner } from '@solana/web3.js';
41-
42-
const wallet = await generateKeyPairSigner();
43-
```
44-
45-
Alternatively, if you have your wallet stored as a 64-byte private key in a `wallet.json` file, you can load it using `createKeyPairSignerFromBytes`.
37+
You can [generate a file system wallet using the Solana CLI](https://docs.solanalabs.com/cli/wallets/file-system) and load it using `createKeyPairSignerFromBytes`.
4638

4739
```tsx
4840
import { createKeyPairSignerFromBytes } from '@solana/web3.js';
4941
import fs from 'fs';
5042

5143
const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
52-
5344
const wallet = await createKeyPairSignerFromBytes(keyPairBytes);
5445
```
5546

docs/whirlpool/docs/03-Whirlpools SDK/02-Whirlpool Management/01-Create Pool.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Splash Pools are the easiest way to get started:
3838
```tsx
3939
import { createSplashPoolInstructions } from '@orca-so/whirlpools'
4040

41-
const { poolAddress, instructions, initializationCost } = await createSplashPoolInstructions(
41+
const { poolAddress, instructions, estInitializationCost } = await createSplashPoolInstructions(
4242
rpc,
4343
tokenMintOne,
4444
tokenMintTwo,
@@ -60,7 +60,7 @@ Concentrated Liquidity Pools offer more flexibility:
6060
```tsx
6161
import { createConcentratedLiquidityPool } from '@orca-so/whirlpools'
6262

63-
const { poolAddress, instructions, initializationCost } = await createConcentratedLiquidityPool(
63+
const { poolAddress, instructions, estInitializationCost } = await createConcentratedLiquidityPool(
6464
rpc,
6565
tokenMintOne,
6666
tokenMintTwo,

docs/whirlpool/docs/03-Whirlpools SDK/03-Position Management/01-Open Position.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ For more details, refer to our [Environment Setup Guide](../01-Environment%20Set
6262
4. **Funder**: This can be your wallet, which will fund the pool initialization. If the funder is not specified, the default wallet will be used. You can configure the default wallet through the SDK.
6363
5. **Create Instructions**: Use the appropriate function to generate the necessary instructions.
6464
```tsx
65-
const { quote, instructions, initializationCost } = await openPositionInstructions(
65+
const { quote, instructions, initializationCost, positionMint } = await openPositionInstructions(
6666
rpc,
6767
poolAddress,
6868
param,

docs/whirlpool/docs/03-Whirlpools SDK/03-Position Management/03-Adjust Liquidity.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ Adjusting liquidity in an existing position can be done as follows:
3232
5. **Funder**: This can be your wallet, which will fund the pool initialization. If a funder is not specified, the default wallet will be used. You can configure the default wallet through the SDK.
3333
6. **Create Instructions**: Use the appropriate function to generate the necessary instructions.
3434
```tsx
35-
const {quote, instructions, initializationCost} = await increaseLiquidityInstructions(
35+
const { quote, instructions, initializationCost, positionMint } = await increaseLiquidityInstructions(
36+
rpc,
37+
positionMint,
38+
param,
39+
slippageTolerance,
40+
wallet
41+
)
42+
43+
const { quote, instructions } = await decreaseLiquidityInstructions(
3644
rpc,
3745
positionMint,
3846
param,

ts-sdk/whirlpool/src/createPool.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,18 @@ export type CreatePoolInstructions = {
6161
*
6262
* @example
6363
* import { createSplashPoolInstructions } from '@orca-so/whirlpools';
64-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
64+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
6565
*
6666
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
67-
* const wallet = await generateKeyPairSigner();
67+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
68+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
6869
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
6970
*
7071
* const tokenMintOne = "TOKEN_MINT_ADDRESS_1";
7172
* const tokenMintTwo = "TOKEN_MINT_ADDRESS_2";
7273
* const initialPrice = 0.01;
7374
*
74-
* const { poolAddress, instructions, initializationCost } = await createSplashPoolInstructions(
75+
* const { poolAddress, instructions, estInitializationCost } = await createSplashPoolInstructions(
7576
* devnetRpc,
7677
* tokenMintOne,
7778
* tokenMintTwo,
@@ -110,18 +111,19 @@ export function createSplashPoolInstructions(
110111
*
111112
* @example
112113
* import { createConcentratedLiquidityPool } from '@orca-so/whirlpools';
113-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
114+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
114115
*
115116
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
116-
* const wallet = await generateKeyPairSigner();
117+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
118+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
117119
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
118120
*
119121
* const tokenMintOne = "TOKEN_MINT_ADDRESS_1";
120122
* const tokenMintTwo = "TOKEN_MINT_ADDRESS_2";
121123
* const tickSpacing = 64;
122124
* const initialPrice = 0.01;
123125
*
124-
* const { poolAddress, instructions, initializationCost } = await createConcentratedLiquidityPool(
126+
* const { poolAddress, instructions, estInitializationCost } = await createConcentratedLiquidityPool(
125127
* devnetRpc,
126128
* tokenMintOne,
127129
* tokenMintTwo,

ts-sdk/whirlpool/src/decreaseLiquidity.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ function getDecreaseLiquidityQuote(
143143
*
144144
* @example
145145
* import { decreaseLiquidityInstructions } from '@orca-so/whirlpools';
146-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
146+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
147147
*
148148
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
149-
* const wallet = await generateKeyPairSigner();
149+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
150+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
150151
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
151152
*
152153
* const positionMint = "POSITION_MINT";
@@ -287,10 +288,11 @@ export type ClosePositionInstructions = DecreaseLiquidityInstructions & {
287288
*
288289
* @example
289290
* import { closePositionInstructions } from '@orca-so/whirlpools';
290-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
291+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
291292
*
292293
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
293-
* const wallet = await generateKeyPairSigner();
294+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
295+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
294296
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
295297
*
296298
* const positionMint = "POSITION_MINT";

ts-sdk/whirlpool/src/harvest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ export type HarvestPositionInstructions = {
6969
* A promise that resolves to an object containing the instructions, fees, and rewards quotes.
7070
* @example
7171
* import { harvestPositionInstructions } from '@orca-so/whirlpools';
72-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
72+
* import { createKeyPairSignerFromBytes , createSolanaRpc, devnet, lamports } from '@solana/web3.js';
7373
*
7474
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
75-
* const wallet = await generateKeyPairSigner();
75+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
76+
* const wallet = await createKeyPairSignerFromBytes(keyPairBytes);
7677
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
7778
*
7879
* const positionMint = "POSITION_MINT";

ts-sdk/whirlpool/src/increaseLiquidity.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,22 @@ function getIncreaseLiquidityQuote(
149149
* @param {IncreaseLiquidityQuoteParam} param - The parameters for adding liquidity. Can specify liquidity, Token A, or Token B amounts.
150150
* @param {number} [slippageToleranceBps=SLIPPAGE_TOLERANCE_BPS] - The maximum acceptable slippage, in basis points (BPS).
151151
* @param {TransactionSigner} [authority=FUNDER] - The account that authorizes the transaction.
152-
* @returns {Promise<IncreaseLiquidityInstructions>} - Instructions and quote for increasing liquidity.
152+
* @returns {Promise<IncreaseLiquidityInstructions>} A promise that resolves to an object containing instructions, quote, position mint address, and initialization costs for increasing liquidity.
153153
*
154154
* @example
155155
* import { increaseLiquidityInstructions } from '@orca-so/whirlpools';
156-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
156+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
157157
*
158158
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
159-
* const wallet = await generateKeyPairSigner();
159+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
160+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
160161
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
161162
*
162163
* const positionMint = "POSITION_MINT";
163164
*
164165
* const param = { tokenA: 1_000_000n };
165166
*
166-
* const { quote, instructions, initializationCost } = await increaseLiquidityInstructions(
167+
* const { quote, instructions, initializationCost, positionMint } = await increaseLiquidityInstructions(
167168
* devnetRpc,
168169
* positionMint,
169170
* param,
@@ -464,21 +465,22 @@ async function internalOpenPositionInstructions(
464465
* @param {IncreaseLiquidityQuoteParam} param - The parameters for adding liquidity, where one of `liquidity`, `tokenA`, or `tokenB` must be specified. The SDK will compute the others.
465466
* @param {number} [slippageToleranceBps=SLIPPAGE_TOLERANCE_BPS] - The maximum acceptable slippage, in basis points (BPS).
466467
* @param {TransactionSigner} [funder=FUNDER] - The account funding the transaction.
467-
* @returns {Promise<IncreaseLiquidityInstructions>} - Instructions and quote for opening a full-range position.
468+
* @returns {Promise<IncreaseLiquidityInstructions>} A promise that resolves to an object containing the instructions, quote, position mint address, and initialization costs for increasing liquidity.
468469
*
469470
* @example
470471
* import { openFullRangePositionInstructions } from '@orca-so/whirlpools';
471-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
472+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
472473
*
473474
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
474-
* const wallet = await generateKeyPairSigner();
475+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
476+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
475477
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
476478
*
477479
* const poolAddress = "POOL_ADDRESS";
478480
*
479481
* const param = { tokenA: 1_000_000n };
480482
*
481-
* const { quote, instructions, initializationCost } = await openFullRangePositionInstructions(
483+
* const { quote, instructions, initializationCost, positionMint } = await openFullRangePositionInstructions(
482484
* devnetRpc,
483485
* poolAddress,
484486
* param,
@@ -530,7 +532,7 @@ export async function openFullRangePositionInstructions(
530532
* @param {number} [slippageToleranceBps=SLIPPAGE_TOLERANCE_BPS] - The slippage tolerance for adding liquidity, in basis points (BPS).
531533
* @param {TransactionSigner} [funder=FUNDER] - The account funding the transaction.
532534
*
533-
* @returns {Promise<IncreaseLiquidityInstructions>} A promise that resolves to an object containing liquidity information and the list of instructions needed to open the position.
535+
* @returns {Promise<IncreaseLiquidityInstructions>} A promise that resolves to an object containing instructions, quote, position mint address, and initialization costs for increasing liquidity.
534536
*
535537
* @example
536538
* import { openPositionInstructions } from '@orca-so/whirlpools';
@@ -546,7 +548,7 @@ export async function openFullRangePositionInstructions(
546548
* const lowerPrice = 0.00005;
547549
* const upperPrice = 0.00015;
548550
*
549-
* const { quote, instructions, initializationCost } = await openPositionInstructions(
551+
* const { quote, instructions, initializationCost, positionMint } = await openPositionInstructions(
550552
* devnetRpc,
551553
* poolAddress,
552554
* param,

ts-sdk/whirlpool/src/pool.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ export type PoolInfo = (InitializablePool | InitializedPool) & {
6262
*
6363
* @example
6464
* import { fetchSplashPool } from '@orca-so/whirlpools';
65-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
65+
* import { createSolanaRpc, devnet } from '@solana/web3.js';
6666
*
6767
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
68-
* const wallet = await generateKeyPairSigner();
69-
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
7068
*
7169
* const tokenMintOne = "TOKEN_MINT_ONE";
7270
* const tokenMintTwo = "TOKEN_MINT_TWO";
@@ -101,11 +99,9 @@ export async function fetchSplashPool(
10199
*
102100
* @example
103101
* import { fetchPool } from '@orca-so/whirlpools';
104-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
102+
* import { createSolanaRpc, devnet } from '@solana/web3.js';
105103
*
106104
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
107-
* const wallet = await generateKeyPairSigner();
108-
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
109105
*
110106
* const tokenMintOne = "TOKEN_MINT_ONE";
111107
* const tokenMintTwo = "TOKEN_MINT_TWO";
@@ -174,11 +170,9 @@ export async function fetchConcentratedLiquidityPool(
174170
*
175171
* @example
176172
* import { fetchWhirlpoolsByTokenPair } from '@orca-so/whirlpools';
177-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
173+
* import { createSolanaRpc, devnet } from '@solana/web3.js';
178174
*
179175
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
180-
* const wallet = await generateKeyPairSigner();
181-
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
182176
*
183177
* const tokenMintOne = "TOKEN_MINT_ONE";
184178
* const tokenMintTwo = "TOKEN_MINT_TWO";

ts-sdk/whirlpool/src/swap.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,11 @@ function getSwapQuote<T extends SwapParams>(
202202
*
203203
* @example
204204
* import { swapInstructions } from '@orca-so/whirlpools';
205-
* import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';
205+
* import { generateKeyPairSigner, createSolanaRpc, devnet, lamports } from '@solana/web3.js';
206206
*
207207
* const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
208-
* const wallet = await generateKeyPairSigner();
208+
* const keyPairBytes = new Uint8Array(JSON.parse(fs.readFileSync('path/to/solana-keypair.json', 'utf8')));
209+
* const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.
209210
* await devnetRpc.requestAirdrop(wallet.address, lamports(1000000000n)).send();
210211
*
211212
* const poolAddress = "POOL_ADDRESS";

0 commit comments

Comments
 (0)