Last active
November 23, 2022 01:52
-
-
Save normanlmfung/0a4bda9eb55d9d3560c76117bd6e2e50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from web3 import Web3 | |
from dydx3 import Client | |
from dydx3.constants import API_HOST_MAINNET | |
from dydx3.constants import NETWORK_ID_MAINNET | |
from dydx3.constants import MARKET_BTC_USD | |
from dydx3.constants import ORDER_SIDE_BUY | |
from dydx3.constants import ORDER_TYPE_LIMIT | |
WEB_PROVIDER_URL = 'https://mainnet.infura.io/v3/????????????????????????????' | |
LEDGER_WALLET_ETHEREUM_ADDRESS = "0x????????????????????????????" | |
API_KEY_CREDEMTIALS = { | |
"walletAddress": "0x??????????????????????????????????????", | |
"secret": "????????????????????????????????", | |
"key": "????????????????????????????????", | |
"passphrase": "????????????????????????????????", | |
"legacySigning": False, | |
"walletType": "METAMASK" | |
} | |
STARK_PUBLIC_KEY = "????????????????????????????????" | |
STARK_PUBLIC_KEY_Y_COORDINATE = "????????????????????????????????" | |
STARK_PRIVATE_KEY = "????????????????????????????????" | |
client = Client( | |
network_id=NETWORK_ID_MAINNET, | |
host=API_HOST_MAINNET, | |
default_ethereum_address=LEDGER_WALLET_ETHEREUM_ADDRESS, | |
web3=Web3(Web3.HTTPProvider(WEB_PROVIDER_URL)), | |
api_key_credentials=API_KEY_CREDEMTIALS | |
) | |
stark_keys = { | |
'public_key' : "0x" + STARK_PUBLIC_KEY, | |
'public_key_y_coordinate' : "0x" + STARK_PUBLIC_KEY_Y_COORDINATE, | |
'private_key' : "0x" + STARK_PRIVATE_KEY | |
} | |
client.stark_private_key = stark_keys | |
from dydx3.constants import MARKET_BTC_USD | |
from dydx3.constants import ORDER_SIDE_BUY | |
from dydx3.constants import ORDER_TYPE_LIMIT | |
account_response = client.private.get_account() | |
position_id = account_response.data['account']['positionId'] | |
client_private = client.private | |
client_private.stark_private_key = stark_keys['private_key'] | |
order_response = client_private.create_order( | |
position_id=position_id, | |
market=MARKET_BTC_USD, | |
side=ORDER_SIDE_BUY, | |
order_type=ORDER_TYPE_LIMIT, | |
post_only=True, | |
size='0.001', | |
price='1', | |
limit_fee=0.0015, | |
expiration_epoch_seconds=time.time() + 1000 * 60 | |
) | |
order_id = order_response.data['order']['id'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment