Skip to content

Commit cba4d84

Browse files
authored
integrator-support + v1.0.5 (#129)
* integrator-support * small name fix * integrate staking tx * update v1.0.5
1 parent b7fc10b commit cba4d84

34 files changed

Lines changed: 1018 additions & 65 deletions

.openapi-generator/FILES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ docs/AnnouncementApi.md
1616
docs/Announcements.md
1717
docs/ApiKey.md
1818
docs/ApiToken.md
19+
docs/ApprovedIntegrator.md
1920
docs/Asset.md
2021
docs/AssetDetails.md
2122
docs/Auth.md
@@ -157,6 +158,7 @@ docs/SubAccounts.md
157158
docs/SystemConfig.md
158159
docs/Ticker.md
159160
docs/Trade.md
161+
docs/TradeStats.md
160162
docs/Trades.md
161163
docs/TransactionApi.md
162164
docs/TransferFeeInfo.md
@@ -205,6 +207,7 @@ lighter/models/announcement.py
205207
lighter/models/announcements.py
206208
lighter/models/api_key.py
207209
lighter/models/api_token.py
210+
lighter/models/approved_integrator.py
208211
lighter/models/asset.py
209212
lighter/models/asset_details.py
210213
lighter/models/auth.py
@@ -337,6 +340,7 @@ lighter/models/sub_accounts.py
337340
lighter/models/system_config.py
338341
lighter/models/ticker.py
339342
lighter/models/trade.py
343+
lighter/models/trade_stats.py
340344
lighter/models/trades.py
341345
lighter/models/transfer_fee_info.py
342346
lighter/models/transfer_history.py
@@ -353,6 +357,7 @@ lighter/rest.py
353357
setup.cfg
354358
test-requirements.txt
355359
test/__init__.py
360+
test/test_approved_integrator.py
356361
test/test_exchange_metric.py
357362
test/test_execute_stat.py
358363
test/test_lease_entry.py
@@ -376,5 +381,6 @@ test/test_slippage_result.py
376381
test/test_spot_avg_entry_price.py
377382
test/test_strategy.py
378383
test/test_system_config.py
384+
test/test_trade_stats.py
379385
test/test_user_referrals.py
380386
tox.ini

docs/ApprovedIntegrator.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ApprovedIntegrator
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
**account_index** | **int** | |
9+
**name** | **str** | |
10+
**max_perps_taker_fee** | **int** | |
11+
**max_perps_maker_fee** | **int** | |
12+
**max_spot_taker_fee** | **int** | |
13+
**max_spot_maker_fee** | **int** | |
14+
**approval_expiry** | **int** | Timestamp in milliseconds, after which the integrator is no longer approved |
15+
16+
## Example
17+
18+
```python
19+
from lighter.models.approved_integrator import ApprovedIntegrator
20+
21+
# TODO update the JSON string below
22+
json = "{}"
23+
# create an instance of ApprovedIntegrator from a JSON string
24+
approved_integrator_instance = ApprovedIntegrator.from_json(json)
25+
# print the JSON string representation of the object
26+
print(ApprovedIntegrator.to_json())
27+
28+
# convert the object into a dict
29+
approved_integrator_dict = approved_integrator_instance.to_dict()
30+
# create an instance of ApprovedIntegrator from a dict
31+
approved_integrator_from_dict = ApprovedIntegrator.from_dict(approved_integrator_dict)
32+
```
33+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
34+
35+

docs/DetailedAccount.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Name | Type | Description | Notes
3232
**pool_info** | [**PublicPoolInfo**](PublicPoolInfo.md) | |
3333
**shares** | [**List[PublicPoolShare]**](PublicPoolShare.md) | |
3434
**pending_unlocks** | [**List[PendingUnlock]**](PendingUnlock.md) | |
35+
**approved_integrators** | [**List[ApprovedIntegrator]**](ApprovedIntegrator.md) | |
3536

3637
## Example
3738

docs/Order.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Name | Type | Description | Notes
3434
**to_trigger_order_id_0** | **str** | |
3535
**to_trigger_order_id_1** | **str** | |
3636
**to_cancel_order_id_0** | **str** | |
37+
**integrator_fee_collector_index** | **str** | |
38+
**integrator_taker_fee** | **str** | |
39+
**integrator_maker_fee** | **str** | |
3740
**block_height** | **int** | |
3841
**timestamp** | **int** | |
3942
**created_at** | **int** | |

docs/Referral.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Name | Type | Description | Notes
88
**l1_address** | **str** | |
99
**referral_code** | **str** | |
1010
**used_at** | **int** | |
11+
**trade_stats** | [**TradeStats**](TradeStats.md) | |
1112

1213
## Example
1314

docs/SystemConfig.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Name | Type | Description | Notes
1212
**funding_fee_rebate_account_index** | **int** | |
1313
**liquidity_pool_cooldown_period** | **int** | |
1414
**staking_pool_lockup_period** | **int** | |
15+
**max_integrator_spot_taker_fee** | **int** | |
16+
**max_integrator_spot_maker_fee** | **int** | |
17+
**max_integrator_perps_taker_fee** | **int** | |
18+
**max_integrator_perps_maker_fee** | **int** | |
1519

1620
## Example
1721

docs/TradeStats.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# TradeStats
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
**count** | **int** | |
9+
**volume** | **str** | |
10+
**web_count** | **int** | |
11+
**web_volume** | **str** | |
12+
**mobile_app_count** | **int** | |
13+
**mobile_app_volume** | **str** | |
14+
**mobile_browser_count** | **int** | |
15+
**mobile_browser_volume** | **str** | |
16+
17+
## Example
18+
19+
```python
20+
from lighter.models.trade_stats import TradeStats
21+
22+
# TODO update the JSON string below
23+
json = "{}"
24+
# create an instance of TradeStats from a JSON string
25+
trade_stats_instance = TradeStats.from_json(json)
26+
# print the JSON string representation of the object
27+
print(TradeStats.to_json())
28+
29+
# convert the object into a dict
30+
trade_stats_dict = trade_stats_instance.to_dict()
31+
# create an instance of TradeStats from a dict
32+
trade_stats_from_dict = TradeStats.from_dict(trade_stats_dict)
33+
```
34+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
35+
36+

examples/integrator_approve.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import asyncio
2+
from utils import default_example_setup
3+
4+
5+
ETH_PRIVATE_KEY = ""
6+
7+
async def main():
8+
client, api_client, _ = default_example_setup()
9+
10+
err = client.check_client()
11+
if err is not None:
12+
print(f"CheckClient error: {err}")
13+
return
14+
15+
tx_info, response, err = await client.approve_integrator(
16+
eth_private_key=ETH_PRIVATE_KEY,
17+
integrator_account_index=6,
18+
max_perps_taker_fee=1000,
19+
max_perps_maker_fee=1000,
20+
max_spot_taker_fee=1000,
21+
max_spot_maker_fee=1000,
22+
approval_expiry=1775518466000
23+
)
24+
print(tx_info, response, err)
25+
26+
await client.close()
27+
await api_client.close()
28+
29+
if __name__ == "__main__":
30+
asyncio.run(main())
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import asyncio
2+
from utils import default_example_setup
3+
4+
5+
async def main():
6+
client, api_client, _ = default_example_setup()
7+
client.check_client()
8+
9+
# Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot.
10+
market_index = 0
11+
integrator_account_index = 6
12+
integrator_taker_fee = 1000
13+
integrator_maker_fee = 500
14+
15+
tx, tx_hash, err = await client.create_market_order(
16+
market_index=market_index,
17+
client_order_index=0,
18+
base_amount=1000, # 0.1 ETH
19+
avg_execution_price=4000_00,
20+
is_ask=False,
21+
integrator_account_index=integrator_account_index,
22+
integrator_taker_fee=integrator_taker_fee,
23+
integrator_maker_fee=integrator_maker_fee,
24+
)
25+
print(f"Create Order {tx=} {tx_hash=} {err=}")
26+
if err is not None:
27+
raise Exception(err)
28+
29+
await client.close()
30+
await api_client.close()
31+
32+
33+
if __name__ == "__main__":
34+
asyncio.run(main())
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import asyncio
2+
from utils import default_example_setup
3+
4+
5+
async def main():
6+
client, api_client, _ = default_example_setup()
7+
client.check_client()
8+
9+
# Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot.
10+
market_index = 0
11+
integrator_account_index = 6
12+
integrator_taker_fee = 1000
13+
integrator_maker_fee = 500
14+
15+
# create order
16+
api_key_index, nonce = client.nonce_manager.next_nonce()
17+
tx, tx_hash, err = await client.create_order(
18+
market_index=market_index,
19+
client_order_index=123,
20+
base_amount=1000, # 0.1 ETH
21+
price=4050_00, # $4050
22+
is_ask=True,
23+
order_type=client.ORDER_TYPE_LIMIT,
24+
time_in_force=client.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME,
25+
reduce_only=False,
26+
trigger_price=0,
27+
integrator_account_index=integrator_account_index,
28+
integrator_taker_fee=integrator_taker_fee,
29+
integrator_maker_fee=integrator_maker_fee,
30+
nonce=nonce,
31+
api_key_index=api_key_index,
32+
)
33+
print(f"Create Order {tx=} {tx_hash=} {err=}")
34+
if err is not None:
35+
raise Exception(err)
36+
37+
## modify order
38+
# use the same API key so the TX goes after the create order TX
39+
api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index)
40+
tx, tx_hash, err = await client.modify_order(
41+
market_index=market_index,
42+
order_index=123,
43+
base_amount=1100, # 0.11 ETH
44+
price=4100_00, # $4100
45+
trigger_price=0,
46+
integrator_account_index=integrator_account_index,
47+
integrator_taker_fee=integrator_taker_fee // 2, # integrator fees can also be modified
48+
integrator_maker_fee=integrator_maker_fee // 2,
49+
nonce=nonce,
50+
api_key_index=api_key_index,
51+
)
52+
print(f"Modify Order {tx=} {tx_hash=} {err=}")
53+
if err is not None:
54+
raise Exception(err)
55+
56+
## cancel order
57+
# use the same API key so the TX goes after the modify order TX
58+
api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index)
59+
tx, tx_hash, err = await client.cancel_order(
60+
market_index=market_index,
61+
order_index=123,
62+
nonce=nonce,
63+
api_key_index=api_key_index,
64+
)
65+
print(f"Cancel Order {tx=} {tx_hash=} {err=}")
66+
if err is not None:
67+
raise Exception(err)
68+
69+
await client.close()
70+
await api_client.close()
71+
72+
73+
if __name__ == "__main__":
74+
asyncio.run(main())

0 commit comments

Comments
 (0)