-
Notifications
You must be signed in to change notification settings - Fork 240
RFQ-T Firm Quotes #162
Changes from all commits
d3cfe8e
05ca1b6
e026de2
0a0de81
89ff735
61cbd5c
268bff8
2578a79
6b21a39
d11b850
b126316
cbecfc4
902b15d
bdc7bae
47227ad
0255b25
29d6215
b0488ef
e50fc98
e150eec
7c448d3
08f4d31
f325f42
ea8c8e9
0633aca
556a45b
e1693bb
11cb5a8
bb2814a
74d3ea7
6a0aed8
fb176a5
2e7c7bb
3ed896f
c772d43
735fe3e
bf835d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,33 +6,38 @@ | |
"author": "Francesco Agosti <[email protected]>", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"clean": "shx rm -rf lib 0x_mesh/db", | ||
"install": "sed -ie 's!import { Provider as Web3Provider } from \"web3/providers\";!import { Web3EthereumProvider as Web3Provider } from \"web3-providers\";!' node_modules/ganache-core/typings/index.d.ts # see https://github.com/trufflesuite/ganache-core/issues/465#issuecomment-610005598", | ||
"clean": "yarn clean:ts && yarn clean:docker", | ||
"clean:ts": "shx rm -rf lib", | ||
"clean:docker": "shx rm -rf 0x_mesh/db", | ||
"build": "tsc -p tsconfig.json", | ||
"test": "ETHEREUM_RPC_URL=http://localhost:8545 mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 100000 --exit", | ||
"test": "ETHEREUM_RPC_URL=http://localhost:8545 CHAIN_ID=1337 RFQT_API_KEY_WHITELIST='koolApiKey1,koolApikey2' RFQT_MAKER_ENDPOINTS='https://mock-rfqt1.club' mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 100000 --exit", | ||
"dev": "nodemon -r dotenv/config src/index.ts | pino-pretty", | ||
"dev:service:http": "nodemon -r dotenv/config src/runners/http_service_runner.ts | pino-pretty", | ||
"dev:service:sra_http": "nodemon -r dotenv/config src/runners/http_sra_service_runner.ts | pino-pretty", | ||
"dev:service:staking_http": "nodemon -r dotenv/config src/runners/http_staking_service_runner.ts | pino-pretty", | ||
"dev:service:swap_http": "nodemon -r dotenv/config src/runners/http_swap_service_runner.ts | pino-pretty", | ||
"dev:service:order_watcher": "nodemon -r dotenv/config src/runners/order_watcher_service_runner.ts | pino-pretty", | ||
"watch": "tsc -w", | ||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc", | ||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc", | ||
"prettier": "prettier --write ${npm_package_config_prettier_target} --config .prettierrc", | ||
"prettier:ci": "prettier --list-different ${npm_package_config_prettier_target} --config .prettierrc", | ||
"start": "node -r dotenv/config lib/src/index.js", | ||
"start:service:http": "node -r dotenv/config lib/src/runners/http_service_runner.js", | ||
"start:service:sra_http": "node -r dotenv/config lib/src/runners/http_sra_service_runner.js", | ||
"start:service:staking_http": "node -r dotenv/config lib/src/runners/http_staking_service_runner.js", | ||
"start:service:swap_http": "node -r dotenv/config lib/src/runners/http_swap_service_runner.js", | ||
"start:service:order_watcher": "node -r dotenv/config lib/src/runners/order_watcher_service_runner.js", | ||
"lint": "tslint --project . --format stylish" | ||
"lint": "tslint --project . --format stylish && yarn prettier:ci" | ||
}, | ||
"config": { | ||
"prettier_target": "{.,test/**,src/**}/*.{ts,tsx,json,md}" | ||
}, | ||
"resolutions": { | ||
"@0x/contract-addresses": "0xProject/gitpkg-registry#0x-contract-addresses-v4.9.0-0e196a59d", | ||
"@0x/contract-addresses": "0xProject/gitpkg-registry#0x-contract-addresses-v4.9.0-110e1afa8", | ||
"@0x/contract-wrappers": "0xProject/gitpkg-registry#0x-contract-wrappers-v13.6.3-0e196a59d" | ||
}, | ||
"devDependencies": { | ||
"@0x/dev-utils": "^3.1.1", | ||
"@0x/migrations": "^5.0.2", | ||
"@0x/tslint-config": "^4.0.0", | ||
"@0x/types": "^3.1.1", | ||
"@0x/typescript-typings": "^5.0.1", | ||
|
@@ -48,6 +53,7 @@ | |
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"dirty-chai": "^2.0.1", | ||
"make-promises-safe": "^5.1.0", | ||
"mocha": "^6.2.2", | ||
"nodemon": "^1.19.4", | ||
"pino-pretty": "^3.2.2", | ||
|
@@ -60,9 +66,9 @@ | |
}, | ||
"dependencies": { | ||
"@0x/assert": "^3.0.4", | ||
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.4.0-0e196a59d", | ||
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.4.0-110e1afa8", | ||
"@0x/connect": "^6.0.4", | ||
"@0x/contract-addresses": "0xProject/gitpkg-registry#0x-contract-addresses-v4.9.0-0e196a59d", | ||
"@0x/contract-addresses": "0xProject/gitpkg-registry#0x-contract-addresses-v4.9.0-110e1afa8", | ||
"@0x/contract-wrappers": "0xProject/gitpkg-registry#0x-contract-wrappers-v13.6.3-0e196a59d", | ||
"@0x/json-schemas": "^5.0.4", | ||
"@0x/mesh-rpc-client": "^9.2.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,17 @@ | |
}, | ||
"excludedSources": { | ||
"type": "string" | ||
}, | ||
"apiKey": { | ||
"type": "string" | ||
}, | ||
"intentOnFilling": { | ||
"type": "string", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to. I tried. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At test runtime i get this json schema error
This happened no matter whether my client said There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. I think this schema could be cleaner if we:
This would allow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How's this: bb2814a |
||
"enum": ["true", "false"] | ||
}, | ||
"skipValidation": { | ||
"type": "string", | ||
"enum": ["true", "false"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
} | ||
}, | ||
"required": ["sellToken", "buyToken"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,13 @@ import { | |
CHAIN_ID, | ||
FEE_RECIPIENT_ADDRESS, | ||
LIQUIDITY_POOL_REGISTRY_ADDRESS, | ||
RFQT_API_KEY_WHITELIST, | ||
RFQT_MAKER_ENDPOINTS, | ||
} from '../config'; | ||
import { | ||
DEFAULT_TOKEN_DECIMALS, | ||
GAS_LIMIT_BUFFER_PERCENTAGE, | ||
NULL_ADDRESS, | ||
ONE, | ||
ONE_SECOND_MS, | ||
PERCENTAGE_SIG_DIGITS, | ||
|
@@ -62,6 +65,10 @@ export class SwapService { | |
chainId: CHAIN_ID, | ||
expiryBufferMs: QUOTE_ORDER_EXPIRATION_BUFFER_MS, | ||
liquidityProviderRegistryAddress: LIQUIDITY_POOL_REGISTRY_ADDRESS, | ||
feuGeneA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rfqt: { | ||
takerApiKeyWhitelist: RFQT_API_KEY_WHITELIST, | ||
makerEndpoints: RFQT_MAKER_ENDPOINTS, | ||
}, | ||
}; | ||
this._swapQuoter = new SwapQuoter(this._provider, orderbook, swapQuoterOpts); | ||
this._swapQuoteConsumer = new SwapQuoteConsumer(this._provider, swapQuoterOpts); | ||
|
@@ -85,13 +92,28 @@ export class SwapService { | |
from, | ||
excludedSources, | ||
affiliateAddress, | ||
apiKey, | ||
rfqt, | ||
// tslint:disable-next-line:boolean-naming | ||
skipValidation, | ||
} = params; | ||
const assetSwapperOpts = { | ||
...ASSET_SWAPPER_MARKET_ORDERS_OPTS, | ||
slippagePercentage, | ||
bridgeSlippage: slippagePercentage, | ||
gasPrice: providedGasPrice, | ||
excludedSources, // TODO(dave4506): overrides the excluded sources selected by chainId | ||
apiKey, | ||
rfqt: | ||
rfqt === undefined || from === undefined || from === NULL_ADDRESS | ||
? undefined | ||
: { | ||
...rfqt, | ||
// 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 ? getContractAddressesForChainOrThrow(CHAIN_ID).forwarder : from, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to add a comment describing what's happening here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 03f7673 |
||
}, | ||
}; | ||
if (sellAmount !== undefined) { | ||
swapQuote = await this._swapQuoter.getMarketSellSwapQuoteAsync( | ||
|
@@ -136,7 +158,7 @@ export class SwapService { | |
const affiliatedData = this._attributeCallData(data, affiliateAddress); | ||
|
||
let suggestedGasEstimate = new BigNumber(gas); | ||
if (from) { | ||
if (!skipValidation && from) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
// Force a revert error if the takerAddress does not have enough ETH. | ||
const txDataValue = | ||
extensionContractType === ExtensionContractType.Forwarder | ||
|
Uh oh!
There was an error while loading. Please reload this page.