Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

RFQ-T Indicative Quotes #172

Merged
merged 23 commits into from
Apr 23, 2020
Merged

RFQ-T Indicative Quotes #172

merged 23 commits into from
Apr 23, 2020

Conversation

feuGeneA
Copy link
Contributor

@feuGeneA feuGeneA commented Apr 17, 2020

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.

  • Expand test cases. There's only a single one right now.

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.
@feuGeneA feuGeneA marked this pull request as ready for review April 17, 2020 07:46
@feuGeneA feuGeneA self-assigned this Apr 17, 2020
@feuGeneA
Copy link
Contributor Author

deploy staging

@feuGeneA
Copy link
Contributor Author

deploy kovan-staging

src/config.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@steveklebanoff steveklebanoff left a 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 💪

src/handlers/swap_handlers.ts Show resolved Hide resolved
src/handlers/swap_handlers.ts Outdated Show resolved Hide resolved
src/handlers/swap_handlers.ts Outdated Show resolved Hide resolved
src/services/swap_service.ts Outdated Show resolved Hide resolved
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 (at least part of) review comment #172 (comment)
@feuGeneA
Copy link
Contributor Author

deploy staging

@feuGeneA
Copy link
Contributor Author

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",
Copy link
Contributor

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?

Copy link
Contributor

@steveklebanoff steveklebanoff left a 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

@steveklebanoff
Copy link
Contributor

LGTM pending the two items mentioned. Would be good to get @dekz blessing here though.

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)}`);
Copy link
Member

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?

Copy link
Contributor Author

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.
feuGeneA added a commit that referenced this pull request Apr 22, 2020
feuGeneA added a commit that referenced this pull request Apr 22, 2020
@feuGeneA
Copy link
Contributor Author

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;
Copy link
Contributor

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 || '',
Copy link
Contributor

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;
Copy link
Contributor

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

Copy link
Contributor

@steveklebanoff steveklebanoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending #184, or we could merge this as-is and merge #184 into master directly

@steveklebanoff
Copy link
Contributor

deploy staging

@feuGeneA
Copy link
Contributor Author

deploy staging

@feuGeneA feuGeneA merged commit 5fa9ba3 into master Apr 23, 2020
@feuGeneA feuGeneA deleted the rfqt-indicative branch April 23, 2020 00:43
@github-actions
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants