flash-sdk 1.0.21 → 1.0.23
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 → dist}/PerpetualsClient.d.ts +4 -0
- package/{lib → dist}/PerpetualsClient.js +121 -0
- package/{lib → dist}/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -4
- package/src/CustodyAccount.ts +0 -125
- package/src/OraclePrice.ts +0 -111
- package/src/PerpetualsClient.ts +0 -1961
- package/src/PoolAccount.ts +0 -491
- package/src/PoolConfig.json +0 -322
- package/src/PoolConfig.ts +0 -182
- package/src/PoolDataClient.ts +0 -173
- package/src/PositionAccount.ts +0 -58
- package/src/Token.ts +0 -1
- package/src/constants/index.ts +0 -21
- package/src/idl/perpetuals.ts +0 -7561
- package/src/index.ts +0 -19
- package/src/type-rules.md +0 -4
- package/src/types/index.ts +0 -290
- package/src/utils/index.ts +0 -234
- package/src/utils/rpc.ts +0 -162
- package/tsconfig.json +0 -23
- /package/{lib → dist}/CustodyAccount.d.ts +0 -0
- /package/{lib → dist}/CustodyAccount.js +0 -0
- /package/{lib → dist}/OraclePrice.d.ts +0 -0
- /package/{lib → dist}/OraclePrice.js +0 -0
- /package/{lib → dist}/PoolAccount.d.ts +0 -0
- /package/{lib → dist}/PoolAccount.js +0 -0
- /package/{lib → dist}/PoolConfig.d.ts +0 -0
- /package/{lib → dist}/PoolConfig.js +0 -0
- /package/{lib → dist}/PoolConfig.json +0 -0
- /package/{lib → dist}/PoolDataClient.d.ts +0 -0
- /package/{lib → dist}/PoolDataClient.js +0 -0
- /package/{lib → dist}/PositionAccount.d.ts +0 -0
- /package/{lib → dist}/PositionAccount.js +0 -0
- /package/{lib → dist}/Token.d.ts +0 -0
- /package/{lib → dist}/Token.js +0 -0
- /package/{lib → dist}/constants/index.d.ts +0 -0
- /package/{lib → dist}/constants/index.js +0 -0
- /package/{lib → dist}/idl/perpetuals.d.ts +0 -0
- /package/{lib → dist}/idl/perpetuals.js +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/index.js +0 -0
- /package/{lib → dist}/types/index.d.ts +0 -0
- /package/{lib → dist}/types/index.js +0 -0
- /package/{lib → dist}/utils/index.d.ts +0 -0
- /package/{lib → dist}/utils/index.js +0 -0
- /package/{lib → dist}/utils/rpc.d.ts +0 -0
- /package/{lib → dist}/utils/rpc.js +0 -0
package/src/PoolConfig.json
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
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": "WSOL",
|
|
36
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
37
|
-
"decimals": 9,
|
|
38
|
-
"isStable": false,
|
|
39
|
-
"pythTicker" : "Crypto.SOL/USD"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"symbol": "BTC",
|
|
43
|
-
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
|
44
|
-
"decimals": 6,
|
|
45
|
-
"isStable": false,
|
|
46
|
-
"pythTicker" : "Crypto.BTC/USD"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"symbol": "ETH",
|
|
50
|
-
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
|
51
|
-
"decimals": 6,
|
|
52
|
-
"isStable": false,
|
|
53
|
-
"pythTicker" : "Crypto.ETH/USD"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"custodies": [
|
|
57
|
-
{
|
|
58
|
-
"custodyId" : 0,
|
|
59
|
-
"custodyAccount": "CkYddgaB8c5tvs9WP11B83HvMaU35ZFpTzLLGg4NviEj",
|
|
60
|
-
"tokenAccount": "DHy9BXo36hwKkvBJnPd11zH77BefA77mTiL7yu2LNWPx",
|
|
61
|
-
"symbol": "USDC",
|
|
62
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
63
|
-
"decimals": 6,
|
|
64
|
-
"isStable": true,
|
|
65
|
-
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"custodyId" : 1,
|
|
69
|
-
"custodyAccount": "4ueMZBmpTMPykYwTENJs7diYfgx6UBCPQnRwb2F5UFgw",
|
|
70
|
-
"tokenAccount": "G9bJQdZkzXZsiwouZ8MsZw6p8Pg5vtM9hbVHjfqSrJZo",
|
|
71
|
-
"symbol": "SOL",
|
|
72
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
73
|
-
"decimals": 9,
|
|
74
|
-
"isStable": false,
|
|
75
|
-
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"custodyId" : 2,
|
|
79
|
-
"custodyAccount": "F9qzX5pHGS5SFfP5M24a8dqXUHQdraexJ3P9TNGF2WFj",
|
|
80
|
-
"tokenAccount": "y5vPUaQdM3fJkEyn3oA8uFMRzwJYcNJsjBZyW1yRUar",
|
|
81
|
-
"symbol": "BTC",
|
|
82
|
-
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
|
83
|
-
"decimals": 6,
|
|
84
|
-
"isStable": false,
|
|
85
|
-
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"custodyId" : 3,
|
|
89
|
-
"custodyAccount": "BZggMsfpcpbB3tnhmtM2qJ1uMobKVBEmYZp2jmDrBHZD",
|
|
90
|
-
"tokenAccount": "HP4CcezCpCZqcoo8BsrroFEaykz2F4bz6sWBCCUJEBPy",
|
|
91
|
-
"symbol": "ETH",
|
|
92
|
-
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
|
93
|
-
"decimals": 6,
|
|
94
|
-
"isStable": false,
|
|
95
|
-
"oracleAddress": "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw"
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
]
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"programId": "f1avUCGxFGLbUTA8L64rMpRKw5KH6LxkTjGEzhWhAEo",
|
|
102
|
-
"cluster": "devnet",
|
|
103
|
-
"poolName": "F1aPool3",
|
|
104
|
-
"poolAddress": "EjrNsViX2JYLjcHhCjMUdn77SVMAps69N3gNyKTpTLfh",
|
|
105
|
-
"lpTokenMint": "CPUj8x9PVyLi1CuEY5CdxBgwZsq9wZkeMdgknBnbNpHq",
|
|
106
|
-
"lpDecimals": 6,
|
|
107
|
-
"perpetuals": "GKXKKi5bj9P2LsCBqFSKwhKfRM7MJrA4qyEMGXzNQcTz",
|
|
108
|
-
"transferAuthority" : "xeizPZDpXPDfu939cxNS27AoAkgw7fJKY4gxbK8khFA",
|
|
109
|
-
"multisig" : "84zJ1bS8w2Fn555qC7BkS8eNDMHpTKN48ZSyaSMSyjdT",
|
|
110
|
-
"tokens": [
|
|
111
|
-
{
|
|
112
|
-
"symbol": "USDC",
|
|
113
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
114
|
-
"decimals": 6,
|
|
115
|
-
"isStable": true,
|
|
116
|
-
"pythTicker" : "Crypto.USDC/USD"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"symbol": "SOL",
|
|
120
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
121
|
-
"decimals": 9,
|
|
122
|
-
"isStable": false,
|
|
123
|
-
"pythTicker" : "Crypto.SOL/USD"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"symbol": "BTC",
|
|
127
|
-
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
|
128
|
-
"decimals": 6,
|
|
129
|
-
"isStable": false,
|
|
130
|
-
"pythTicker" : "Crypto.BTC/USD"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"symbol": "ETH",
|
|
134
|
-
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
|
135
|
-
"decimals": 6,
|
|
136
|
-
"isStable": false,
|
|
137
|
-
"pythTicker" : "Crypto.ETH/USD"
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
"custodies": [
|
|
141
|
-
{
|
|
142
|
-
"custodyAccount": "5n8Ga254uA4fy2UdCWwjHUvrRHGc3WwmmNsvjpbQYgwE",
|
|
143
|
-
"tokenAccount": "Ga1xofAe2EP3T2KTwL7KPEri9JGTwMTBwgrNmnchrGAg",
|
|
144
|
-
"symbol": "USDC",
|
|
145
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
146
|
-
"decimals": 6,
|
|
147
|
-
"isStable": true,
|
|
148
|
-
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"custodyAccount": "8NpLh7UknY7p43432ETcWZQYp8QK81tesxNqisDmnMNU",
|
|
152
|
-
"tokenAccount": "FDMmwmeQrZ6xWTdxXA2MZhZ9uggLgvwfKaW366WH2UAM",
|
|
153
|
-
"symbol": "SOL",
|
|
154
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
155
|
-
"decimals": 9,
|
|
156
|
-
"isStable": false,
|
|
157
|
-
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"custodyAccount": "BUkVeJxhkQMGJbibjTJUCG8afdudSpm5j2GpnyYrawQA",
|
|
161
|
-
"tokenAccount": "CrCSQpkug4uQCWiqET9AL4sXeBudy7t4RPZ5UPV1xti6",
|
|
162
|
-
"symbol": "BTC",
|
|
163
|
-
"mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
|
|
164
|
-
"decimals": 6,
|
|
165
|
-
"isStable": false,
|
|
166
|
-
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"custodyAccount": "Hq1JffLuvj8XjBuL552aCFJkgoNWyMLfvQ2wUaNSX8yC",
|
|
170
|
-
"tokenAccount": "D8kDJSWVuMm9oERTJGwUHwLg34TtigYgSbCBAQ5LGvDd",
|
|
171
|
-
"symbol": "ETH",
|
|
172
|
-
"mintKey": "BA17bkYW78GvnirtgRHcceQxZdwkhpzbvrwDU6voUXRz",
|
|
173
|
-
"decimals": 6,
|
|
174
|
-
"isStable": false,
|
|
175
|
-
"oracleAddress": "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw"
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"programId": "FastuHRd9PRiuKGy2dHgH4zcSRjARKnPcHiQZnxpR5fD",
|
|
182
|
-
"cluster": "devnet",
|
|
183
|
-
"poolName": "FlashPool1",
|
|
184
|
-
"poolAddress": "98Z59gXJHFFmwmNTR7r2WCkcSiYhp7UTN64YrW6JxVuX",
|
|
185
|
-
"lpTokenMint": "8Kd733EK6ARFbGZXYZbcVTuzLufTTrDWVGLqPwJQabr",
|
|
186
|
-
"lpDecimals": 6,
|
|
187
|
-
"perpetuals": "23APwx3K4h7b2FwVYPCc6QUhjxq1HnfiLF5gJGzjjBug",
|
|
188
|
-
"transferAuthority" : "HgM32odRRY36KSmGjAdypSuN5e4QnRdGqQMXMz3Vk26L",
|
|
189
|
-
"multisig" : "CHi41aTYPbZf3M4hyT18oiafKQLZZNw8e9VRyUAr2Hgz",
|
|
190
|
-
"tokens": [
|
|
191
|
-
{
|
|
192
|
-
"symbol": "USDC",
|
|
193
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
194
|
-
"decimals": 6,
|
|
195
|
-
"isStable": true,
|
|
196
|
-
"pythTicker" : "Crypto.USDC/USD"
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
"symbol": "SOL",
|
|
200
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
201
|
-
"decimals": 9,
|
|
202
|
-
"isStable": false,
|
|
203
|
-
"pythTicker" : "Crypto.SOL/USD"
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
"custodies": [
|
|
207
|
-
{
|
|
208
|
-
"custodyAccount": "5P4mY4AYuzbm5VbbQvHwBrbrWTdTKrtFSGWSi1n6jcnE",
|
|
209
|
-
"tokenAccount": "EU7vvLZqoKcqaNwge1jEB5psvM1Fs4UnbqAzs8bsfeKU",
|
|
210
|
-
"symbol": "SOL",
|
|
211
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
212
|
-
"decimals": 9,
|
|
213
|
-
"isStable": false,
|
|
214
|
-
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"custodyAccount": "2oYSArUnXE2L9a9NTYPmgKCjwdTpcrXxMaoQDQfoo8sE",
|
|
218
|
-
"tokenAccount": "EUhfKyh2fuwgxJFr7abLscwsATn82M3rmuGGvfqxsDKc",
|
|
219
|
-
"symbol": "USDC",
|
|
220
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
221
|
-
"decimals": 6,
|
|
222
|
-
"isStable": true,
|
|
223
|
-
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
"programId": "PERP9EeXeGnyEqGmxGSan4nGRAFNLwTufLJmiYsTJ8j",
|
|
229
|
-
"cluster": "devnet",
|
|
230
|
-
"poolName": "TestPool1",
|
|
231
|
-
"poolAddress": "GSa3BkjXpoUdd1Bw1EiuMLRY3jFZBwQJJivPNWgSiGJ3",
|
|
232
|
-
"lpTokenMint": "Han23mxQeHeoBbj4vYtYZNaB5bhwV3n4nxKezM6H6nbr",
|
|
233
|
-
"lpDecimals": 6,
|
|
234
|
-
"perpetuals": "5CpxhcrfvH8s9QDT2nMaPWqPoMwpuiPuP8e8x4YN61A2",
|
|
235
|
-
"transferAuthority" : "",
|
|
236
|
-
"multisig" : "",
|
|
237
|
-
"tokens": [
|
|
238
|
-
{
|
|
239
|
-
"symbol": "USDC",
|
|
240
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
241
|
-
"decimals": 6,
|
|
242
|
-
"isStable": true,
|
|
243
|
-
"pythTicker" : "Crypto.USDC/USD"
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
"symbol": "SOL",
|
|
247
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
248
|
-
"decimals": 9,
|
|
249
|
-
"isStable": false,
|
|
250
|
-
"pythTicker" : "Crypto.SOL/USD"
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
"custodies": [
|
|
254
|
-
{
|
|
255
|
-
"custodyAccount": "GBrsFAWty2G2WfsP8XWmzDTrBj8Dafx8ZXpXHD1Th6Y9",
|
|
256
|
-
"tokenAccount": "EYYCHS8eGZYo7yWSwqL3dd2uY3Um5E8vLXjr6EE4zcQv",
|
|
257
|
-
"symbol": "SOL",
|
|
258
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
259
|
-
"decimals": 9,
|
|
260
|
-
"isStable": false,
|
|
261
|
-
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"custodyAccount": "BCuesBYYCUzfAHoLc1BeJo1Lq71Kacb2hMKJAi5FW9Be",
|
|
265
|
-
"tokenAccount": "BE9ih3oiCSNpMPhdJHzkQs73UUE6tHrdV7nRi3QkfHpi",
|
|
266
|
-
"symbol": "USDC",
|
|
267
|
-
"mintKey": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
|
|
268
|
-
"decimals": 6,
|
|
269
|
-
"isStable": true,
|
|
270
|
-
"oracleAddress": "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
"programId": "PERP9EeXeGnyEqGmxGSan4nGRAFNLwTufLJmiYsTJ8j",
|
|
276
|
-
"cluster": "devnet",
|
|
277
|
-
"poolName": "internal_test",
|
|
278
|
-
"poolAddress": "DXdPxx7mS1EtCPcEm2uoLioYdXoE2HoVrHaR4o8Kg2uh",
|
|
279
|
-
"lpTokenMint": "J1887XKSeZFRzD6ACyiWMurXZd8xtNyb1Edj2oAxKT9E",
|
|
280
|
-
"lpDecimals": 6,
|
|
281
|
-
"perpetuals": "5CpxhcrfvH8s9QDT2nMaPWqPoMwpuiPuP8e8x4YN61A2",
|
|
282
|
-
"transferAuthority" : "",
|
|
283
|
-
"multisig" : "",
|
|
284
|
-
"tokens": [
|
|
285
|
-
{
|
|
286
|
-
"symbol": "Test",
|
|
287
|
-
"mintKey": "6QGdQbaZEgpXqqbGwXJZXwbZ9xJnthfyYNZ92ARzTdAX",
|
|
288
|
-
"decimals": 9,
|
|
289
|
-
"isStable": true,
|
|
290
|
-
"pythTicker" : "Crypto.USDC/USD"
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"symbol": "SOL",
|
|
294
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
295
|
-
"decimals": 9,
|
|
296
|
-
"isStable": false,
|
|
297
|
-
"pythTicker" : "Crypto.SOL/USD"
|
|
298
|
-
}
|
|
299
|
-
],
|
|
300
|
-
"custodies": [
|
|
301
|
-
{
|
|
302
|
-
"custodyAccount": "5Yk9k7Gpyip9ySqYoXgRANVfPbmJdqhXBemancsV5QLJ",
|
|
303
|
-
"tokenAccount": "DmEf6bvLt9eTkRWGUhpmwhJjf7dZL31ziGqNqALYctvH",
|
|
304
|
-
"symbol": "SOL",
|
|
305
|
-
"mintKey": "So11111111111111111111111111111111111111112",
|
|
306
|
-
"decimals": 9,
|
|
307
|
-
"isStable": false,
|
|
308
|
-
"oracleAddress": "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
"custodyAccount": "AZCvUZ1qmbvnqebiYrExLoZtqyCgS33LN4XobAwwizR8",
|
|
312
|
-
"tokenAccount": "EuTHwLfV5pjtWE3sJTbjTgFb4BdLCwo6FZFAc8YdgxeM",
|
|
313
|
-
"symbol": "Test",
|
|
314
|
-
"mintKey": "6QGdQbaZEgpXqqbGwXJZXwbZ9xJnthfyYNZ92ARzTdAX",
|
|
315
|
-
"decimals": 9,
|
|
316
|
-
"isStable": true,
|
|
317
|
-
"oracleAddress": "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
|
|
318
|
-
}
|
|
319
|
-
]
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
}
|
package/src/PoolConfig.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Address } from '@coral-xyz/anchor';
|
|
2
|
-
import { Cluster, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import poolConfigs from './PoolConfig.json';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface CustodyConfig {
|
|
7
|
-
custodyId: number;
|
|
8
|
-
custodyAccount: PublicKey;
|
|
9
|
-
tokenAccount: PublicKey;
|
|
10
|
-
symbol: string;
|
|
11
|
-
mintKey: PublicKey;
|
|
12
|
-
decimals: number;
|
|
13
|
-
isStable: boolean,
|
|
14
|
-
oracleAddress: PublicKey;
|
|
15
|
-
}
|
|
16
|
-
type Token = {
|
|
17
|
-
symbol: string;
|
|
18
|
-
mintKey: PublicKey;
|
|
19
|
-
decimals: number;
|
|
20
|
-
isStable: boolean;
|
|
21
|
-
pythTicker: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export class PoolConfig {
|
|
25
|
-
constructor(
|
|
26
|
-
public programId: PublicKey,
|
|
27
|
-
public cluster: Cluster,
|
|
28
|
-
public poolName: string,
|
|
29
|
-
public poolAddress: PublicKey,
|
|
30
|
-
public lpTokenMint: PublicKey,
|
|
31
|
-
public lpDecimals: number,
|
|
32
|
-
public perpetuals: PublicKey,
|
|
33
|
-
public transferAuthority: PublicKey,
|
|
34
|
-
public multisig: PublicKey,
|
|
35
|
-
|
|
36
|
-
public tokens: Token[],
|
|
37
|
-
|
|
38
|
-
public custodies: CustodyConfig[],
|
|
39
|
-
) { }
|
|
40
|
-
|
|
41
|
-
public getAllTokenMints(): PublicKey[] {
|
|
42
|
-
return Array.from(
|
|
43
|
-
this.tokens.map((token) => new PublicKey(token.mintKey)),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public getNonStableTokens(): PublicKey[] {
|
|
48
|
-
return Array.from(
|
|
49
|
-
this.tokens
|
|
50
|
-
.filter((token) => !token.isStable)
|
|
51
|
-
.map((token) => new PublicKey(token.mintKey)),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public getAllCustodies(): PublicKey[] {
|
|
56
|
-
return Array.from(
|
|
57
|
-
this.custodies.map((custody) => new PublicKey(custody.custodyAccount)),
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public getNonStableCustodies(): PublicKey[] {
|
|
62
|
-
return Array.from(
|
|
63
|
-
this.custodies
|
|
64
|
-
.filter((custody) => !custody.isStable)
|
|
65
|
-
.map((custody) => new PublicKey(custody.custodyAccount)),
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
public getTokenFromSymbol = (symbol: string) : Token => {
|
|
71
|
-
return this.tokens.find(f => f.symbol.toUpperCase() === symbol.toUpperCase())!;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public getTokenFromMintString = (mint: string) : Token => {
|
|
75
|
-
return this.tokens.find(f => f.mintKey.toBase58() === mint)!;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public getTokenFromMintPk = (mint: PublicKey) : Token => {
|
|
79
|
-
return this.tokens.find(f => f.mintKey.equals(mint))!;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// static getAllPoolConfigs(cluster: Cluster): PoolConfig[] {
|
|
84
|
-
// return poolConfigs.pools.map(p => this.fromIdsByName(p.poolName, cluster))
|
|
85
|
-
// }
|
|
86
|
-
|
|
87
|
-
static getCustodyConfig(custodyAccountPk: Address, poolName: string, cluster: Cluster) : CustodyConfig {
|
|
88
|
-
return this.fromIdsByName(poolName, cluster).custodies.find(f => f.custodyAccount.toBase58() === custodyAccountPk.toString())
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public getCustodyIdFromCustodyAccount(custodyAccountPk: Address): number {
|
|
92
|
-
return this.custodies.find(f => f.custodyAccount.toBase58() === custodyAccountPk.toString()).custodyId;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public getCustodyAccountFromCustodyId(custodyId: number): PublicKey {
|
|
96
|
-
return this.custodies.find(f => f.custodyId === custodyId).custodyAccount;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static getTokensInPool(name: string, cluster: Cluster): Token[] {
|
|
100
|
-
const poolConfig = poolConfigs.pools.find((pool) => pool['poolName'] === name && cluster === pool['cluster']);
|
|
101
|
-
if (!poolConfig) throw new Error(`No pool config ${name} found in Ids!`);
|
|
102
|
-
const tokens :Token[] = poolConfig['tokens'].map(i => {
|
|
103
|
-
return {
|
|
104
|
-
...i,
|
|
105
|
-
mintKey: new PublicKey(i.mintKey)
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
return tokens
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static fromIdsByName(name: string, cluster: Cluster): PoolConfig {
|
|
112
|
-
const poolConfig = poolConfigs.pools.find((pool) => pool['poolName'] === name && cluster === pool['cluster']);
|
|
113
|
-
if (!poolConfig) throw new Error(`No pool config ${name} found in Ids!`);
|
|
114
|
-
const tokens:Token[] = poolConfig['tokens'].map(i => {
|
|
115
|
-
return {
|
|
116
|
-
...i,
|
|
117
|
-
mintKey : new PublicKey(i.mintKey)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
const custodies : CustodyConfig[] = poolConfig['custodies'].map((i, index) => {
|
|
121
|
-
return {
|
|
122
|
-
...i,
|
|
123
|
-
custodyId : i?.custodyId ?? index,
|
|
124
|
-
custodyAccount : new PublicKey(i.custodyAccount),
|
|
125
|
-
tokenAccount : new PublicKey(i.tokenAccount),
|
|
126
|
-
mintKey : new PublicKey(i.mintKey),
|
|
127
|
-
oracleAddress : new PublicKey(i.oracleAddress),
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
return new PoolConfig(
|
|
131
|
-
new PublicKey(poolConfig.programId),
|
|
132
|
-
poolConfig.cluster as Cluster,
|
|
133
|
-
poolConfig.poolName,
|
|
134
|
-
new PublicKey(poolConfig.poolAddress),
|
|
135
|
-
new PublicKey(poolConfig.lpTokenMint),
|
|
136
|
-
poolConfig.lpDecimals,
|
|
137
|
-
new PublicKey(poolConfig.perpetuals),
|
|
138
|
-
new PublicKey(poolConfig.transferAuthority),
|
|
139
|
-
new PublicKey(poolConfig.multisig),
|
|
140
|
-
tokens,
|
|
141
|
-
custodies,
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
static fromIdsByPk(poolPk: PublicKey, cluster: Cluster): PoolConfig {
|
|
146
|
-
const poolConfig = poolConfigs.pools.find(
|
|
147
|
-
(pool) => pool['poolAddress'] === poolPk.toString() && cluster === pool['cluster'],
|
|
148
|
-
);
|
|
149
|
-
if (!poolConfig)
|
|
150
|
-
throw new Error(`No pool config ${poolPk.toString()} found in Ids!`);
|
|
151
|
-
|
|
152
|
-
const tokens :Token[] = poolConfig['tokens'].map(i => {
|
|
153
|
-
return {
|
|
154
|
-
...i,
|
|
155
|
-
mintKey : new PublicKey(i.mintKey)
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
const custodies : CustodyConfig[] = poolConfig['custodies'].map(i => {
|
|
159
|
-
return {
|
|
160
|
-
...i,
|
|
161
|
-
custodyAccount : new PublicKey(i.custodyAccount),
|
|
162
|
-
tokenAccount : new PublicKey(i.tokenAccount),
|
|
163
|
-
mintKey : new PublicKey(i.mintKey),
|
|
164
|
-
oracleAddress : new PublicKey(i.oracleAddress),
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
return new PoolConfig(
|
|
169
|
-
new PublicKey(poolConfig.programId),
|
|
170
|
-
poolConfig.cluster as Cluster,
|
|
171
|
-
poolConfig.poolName,
|
|
172
|
-
new PublicKey(poolConfig.poolAddress),
|
|
173
|
-
new PublicKey(poolConfig.lpTokenMint),
|
|
174
|
-
poolConfig.lpDecimals,
|
|
175
|
-
new PublicKey(poolConfig.perpetuals),
|
|
176
|
-
new PublicKey(poolConfig.transferAuthority),
|
|
177
|
-
new PublicKey(poolConfig.multisig),
|
|
178
|
-
tokens,
|
|
179
|
-
custodies,
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
}
|
package/src/PoolDataClient.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
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, toUiDecimals } from "./utils";
|
|
11
|
-
import { PoolConfig } from "./PoolConfig";
|
|
12
|
-
import { PoolAccount } from "./PoolAccount";
|
|
13
|
-
|
|
14
|
-
export class PoolDataClient {
|
|
15
|
-
|
|
16
|
-
public poolConfig: PoolConfig;
|
|
17
|
-
public pool: PoolAccount;
|
|
18
|
-
public lpTokenInfo: Mint;
|
|
19
|
-
public custodies: CustodyAccount[];
|
|
20
|
-
public totalPoolValueUsd: BN;
|
|
21
|
-
|
|
22
|
-
constructor(poolConfig: PoolConfig, pool: PoolAccount, lpTokenInfo: Mint, custodies: CustodyAccount[]) {
|
|
23
|
-
this.poolConfig = poolConfig;
|
|
24
|
-
this.pool = pool;
|
|
25
|
-
this.lpTokenInfo = lpTokenInfo;
|
|
26
|
-
this.custodies = custodies;
|
|
27
|
-
this.totalPoolValueUsd = new BN(-1); // -1 meaning unset
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
loadCustodies(custodies: CustodyAccount[]) {
|
|
31
|
-
this.custodies = custodies;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
loadPoolData(pool: PoolAccount) {
|
|
35
|
-
this.pool = pool
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
loadLpData(lpTokenInfo: Mint) {
|
|
39
|
-
this.lpTokenInfo = lpTokenInfo
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// TODO :: replace this with PoolAccount.getAssetsUnderManagementUsd()
|
|
43
|
-
// should take pnl's into account
|
|
44
|
-
getLpStats(prices: any) {
|
|
45
|
-
|
|
46
|
-
let stableCoinAmount = new BN(0);
|
|
47
|
-
let totalPoolValueUsd = new BN(0);
|
|
48
|
-
|
|
49
|
-
for (const custody of this.poolConfig.custodies) {
|
|
50
|
-
const custodyData = this.custodies.find(t => t.mint.toBase58() === custody.mintKey.toBase58())
|
|
51
|
-
if (custodyData) {
|
|
52
|
-
if (custodyData.isStable) {
|
|
53
|
-
stableCoinAmount = stableCoinAmount.add(custodyData.assets.owned)
|
|
54
|
-
}
|
|
55
|
-
const priceBN = new BN(prices.get(custody.symbol) * 10 ** PRICE_DECIMALS); // so always keep prices with 6 decimals
|
|
56
|
-
const custodyValue = priceBN.mul(custodyData.assets.owned).div(new BN(10 ** custody.decimals));
|
|
57
|
-
totalPoolValueUsd = totalPoolValueUsd.add(custodyValue)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// console.log("totalPoolValueUsd.toNumber():",totalPoolValueUsd.toString())
|
|
62
|
-
// console.log("stableCoinAmount.toNumber():",stableCoinAmount.toString())
|
|
63
|
-
|
|
64
|
-
// if(this.lpTokenInfo.supply.toString() =='0' || totalPoolValueUsd.toString()=='0'){
|
|
65
|
-
// console.error("supply or amt cannot be zero")
|
|
66
|
-
// throw "supply or amt cannot be zero";
|
|
67
|
-
// }
|
|
68
|
-
this.totalPoolValueUsd = totalPoolValueUsd;
|
|
69
|
-
const lpPrice = totalPoolValueUsd.div(new BN(this.lpTokenInfo.supply.toString() === '0' ? 1 : this.lpTokenInfo.supply.toString()))
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
lpTokenSupply: new BN(this.lpTokenInfo.supply.toString()),
|
|
73
|
-
decimals: this.poolConfig.lpDecimals,
|
|
74
|
-
totalPoolValue: totalPoolValueUsd,
|
|
75
|
-
price: lpPrice,
|
|
76
|
-
stableCoinPercentage: totalPoolValueUsd.toNumber() != 0 ? stableCoinAmount.mul(new BN(PERCENTAGE_DECIMALS)).div(totalPoolValueUsd) : new BN(1),
|
|
77
|
-
marketCap: lpPrice.mul(new BN(this.lpTokenInfo.supply.toString())),
|
|
78
|
-
// totalStaked : BN,
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getOiLongUI() {
|
|
83
|
-
let totalAmount = new BN('0');
|
|
84
|
-
this.custodies.forEach(i => {
|
|
85
|
-
totalAmount = totalAmount.add(i.tradeStats.oiLongUsd);
|
|
86
|
-
})
|
|
87
|
-
return totalAmount;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getOiShortUI() {
|
|
91
|
-
let totalAmount = new BN('0');
|
|
92
|
-
this.custodies.forEach(i => {
|
|
93
|
-
totalAmount = totalAmount.add(i.tradeStats.oiShortUsd);
|
|
94
|
-
})
|
|
95
|
-
return totalAmount;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// handle decimal and this should accept a list of prices probs map or object
|
|
99
|
-
getCustodyDetails(prices: any) {
|
|
100
|
-
const custodyDetails = [];
|
|
101
|
-
|
|
102
|
-
for (let i = 0; i < this.poolConfig.custodies.length; i++) {
|
|
103
|
-
const custody = this.poolConfig.custodies[i];
|
|
104
|
-
if (!custody) continue;
|
|
105
|
-
|
|
106
|
-
// console.log('this.pool :>> ', this.pool);
|
|
107
|
-
// const token = this.pool.tokens.find(t => t.custody.toBase58() === custody.custodyAccount.toBase58());
|
|
108
|
-
const tokenRatio = this.pool.ratios[i]
|
|
109
|
-
const custodyData = this.custodies.find(t => t.mint.toBase58() === custody.mintKey.toBase58())
|
|
110
|
-
const priceBN = new BN(prices.get(custody.symbol) * 10 ** 6); // so always keep prices with 6 decimals
|
|
111
|
-
|
|
112
|
-
if (this.totalPoolValueUsd.toString() == "-1") {
|
|
113
|
-
console.error("call getLpStats first")
|
|
114
|
-
throw "call getLpStats first";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// if(this.totalPoolValueUsd.toString()=='0'){
|
|
118
|
-
// console.error("call getLpStats first , totalPoolValueUsd ZERO")
|
|
119
|
-
// return defaultData.custodyDetails;
|
|
120
|
-
// }
|
|
121
|
-
// console.log("this.totalPoolValueUsd:",this.totalPoolValueUsd.toString())
|
|
122
|
-
|
|
123
|
-
if (custodyData && tokenRatio) {
|
|
124
|
-
custodyDetails.push({
|
|
125
|
-
symbol: custody.symbol,
|
|
126
|
-
price: new BN(prices.get(custody.symbol)),
|
|
127
|
-
targetWeight: tokenRatio.target,
|
|
128
|
-
currentWeight: this.totalPoolValueUsd.toNumber() ?
|
|
129
|
-
(custodyData.assets.owned.mul(priceBN)).mul(new BN(10 ** PERCENTAGE_DECIMALS)).div(this.totalPoolValueUsd).div(new BN(10 ** custody.decimals))
|
|
130
|
-
: new BN(0),
|
|
131
|
-
utilization: custodyData.assets.owned.toNumber() ?
|
|
132
|
-
toUiDecimals(custodyData.assets.locked.mul(new BN(10 ** PERCENTAGE_DECIMALS)).div(custodyData.assets.owned), PERCENTAGE_DECIMALS, 2)
|
|
133
|
-
: '0',
|
|
134
|
-
// assetsAmountUi : (custodyData.assets.owned.toNumber() / 10**(custody.decimals)).toFixed(4),
|
|
135
|
-
assetsAmountUi: toUiDecimals(custodyData.assets.owned, custody.decimals, 4, true),
|
|
136
|
-
// totalUsdAmountUi : ((custodyData.assets.owned.mul(priceBN)).div(new BN(10**(custody.decimals))).toNumber() / 10**6).toFixed(4),
|
|
137
|
-
totalUsdAmountUi: toUiDecimals((custodyData.assets.owned.mul(priceBN)), custody.decimals + PRICE_DECIMALS, 2, true),
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return custodyDetails;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
getPoolStats() {
|
|
145
|
-
let totalFees = new BN(0)
|
|
146
|
-
let totalVolume = new BN(0)
|
|
147
|
-
let currentLongPositionsUsd = new BN(0)
|
|
148
|
-
let currentShortPositionsUsd = new BN(0)
|
|
149
|
-
|
|
150
|
-
for (const custody of this.poolConfig.custodies) {
|
|
151
|
-
const custodyData = this.custodies.find(t => t.mint.toBase58() === custody.mintKey.toBase58())
|
|
152
|
-
if (custodyData) {
|
|
153
|
-
const custodyFeeTotal = Object.values(custodyData.collectedFees).reduce((a: BN, b: BN) => a.add(b), new BN(0))
|
|
154
|
-
totalFees = totalFees.add(custodyFeeTotal)
|
|
155
|
-
|
|
156
|
-
const custodyVolume = Object.values(custodyData.volumeStats).reduce((a: BN, b: BN) => a.add(b), new BN(0))
|
|
157
|
-
totalVolume = totalVolume.add(custodyVolume)
|
|
158
|
-
|
|
159
|
-
currentLongPositionsUsd = currentLongPositionsUsd.add(custodyData.tradeStats.oiLongUsd)
|
|
160
|
-
currentShortPositionsUsd = currentShortPositionsUsd.add(custodyData.tradeStats.oiShortUsd)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
totalFees,
|
|
165
|
-
totalVolume,
|
|
166
|
-
currentLongPositionsUsd,
|
|
167
|
-
currentShortPositionsUsd
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
} // PoolDisplayData
|