Compare commits

...

3 Commits

Author SHA1 Message Date
Github Actions
bb04726e7f Publish
- @0x/contracts-integrations@2.7.42
 - @0x/asset-swapper@6.12.0
2021-05-10 01:36:49 +00:00
Github Actions
220ca370c2 Updated CHANGELOGS & MD docs 2021-05-10 01:36:44 +00:00
Jacob Evans
63af4e3e98 fix: TwoHopSampler call (#233) 2021-05-10 11:05:30 +10:00
8 changed files with 42 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-integrations",
"version": "2.7.41",
"version": "2.7.42",
"private": true,
"engines": {
"node": ">=6.12"
@@ -93,7 +93,7 @@
"typescript": "4.2.2"
},
"dependencies": {
"@0x/asset-swapper": "^6.11.0",
"@0x/asset-swapper": "^6.12.0",
"@0x/base-contract": "^6.4.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc1155": "^2.1.29",

View File

@@ -1,4 +1,14 @@
[
{
"version": "6.12.0",
"changes": [
{
"note": "`TwoHopSampler` to use `call` over `staticcall` in order to support sources like `Uniswap_V3` and `Balancer_V2`",
"pr": 233
}
],
"timestamp": 1620610602
},
{
"version": "6.11.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.12.0 - _May 10, 2021_
* `TwoHopSampler` to use `call` over `staticcall` in order to support sources like `Uniswap_V3` and `Balancer_V2` (#233)
## v6.11.0 - _May 7, 2021_
* Add price comparisons data separate from the quote report (#219)

View File

@@ -37,7 +37,6 @@ contract TwoHopSampler {
uint256 sellAmount
)
public
view
returns (
HopInfo memory firstHop,
HopInfo memory secondHop,
@@ -47,7 +46,7 @@ contract TwoHopSampler {
uint256 intermediateAssetAmount = 0;
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
firstHopCalls[i].writeUint256(firstHopCalls[i].length - 32, sellAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(firstHopCalls[i]);
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (amount > intermediateAssetAmount) {
@@ -62,7 +61,7 @@ contract TwoHopSampler {
}
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
secondHopCalls[j].writeUint256(secondHopCalls[j].length - 32, intermediateAssetAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(secondHopCalls[j]);
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (amount > buyAmount) {
@@ -80,7 +79,6 @@ contract TwoHopSampler {
uint256 buyAmount
)
public
view
returns (
HopInfo memory firstHop,
HopInfo memory secondHop,
@@ -91,7 +89,7 @@ contract TwoHopSampler {
uint256 intermediateAssetAmount = uint256(-1);
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
secondHopCalls[j].writeUint256(secondHopCalls[j].length - 32, buyAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(secondHopCalls[j]);
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (
@@ -109,7 +107,7 @@ contract TwoHopSampler {
}
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
firstHopCalls[i].writeUint256(firstHopCalls[i].length - 32, intermediateAssetAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(firstHopCalls[i]);
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (

View File

@@ -57,9 +57,9 @@ contract UniswapV3Sampler
/// @param quoter UniswapV3 Quoter contract.
/// @param path Token route. Should be takerToken -> makerToken
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return uniswapPaths The encoded uniswap path for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
/// @return uniswapPaths The encoded uniswap path for each sample.
function sampleSellsFromUniswapV3(
IUniswapV3Quoter quoter,
IERC20TokenV06[] memory path,
@@ -67,8 +67,8 @@ contract UniswapV3Sampler
)
public
returns (
uint256[] memory makerTokenAmounts,
bytes[] memory uniswapPaths
bytes[] memory uniswapPaths,
uint256[] memory makerTokenAmounts
)
{
IUniswapV3Pool[][] memory poolPaths =
@@ -108,9 +108,9 @@ contract UniswapV3Sampler
/// @param quoter UniswapV3 Quoter contract.
/// @param path Token route. Should be takerToken -> makerToken.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return uniswapPaths The encoded uniswap path for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
/// @return uniswapPaths The encoded uniswap path for each sample.
function sampleBuysFromUniswapV3(
IUniswapV3Quoter quoter,
IERC20TokenV06[] memory path,
@@ -118,8 +118,8 @@ contract UniswapV3Sampler
)
public
returns (
uint256[] memory takerTokenAmounts,
bytes[] memory uniswapPaths
bytes[] memory uniswapPaths,
uint256[] memory takerTokenAmounts
)
{
IUniswapV3Pool[][] memory poolPaths =

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "6.11.0",
"version": "6.12.0",
"engines": {
"node": ">=6.12"
},

View File

@@ -453,7 +453,10 @@ export const NATIVE_FEE_TOKEN_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);
export const NATIVE_FEE_TOKEN_AMOUNT_BY_CHAIN_ID = valueByChainId({}, ONE_ETHER);
export const NATIVE_FEE_TOKEN_AMOUNT_BY_CHAIN_ID = valueByChainId(
{ [ChainId.Mainnet]: ONE_ETHER.times(0.1) },
ONE_ETHER,
);
// Order dependent
const CURVE_TRI_POOL_MAINNET_TOKENS = [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC, MAINNET_TOKENS.USDT];

View File

@@ -1,6 +1,6 @@
import { ChainId } from '@0x/contract-addresses';
import { LimitOrderFields } from '@0x/protocol-utils';
import { BigNumber } from '@0x/utils';
import { BigNumber, logUtils } from '@0x/utils';
import * as _ from 'lodash';
import { SamplerCallResult, SignedNativeOrder } from '../../types';
@@ -692,7 +692,7 @@ export class SamplerOperations {
function: this._samplerContract.sampleSellsFromUniswapV3,
params: [quoter, tokenAddressPath, takerFillAmounts],
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
const [samples, paths] = this._samplerContract.getABIDecodedReturnData<[BigNumber[], string[]]>(
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleSellsFromUniswapV3',
callResults,
);
@@ -720,7 +720,7 @@ export class SamplerOperations {
function: this._samplerContract.sampleBuysFromUniswapV3,
params: [quoter, tokenAddressPath, makerFillAmounts],
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
const [samples, paths] = this._samplerContract.getABIDecodedReturnData<[BigNumber[], string[]]>(
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleBuysFromUniswapV3',
callResults,
);
@@ -783,7 +783,10 @@ export class SamplerOperations {
};
});
},
() => [],
() => {
logUtils.warn('SamplerContractOperation: Two hop sampler reverted');
return [];
},
);
}
@@ -838,7 +841,10 @@ export class SamplerOperations {
};
});
},
() => [],
() => {
logUtils.warn('SamplerContractOperation: Two hop sampler reverted');
return [];
},
);
}