Development resources could use a little brushing up

I haven’t tried to do a market order since the new releases. Last time I did it was with the python api. But in the description you have posted the CryptoCurrency amount is used as the first mentioned currency in the market. Maybe it has to be this way around?

await client.placeMarketOrder(
  createCurrencyAmount('5.02', CryptoCurrency.BTC),
  OrderBuyOrSell.BUY,
  'btc_usdc'
)
1 Like

What I’m actually interested in is using the apiKey only to login (without the secret ), instead of the whole json file. So instead of:

That is not technically possible @Oldsport. The apiKey parameter is just a identifier, what you actually use to authenticate is the secret part. This is true not only for Nash but for any API key system. So unfortunately there is not way around it :expressionless:

await client.placeMarketOrder(
createCurrencyAmount(‘5.02’, CryptoCurrency.USDC),
OrderBuyOrSell.BUY,
‘btc_usdc’
)

@Symiaq is correct, in a market order is not possible to define the resulting total since the price is undefined, you can only specify the order in base currency, so use CryptoCurrency.BTC instead.

Best,

1 Like

But what if someone only want to use non authenticated API methods, for instance listMarket or getOrderBook ? Calling login is still required because the ‘apiKey’ is added into a Authorization header for all methods, even the non authenticated ones, but I guess the secret should not be required.

So maybe calling: nash.login({ apiKey: '58652459-39...', secret: "" }); works, but I haven’t tested it.

1 Like

Not true. I can call a non-authenticated method (e.g. listMarkets()) without any authorization:

let NashTS = require('@neon-exchange/api-client-typescript');

let nash = new NashTS.Client({
    apiURI: 'https://app.nash.io/api/graphql',
    casURI: 'https://app.nash.io/api',
    debug: false
});

const run = async () => {
    let marketsList = await nash.listMarkets()

    marketsList.markets.forEach(async (Market, index) => {
        //  
    })
}

run()
2 Likes

Ah ok, good to know!

Thanks.

Just made the adjustment and it works for market sell orders:

Yes, 5.02 BTC for 21 USDC… :grimacing:

However when trying to market buy BTC with USDC, I get the following error:

which is all the more astonishing that I’m working on sandbox.

Here’s the snippet:

await client.placeMarketOrder(
  createCurrencyAmount('1.06', CryptoCurrency.BTC),
  OrderBuyOrSell.BUY,
  'btc_usdc'
)

@canesin Any known restrictions could be triggering this?

Markets buy have some technical limitations on the protocol, so to emulate that you can do a market sell in the inverse market. The equivalent would be:

await client.placeMarketOrder(
  createCurrencyAmount('21', CryptoCurrency.USDC),
  OrderBuyOrSell.SELL,
  'usdc_btc'
)
3 Likes

It works, thanks!

I didn’t know you could inverse a pair like this.

Market order min amount

Found something a little odd when executing a market sell order of USDC into BTC (so buying BTC with USDC):

Amount 0.13 for currency usdc is less than min amount for market: 5.00000000.  Defaulting to min amount

0.13 < 5 so the message is appropriate, but I would have expected the trade not to go through and getting an error instead. I guess the frontend there for that, but it means if I build an app, it must also implement this front validation myself.

Withdrawal

I am trying to make a withdrawal from a personal account to an external one. Is signWithdrawRequest the right method for that? No luck with the following snippet:

const address = 'AbH99atcxwGECSNBdfoQJDPoC2LWndyCwt';
const amount = createCurrencyAmount('14', CryptoCurrency.NEX);
const signedMovement = await client.signWithdrawRequest(address, amount);
console.log(signedMovement)

Do you get these nonce errors on the latest version of the SDK @Oldsport?

@canesin My version was 5.0.11, I think it’s still the latest.

However, I changed the very method I’m using. I don’t know why it wasn’t showing up in the documentation search before, but I’m now trying to use transferToExternal.

I first tried this, as per the documentation.

const address = 'AbH99atcxwGECSNBdfoQJDPoC2LWndyCwt';
const cryptoAmount = createCurrencyAmount(amountString, CryptoCurrency.NEX);
await client.transferToExternal(cryptoAmount, address);

but got an error:

After taking a closer look inside the SDK, I am now trying this:

const address = 'AbH99atcxwGECSNBdfoQJDPoC2LWndyCwt';
const transferParams = {
  quantity: {
    currency: CryptoCurrency.NEO,
    amount: 25
  },
  address: address
}
await client.transferToExternal(transferParams);

Which yields this error:

I know the message looks pretty self-explanatory, but I did add the destination address to the whitelist of the API key I’m using. I even tried with a newly created API key, to no avail.

Any help would be greatly appreciated :slight_smile:

1 Like

will look into it!

1 Like

I think I misread the documentation :thinking: Parameters appear to be correctly documented. My bad!

My second point (about it not working) still stands :pray:

Quick question: Is there a reason API keys’ secret are so long? Over 6000 characters!

Also, any news about transfers?

Doesn’t work for you on latest version? There was a specific issue with NEO transfers.

The secret is so long because it is a lot of information :sweat_smile:… it is keys for all the chains supported and homomorphic encryption keys. It needs to be able to sign transactions on all the chains and collaborate with the matching engine in the MPC protocol. Not a single simple secret to sign hmacs like usual to API keys.

1 Like

It doesn’t look like it. I updated to version 5.0.19 and still getting that destination address is not part of the whitelisted addresses error. However the destination address is part of the API key whitelist.

Ok, I understand. FYI I had to split it in half to fit into cookies, not the best dev experience, but what can you do! Maybe I ought to use localStorage, but it feels less safe than httpOnly cookies.

1 Like

Will verify, I guess might be some issue on sandbox.

Are you sending the secret to a server in the headers? If you share the use I might help. Normally if the use is only on the client side localStorage or sessionStorage might be better.
If it is used on the server only than doing a push for the keys once and having in a encrypted database might be better.

2 Likes

Happy to report that with sandbox’s latest reset last night, transfers are working for me (using the API I mean ofc).

Also, found this being tested :wink:

image

8 Likes

Following my above comment:

Has the upgrade (on transfers) been released to production yet? It appears to be working in sandbox but not in production.

Cheers!

1 Like

thanks for the report @Oldsport, will look into it - we use it in several places, so it is there will check if there is some issue on the middle of the path.

3 Likes