-
Notifications
You must be signed in to change notification settings - Fork 56
getting same order from openrelay api always using 0xproject/connect api #35
Comments
Here's what's happening: 0x Connect isn't looking for an object with {"OrderRequestOpts": {...}, "PagedRequestOpts": {...}}, it's looking for am object with the properties of an OrderRequestOpts object and a PagedRequestOpts object. Using your example above, you'd want:
Note that rather than a blank feeRecipient, I left the feeRecipient out entirely, as if it is present 0x Connect expects it to match the regular expression of an Ethereum address. I'd also note that the above order returns an empty list [] - OpenRelay has no orders that match your query. Broadly speaking, you only need to add fields to your OrdersRequestOpts when you want to filter on them. Generally you wouldn't set all three of "maker", "taker", and "trader, as "trader" means "Either the maker or the taker matches this value". Likewise, you wouldn't set all three of "makerTokenAddress", "takerTokenAddress", and "tokenAddress", as "tokenAddress" means "Either the makerTokenAddress or the takerTokenAddress matches this value." I would probably reduce your filter down to:
Which ensures that you're filtering for orders on Ropsten, where the makerTokenAddress is a particular token, the takerTokenAddress is a particular token, and anybody can take the order (this is currently superfluous on OpenRelay, as we only allow orders that anyone can take, but that will change in the near future, so it's best to leave that in). Note that this will still get you an empty list of orders, as we don't have any orders for that token pair (OpenRelay's order volume is currently quite small, even on Ropsten). I'm closing this for now, as it's not an issue with OpenRelay, but I'm happy to continue the discussion if you have further questions. |
Hi AusIV,
Thanks for your reply. It really helped me understanding about how I can
get orders from openrelay.
But as you've mentioned that there is no such order in openrelay I'm not
getting any order. But I did sent order to openrelay. So I'm afraid that I
couldn't send order correctly. can you please help me on that?
Here is the order object that is sent to openrelay, its signed and I'm
using 0xproject/connect api method to send it to openrelay:
{
"maker": "0xe60c537190939913291db1296a8758b654519e46",
"taker": "0x0000000000000000000000000000000000000000",
"makerTokenAddress": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
"takerTokenAddress": "0xc778417e063141139fce010982780140aa0cd5ab",
"makerTokenAmount": "1000000000000000000000",
"takerTokenAmount": "700000000000000000",
"expirationUnixTimestampSec": "1524718057",
"salt":
"89108604419398401121014795527618164366518066557834879060001683632085784687069",
"exchangeContractAddress": "0x479cc461fecd078f766ecc58533d6f69580cf3ac",
"makerFee": "500000000000000000",
"takerFee": "0",
"feeRecipient": "0xc22d5b2951db72b44cfb8089bb8cd374a3c354ea",
"ecSignature": {
"v": 27,
"r":
"0x7f13b3df232d53377a397dd433c587c64353883d1497256170401efb415daccb",
"s":
"0x1d7ac43d9fe245eeec2aaa333bdfdfb2de4622c08462bf31c252906fc11ddffa"
}
}
Here is the code I'm using to send:
var order = {
maker: web3.eth.accounts[0],
taker: "0x0000000000000000000000000000000000000000",
makerTokenAddress: "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
takerTokenAddress: "0xc778417e063141139fce010982780140aa0cd5ab",
makerTokenAmount: new BigNumber("1000000000000000000000"),
takerTokenAmount: new BigNumber("700000000000000000"),
expirationUnixTimestampSec: parseInt(
(new Date().getTime()/1000) + duration
).toString(),
salt: ZeroEx.generatePseudoRandomSalt()
}
order.exchangeContractAddress = zeroEx.exchange.getContractAddress();
var feePr = httpClient.getFeesAsync(order).then(function(feeResponse) {
order.makerFee = new BigNumber(feeResponse.makerFee || 0);
order.takerFee = new BigNumber(feeResponse.takerFee || 0);
order.taker = feeResponse.takerToSpecify;
order.feeRecipient = feeResponse.feeRecipient ||
ZeroEx.NULL_ADDRESS;
});
Promise.all([feePr]).then(() => {
// Once those promises have resolved, our order is ready to be
signed
var orderHash = ZeroEx.getOrderHashHex(order);
return zeroEx.signOrderHashAsync(orderHash, order.maker, true);
}).then((signature) => {
order.ecSignature = signature;
// validSignature =
zeroEx.exchange.validateOrderFillableOrThrowAsync(order);
return order;
});
var makerAllowance = zeroEx.token.setProxyAllowanceAsync(
// order.makerToken,
order.makerTokenAddress,
order.maker,
order.makerTokenAmount
);
var feeAllowance = zeroEx.token.setProxyAllowanceAsync(
order.makerTokenAddress,
order.maker,
order.makerFee || new BigNumber(0)
);
Promise.all([makerAllowance, feeAllowance, feePr]).then(function(){
httpClient.submitOrderAsync(order).then(function(orderResponse) {
console.log(orderResponse);
});
});
But in httpClient.submitOrderAsync(order) response I'm getting nothing
orderResponse variable. As per documentation I should get a HTTP 201
response upon success or on error should get response like the following.
{
"code": 101,
"reason": "Validation failed",
"validationErrors": [
{
"field": "maker",
"code": 1002,
"reason": "Invalid address"
}
]
}
But I'm getting nothing. it returns the promise with orderResponse variable
'undefined'. I did put a breakpoint on console.log(orderResponse); line
from where I got this that orderResponse is undefined.
can you please help me find out where did I make the mistake?
regards
Mahbub
…On Wed, Apr 25, 2018 at 12:59 AM, AusIV ***@***.***> wrote:
Here's what's happening:
0x Connect isn't looking for an object with {"OrderRequestOpts": {...},
"PagedRequestOpts": {...}}, it's looking for am object with the properties
of an OrderRequestOpts object *and* a PagedRequestOpts object. Using your
example above, you'd want:
{
"exchangeContractAddress": "0x479cc461fecd078f766ecc58533d6f69580cf3ac",
"maker": "0xe60c537190939913291db1296a8758b654519e46",
"makerTokenAddress": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
"taker": "0x0000000000000000000000000000000000000000",
"takerTokenAddress": "0xc778417e063141139fce010982780140aa0cd5ab",
"tokenAddress": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
"trader": "0xe60c537190939913291db1296a8758b654519e46",
"page": 1,
"perPage": 100
}
Note that rather than a blank feeRecipient, I left the feeRecipient out
entirely, as if it is present 0x Connect expects it to match the regular
expression of an Ethereum address.
I'd also note that the above order returns an empty list [] - OpenRelay
has no orders that match your query.
Broadly speaking, you only need to add fields to your OrdersRequestOpts
when you want to filter on them. Generally you wouldn't set all three of
"maker", "taker", and "trader, as "trader" means "Either the maker or the
taker matches this value". Likewise, you wouldn't set all three of
"makerTokenAddress", "takerTokenAddress", and "tokenAddress", as
"tokenAddress" means "Either the makerTokenAddress or the takerTokenAddress
matches this value."
I would probably reduce your filter down to:
{
"exchangeContractAddress": "0x479cc461fecd078f766ecc58533d6f69580cf3ac",
"makerTokenAddress": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
"taker": "0x0000000000000000000000000000000000000000",
"takerTokenAddress": "0xc778417e063141139fce010982780140aa0cd5ab",
"page": 1,
"perPage": 100
}
Which ensures that you're filtering for orders on Ropsten, where the
makerTokenAddress is a particular token, the takerTokenAddress is a
particular token, and anybody can take the order (this is currently
superfluous on OpenRelay, as we only allow orders that anyone can take, but
that will change in the near future, so it's best to leave that in).
Note that this will still get you an empty list of orders, as we don't
have any orders for that token pair (OpenRelay's order volume is currently
quite small, even on Ropsten).
I'm closing this for now, as it's not an issue with OpenRelay, but I'm
happy to continue the discussion if you have further questions.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADbVGDNQAM_qFUGY5LCrHIYDFLP7MlBBks5tr3YqgaJpZM4Thrw2>
.
|
submitOrderAsync() returns a promise for a JSON object returned in the content of the HTTP request made by 0x Connect. This HTTP request doesn't return anything other than a status code, so the content would be empty. If it had gotten an error status code, the promise would have thrown an error (you'd get it with However, in responding to the initial request, OpenRelay only validates details that can be validated upon a simple inspection of the order. It considers things like:
There are other details that require communication with an Ethereum RPC server to determine:
Because the Ethereum RPC server is a bit fragile, we don't do those validations during the HTTP request. Instead we queue those orders for further validation and validate them after the HTTP response, but before they get listed in the order book. It's worth noting that we also track those attributes continuously, and if any of them should ever cease to be valid we will remove an order from the orderbook. For this reason, I would recommend using zeroEx.exchange.validateOrderFillableOrThrowAsync to test that your orders are fillable before submitting them to OpenRelay, as it will give you more detailed information about why your order may not make it into the orderbook. In your case, I looked at the maker address on Etherscan: https://ropsten.etherscan.io/address/0xe60c537190939913291db1296a8758b654519e46 I see that you have approved transfers for Ropsten ZRX (the fee token and maker token), but that you don't actually hold any ZRX. As a result, your order is being invalidated before it gets listed in the orderbook. You can create WETH using zeroEx.etherToken.depositAsync, set the proper allowances for that, then OpenRelay has at least one order on the orderbook offering ZRX in exchange for WETH. If you fill that order (at least partially), you should then have the necessary tokens to submit the order you're trying to fill. |
I've been trying to get orders from https://api.openrelay.xyz/v0
I've used ZeroEx api and @0xproject/connect to do this. And I'm using Ropstan Test Network.
Here is the flow and code I've used:
firstly I've created an PagedRequestOpts object:
var PagedRequestOpts = {
page: 1,
perPage: 100,
};
var requestOpts = {
OrderRequestOpts: OrderRequestOpts,
PagedRequestOpts: PagedRequestOpts,
};
Here is the problem I'm facing:
while trying to get orders from 'https://api.openrelay.xyz/v0' using 0xproject/connect api method getOrdersAsync I'm getting the same order over and over. And that order is not even related to my request. Am I doing anything wrong? please help me.
Btw The requestOpts object that I'm passing in getOrderAsync function is :
"{"OrderRequestOpts":{"exchangeContractAddress":"0x479cc461fecd078f766ecc58533d6f69580cf3ac","feeRecipient":"","maker":"0xe60c537190939913291db1296a8758b654519e46","makerTokenAddress":"0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d","taker":"0x0000000000000000000000000000000000000000","takerTokenAddress":"0xc778417e063141139fce010982780140aa0cd5ab","tokenAddress":"0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d","trader":"0xe60c537190939913291db1296a8758b654519e46"},"PagedRequestOpts":{"page":1,"perPage":100}}"
Here I'm showing it by stringifying. but in code I'm sending it as object.
And the array of order object I'm getting is:
"[{"maker":"0xe689f23ae131e18356aeb130917ca510ee454033","taker":"0x0000000000000000000000000000000000000000","makerTokenAddress":"0xa1df88ea6a08722055250ed65601872e59cddfaa","takerTokenAddress":"0xc778417e063141139fce010982780140aa0cd5ab","feeRecipient":"0xc22d5b2951db72b44cfb8089bb8cd374a3c354ea","exchangeContractAddress":"0x479cc461fecd078f766ecc58533d6f69580cf3ac","makerTokenAmount":"1000000000000000000","takerTokenAmount":"1000000000000000000","makerFee":"250000000000000000","takerFee":"250000000000000000","expirationUnixTimestampSec":"1525030534","salt":"1524166534","ecSignature":{"v":28,"r":"0xf8f601793caf4d1596cf5d1324ff3e51a004d99e0d147bd9b5735af376be8dc9","s":"0x1c6e12fce632f92d722496b637b9830ecd797e8eff50524226d857ac1ee42bd1"}}]"
Thank you in advance.
regards
The text was updated successfully, but these errors were encountered: