flash-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/PoolAccount.js +0 -58
- package/lib/PoolConfig.d.ts +39 -0
- package/lib/PoolConfig.js +93 -0
- package/lib/PoolConfig.json +305 -0
- package/lib/PoolDisplayData.d.ts +13 -0
- package/lib/PoolDisplayData.js +9 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.js +3 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/PoolAccount.ts +0 -63
- package/src/PoolConfig.json +307 -0
- package/src/PoolConfig.ts +158 -0
- package/src/PoolDisplayData.ts +23 -0
- package/src/constants/index.ts +4 -0
- package/src/index.ts +2 -0
- package/src/target/idl/perpetuals.json +3537 -0
- package/tsconfig.json +1 -1
@@ -0,0 +1,307 @@
|
|
1
|
+
{
|
2
|
+
"cluster_urls": {
|
3
|
+
"devnet": "https://api.devnet.solana.com",
|
4
|
+
"localnet": "http://127.0.0.1:8899",
|
5
|
+
"mainnet": "https://api.mainnet-beta.solana.com",
|
6
|
+
"testnet": "http://api.testnet.rpcpool.com"
|
7
|
+
},
|
8
|
+
"pools": [
|
9
|
+
{
|
10
|
+
"programId": "BPkaJkzjqZ3u3sMnK7oHup5GGV5EHp4hYthz9Yodvydj",
|
11
|
+
"cluster": "devnet",
|
12
|
+
"poolName": "pool1",
|
13
|
+
"poolAddress": "Goy1R4LyBbvrmzqdCAs5M8KUb3baMxFnZP3bYoEtLEjA",
|
14
|
+
"lpTokenMint": "8nw7Qg7t6wAvfLpQhUxyWhXUbdQ9QSMcLJsV1e5Ggom1",
|
15
|
+
"lpDecimals": 6,
|
16
|
+
"perpetuals": "GZTJamEMs5fhCh6y4fRskTA9n8UsXSAWpQNd2sesevLX",
|
17
|
+
"transferAuthority" : "FidHtZMaZXzUBcfqTt9jHffNoydHP4RGiaVwwoE15mMu",
|
18
|
+
"multisig" : "4cMawSeiiJe6JKxF4Qzc3NQ1ZAJ37gVdsd6LF27gZBv9",
|
19
|
+
"tokens": [
|
20
|
+
{
|
21
|
+
"symbol": "USDC",
|
22
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
23
|
+
"decimals": 6,
|
24
|
+
"isStable": true,
|
25
|
+
"pythTicker" : "Crypto.USDC/USD"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"symbol": "SOL",
|
29
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
30
|
+
"decimals": 9,
|
31
|
+
"isStable": false,
|
32
|
+
"pythTicker" : "Crypto.SOL/USD"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"symbol": "BTC",
|
36
|
+
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
37
|
+
"decimals": 6,
|
38
|
+
"isStable": false,
|
39
|
+
"pythTicker" : "Crypto.BTC/USD"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"symbol": "ETH",
|
43
|
+
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
44
|
+
"decimals": 6,
|
45
|
+
"isStable": false,
|
46
|
+
"pythTicker" : "Crypto.ETH/USD"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"custodies": [
|
50
|
+
{
|
51
|
+
"custodyAccount": "CkYddgaB8c5tvs9WP11B83HvMaU35ZFpTzLLGg4NviEj",
|
52
|
+
"tokenAccount": "DHy9BXo36hwKkvBJnPd11zH77BefA77mTiL7yu2LNWPx",
|
53
|
+
"symbol": "USDC",
|
54
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
55
|
+
"decimals": 6,
|
56
|
+
"isStable": true,
|
57
|
+
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"custodyAccount": "4ueMZBmpTMPykYwTENJs7diYfgx6UBCPQnRwb2F5UFgw",
|
61
|
+
"tokenAccount": "G9bJQdZkzXZsiwouZ8MsZw6p8Pg5vtM9hbVHjfqSrJZo",
|
62
|
+
"symbol": "SOL",
|
63
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
64
|
+
"decimals": 9,
|
65
|
+
"isStable": false,
|
66
|
+
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"custodyAccount": "F9qzX5pHGS5SFfP5M24a8dqXUHQdraexJ3P9TNGF2WFj",
|
70
|
+
"tokenAccount": "y5vPUaQdM3fJkEyn3oA8uFMRzwJYcNJsjBZyW1yRUar",
|
71
|
+
"symbol": "BTC",
|
72
|
+
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
73
|
+
"decimals": 6,
|
74
|
+
"isStable": false,
|
75
|
+
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"custodyAccount": "BZggMsfpcpbB3tnhmtM2qJ1uMobKVBEmYZp2jmDrBHZD",
|
79
|
+
"tokenAccount": "HP4CcezCpCZqcoo8BsrroFEaykz2F4bz6sWBCCUJEBPy",
|
80
|
+
"symbol": "ETH",
|
81
|
+
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
82
|
+
"decimals": 6,
|
83
|
+
"isStable": false,
|
84
|
+
"oracleAddress": "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw"
|
85
|
+
}
|
86
|
+
|
87
|
+
]
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"programId": "f1avUCGxFGLbUTA8L64rMpRKw5KH6LxkTjGEzhWhAEo",
|
91
|
+
"cluster": "devnet",
|
92
|
+
"poolName": "F1aPool3",
|
93
|
+
"poolAddress": "EjrNsViX2JYLjcHhCjMUdn77SVMAps69N3gNyKTpTLfh",
|
94
|
+
"lpTokenMint": "CPUj8x9PVyLi1CuEY5CdxBgwZsq9wZkeMdgknBnbNpHq",
|
95
|
+
"lpDecimals": 6,
|
96
|
+
"perpetuals": "GKXKKi5bj9P2LsCBqFSKwhKfRM7MJrA4qyEMGXzNQcTz",
|
97
|
+
"transferAuthority" : "xeizPZDpXPDfu939cxNS27AoAkgw7fJKY4gxbK8khFA",
|
98
|
+
"multisig" : "84zJ1bS8w2Fn555qC7BkS8eNDMHpTKN48ZSyaSMSyjdT",
|
99
|
+
"tokens": [
|
100
|
+
{
|
101
|
+
"symbol": "USDC",
|
102
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
103
|
+
"decimals": 6,
|
104
|
+
"isStable": true,
|
105
|
+
"pythTicker" : "Crypto.USDC/USD"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"symbol": "SOL",
|
109
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
110
|
+
"decimals": 9,
|
111
|
+
"isStable": false,
|
112
|
+
"pythTicker" : "Crypto.SOL/USD"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"symbol": "BTC",
|
116
|
+
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
117
|
+
"decimals": 6,
|
118
|
+
"isStable": false,
|
119
|
+
"pythTicker" : "Crypto.BTC/USD"
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"symbol": "ETH",
|
123
|
+
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
124
|
+
"decimals": 6,
|
125
|
+
"isStable": false,
|
126
|
+
"pythTicker" : "Crypto.ETH/USD"
|
127
|
+
}
|
128
|
+
],
|
129
|
+
"custodies": [
|
130
|
+
{
|
131
|
+
"custodyAccount": "5n8Ga254uA4fy2UdCWwjHUvrRHGc3WwmmNsvjpbQYgwE",
|
132
|
+
"tokenAccount": "Ga1xofAe2EP3T2KTwL7KPEri9JGTwMTBwgrNmnchrGAg",
|
133
|
+
"symbol": "USDC",
|
134
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
135
|
+
"decimals": 6,
|
136
|
+
"isStable": true,
|
137
|
+
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"custodyAccount": "8NpLh7UknY7p43432ETcWZQYp8QK81tesxNqisDmnMNU",
|
141
|
+
"tokenAccount": "FDMmwmeQrZ6xWTdxXA2MZhZ9uggLgvwfKaW366WH2UAM",
|
142
|
+
"symbol": "SOL",
|
143
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
144
|
+
"decimals": 9,
|
145
|
+
"isStable": false,
|
146
|
+
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"custodyAccount": "BUkVeJxhkQMGJbibjTJUCG8afdudSpm5j2GpnyYrawQA",
|
150
|
+
"tokenAccount": "CrCSQpkug4uQCWiqET9AL4sXeBudy7t4RPZ5UPV1xti6",
|
151
|
+
"symbol": "BTC",
|
152
|
+
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
153
|
+
"decimals": 6,
|
154
|
+
"isStable": false,
|
155
|
+
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"custodyAccount": "Hq1JffLuvj8XjBuL552aCFJkgoNWyMLfvQ2wUaNSX8yC",
|
159
|
+
"tokenAccount": "D8kDJSWVuMm9oERTJGwUHwLg34TtigYgSbCBAQ5LGvDd",
|
160
|
+
"symbol": "ETH",
|
161
|
+
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
162
|
+
"decimals": 6,
|
163
|
+
"isStable": false,
|
164
|
+
"oracleAddress": "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw"
|
165
|
+
}
|
166
|
+
|
167
|
+
]
|
168
|
+
},
|
169
|
+
{
|
170
|
+
"programId": "FastuHRd9PRiuKGy2dHgH4zcSRjARKnPcHiQZnxpR5fD",
|
171
|
+
"cluster": "devnet",
|
172
|
+
"poolName": "FlashPool1",
|
173
|
+
"poolAddress": "98Z59gXJHFFmwmNTR7r2WCkcSiYhp7UTN64YrW6JxVuX",
|
174
|
+
"lpTokenMint": "8Kd733EK6ARFbGZXYZbcVTuzLufTTrDWVGLqPwJQabr",
|
175
|
+
"lpDecimals": 6,
|
176
|
+
"perpetuals": "23APwx3K4h7b2FwVYPCc6QUhjxq1HnfiLF5gJGzjjBug",
|
177
|
+
"transferAuthority" : "HgM32odRRY36KSmGjAdypSuN5e4QnRdGqQMXMz3Vk26L",
|
178
|
+
"multisig" : "CHi41aTYPbZf3M4hyT18oiafKQLZZNw8e9VRyUAr2Hgz",
|
179
|
+
"tokens": [
|
180
|
+
{
|
181
|
+
"symbol": "USDC",
|
182
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
183
|
+
"decimals": 6,
|
184
|
+
"isStable": true,
|
185
|
+
"pythTicker" : "Crypto.USDC/USD"
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"symbol": "SOL",
|
189
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
190
|
+
"decimals": 9,
|
191
|
+
"isStable": false,
|
192
|
+
"pythTicker" : "Crypto.SOL/USD"
|
193
|
+
}
|
194
|
+
],
|
195
|
+
"custodies": [
|
196
|
+
{
|
197
|
+
"custodyAccount": "5P4mY4AYuzbm5VbbQvHwBrbrWTdTKrtFSGWSi1n6jcnE",
|
198
|
+
"tokenAccount": "EU7vvLZqoKcqaNwge1jEB5psvM1Fs4UnbqAzs8bsfeKU",
|
199
|
+
"symbol": "SOL",
|
200
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
201
|
+
"decimals": 9,
|
202
|
+
"isStable": false,
|
203
|
+
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"custodyAccount": "2oYSArUnXE2L9a9NTYPmgKCjwdTpcrXxMaoQDQfoo8sE",
|
207
|
+
"tokenAccount": "EUhfKyh2fuwgxJFr7abLscwsATn82M3rmuGGvfqxsDKc",
|
208
|
+
"symbol": "USDC",
|
209
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
210
|
+
"decimals": 6,
|
211
|
+
"isStable": true,
|
212
|
+
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
213
|
+
}
|
214
|
+
]
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"programId": "PERP9EeXeGnyEqGmxGSan4nGRAFNLwTufLJmiYsTJ8j",
|
218
|
+
"cluster": "devnet",
|
219
|
+
"poolName": "TestPool1",
|
220
|
+
"poolAddress": "GSa3BkjXpoUdd1Bw1EiuMLRY3jFZBwQJJivPNWgSiGJ3",
|
221
|
+
"lpTokenMint": "Han23mxQeHeoBbj4vYtYZNaB5bhwV3n4nxKezM6H6nbr",
|
222
|
+
"lpDecimals": 6,
|
223
|
+
"perpetuals": "5CpxhcrfvH8s9QDT2nMaPWqPoMwpuiPuP8e8x4YN61A2",
|
224
|
+
"tokens": [
|
225
|
+
{
|
226
|
+
"symbol": "USDC",
|
227
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
228
|
+
"decimals": 6,
|
229
|
+
"isStable": true,
|
230
|
+
"pythTicker" : "Crypto.USDC/USD"
|
231
|
+
},
|
232
|
+
{
|
233
|
+
"symbol": "SOL",
|
234
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
235
|
+
"decimals": 9,
|
236
|
+
"isStable": false,
|
237
|
+
"pythTicker" : "Crypto.SOL/USD"
|
238
|
+
}
|
239
|
+
],
|
240
|
+
"custodies": [
|
241
|
+
{
|
242
|
+
"custodyAccount": "GBrsFAWty2G2WfsP8XWmzDTrBj8Dafx8ZXpXHD1Th6Y9",
|
243
|
+
"tokenAccount": "EYYCHS8eGZYo7yWSwqL3dd2uY3Um5E8vLXjr6EE4zcQv",
|
244
|
+
"symbol": "SOL",
|
245
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
246
|
+
"decimals": 9,
|
247
|
+
"isStable": false,
|
248
|
+
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
249
|
+
},
|
250
|
+
{
|
251
|
+
"custodyAccount": "BCuesBYYCUzfAHoLc1BeJo1Lq71Kacb2hMKJAi5FW9Be",
|
252
|
+
"tokenAccount": "BE9ih3oiCSNpMPhdJHzkQs73UUE6tHrdV7nRi3QkfHpi",
|
253
|
+
"symbol": "USDC",
|
254
|
+
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
255
|
+
"decimals": 6,
|
256
|
+
"isStable": true,
|
257
|
+
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
258
|
+
}
|
259
|
+
]
|
260
|
+
},
|
261
|
+
{
|
262
|
+
"programId": "PERP9EeXeGnyEqGmxGSan4nGRAFNLwTufLJmiYsTJ8j",
|
263
|
+
"cluster": "devnet",
|
264
|
+
"poolName": "internal_test",
|
265
|
+
"poolAddress": "DXdPxx7mS1EtCPcEm2uoLioYdXoE2HoVrHaR4o8Kg2uh",
|
266
|
+
"lpTokenMint": "J1887XKSeZFRzD6ACyiWMurXZd8xtNyb1Edj2oAxKT9E",
|
267
|
+
"lpDecimals": 6,
|
268
|
+
"perpetuals": "5CpxhcrfvH8s9QDT2nMaPWqPoMwpuiPuP8e8x4YN61A2",
|
269
|
+
"tokens": [
|
270
|
+
{
|
271
|
+
"symbol": "Test",
|
272
|
+
"mintKey": "6QGdQbaZEgpXqqbGwXJZXwbZ9xJnthfyYNZ92ARzTdAX",
|
273
|
+
"decimals": 9,
|
274
|
+
"isStable": true,
|
275
|
+
"pythTicker" : "Crypto.USDC/USD"
|
276
|
+
},
|
277
|
+
{
|
278
|
+
"symbol": "SOL",
|
279
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
280
|
+
"decimals": 9,
|
281
|
+
"isStable": false,
|
282
|
+
"pythTicker" : "Crypto.SOL/USD"
|
283
|
+
}
|
284
|
+
],
|
285
|
+
"custodies": [
|
286
|
+
{
|
287
|
+
"custodyAccount": "5Yk9k7Gpyip9ySqYoXgRANVfPbmJdqhXBemancsV5QLJ",
|
288
|
+
"tokenAccount": "DmEf6bvLt9eTkRWGUhpmwhJjf7dZL31ziGqNqALYctvH",
|
289
|
+
"symbol": "SOL",
|
290
|
+
"mintKey": "So11111111111111111111111111111111111111112",
|
291
|
+
"decimals": 9,
|
292
|
+
"isStable": false,
|
293
|
+
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
294
|
+
},
|
295
|
+
{
|
296
|
+
"custodyAccount": "AZCvUZ1qmbvnqebiYrExLoZtqyCgS33LN4XobAwwizR8",
|
297
|
+
"tokenAccount": "EuTHwLfV5pjtWE3sJTbjTgFb4BdLCwo6FZFAc8YdgxeM",
|
298
|
+
"symbol": "Test",
|
299
|
+
"mintKey": "6QGdQbaZEgpXqqbGwXJZXwbZ9xJnthfyYNZ92ARzTdAX",
|
300
|
+
"decimals": 9,
|
301
|
+
"isStable": true,
|
302
|
+
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
303
|
+
}
|
304
|
+
]
|
305
|
+
}
|
306
|
+
]
|
307
|
+
}
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import { Address } from '@project-serum/anchor';
|
2
|
+
import { Cluster, PublicKey } from '@solana/web3.js';
|
3
|
+
import poolConfigs from './PoolConfig.json';
|
4
|
+
|
5
|
+
|
6
|
+
export interface CustodyConfig {
|
7
|
+
custodyAccount: PublicKey;
|
8
|
+
tokenAccount: PublicKey;
|
9
|
+
symbol: string;
|
10
|
+
mintKey: PublicKey;
|
11
|
+
decimals: number;
|
12
|
+
isStable: boolean,
|
13
|
+
oracleAddress: PublicKey;
|
14
|
+
}
|
15
|
+
type Token = {
|
16
|
+
symbol: string;
|
17
|
+
mintKey: PublicKey;
|
18
|
+
decimals: number;
|
19
|
+
isStable: boolean;
|
20
|
+
pythTicker: string;
|
21
|
+
};
|
22
|
+
|
23
|
+
export class PoolConfig {
|
24
|
+
constructor(
|
25
|
+
public programId: PublicKey,
|
26
|
+
public cluster: Cluster,
|
27
|
+
public poolName: string,
|
28
|
+
public poolAddress: PublicKey,
|
29
|
+
public lpTokenMint: PublicKey,
|
30
|
+
public lpDecimals: number,
|
31
|
+
public perpetuals: PublicKey,
|
32
|
+
|
33
|
+
|
34
|
+
// public perpMarketAccountKey: string,
|
35
|
+
// public multisigAccountKey: string,
|
36
|
+
// public transferAuthorityAccountKey: string,
|
37
|
+
|
38
|
+
public tokens: Token[],
|
39
|
+
|
40
|
+
public custodies: CustodyConfig[],
|
41
|
+
) { }
|
42
|
+
|
43
|
+
public getAllTokenMints(): PublicKey[] {
|
44
|
+
return Array.from(
|
45
|
+
this.tokens.map((token) => new PublicKey(token.mintKey)),
|
46
|
+
);
|
47
|
+
}
|
48
|
+
|
49
|
+
public getNonStableTokens(): PublicKey[] {
|
50
|
+
return Array.from(
|
51
|
+
this.tokens
|
52
|
+
.filter((token) => !token.isStable)
|
53
|
+
.map((token) => new PublicKey(token.mintKey)),
|
54
|
+
);
|
55
|
+
}
|
56
|
+
|
57
|
+
public getAllCustodies(): PublicKey[] {
|
58
|
+
return Array.from(
|
59
|
+
this.custodies.map((custody) => new PublicKey(custody.custodyAccount)),
|
60
|
+
);
|
61
|
+
}
|
62
|
+
|
63
|
+
public getNonStableCustodies(): PublicKey[] {
|
64
|
+
return Array.from(
|
65
|
+
this.custodies
|
66
|
+
.filter((custody) => !custody.isStable)
|
67
|
+
.map((custody) => new PublicKey(custody.custodyAccount)),
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
// static getAllPoolConfigs(cluster: Cluster): PoolConfig[] {
|
72
|
+
// return poolConfigs.pools.map(p => this.fromIdsByName(p.poolName, cluster))
|
73
|
+
// }
|
74
|
+
|
75
|
+
static getCustodyConfig(custodyAccountPk: Address, poolName: string, cluster: Cluster) {
|
76
|
+
return this.fromIdsByName(poolName, cluster).custodies.find(f => f.custodyAccount.toBase58() === custodyAccountPk.toString())
|
77
|
+
}
|
78
|
+
|
79
|
+
static getTokensInPool(name: string, cluster: Cluster): Token[] {
|
80
|
+
const poolConfig = poolConfigs.pools.find((pool) => pool['poolName'] === name && cluster === pool['cluster']);
|
81
|
+
if (!poolConfig) throw new Error(`No pool config ${name} found in Ids!`);
|
82
|
+
const tokens = poolConfig['tokens'].map(i => {
|
83
|
+
return {
|
84
|
+
...i,
|
85
|
+
mintKey: new PublicKey(i.mintKey)
|
86
|
+
}
|
87
|
+
})
|
88
|
+
return tokens
|
89
|
+
}
|
90
|
+
|
91
|
+
static fromIdsByName(name: string, cluster: Cluster): PoolConfig {
|
92
|
+
const poolConfig = poolConfigs.pools.find((pool) => pool['poolName'] === name && cluster === pool['cluster']);
|
93
|
+
if (!poolConfig) throw new Error(`No pool config ${name} found in Ids!`);
|
94
|
+
const tokens = poolConfig['tokens'].map(i => {
|
95
|
+
return {
|
96
|
+
...i,
|
97
|
+
mintKey : new PublicKey(i.mintKey)
|
98
|
+
}
|
99
|
+
})
|
100
|
+
const custodies = poolConfig['custodies'].map(i => {
|
101
|
+
return {
|
102
|
+
...i,
|
103
|
+
custodyAccount : new PublicKey(i.custodyAccount),
|
104
|
+
tokenAccount : new PublicKey(i.tokenAccount),
|
105
|
+
mintKey : new PublicKey(i.mintKey),
|
106
|
+
oracleAddress : new PublicKey(i.oracleAddress),
|
107
|
+
}
|
108
|
+
})
|
109
|
+
return new PoolConfig(
|
110
|
+
new PublicKey(poolConfig.programId),
|
111
|
+
poolConfig.cluster as Cluster,
|
112
|
+
poolConfig.poolName,
|
113
|
+
new PublicKey(poolConfig.poolAddress),
|
114
|
+
new PublicKey(poolConfig.lpTokenMint),
|
115
|
+
poolConfig.lpDecimals,
|
116
|
+
new PublicKey(poolConfig.perpetuals),
|
117
|
+
tokens,
|
118
|
+
custodies,
|
119
|
+
);
|
120
|
+
}
|
121
|
+
|
122
|
+
static fromIdsByPk(poolPk: PublicKey, cluster: Cluster): PoolConfig {
|
123
|
+
const poolConfig = poolConfigs.pools.find(
|
124
|
+
(pool) => pool['poolAddress'] === poolPk.toString() && cluster === pool['cluster'],
|
125
|
+
);
|
126
|
+
if (!poolConfig)
|
127
|
+
throw new Error(`No pool config ${poolPk.toString()} found in Ids!`);
|
128
|
+
|
129
|
+
const tokens = poolConfig['tokens'].map(i => {
|
130
|
+
return {
|
131
|
+
...i,
|
132
|
+
mintKey : new PublicKey(i.mintKey)
|
133
|
+
}
|
134
|
+
})
|
135
|
+
const custodies = poolConfig['custodies'].map(i => {
|
136
|
+
return {
|
137
|
+
...i,
|
138
|
+
custodyAccount : new PublicKey(i.custodyAccount),
|
139
|
+
tokenAccount : new PublicKey(i.tokenAccount),
|
140
|
+
mintKey : new PublicKey(i.mintKey),
|
141
|
+
oracleAddress : new PublicKey(i.oracleAddress),
|
142
|
+
}
|
143
|
+
})
|
144
|
+
|
145
|
+
return new PoolConfig(
|
146
|
+
new PublicKey(poolConfig.programId),
|
147
|
+
poolConfig.cluster as Cluster,
|
148
|
+
poolConfig.poolName,
|
149
|
+
new PublicKey(poolConfig.poolAddress),
|
150
|
+
new PublicKey(poolConfig.lpTokenMint),
|
151
|
+
poolConfig.lpDecimals,
|
152
|
+
new PublicKey(poolConfig.perpetuals),
|
153
|
+
tokens,
|
154
|
+
custodies,
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
158
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
import { BN_ZERO, BPS_DECIMALS, BPS_POWER, PERCENTAGE_DECIMALS, PRICE_DECIMALS, USD_DECIMALS } from "./constants";
|
3
|
+
import { BN } from "@coral-xyz/anchor";
|
4
|
+
import { Mint } from "@solana/spl-token";
|
5
|
+
import { Custody, FeesMode, Pool, Side, TokenRatios, isVariant } from "./types";
|
6
|
+
import { PublicKey } from "@solana/web3.js";
|
7
|
+
import {CustodyAccount} from "./CustodyAccount";
|
8
|
+
import { OraclePrice } from "./OraclePrice";
|
9
|
+
import { PositionAccount } from "./PositionAccount";
|
10
|
+
import { checkedCeilDiv, checkedDecimalCeilMul, checkedDecimalMul, scaleToExponent } from "./utils";
|
11
|
+
import { PoolConfig } from "./PoolConfig";
|
12
|
+
|
13
|
+
export class PoolDisplayData {
|
14
|
+
|
15
|
+
public poolConfig: PoolConfig;
|
16
|
+
public poolData : Pool;
|
17
|
+
public lpTokenInfo : Mint;
|
18
|
+
public custodies : CustodyAccount[];
|
19
|
+
public totalPoolValueUsd : BN;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
} // Pool
|
package/src/constants/index.ts
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
import { Cluster } from "@solana/web3.js";
|
1
2
|
import { BN } from "bn.js";
|
2
3
|
|
4
|
+
export const DEFAULT_CLUSTER: Cluster = 'devnet';
|
5
|
+
export const DEFAULT_POOL: string = 'pool1';
|
6
|
+
|
3
7
|
export const PERCENTAGE_DECIMALS = 4; // stableCoinPercentage
|
4
8
|
export const PRICE_DECIMALS = 6; //
|
5
9
|
export const USD_DECIMALS = 6; //
|