Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rfqt included #293

Merged
merged 16 commits into from
Jul 27, 2020
Merged

feat: Rfqt included #293

merged 16 commits into from
Jul 27, 2020

Conversation

PirosB3
Copy link
Contributor

@PirosB3 PirosB3 commented Jul 23, 2020

Description

Adds a new parameter includedSources=RFQT which allows a requestor to solely request RFQT liquidity from the order salad. As of now, the implementation of includedSources exclusively permits RFQT but it can be extended in the future will full backwards-compatibility for our integrators.

Testing Instructions

  • Added unit tests
  • Tested in staging

Checklist

  • Update documentation as needed. Website Documentation PR:
  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.

@PirosB3 PirosB3 changed the title Rfqt included feat: Rfqt included Jul 23, 2020
@PirosB3
Copy link
Contributor Author

PirosB3 commented Jul 24, 2020

deploy staging

@PirosB3 PirosB3 requested review from steveklebanoff and dekz and removed request for steveklebanoff July 24, 2020 05:40
@PirosB3 PirosB3 marked this pull request as ready for review July 24, 2020 05:41
},
]);
}
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to confirm here @steveklebanoff we shouldn't be making any check for intentOnFilling right? I partially remember our discussion and wanted to confirm :)

Copy link
Contributor

Choose a reason for hiding this comment

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

i think it'd be nice to confirm intentOnFilling if they are hitting /quote but we'd have to make sure this doesn't trigger if they hit /price (switch on endpoint) -- that being said, this is just a 'nice to have' feature

Copy link
Contributor

Choose a reason for hiding this comment

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

Per convo, let's do it

@@ -22,6 +22,9 @@
"excludedSources": {
"type": "string"
},
"includedSources": {
"type": "string"
},
"apiKey": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

curious, why is apiKey a GET parameter here?

Copy link
Contributor

Choose a reason for hiding this comment

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

good call -- perhaps this is a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

delete this

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.

Awesome work! I'm impressed you did this so quickly

);

const affiliateAddress = req.query.affiliateAddress as string;
const rfqt: Partial<RfqtRequestOpts> =
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for adding this typing!

@@ -22,6 +22,9 @@
"excludedSources": {
"type": "string"
},
"includedSources": {
"type": "string"
},
"apiKey": {
Copy link
Contributor

Choose a reason for hiding this comment

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

good call -- perhaps this is a mistake?

// tslint:disable-next-line: boolean-naming
const { excludedSources, nativeExclusivelyRFQT } = parseUtils.parseRequestForExcludedSources(
{
excludedSources: req.query.excludedSources as string,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's the case that excludedSources can be undefined? If so :as string | undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

/**
* This constant contains, as keys, all ERC20BridgeSource types except from `Native`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Great documentation, thank you

@@ -10,7 +11,101 @@ import {

import { AvailableRateLimiter, DatabaseKeysUsedForRateLimiter, RollingLimiterIntervalUnit } from './rate-limiters';

interface SwapRequestParams {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this name is too generic and could be confusing in the future. That being said, I can't think of a great name for this.

This is leading me to believe that it may be better to just send in these as regular parameters instead of introducing an object to hold them. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

ParseRequestForExcludedSourcesParams

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

throw new ValidationError([
{
field: '0x-api-key',
code: ValidationErrorCodes.IncorrectFormat,
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like these are not quite 'IncorrectFormat's -- as the format is correct but the value is invalid.

What do you think about introducing FieldValueInvalid as a ValidationErrorCode instead of a reason? Then we could add InvalidApiKey as a reason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code: FieldInvalid
reason: Invalid API key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/errors.ts Outdated
@@ -135,6 +135,9 @@ export enum ValidationErrorCodes {

export enum ValidationErrorReasons {
PercentageOutOfRange = 'MUST_BE_LESS_THAN_OR_EQUAL_TO_ONE',
ConflictingFilteringArguments = 'CONFLICTING_FILTERING_ARGUMENTS',
ArgumentNotYetSupported = 'ARGUMENT_NOT_YET_SUPPORTED',
FieldInvalid = 'FieldInvalid',
Copy link
Contributor

Choose a reason for hiding this comment

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

FieldInvalid seems more like a ValidationErrorCode to me than a ValidationErrorReason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/types.ts Outdated
intentOnFilling?: boolean;
isIndicative?: boolean;
};
rfqt?: Partial<RfqtRequestOpts>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we only want this to be intentOnFilling, isIndicative and nativeExclusivelyRFQT, not the other RfqtRequestOpts -- is that correct?

If so, use Pick instead of Partial

Copy link
Contributor

@steveklebanoff steveklebanoff Jul 24, 2020

Choose a reason for hiding this comment

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

Pick< RfqtRequestOpts , 'intentOnFilling' | ....>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


const SUITE_NAME = 'parseUtils';

describe(SUITE_NAME, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice tests!

@@ -0,0 +1,101 @@
import { ERC20BridgeSource } from '@0x/asset-swapper';
Copy link
Contributor

Choose a reason for hiding this comment

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

it'd be nice to add to the RFQT integration tests, to show that indicative & firm quotes return as expect when specifying includedSources=RFQT

@@ -131,10 +131,16 @@ export enum ValidationErrorCodes {
InvalidOrder = 1007,
InternalError = 1008,
TokenNotSupported = 1009,
FieldInvalid = 1010,
Copy link
Contributor

Choose a reason for hiding this comment

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

image
We should update the documentation here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

throw new ValidationError([
{
field: 'takerAddress',
code: ValidationErrorCodes.FieldInvalid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this just be the RequiredField code?

throw new ValidationError([
{
field: 'intentOnFilling',
code: ValidationErrorCodes.FieldInvalid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Again - should this just be a RequiredField code?

@PirosB3
Copy link
Contributor Author

PirosB3 commented Jul 27, 2020

deploy staging

}

// We enforce a valid API key - we don't want to fail silently.
if (request.apiKey === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for distinguishing these!

{
field: 'takerAddress',
code: ValidationErrorCodes.RequiredField,
reason: ValidationErrorReasons.TakerAddressInvalid,
Copy link
Contributor

@steveklebanoff steveklebanoff Jul 27, 2020

Choose a reason for hiding this comment

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

Looking at this again, I think we could get rid of ValidationErrorReasons.TakerAddressInvalid

field: takerAddress, code: ValidationErrorCodes.RequiredField is descriptive enough.

EDIT: looks like reason is required, so perhaps we leave as-is

@PirosB3 PirosB3 merged commit 965dedb into master Jul 27, 2020
@PirosB3 PirosB3 deleted the rfqt-included branch July 27, 2020 23:01
github-actions bot pushed a commit that referenced this pull request Aug 3, 2020
# [1.13.0](v1.12.0...v1.13.0) (2020-08-03)

### Bug Fixes

* Kovan deploy UniswapV2 ([#304](#304)) ([f4fb99b](f4fb99b))
* Kovan ERC20BridgeSampler ([#299](#299)) ([56f7a90](56f7a90))

### Features

* added a unique identifier to the quote within the timestamp metadata … ([#281](#281)) ([d992563](d992563))
* Rfqt included ([#293](#293)) ([965dedb](965dedb))
@github-actions
Copy link

github-actions bot commented Aug 3, 2020

🎉 This PR is included in version 1.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants