-
Notifications
You must be signed in to change notification settings - Fork 235
feat: add estimatedGas, estimatedGasTokenRefund and minimumProtocolFee to /quote and /price response #237
Conversation
deploy staging |
deploy staging |
src/utils/service_utils.ts
Outdated
@@ -132,4 +134,30 @@ export const serviceUtils = { | |||
breakdown, | |||
); | |||
}, | |||
getEstimatedGasTokenRefundInfo( | |||
orders: OptimizedMarketOrder[], | |||
gasTokenBalance: BigNumber = new BigNumber('100000000000000000000000'), |
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.
TODO: remove.
deploy staging |
04826fd
to
21f23cd
Compare
src/constants.ts
Outdated
@@ -15,6 +15,7 @@ export const DEFAULT_LOGGER_INCLUDE_TIMESTAMP = true; | |||
export const ONE_SECOND_MS = 1000; | |||
export const ONE_MINUTE_MS = ONE_SECOND_MS * 60; | |||
export const TEN_MINUTES_MS = ONE_MINUTE_MS * 10; | |||
export const GST2_TOKEN_ADDRESS = '0x0000000000b3f879cb30fe243b4dfee438691c04'; |
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.
Might this belong in the @0x/contract-addresses package? What happens on kovan / ganache?
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.
The contract-addresses package mostly contains smart contracts that we own, this is just a token, so put it in the token_metadatas_for_networks file.
src/config.ts
Outdated
@@ -205,6 +205,10 @@ export const PROMETHEUS_PORT: number = _.isEmpty(process.env.PROMETHEUS_PORT) | |||
? 8080 | |||
: assertEnvVarType('PROMETHEUS_PORT', process.env.PROMETHEUS_PORT, EnvVarType.Port); | |||
|
|||
export const GST2_WALLET_ADDRESS: string = _.isEmpty(process.env.GST2_WALLET_ADDRESS) |
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.
Same thing here about multiple networks
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.
Are you saying we make it required? For different networks we can override the deployment.
It's a bit of a weird one because the bridges have an allowance to this address, so it makes sense to have it be baked in.
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.
just wanted to call it out, what happens if we forget to override the deployment? Any risk?
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.
Nothing would happen but I moved it to a chainId -> string object in constants.ts which probably makes more sense
src/utils/service_utils.ts
Outdated
const usedGasTokens = BigNumber.min( | ||
gasTokenBalance, | ||
costOfBridgeFills | ||
.plus(14154) |
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.
Should these numbers be in constants somewhere?
6487c64
to
c4fb67d
Compare
…t/estimated-fields
883afc6
to
eae6007
Compare
eae6007
to
9befc58
Compare
9d1d818
to
5ba0ace
Compare
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.
In the future It'd be nice to cache the GST balance for some time (1min?) rather than query it live every time. Whilst it may have a delay in accuracy as we approach a 0 balance for that time, but it would be faster (and less RPC calls) for 99.99% of the time where we have a reserve.
🎉 This PR is included in version 1.6.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Description
estimatedGas
field which represents a more optimistic gas estimate for the UI.estimagedGasTokenRefund
field which represents an estimate for the gas token refund in the transaction.minimumProtocolFee
field which represents the protocol fee if only the minimum amount of orders are filled.Testing Instructions
It is deployed on staging. https://staging.api.0x.org/swap/v0/quote?sellToken=DAI&buyToken=WETH&buyAmount=1000000000000000000000
Checklist
[WIP]
if necessary.