-
Notifications
You must be signed in to change notification settings - Fork 238
Conversation
A handful of RFQ-T options were restructured in 0xProject/0x-monorepo@957e3eb This adapts to those changes.
Renamed method getSwapQuoteAsync() to _getSwapQuoteAsync(), and created a new getSwapQuoteAsync() to delegeate to it, all for the purposes of also calling into _getSwapQuoteAsync() of the newly introduced method getSwapPriceAsync(). Unfortunately, the diff looks noisy because the old public method was changed to be private, forcing it to move down below publics in the method order. This resulted resulting in my diff viewer showing that two previously existing methods (getSwapPricesAsync() [notice that one's plural, not to be confused with the aforementioned singular version] and getTokenPricesAsync()) moved UP in the diff. Those two existing methods have not changed, and it's easier to review this commit if you understand the pattern they contribute to the overall diff.
deploy staging |
deploy kovan-staging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments but LGTM besides that 💪
Log the orders that are used to construct indicative quotes. These are "dummy" orders, but for now we need to see them in the logs in order to verify that indicative quotes are being served, since there is no separate source for RFQ-T (they are lumped in with the '0x' source.) Long term, this log entry may prove useful if it isn't too noisy. If it is, we can remove it after manual testing.
Addresses review comment #172 (comment)
Addresses (at least part of) review comment #172 (comment)
c29677a
to
90d8dca
Compare
deploy staging |
deploy staging |
package.json
Outdated
@@ -66,7 +66,7 @@ | |||
}, | |||
"dependencies": { | |||
"@0x/assert": "^3.0.4", | |||
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.4.0-a458e81f8", | |||
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.4.0-a9f445173", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this needs to be updated now, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Pending
- Update asset-swapper git hash
- Getting rid of CORS change
LGTM pending the two items mentioned. Would be good to get @dekz blessing here though. |
src/handlers/swap_handlers.ts
Outdated
params.skipValidation = true; | ||
const quote = await this._calculateSwapQuoteAsync(params); | ||
const { price, value, gasPrice, gas, protocolFee, buyAmount, sellAmount, sources, orders } = quote; | ||
logger.info(`Serving indicative quote based on the following orders: ${JSON.stringify(orders)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would get a little verbose. Can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in b2f6fe7
When the client gives an API key and a taker address, but not saying intentOnFilling=true, the process is falling into an indicative quote mode, and a weird "all zeroes" order (zero salt, NULL_ADDRESS exchange address, etc) was being included in the order salad.
Utilize the new `isIndicative` flag provided by asset-swapper in order to indicate when indicative quotes should NOT be solicited.
Addresses review comment #172 (comment)
Addresses review comment #172 (comment)
deploy staging |
// tslint:disable-next-line:prefer-function-over-method | ||
public async getSwapPriceAsync(req: express.Request, res: express.Response): Promise<void> { | ||
const params = parseGetSwapQuoteRequestParams(req, 'price'); | ||
params.skipValidation = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but it'd be nice to have a comment explaining what's going on here
// If this is a forwarder transaction, then we want to request quotes with the taker as the | ||
// forwarder contract. If it's not, then we want to request quotes with the taker set to the | ||
// API's takerAddress query parameter, which in this context is known as `from`. | ||
takerAddress: isETHSell ? this._forwarderAddress : from || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected this to be || undefined
, does it have to be || ''
?
@@ -433,7 +435,8 @@ export interface CalculateSwapQuoteParams { | |||
affiliateAddress?: string; | |||
apiKey?: string; | |||
rfqt?: { | |||
intentOnFilling: boolean; | |||
intentOnFilling?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but I'd prefer for both of these to be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deploy staging |
deploy staging |
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Adds a
/swap/v0/price
endpoint, delegating almost entirely to the handler for the/swap/v0/quote
endpoint.This depends on 0xProject/0x-monorepo#2555 and is pinned to a revision there in the
TEMPORARY
commit here, which will be updated when that PR lands.