Skip to content

Commit

Permalink
More CLI commands (#642)
Browse files Browse the repository at this point in the history
* fix yarn link issue

* display whirlpool address

* add initializePositionBundle

* initial impl sync position bundle state

* tweak initialize_tick_array (init multiple tick arrays)

* tweak sendTransaction (defaultPF, alts)

* Update sync_position_bundle_state.ts

* add alt support

* tweak directory structure

* remove todo

* tweak

* cleanup

* cleanup

* fix lint errors

* prettier

* revert package.json (use *)

* Revert "revert package.json (use *)"

This reverts commit 56845ca.
  • Loading branch information
yugure-orca authored Jan 13, 2025
1 parent 86c8dd1 commit 68b9401
Show file tree
Hide file tree
Showing 23 changed files with 2,527 additions and 491 deletions.
17 changes: 16 additions & 1 deletion legacy-sdk/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,29 @@ Token-2022 tokens are acceptable 👍
- `yarn start collectRewards`: collect rewards from a position
- `yarn start closePosition`: close an empty position

## PositionBundle
- `yarn start initializePositionBundle`: create a new position bundle
- `yarn start syncPositionBundleState`: update the state of a position bundle based on an input CSV file

## Swap
- `yarn start pushPrice`: adjust pool price (possible if pool liquidity is zero or very small)

## WSOL and ATA creation
TODO: WSOL handling & create ATA if needed (workaround exists, please see the following)

## ALT
### Shared ALT
Shared ALT contains well-known program ID and WhirlpoolsConfig address and mint addresses.

Solana: `7Vyx1y8vG9e9Q1MedmXpopRC6ZhVaZzGcvYh5Z3Cs75i`
Eclipse: `Fsq7DQa13Lx9FvR5QheHigaccRkjiNqfnHQouXyFsg4z`

### Custom ALT
- `yarn start initializeAltForWhirlpool`: create ALT containing whirlpool address, mint address, vault address, some TickArray addresses and ATAs
- `yarn start initializeAltForBundledPositions`: create ALT containing all (256) bundled position addresses

### workaround for WSOL
`whirlpool-mgmt-tools` works well with ATA, so using WSOL on ATA is workaround.
CLI works well with ATA, so using WSOL on ATA is workaround.

- wrap 1 SOL: `spl-token wrap 1` (ATA for WSOL will be initialized with 1 SOL)
- unwrap: `spl-token unwrap` (ATA for WSOL will be closed)
Expand Down
4 changes: 2 additions & 2 deletions legacy-sdk/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"dependencies": {
"@coral-xyz/anchor": "0.29.0",
"@orca-so/common-sdk": "*",
"@orca-so/whirlpools-sdk": "*",
"@orca-so/common-sdk": "0.6.4",
"@orca-so/whirlpools-sdk": "0.13.12",
"@solana/spl-token": "0.4.1",
"@solana/web3.js": "^1.90.0",
"@types/bn.js": "^5.1.0",
Expand Down
257 changes: 257 additions & 0 deletions legacy-sdk/cli/sample/position_bundle_state/close.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
bundle index,state,lower tick index,upper tick index,liquidity
0,closed,,,
1,closed,,,
2,closed,,,
3,closed,,,
4,closed,,,
5,closed,,,
6,closed,,,
7,closed,,,
8,closed,,,
9,closed,,,
10,closed,,,
11,closed,,,
12,closed,,,
13,closed,,,
14,closed,,,
15,closed,,,
16,closed,,,
17,closed,,,
18,closed,,,
19,closed,,,
20,closed,,,
21,closed,,,
22,closed,,,
23,closed,,,
24,closed,,,
25,closed,,,
26,closed,,,
27,closed,,,
28,closed,,,
29,closed,,,
30,closed,,,
31,closed,,,
32,closed,,,
33,closed,,,
34,closed,,,
35,closed,,,
36,closed,,,
37,closed,,,
38,closed,,,
39,closed,,,
40,closed,,,
41,closed,,,
42,closed,,,
43,closed,,,
44,closed,,,
45,closed,,,
46,closed,,,
47,closed,,,
48,closed,,,
49,closed,,,
50,closed,,,
51,closed,,,
52,closed,,,
53,closed,,,
54,closed,,,
55,closed,,,
56,closed,,,
57,closed,,,
58,closed,,,
59,closed,,,
60,closed,,,
61,closed,,,
62,closed,,,
63,closed,,,
64,closed,,,
65,closed,,,
66,closed,,,
67,closed,,,
68,closed,,,
69,closed,,,
70,closed,,,
71,closed,,,
72,closed,,,
73,closed,,,
74,closed,,,
75,closed,,,
76,closed,,,
77,closed,,,
78,closed,,,
79,closed,,,
80,closed,,,
81,closed,,,
82,closed,,,
83,closed,,,
84,closed,,,
85,closed,,,
86,closed,,,
87,closed,,,
88,closed,,,
89,closed,,,
90,closed,,,
91,closed,,,
92,closed,,,
93,closed,,,
94,closed,,,
95,closed,,,
96,closed,,,
97,closed,,,
98,closed,,,
99,closed,,,
100,closed,,,
101,closed,,,
102,closed,,,
103,closed,,,
104,closed,,,
105,closed,,,
106,closed,,,
107,closed,,,
108,closed,,,
109,closed,,,
110,closed,,,
111,closed,,,
112,closed,,,
113,closed,,,
114,closed,,,
115,closed,,,
116,closed,,,
117,closed,,,
118,closed,,,
119,closed,,,
120,closed,,,
121,closed,,,
122,closed,,,
123,closed,,,
124,closed,,,
125,closed,,,
126,closed,,,
127,closed,,,
128,closed,,,
129,closed,,,
130,closed,,,
131,closed,,,
132,closed,,,
133,closed,,,
134,closed,,,
135,closed,,,
136,closed,,,
137,closed,,,
138,closed,,,
139,closed,,,
140,closed,,,
141,closed,,,
142,closed,,,
143,closed,,,
144,closed,,,
145,closed,,,
146,closed,,,
147,closed,,,
148,closed,,,
149,closed,,,
150,closed,,,
151,closed,,,
152,closed,,,
153,closed,,,
154,closed,,,
155,closed,,,
156,closed,,,
157,closed,,,
158,closed,,,
159,closed,,,
160,closed,,,
161,closed,,,
162,closed,,,
163,closed,,,
164,closed,,,
165,closed,,,
166,closed,,,
167,closed,,,
168,closed,,,
169,closed,,,
170,closed,,,
171,closed,,,
172,closed,,,
173,closed,,,
174,closed,,,
175,closed,,,
176,closed,,,
177,closed,,,
178,closed,,,
179,closed,,,
180,closed,,,
181,closed,,,
182,closed,,,
183,closed,,,
184,closed,,,
185,closed,,,
186,closed,,,
187,closed,,,
188,closed,,,
189,closed,,,
190,closed,,,
191,closed,,,
192,closed,,,
193,closed,,,
194,closed,,,
195,closed,,,
196,closed,,,
197,closed,,,
198,closed,,,
199,closed,,,
200,closed,,,
201,closed,,,
202,closed,,,
203,closed,,,
204,closed,,,
205,closed,,,
206,closed,,,
207,closed,,,
208,closed,,,
209,closed,,,
210,closed,,,
211,closed,,,
212,closed,,,
213,closed,,,
214,closed,,,
215,closed,,,
216,closed,,,
217,closed,,,
218,closed,,,
219,closed,,,
220,closed,,,
221,closed,,,
222,closed,,,
223,closed,,,
224,closed,,,
225,closed,,,
226,closed,,,
227,closed,,,
228,closed,,,
229,closed,,,
230,closed,,,
231,closed,,,
232,closed,,,
233,closed,,,
234,closed,,,
235,closed,,,
236,closed,,,
237,closed,,,
238,closed,,,
239,closed,,,
240,closed,,,
241,closed,,,
242,closed,,,
243,closed,,,
244,closed,,,
245,closed,,,
246,closed,,,
247,closed,,,
248,closed,,,
249,closed,,,
250,closed,,,
251,closed,,,
252,closed,,,
253,closed,,,
254,closed,,,
255,closed,,,
Loading

0 comments on commit 68b9401

Please sign in to comment.