Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import asyncio
from utils import default_example_setup
import time
from examples.utils import default_example_setup


ETH_PRIVATE_KEY = ""
CONFIG_FILE = "../api_key_config.json"
APPROVAL_EXPIRY = int(time.time() * 1000) + 90 * 24 * 60 * 60 * 1000 # now + 90 days, in ms


async def main():
client, api_client, _ = default_example_setup()
client, api_client, _ = default_example_setup(CONFIG_FILE)

err = client.check_client()
if err is not None:
Expand All @@ -19,7 +23,7 @@ async def main():
max_perps_maker_fee=1000,
max_spot_taker_fee=1000,
max_spot_maker_fee=1000,
approval_expiry=1775518466000
approval_expiry=APPROVAL_EXPIRY
)
print(tx_info, response, err)

Expand Down
33 changes: 33 additions & 0 deletions examples/integrator/approve_same_master_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import asyncio
import time
from examples.utils import default_example_setup


CONFIG_FILE = "../api_key_config.json"
APPROVAL_EXPIRY = int(time.time() * 1000) + 90 * 24 * 60 * 60 * 1000 # now + 90 days, in ms


async def main():
client, api_client, _ = default_example_setup(CONFIG_FILE)

err = client.check_client()
if err is not None:
print(f"CheckClient error: {err}")
return

# no L1 sig required for approving integrator who is tied to the same address (e.g. subaccount)
tx_info, response, err = await client.approve_integrator(
integrator_account_index=281474976710649,
max_perps_taker_fee=1000,
max_perps_maker_fee=1000,
max_spot_taker_fee=1000,
max_spot_maker_fee=1000,
approval_expiry=APPROVAL_EXPIRY
)
print(tx_info, response, err)

await client.close()
await api_client.close()

if __name__ == "__main__":
asyncio.run(main())
35 changes: 35 additions & 0 deletions examples/integrator/approve_zero_fees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import asyncio
import os
import time
from examples.utils import default_example_setup


CONFIG_FILE = "../api_key_config.json"
APPROVAL_EXPIRY = int(time.time() * 1000) + 90 * 24 * 60 * 60 * 1000 # now + 90 days, in ms


async def main():
client, api_client, _ = default_example_setup(CONFIG_FILE)

err = client.check_client()
if err is not None:
print(f"CheckClient error: {err}")
return

# no L1 sig required if integrator takes no fees
tx_info, response, err = await client.approve_integrator(
integrator_account_index=6,
max_perps_taker_fee=0,
max_perps_maker_fee=0,
max_spot_taker_fee=0,
max_spot_maker_fee=0,
approval_expiry=APPROVAL_EXPIRY,
)
print(tx_info, response, err)

await client.close()
await api_client.close()


if __name__ == "__main__":
asyncio.run(main())
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import asyncio
from utils import default_example_setup
from examples.utils import default_example_setup


CONFIG_FILE = "../api_key_config.json"


async def main():
client, api_client, _ = default_example_setup()
client, api_client, _ = default_example_setup(CONFIG_FILE)
client.check_client()

# Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot.
market_index = 2048
# integrator_account_index = 6
integrator_account_index = 281474976710647
integrator_account_index = 281474976710649
integrator_taker_fee = 1000
integrator_maker_fee = 500

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import asyncio
from utils import default_example_setup
from examples.utils import default_example_setup


CONFIG_FILE = "../api_key_config.json"


async def main():
client, api_client, _ = default_example_setup()
client, api_client, _ = default_example_setup(CONFIG_FILE)
client.check_client()

# Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot.
market_index = 0
# integrator_account_index = 6
integrator_account_index = 281474976710647
integrator_account_index = 281474976710649
integrator_taker_fee = 1000
integrator_maker_fee = 500

Expand Down
11 changes: 6 additions & 5 deletions examples/integrator_revoke.py → examples/integrator/revoke.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import asyncio
from utils import default_example_setup
from examples.utils import default_example_setup


ETH_PRIVATE_KEY = ""
CONFIG_FILE = "../api_key_config.json"


async def main():
client, api_client, _ = default_example_setup()
client, api_client, _ = default_example_setup(CONFIG_FILE)

err = client.check_client()
if err is not None:
print(f"CheckClient error: {err}")
return

# no L1 sig required for revoking
tx_info, response, err = await client.approve_integrator(
eth_private_key=ETH_PRIVATE_KEY,
integrator_account_index=6,
integrator_account_index=281474976710649,
max_perps_taker_fee=0,
max_perps_maker_fee=0,
max_spot_taker_fee=0,
Expand Down
26 changes: 0 additions & 26 deletions examples/integrator_approve_same_master_account.py

This file was deleted.

40 changes: 5 additions & 35 deletions lighter/signer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def sign_modify_order(

def sign_approve_integrator(
self,
eth_private_key: str,
eth_private_key: Optional[str],
integrator_account_index: int,
max_perps_taker_fee: int,
max_perps_maker_fee: int,
Expand All @@ -591,6 +591,8 @@ def sign_approve_integrator(
api_key_index,
self.account_index
)
if eth_private_key is None:
return self.__decode_tx_info(res)
return self.__decode_and_sign_tx_info(eth_private_key, res)

def sign_approve_integrator_same_master_account(
Expand Down Expand Up @@ -1200,7 +1202,6 @@ async def modify_order(
@process_api_key_and_nonce
async def approve_integrator(
self,
eth_private_key: str,
integrator_account_index: int,
max_perps_taker_fee: int,
max_perps_maker_fee: int,
Expand All @@ -1209,7 +1210,8 @@ async def approve_integrator(
approval_expiry: int,
skip_nonce: int = SKIP_NONCE_OFF,
nonce: int = DEFAULT_NONCE,
api_key_index: int = DEFAULT_API_KEY_INDEX
api_key_index: int = DEFAULT_API_KEY_INDEX,
eth_private_key: Optional[str] = None,
):
tx_type, tx_info, tx_hash, error = self.sign_approve_integrator(
eth_private_key,
Expand All @@ -1231,38 +1233,6 @@ async def approve_integrator(
logging.debug(f"Approve Integrator Send. TxResponse: {api_response}")
return tx_info, api_response, None

@process_api_key_and_nonce
async def approve_integrator_same_master_account(
self,
integrator_account_index: int,
max_perps_taker_fee: int,
max_perps_maker_fee: int,
max_spot_taker_fee: int,
max_spot_maker_fee: int,
approval_expiry: int,
skip_nonce: int = SKIP_NONCE_OFF,
nonce: int = DEFAULT_NONCE,
api_key_index: int = DEFAULT_API_KEY_INDEX
):
tx_type, tx_info, tx_hash, error = self.sign_approve_integrator_same_master_account(
integrator_account_index,
max_perps_taker_fee,
max_perps_maker_fee,
max_spot_taker_fee,
max_spot_maker_fee,
approval_expiry,
skip_nonce,
nonce,
api_key_index
)
if error is not None:
return None, None, error

logging.debug(f"Approve Integrator TxHash: {tx_hash} TxInfo: {tx_info}")
api_response = await self.send_tx(tx_type=tx_type, tx_info=tx_info)
logging.debug(f"Approve Integrator Send. TxResponse: {api_response}")
return tx_info, api_response, None

@process_api_key_and_nonce
async def transfer(self, eth_private_key: str, to_account_index: int, asset_id: int, route_from: int, route_to: int, amount: float, fee: int, memo: str, skip_nonce : int = SKIP_NONCE_OFF, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX):
if asset_id in self.ASSET_TO_TICKER_SCALE:
Expand Down
Binary file modified lighter/signers/lighter-signer-darwin-amd64.dylib
Binary file not shown.
10 changes: 1 addition & 9 deletions lighter/signers/lighter-signer-darwin-amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
extern size_t _GoStringLen(_GoString_ s);
extern const char *_GoStringPtr(_GoString_ s);
#endif

#endif
Expand Down Expand Up @@ -83,16 +81,10 @@ typedef size_t GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
#ifdef _MSC_VER
#if !defined(__cplusplus) || _MSVC_LANG <= 201402L
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else
#include <complex>
typedef std::complex<float> GoComplex64;
typedef std::complex<double> GoComplex128;
#endif
#else
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
#endif
Expand All @@ -119,7 +111,7 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
extern "C" {
#endif

extern ApiKeyResponse GenerateAPIKey(void);
extern ApiKeyResponse GenerateAPIKey();
extern char* CreateClient(char* cUrl, char* cPrivateKey, int cChainId, int cApiKeyIndex, long long cAccountIndex);
extern char* CheckClient(int cApiKeyIndex, long long cAccountIndex);
extern SignedTxResponse SignChangePubKey(char* cPubKey, uint8_t cSkipNonce, long long cNonce, int cApiKeyIndex, long long cAccountIndex);
Expand Down
Binary file modified lighter/signers/lighter-signer-darwin-arm64.dylib
Binary file not shown.
Binary file modified lighter/signers/lighter-signer-linux-amd64.so
Binary file not shown.
Binary file modified lighter/signers/lighter-signer-linux-arm64.so
Binary file not shown.
Binary file modified lighter/signers/lighter-signer-windows-amd64.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion lighter/signers/lighter-signer-windows-amd64.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package command-line-arguments */
/* package github.com/elliottech/lighter-go/sharedlib */


#line 1 "cgo-builtin-export-prolog"
Expand Down
Loading