Updates: Transaction Ordering Optimization and Enhancements

we are introducing several enhancements in the upcoming product upgrade.

Updates: Transaction Ordering Optimization and Enhancements

Overview

Direct Route is set up with the primary goal to protect users from front-running and sandwich attacks. This is made possible through SDK and a front-end trading interface known as Direct Route Swap.

In the public testing phase, we do note there were some improper use cases mainly surrounding the transaction sequence not being ordered strictly by gas price. Hence we are introducing enhancements in the upcoming product upgrade and explain in this article. Major changes include:

1. All transactions will be ordered strictly by gas price;

2. Bundle price calculation logic changes;

3. API changes.

Details

1. Transaction Order

Although there is no hard rule about the transaction order in BSC specification, the Direct Route will sort all transactions by gas price, which is consistent as the typical BSC transaction sequence. After the new release, it can be demonstrated as below :

2. Minimal Gas Price

Zero gas price bundles are no longer allowed, it is mandatory to set a minimal gas price for all bundles. The minimum gas price is fluctuant according to the network traffic situation. Users should fetch the suggested minimal gas price through the Direct Route API.

3. Bundle Price Calculation

Current bundle price calculation formula:

BundlePrice = sum(gasPrice * gasUsed) / sum(gasUsed) + BNBToCoinbase/sum(gasUsed)

New bundle price calculation formula:

BundlePrice = sum(gasPrice * gasUsed) / sum(gasUsed) + BNBToCoinbase/sum(gasUsed) * nativeScale

The nativeScale parameter in the calculation formula is setted to 2. The bundle with higher price will get higher priority to enter the bundle pool when the Direct Route service is congested.

4. API Change

Now that the Direct Route has the minimum gas price requirement for the bundle, users can get the suggested minimalGasPrice from the eth_bundlePrice API. Users can set the gas price to an equal or higher price than the suggested mininalGasPrice when submitting the transaction to ensure the bundle can be accepted by the service.

The example of new API:

curl -X POST — data ‘{“jsonrpc”:”2.0",”method”:”eth_bundlePrice”,”params”:[],”id”:83}’ -H “Content-Type: application/json”

Response: {“jsonrpc”:”2.0",”id”:83,”result”:{“bundlePrice”:20000000000,”minimalGasPrice”:20000000000}}

The minimalGasPrice will expire after 60 seconds and users need to fetch it again.

More detailed information can be found in the following documents:

  1. https://github.com/node-real/go-direct-route
  2. https://github.com/node-real/js-direct-route

Release plan

The new version is scheduled to release on January 28th between 10:00 and 14:00 UTC timezone, and at the same time our front-end trading interface Direct Route Swap will also be updated simultaneously.

We place our best attention to user’s feedback. Want to ask our team anything or stay up-to-date on any relevant news? Join us on our social media group to discuss more!

Follow us on Twitter

Join our Discord community