swap-orders-lib icon indicating copy to clipboard operation
swap-orders-lib copied to clipboard

Migrate nonEthereum chains to "gas-model"

Open HarryTgerman opened this issue 2 years ago • 0 comments

Currently, we calculate the fee for every limit order in two ways. On Ethereum, we calculate the Fee based on the gas cost. On other chains, the assumption was, that we can take a percentage "0.1%" of the order volume, which would pay for the transactions and because of that specify an exact execution price. This assumption proves to be wrong since transaction costs keep rising which means that the limit order volume on nonEth chains is not sufficient to pay for the transaction costs.

Solution: Switch "percentage-model" to "gas-model".

Step 1: In packages/limit-orders-lib/src/utils/index.ts hook, add side effect realExecutionPrice on Order object to open orders. Use useGasOverhead hook to calculate.

Step 2: in packages/limit-orders-lib/src/limit-orders/index.ts change isEthereumChain to usestransactionCostDependentFee, include new chainId's.

Step 3: In backend change isEthereumChain to usestransactionCostDependentFee

HarryTgerman avatar Feb 28 '22 15:02 HarryTgerman