dydxprotocol / v3-client

TypeScript client for dYdX (v3 API).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to make an order with the market.indexPrice ?

slashbinslashnoname opened this issue · comments

How to get the price for long or short ?

To pass an order i'm using getMarket.indexPrice but order cannot pass without using a multiplier (0.1%)


	const accounts = await getAccounts();
	console.log(accounts);

	const market = await getMarket("MATIC-USD");
	console.log(market);

then

const order = await placeOrder(
	"MATIC-USD",
	"BUY",
	"MARKET",
	"FOK",
	false,
	parseInt(accounts[0].freeCollateral / market.indexPrice).toString(),
	(market.indexPrice * 1.002).toFixed(size),
	plus30m
);
console.log(order);

What can I use as price to a market order ?

Transaction is systematically expired

Probably because it can round it down below market price. You can try something like that, it worked for me:
Math.round(market.indexPrice * 1.001) + 1