@gmsol-labs/gmsol-sdk 0.6.0 → 0.7.0-beta.2
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/README.md +49 -7
- package/index.d.ts +7 -1
- package/index_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
| Program | Last Audit Date | Version |
|
|
12
12
|
| ------------------- | --------------- | --------- |
|
|
13
|
-
| [gmsol-store] | [2025-
|
|
14
|
-
| [gmsol-treasury] | [2025-
|
|
15
|
-
| [gmsol-timelock] | [2025-
|
|
16
|
-
| [gmsol-competition] | [2025-
|
|
13
|
+
| [gmsol-store] | [2025-07-28] | [3202f7c] |
|
|
14
|
+
| [gmsol-treasury] | [2025-07-28] | [3202f7c] |
|
|
15
|
+
| [gmsol-timelock] | [2025-07-28] | [3202f7c] |
|
|
16
|
+
| [gmsol-competition] | [2025-07-28] | [3202f7c] |
|
|
17
17
|
|
|
18
18
|
[gmsol-store]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/store
|
|
19
19
|
[gmsol-treasury]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/treasury
|
|
20
20
|
[gmsol-timelock]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/timelock
|
|
21
21
|
[gmsol-competition]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/competition
|
|
22
|
-
[2025-
|
|
23
|
-
[
|
|
22
|
+
[2025-07-28]: https://github.com/gmsol-labs/gmx-solana-audits/blob/main/GMX_Solana_Audit_Report_July_28_2025_Zenith.pdf
|
|
23
|
+
[3202f7c]: https://github.com/gmsol-labs/gmx-solana/commit/3202f7ca1a01a076425af59d2bca7369fe9c156c
|
|
24
24
|
|
|
25
25
|
## Integration
|
|
26
26
|
|
|
@@ -30,7 +30,7 @@ Add the following to your `Cargo.toml`:
|
|
|
30
30
|
|
|
31
31
|
```toml
|
|
32
32
|
[dependencies]
|
|
33
|
-
gmsol-sdk = { version = "0.
|
|
33
|
+
gmsol-sdk = { version = "0.7.0", features = ["client"] }
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Create a `Client` and start using the core APIs:
|
|
@@ -128,6 +128,48 @@ For a working implementation, check out the [gmx-solana-programs][gmx-solana-pro
|
|
|
128
128
|
[treasury-program-link]: https://explorer.solana.com/address/GTuvYD5SxkTq4FLG6JV1FQ5dkczr1AfgDcBHaFsBdtBg/anchor-program
|
|
129
129
|
[gmx-solana-programs-link]: https://github.com/gmsol-labs/gmx-solana-programs
|
|
130
130
|
|
|
131
|
+
## Known Issues
|
|
132
|
+
|
|
133
|
+
### Keepers
|
|
134
|
+
|
|
135
|
+
- Order keepers can use prices from different timestamps for limit orders with a swap, which would lead to different output amounts.
|
|
136
|
+
|
|
137
|
+
- Order Keepers are expected to select an execution fee that does not exceed the actual network fee incurred. In addition, the execution fee that the Order Keeper can specify is capped by the program. Even if the actual network fee incurred exceeds this cap, it will not affect the executability of the request.
|
|
138
|
+
|
|
139
|
+
- A malicious Order Keeper could potentially profit consistently by manipulating the execution order of orders, but this risk can be mitigated by deploying a sufficient number of high-frequency and trusted Order Keepers, since a successful attack would require the malicious Order Keeper to ensure that the orders it creates are not executed within the valid price time window, which is typically 30 seconds.
|
|
140
|
+
|
|
141
|
+
- A malicious Order Keeper could potentially extract rent paid by other Order Keepers by closing claimable accounts created by them. However, since claimable accounts are typically created and closed within the same transaction that executes the order, such situations are extremely rare.
|
|
142
|
+
|
|
143
|
+
- Orders may be prevented from execution by a malicious user intentionally causing a market to be unbalanced resulting in a high price impact, this should be costly and difficult to benefit from.
|
|
144
|
+
|
|
145
|
+
### Price Impact
|
|
146
|
+
|
|
147
|
+
- Price impact can be reduced by using positions and swaps and trading across markets, chains, forks, other protocols, this is partially mitigated with virtual inventory tracking.
|
|
148
|
+
|
|
149
|
+
- A user can reduce price impact by using high leverage positions, this is partially mitigated with the MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER value.
|
|
150
|
+
|
|
151
|
+
- Calculation of price impact values do not account for fees and the effects resulting from the price impact itself, for most cases the effect on the price impact calculation should be small.
|
|
152
|
+
|
|
153
|
+
### Market Token Price
|
|
154
|
+
|
|
155
|
+
- It is rare but possible for a pool's value to become negative, this can happen since the impactPoolAmount and pending PnL is subtracted from the worth of the tokens in the pool.
|
|
156
|
+
|
|
157
|
+
- Due to the difference in positive and negative position price impact, there can be a build up of virtual token amounts in the position impact pool which would affect the pricing of market tokens, the position impact pool should be gradually distributed if needed.
|
|
158
|
+
|
|
159
|
+
### Virtual Inventory
|
|
160
|
+
|
|
161
|
+
- Virtual inventory (for swap) tracks the amount of tokens in pools, it must be ensured that the tokens in each grouping are the same type and have the same decimals, i.e. the long tokens across pools in the group should have the same decimals, the short tokens across pools in the group should have the same decimals, assuming USDC has 6 decimals and WBTC has 8 decimals, markets like WSOL-USDC, WSOL-WBTC should not be grouped.
|
|
162
|
+
|
|
163
|
+
### GLV
|
|
164
|
+
|
|
165
|
+
- The GLV shift feature can be exploited by temporarily increasing the utilization in a market that typically has low utilization. Once the keeper executes the shift, the attacker can lower the utilization back to its normal levels. Position fees and price impact should be configured in a way that makes this attack expensive enough to cover the GLV loss.
|
|
166
|
+
|
|
167
|
+
- In GLV there may be GM markets which are above their maximum pnl_to_pool_factor_for_traders. If this GM market's max_pnl_factor_for_deposits is higher than max_pnl_factor_for_traders then the GM market is valued lower during deposits than it will be once traders have realized their capped profits. Malicious user may observe a GM market in such a condition and deposit into the GLV containing it in order to gain from ADLs which will soon follow. To avoid this max_pnl_factor_for_deposits should be less than or equal to max_pnl_factor_for_traders.
|
|
168
|
+
|
|
169
|
+
- It's technically possible for market value to become negative. In this case the GLV would be unusable until the market value becomes positive.
|
|
170
|
+
|
|
171
|
+
- GM tokens could become illiquid due to high pnl factor or high reserved usd. Users can deposit illiquid GM tokens into GLV and withdraw liquidity from a different market, leaving the GLV with illiquid tokens. The glv_max_market_token_value and glv_max_market_token_amount parameters should account for the riskiness of a market to avoid having too many GM tokens from a risky market.
|
|
172
|
+
|
|
131
173
|
## Development
|
|
132
174
|
|
|
133
175
|
### Prerequisites
|
package/index.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export interface BestSwapPath {
|
|
|
79
79
|
*/
|
|
80
80
|
export interface CreateOrderOptions {
|
|
81
81
|
recent_blockhash: string;
|
|
82
|
+
compute_unit_price_micro_lamports?: number | undefined;
|
|
83
|
+
compute_unit_min_priority_lamports?: number | undefined;
|
|
82
84
|
payer: StringPubkey;
|
|
83
85
|
collateral_or_swap_out_token: StringPubkey;
|
|
84
86
|
hints: Map<StringPubkey, CreateOrderHint>;
|
|
@@ -88,6 +90,7 @@ export interface CreateOrderOptions {
|
|
|
88
90
|
swap_path?: StringPubkey[] | undefined;
|
|
89
91
|
skip_wrap_native_on_pay?: boolean | undefined;
|
|
90
92
|
skip_unwrap_native_on_receive?: boolean | undefined;
|
|
93
|
+
callback?: Callback | undefined;
|
|
91
94
|
transaction_group?: TransactionGroupOptions;
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -96,6 +99,8 @@ export interface CreateOrderOptions {
|
|
|
96
99
|
*/
|
|
97
100
|
export interface CloseOrderArgs {
|
|
98
101
|
recent_blockhash: string;
|
|
102
|
+
compute_unit_price_micro_lamports?: number | undefined;
|
|
103
|
+
compute_unit_min_priority_lamports?: number | undefined;
|
|
99
104
|
payer: StringPubkey;
|
|
100
105
|
orders: Map<StringPubkey, CloseOrderHint>;
|
|
101
106
|
program?: StoreProgram | undefined;
|
|
@@ -112,6 +117,8 @@ export interface UpdateParams {
|
|
|
112
117
|
*/
|
|
113
118
|
export interface UpdateOrderArgs {
|
|
114
119
|
recent_blockhash: string;
|
|
120
|
+
compute_unit_price_micro_lamports?: number | undefined;
|
|
121
|
+
compute_unit_min_priority_lamports?: number | undefined;
|
|
115
122
|
payer: StringPubkey;
|
|
116
123
|
orders: Map<StringPubkey, UpdateParams>;
|
|
117
124
|
program?: StoreProgram | undefined;
|
|
@@ -124,7 +131,6 @@ export interface UpdateOrderArgs {
|
|
|
124
131
|
export interface TransactionGroupOptions {
|
|
125
132
|
max_transaction_size?: number | undefined;
|
|
126
133
|
max_instructions_per_tx?: number | undefined;
|
|
127
|
-
compute_unit_price_micro_lamports?: number | undefined;
|
|
128
134
|
luts?: Map<StringPubkey, StringPubkey[]>;
|
|
129
135
|
memo?: string | undefined;
|
|
130
136
|
}
|
package/index_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED