fixed bancor sell quotes

This commit is contained in:
Noah Khamliche
2022-06-02 21:57:13 -04:00
committed by Noah Khamliche
parent 8bfb58eba9
commit cc387ae176
6 changed files with 61 additions and 2 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "0.35.0",
"changes": [
{
"note": "Adds support for BancorV3 to EthereumBridgeAdapter",
"pr": 492
}
]
},
{
"version": "0.34.0",
"changes": [

View File

@@ -13,6 +13,10 @@
{
"note": "Add MeshSwap on Polygon",
"pr": 491
},
{
"note": "Added support for BancorV3 on ethereum mainnet",
"pr": 492
}
]
},

View File

@@ -26,11 +26,12 @@ import "./interfaces/IBancorV3.sol";
contract BancorV3Sampler
{
/// @dev Gas limit for BancorV3 calls.
uint256 constant private BancorV3_CALL_GAS = 150e3; // 150k
uint256 constant private BancorV3_CALL_GAS = 1500e3; // 150k
address constant public ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Sample sell quotes from BancorV3.
/// @param weth The WETH contract address
/// @param router Router to look up tokens and amounts
/// @param path Token route. Should be takerToken -> makerToken
/// @param takerTokenAmounts Taker token sell amount for each sample.
@@ -74,6 +75,7 @@ contract BancorV3Sampler
}
/// @dev Sample buy quotes from BancorV3.
/// @param weth The WETH contract address
/// @param router Router to look up tokens and amounts
/// @param path Token route. Should be takerToken -> makerToken.
/// @param makerTokenAmounts Maker token buy amount for each sample.

View File

@@ -227,7 +227,41 @@ export class MarketOperationUtils {
const [{ decimals: makerTokenDecimals }, { decimals: takerTokenDecimals }] = tokenInfos;
<<<<<<< HEAD
const isRfqSupported = !!_opts.rfqt;
=======
const [
[
blockNumber,
gasBefore,
tokenDecimals,
orderFillableTakerAmounts,
outputAmountPerEth,
inputAmountPerEth,
dexQuotes,
rawTwoHopQuotes,
isTxOriginContract,
gasAfter,
],
] = await Promise.all([samplerPromise]);
console.log(dexQuotes);
// Log the gas metrics
_opts.samplerMetrics?.logGasDetails({ gasBefore, gasAfter });
_opts.samplerMetrics?.logBlockNumber(blockNumber);
// Filter out any invalid two hop quotes where we couldn't find a route
const twoHopQuotes = rawTwoHopQuotes.filter(
q => q && q.fillData && q.fillData.firstHopSource && q.fillData.secondHopSource,
);
const [makerTokenDecimals, takerTokenDecimals] = tokenDecimals;
const isRfqSupported = !!(_opts.rfqt && !isTxOriginContract);
const limitOrdersWithFillableAmounts = nativeOrders.map((order, i) => ({
...order,
...getNativeAdjustedFillableAmountsFromTakerAmount(order, orderFillableTakerAmounts[i]),
}));
>>>>>>> 83da7caab (fixed bancor sell quotes)
return {
side: MarketOperation.Sell,

View File

@@ -722,7 +722,7 @@ export class SamplerOperations {
source: ERC20BridgeSource.BancorV3,
fillData: { networkAddress, path},
contract: this._samplerContract,
function: this._samplerContract.sampleBuysFromBancorV3,
function: this._samplerContract.sampleSellsFromBancorV3,
params: [MAINNET_TOKENS.WETH, networkInfoAddress, path, takerFillAmounts],
});
}

View File

@@ -1,4 +1,14 @@
[
{
"version": "11.14.0",
"changes": [
{
"note": "Adds Support for BancorV3 on Ethereum",
"pr": 492
}
],
},
{
"version": "11.13.0",
"changes": [