forked from rhinofi/client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_sell_eth_infura.js
53 lines (43 loc) · 1.25 KB
/
node_sell_eth_infura.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
const HDWalletProvider = require('@truffle/hdwallet-provider')
const Web3 = require('web3')
const DVF = require('../src/dvf')
const privateKey = '8F085...' // Account's private key
const rpcUrl = 'https://mainnet.infura.io/v3/9e28b...'
const starkPrivKey = privateKey
const provider = new HDWalletProvider(privateKey, rpcUrl)
const web3 = new Web3(provider)
const dvfConfig = {
// Using staging API.
api: 'https://api.stg.deversifi.com'
}
;(async () => {
const dvf = await DVF(web3, dvfConfig)
// Submit an order to sell 0.3 Eth for 200 USDT per 1 Eth
const symbol = 'ETH:USDT'
const amount = -0.3
const price = 200
const validFor = '0'
const feeRate = ''
const submitOrderResponse = await dvf.submitOrder({
symbol,
amount,
price,
starkPrivateKey: starkPrivKey,
validFor, // Optional
feeRate, // Optional
gid: '1', // Optional
cid: '1', // Optional
partnerId: 'P1' // Optional
})
console.log('submitOrder response ->', submitOrderResponse)
})()
// Stop provider to allow process to exit.
.then(() => {
console.log('Stopping provider...')
provider.engine.stop()
})
.catch(error => {
console.error(error)
process.exit(1)
})