Update for buys
This commit is contained in:
@@ -130,6 +130,29 @@ contract BalancerSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Balancer.
|
||||||
|
/// @param poolAddress Address of the Balancer pool to query.
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromBalancerGlobal(
|
||||||
|
address poolAddress,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromBalancer(
|
||||||
|
poolAddress,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Balancer.
|
/// @dev Sample buy quotes from Balancer.
|
||||||
/// @param poolAddress Address of the Balancer pool to query.
|
/// @param poolAddress Address of the Balancer pool to query.
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -137,13 +160,13 @@ contract BalancerSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromBalancer(
|
function _sampleBuysFromBalancer(
|
||||||
address poolAddress,
|
address poolAddress,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -135,6 +135,28 @@ contract BalancerV2Sampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Balancer V2.
|
||||||
|
/// @param poolInfo Struct with pool related data
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromBalancerV2Global(
|
||||||
|
BalancerV2PoolInfo memory poolInfo,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromBalancerV2(
|
||||||
|
poolInfo,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Balancer V2.
|
/// @dev Sample buy quotes from Balancer V2.
|
||||||
/// @param poolInfo Struct with pool related data
|
/// @param poolInfo Struct with pool related data
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -142,13 +164,13 @@ contract BalancerV2Sampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromBalancerV2(
|
function _sampleBuysFromBalancerV2(
|
||||||
BalancerV2PoolInfo memory poolInfo,
|
BalancerV2PoolInfo memory poolInfo,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
_assertValidPair(makerToken, takerToken);
|
_assertValidPair(makerToken, takerToken);
|
||||||
|
|||||||
@@ -112,21 +112,20 @@ contract BancorSampler is
|
|||||||
/// @param opts BancorSamplerOpts The Bancor registry contract address and paths
|
/// @param opts BancorSamplerOpts The Bancor registry contract address and paths
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
/// @param makerToken Address of the maker token (what to buy).
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
|
||||||
/// @return bancorNetwork the Bancor Network address
|
/// @return bancorNetwork the Bancor Network address
|
||||||
/// @return path the selected conversion path from bancor
|
/// @return path the selected conversion path from bancor
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromBancor(
|
function sampleBuysFromBancorGlobal(
|
||||||
BancorSamplerOpts memory opts,
|
BancorSamplerOpts memory opts,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken
|
||||||
uint256[] memory makerTokenAmounts
|
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
returns (address bancorNetwork, address[] memory path, uint256[] memory takerTokenAmounts)
|
returns (address bancorNetwork, address[] memory path, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
takerTokenAmounts = new uint256[](SAMPLE_VALUES.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _findBestPath(
|
function _findBestPath(
|
||||||
|
|||||||
@@ -86,13 +86,30 @@ contract CompoundSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleBuysFromCompound(
|
function sampleBuysFromCompoundGlobal(
|
||||||
|
ICToken cToken,
|
||||||
|
IERC20TokenV06 takerToken,
|
||||||
|
IERC20TokenV06 makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromCompound(
|
||||||
|
cToken,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _sampleBuysFromCompound(
|
||||||
ICToken cToken,
|
ICToken cToken,
|
||||||
IERC20TokenV06 takerToken,
|
IERC20TokenV06 takerToken,
|
||||||
IERC20TokenV06 makerToken,
|
IERC20TokenV06 makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,6 +105,29 @@ contract CurveSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Curve.
|
||||||
|
/// @param curveInfo Curve information specific to this token pair.
|
||||||
|
/// @param fromTokenIdx Index of the taker token (what to sell).
|
||||||
|
/// @param toTokenIdx Index of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromCurveGlobal(
|
||||||
|
CurveInfo memory curveInfo,
|
||||||
|
int128 fromTokenIdx,
|
||||||
|
int128 toTokenIdx
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromCurve(
|
||||||
|
curveInfo,
|
||||||
|
fromTokenIdx,
|
||||||
|
toTokenIdx,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Curve.
|
/// @dev Sample buy quotes from Curve.
|
||||||
/// @param curveInfo Curve information specific to this token pair.
|
/// @param curveInfo Curve information specific to this token pair.
|
||||||
/// @param fromTokenIdx Index of the taker token (what to sell).
|
/// @param fromTokenIdx Index of the taker token (what to sell).
|
||||||
@@ -112,13 +135,13 @@ contract CurveSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromCurve(
|
function _sampleBuysFromCurve(
|
||||||
CurveInfo memory curveInfo,
|
CurveInfo memory curveInfo,
|
||||||
int128 fromTokenIdx,
|
int128 fromTokenIdx,
|
||||||
int128 toTokenIdx,
|
int128 toTokenIdx,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,6 +134,31 @@ contract DODOSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from DODO.
|
||||||
|
/// @param opts DODOSamplerOpts DODO Registry and helper addresses
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return sellBase whether the bridge needs to sell the base token
|
||||||
|
/// @return pool the DODO pool address
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromDODOGlobal(
|
||||||
|
DODOSamplerOpts memory opts,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(sellBase, pool, takerTokenAmounts) = _sampleBuysFromDODO(
|
||||||
|
opts,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from DODO.
|
/// @dev Sample buy quotes from DODO.
|
||||||
/// @param opts DODOSamplerOpts DODO Registry and helper addresses
|
/// @param opts DODOSamplerOpts DODO Registry and helper addresses
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -143,13 +168,13 @@ contract DODOSampler is
|
|||||||
/// @return pool the DODO pool address
|
/// @return pool the DODO pool address
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromDODO(
|
function _sampleBuysFromDODO(
|
||||||
DODOSamplerOpts memory opts,
|
DODOSamplerOpts memory opts,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,6 +125,34 @@ contract DODOV2Sampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from DODO.
|
||||||
|
/// @param registry Address of the registry to look up.
|
||||||
|
/// @param offset offset index for the pool in the registry.
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return sellBase whether the bridge needs to sell the base token
|
||||||
|
/// @return pool the DODO pool address
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromDODOV2Global(
|
||||||
|
address registry,
|
||||||
|
uint256 offset,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(sellBase, pool, takerTokenAmounts) = _sampleBuysFromDODOV2(
|
||||||
|
registry,
|
||||||
|
offset,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from DODO.
|
/// @dev Sample buy quotes from DODO.
|
||||||
/// @param registry Address of the registry to look up.
|
/// @param registry Address of the registry to look up.
|
||||||
/// @param offset offset index for the pool in the registry.
|
/// @param offset offset index for the pool in the registry.
|
||||||
@@ -135,14 +163,14 @@ contract DODOV2Sampler is
|
|||||||
/// @return pool the DODO pool address
|
/// @return pool the DODO pool address
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromDODOV2(
|
function _sampleBuysFromDODOV2(
|
||||||
address registry,
|
address registry,
|
||||||
uint256 offset,
|
uint256 offset,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
returns (bool sellBase, address pool, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,6 +122,27 @@ contract KyberDmmSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from KyberDmm.
|
||||||
|
/// @param router Router to look up tokens and amounts
|
||||||
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
|
/// @return pools The pool addresses involved in the multi path trade
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromKyberDmmGlobal(
|
||||||
|
address router,
|
||||||
|
address[] memory path
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (address[] memory pools, uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(pools, takerTokenAmounts) = _sampleBuysFromKyberDmm(
|
||||||
|
router,
|
||||||
|
path,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from KyberDmm.
|
/// @dev Sample buy quotes from KyberDmm.
|
||||||
/// @param router Router to look up tokens and amounts
|
/// @param router Router to look up tokens and amounts
|
||||||
/// @param path Token route. Should be takerToken -> makerToken.
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
@@ -129,12 +150,12 @@ contract KyberDmmSampler is
|
|||||||
/// @return pools The pool addresses involved in the multi path trade
|
/// @return pools The pool addresses involved in the multi path trade
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromKyberDmm(
|
function _sampleBuysFromKyberDmm(
|
||||||
address router,
|
address router,
|
||||||
address[] memory path,
|
address[] memory path,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (address[] memory pools, uint256[] memory takerTokenAmounts)
|
returns (address[] memory pools, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,6 +111,30 @@ contract KyberSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Kyber.
|
||||||
|
/// @param opts KyberSamplerOpts The nth reserve
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return reserveId The id of the reserve found at reserveOffset
|
||||||
|
/// @return hint The hint for the selected reserve
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
|
||||||
|
function sampleBuysFromKyberNetworkGlobal(
|
||||||
|
KyberSamplerOpts memory opts,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (bytes32 reserveId, bytes memory hint, uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(reserveId, hint, takerTokenAmounts) = _sampleBuysFromKyberNetwork(
|
||||||
|
opts,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Kyber.
|
/// @dev Sample buy quotes from Kyber.
|
||||||
/// @param opts KyberSamplerOpts The nth reserve
|
/// @param opts KyberSamplerOpts The nth reserve
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -119,13 +143,13 @@ contract KyberSampler is
|
|||||||
/// @return reserveId The id of the reserve found at reserveOffset
|
/// @return reserveId The id of the reserve found at reserveOffset
|
||||||
/// @return hint The hint for the selected reserve
|
/// @return hint The hint for the selected reserve
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
|
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
|
||||||
function sampleBuysFromKyberNetwork(
|
function _sampleBuysFromKyberNetwork(
|
||||||
KyberSamplerOpts memory opts,
|
KyberSamplerOpts memory opts,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (bytes32 reserveId, bytes memory hint, uint256[] memory takerTokenAmounts)
|
returns (bytes32 reserveId, bytes memory hint, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,6 +85,29 @@ contract LidoSampler is
|
|||||||
return takerTokenAmounts;
|
return takerTokenAmounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Lido.
|
||||||
|
/// @param lidoInfo Info regarding a specific Lido deployment
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromLidoGlobal(
|
||||||
|
LidoInfo memory lidoInfo,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromLido(
|
||||||
|
lidoInfo,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Lido.
|
/// @dev Sample buy quotes from Lido.
|
||||||
/// @param lidoInfo Info regarding a specific Lido deployment
|
/// @param lidoInfo Info regarding a specific Lido deployment
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -92,13 +115,13 @@ contract LidoSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromLido(
|
function _sampleBuysFromLido(
|
||||||
LidoInfo memory lidoInfo,
|
LidoInfo memory lidoInfo,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
pure
|
pure
|
||||||
returns (uint256[] memory)
|
returns (uint256[] memory)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,6 +102,29 @@ contract LiquidityProviderSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
|
||||||
|
/// @param providerAddress Address of the liquidity provider.
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromLiquidityProviderGlobal(
|
||||||
|
address providerAddress,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(takerTokenAmounts) = _sampleBuysFromLiquidityProvider(
|
||||||
|
providerAddress,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
|
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
|
||||||
/// @param providerAddress Address of the liquidity provider.
|
/// @param providerAddress Address of the liquidity provider.
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -109,13 +132,13 @@ contract LiquidityProviderSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromLiquidityProvider(
|
function _sampleBuysFromLiquidityProvider(
|
||||||
address providerAddress,
|
address providerAddress,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,6 +97,29 @@ contract MStableSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from MStable contract
|
||||||
|
/// @param router Address of the mStable contract
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromMStableGlobal(
|
||||||
|
address router,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(takerTokenAmounts) = _sampleBuysFromMStable(
|
||||||
|
router,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from MStable contract
|
/// @dev Sample buy quotes from MStable contract
|
||||||
/// @param router Address of the mStable contract
|
/// @param router Address of the mStable contract
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -104,13 +127,13 @@ contract MStableSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromMStable(
|
function _sampleBuysFromMStable(
|
||||||
address router,
|
address router,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -157,13 +157,30 @@ contract MakerPSMSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleBuysFromMakerPsm(
|
function sampleBuysFromMakerPsmGlobal(
|
||||||
|
MakerPsmInfo memory psmInfo,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(takerTokenAmounts) = _sampleBuysFromMakerPsm(
|
||||||
|
psmInfo,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _sampleBuysFromMakerPsm(
|
||||||
MakerPsmInfo memory psmInfo,
|
MakerPsmInfo memory psmInfo,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,6 +138,30 @@ contract MooniswapSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Mooniswap.
|
||||||
|
/// @param registry Address of the Mooniswap Registry.
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return pool The contract address for the pool
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromMooniswapGlobal(
|
||||||
|
address registry,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (IMooniswap pool, uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
(pool, takerTokenAmounts) = _sampleBuysFromMooniswap(
|
||||||
|
registry,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Mooniswap.
|
/// @dev Sample buy quotes from Mooniswap.
|
||||||
/// @param registry Address of the Mooniswap Registry.
|
/// @param registry Address of the Mooniswap Registry.
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -146,13 +170,13 @@ contract MooniswapSampler is
|
|||||||
/// @return pool The contract address for the pool
|
/// @return pool The contract address for the pool
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromMooniswap(
|
function _sampleBuysFromMooniswap(
|
||||||
address registry,
|
address registry,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (IMooniswap pool, uint256[] memory takerTokenAmounts)
|
returns (IMooniswap pool, uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,6 +98,29 @@ contract ShellSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Shell pool contract
|
||||||
|
/// @param pool Address of the Shell pool contract
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromShellGlobal(
|
||||||
|
address pool,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromShell(
|
||||||
|
pool,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Shell pool contract
|
/// @dev Sample buy quotes from Shell pool contract
|
||||||
/// @param pool Address of the Shell pool contract
|
/// @param pool Address of the Shell pool contract
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
@@ -105,13 +128,13 @@ contract ShellSampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromShell(
|
function _sampleBuysFromShell(
|
||||||
address pool,
|
address pool,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -123,6 +123,29 @@ contract SmoothySampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Smoothy.
|
||||||
|
/// @param smoothyInfo Smoothy information specific to this token pair.
|
||||||
|
/// @param fromTokenIdx Index of the taker token (what to sell).
|
||||||
|
/// @param toTokenIdx Index of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromSmoothyGlobal(
|
||||||
|
SmoothyInfo memory smoothyInfo,
|
||||||
|
int128 fromTokenIdx,
|
||||||
|
int128 toTokenIdx
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromSmoothy(
|
||||||
|
smoothyInfo,
|
||||||
|
fromTokenIdx,
|
||||||
|
toTokenIdx,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Smoothy.
|
/// @dev Sample buy quotes from Smoothy.
|
||||||
/// @param smoothyInfo Smoothy information specific to this token pair.
|
/// @param smoothyInfo Smoothy information specific to this token pair.
|
||||||
/// @param fromTokenIdx Index of the taker token (what to sell).
|
/// @param fromTokenIdx Index of the taker token (what to sell).
|
||||||
@@ -130,13 +153,13 @@ contract SmoothySampler is
|
|||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromSmoothy(
|
function _sampleBuysFromSmoothy(
|
||||||
SmoothyInfo memory smoothyInfo,
|
SmoothyInfo memory smoothyInfo,
|
||||||
int128 fromTokenIdx,
|
int128 fromTokenIdx,
|
||||||
int128 toTokenIdx,
|
int128 toTokenIdx,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ contract TwoHopSampler is
|
|||||||
bytes[] memory firstHopCalls,
|
bytes[] memory firstHopCalls,
|
||||||
bytes[] memory secondHopCalls,
|
bytes[] memory secondHopCalls,
|
||||||
uint256 buyAmount
|
uint256 buyAmount
|
||||||
)
|
)
|
||||||
|
resetsSampleValues()
|
||||||
public
|
public
|
||||||
returns (
|
returns (
|
||||||
HopInfo memory firstHop,
|
HopInfo memory firstHop,
|
||||||
@@ -96,8 +97,11 @@ contract TwoHopSampler is
|
|||||||
{
|
{
|
||||||
sellAmount = uint256(-1);
|
sellAmount = uint256(-1);
|
||||||
uint256 intermediateAssetAmount = uint256(-1);
|
uint256 intermediateAssetAmount = uint256(-1);
|
||||||
|
uint256[] memory tmpSampleValues = new uint256[](1);
|
||||||
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
|
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
|
||||||
secondHopCalls[j].writeUint256(secondHopCalls[j].length - 32, buyAmount);
|
// Set the temporary global sample values
|
||||||
|
tmpSampleValues[0] = buyAmount;
|
||||||
|
SAMPLE_VALUES = tmpSampleValues;
|
||||||
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
|
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
|
||||||
if (didSucceed) {
|
if (didSucceed) {
|
||||||
uint256 amount = returnData.readUint256(returnData.length - 32);
|
uint256 amount = returnData.readUint256(returnData.length - 32);
|
||||||
@@ -115,7 +119,9 @@ contract TwoHopSampler is
|
|||||||
return (firstHop, secondHop, sellAmount);
|
return (firstHop, secondHop, sellAmount);
|
||||||
}
|
}
|
||||||
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
|
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
|
||||||
firstHopCalls[i].writeUint256(firstHopCalls[i].length - 32, intermediateAssetAmount);
|
// Set the temporary global sample values
|
||||||
|
tmpSampleValues[0] = intermediateAssetAmount;
|
||||||
|
SAMPLE_VALUES = tmpSampleValues;
|
||||||
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
|
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
|
||||||
if (didSucceed) {
|
if (didSucceed) {
|
||||||
uint256 amount = returnData.readUint256(returnData.length - 32);
|
uint256 amount = returnData.readUint256(returnData.length - 32);
|
||||||
|
|||||||
@@ -128,19 +128,41 @@ contract UniswapSampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from Uniswap.
|
||||||
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromUniswapGlobal(
|
||||||
|
address router,
|
||||||
|
address takerToken,
|
||||||
|
address makerToken
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromUniswap(
|
||||||
|
router,
|
||||||
|
takerToken,
|
||||||
|
makerToken,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from Uniswap.
|
/// @dev Sample buy quotes from Uniswap.
|
||||||
/// @param takerToken Address of the taker token (what to sell).
|
/// @param takerToken Address of the taker token (what to sell).
|
||||||
/// @param makerToken Address of the maker token (what to buy).
|
/// @param makerToken Address of the maker token (what to buy).
|
||||||
/// @param makerTokenAmounts Maker token sell amount for each sample.
|
/// @param makerTokenAmounts Maker token sell amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromUniswap(
|
function _sampleBuysFromUniswap(
|
||||||
address router,
|
address router,
|
||||||
address takerToken,
|
address takerToken,
|
||||||
address makerToken,
|
address makerToken,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,18 +86,38 @@ contract UniswapV2Sampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from UniswapV2.
|
||||||
|
/// @param router Router to look up tokens and amounts
|
||||||
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromUniswapV2Global(
|
||||||
|
address router,
|
||||||
|
address[] memory path
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
|
{
|
||||||
|
takerTokenAmounts = _sampleBuysFromUniswapV2(
|
||||||
|
router,
|
||||||
|
path,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from UniswapV2.
|
/// @dev Sample buy quotes from UniswapV2.
|
||||||
/// @param router Router to look up tokens and amounts
|
/// @param router Router to look up tokens and amounts
|
||||||
/// @param path Token route. Should be takerToken -> makerToken.
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromUniswapV2(
|
function _sampleBuysFromUniswapV2(
|
||||||
address router,
|
address router,
|
||||||
address[] memory path,
|
address[] memory path,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256[] memory takerTokenAmounts)
|
returns (uint256[] memory takerTokenAmounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,6 +128,29 @@ contract UniswapV3Sampler is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Sample buy quotes from UniswapV3.
|
||||||
|
/// @param quoter UniswapV3 Quoter contract.
|
||||||
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
|
/// @return uniswapPaths The encoded uniswap path for each sample.
|
||||||
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
|
/// amount.
|
||||||
|
function sampleBuysFromUniswapV3Global(
|
||||||
|
IUniswapV3Quoter quoter,
|
||||||
|
IERC20TokenV06[] memory path
|
||||||
|
)
|
||||||
|
public
|
||||||
|
returns (
|
||||||
|
bytes[] memory uniswapPaths,
|
||||||
|
uint256[] memory takerTokenAmounts
|
||||||
|
)
|
||||||
|
{
|
||||||
|
(uniswapPaths, takerTokenAmounts) = _sampleBuysFromUniswapV3(
|
||||||
|
quoter,
|
||||||
|
path,
|
||||||
|
SAMPLE_VALUES
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Sample buy quotes from UniswapV3.
|
/// @dev Sample buy quotes from UniswapV3.
|
||||||
/// @param quoter UniswapV3 Quoter contract.
|
/// @param quoter UniswapV3 Quoter contract.
|
||||||
/// @param path Token route. Should be takerToken -> makerToken.
|
/// @param path Token route. Should be takerToken -> makerToken.
|
||||||
@@ -135,12 +158,12 @@ contract UniswapV3Sampler is
|
|||||||
/// @return uniswapPaths The encoded uniswap path for each sample.
|
/// @return uniswapPaths The encoded uniswap path for each sample.
|
||||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||||
/// amount.
|
/// amount.
|
||||||
function sampleBuysFromUniswapV3(
|
function _sampleBuysFromUniswapV3(
|
||||||
IUniswapV3Quoter quoter,
|
IUniswapV3Quoter quoter,
|
||||||
IERC20TokenV06[] memory path,
|
IERC20TokenV06[] memory path,
|
||||||
uint256[] memory makerTokenAmounts
|
uint256[] memory makerTokenAmounts
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
returns (
|
returns (
|
||||||
bytes[] memory uniswapPaths,
|
bytes[] memory uniswapPaths,
|
||||||
uint256[] memory takerTokenAmounts
|
uint256[] memory takerTokenAmounts
|
||||||
|
|||||||
@@ -286,17 +286,17 @@ export class SamplerOperations {
|
|||||||
reserveOffset: BigNumber,
|
reserveOffset: BigNumber,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation {
|
): SourceQuoteOperation {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Kyber,
|
source: ERC20BridgeSource.Kyber,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromKyberNetwork,
|
function: this._samplerContract.sampleBuysFromKyberNetworkGlobal,
|
||||||
params: [{ ...kyberOpts, reserveOffset, hint: NULL_BYTES }, takerToken, makerToken, makerFillAmounts],
|
params: [{ ...kyberOpts, reserveOffset, hint: NULL_BYTES }, takerToken, makerToken],
|
||||||
callback: (callResults: string, fillData: KyberFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: KyberFillData): BigNumber[] => {
|
||||||
const [reserveId, hint, samples] = this._samplerContract.getABIDecodedReturnData<
|
const [reserveId, hint, samples] = this._samplerContract.getABIDecodedReturnData<
|
||||||
[string, string, BigNumber[]]
|
[string, string, BigNumber[]]
|
||||||
>('sampleBuysFromKyberNetwork', callResults);
|
>('sampleBuysFromKyberNetworkGlobal', callResults);
|
||||||
fillData.hint = hint;
|
fillData.hint = hint;
|
||||||
fillData.reserveId = reserveId;
|
fillData.reserveId = reserveId;
|
||||||
fillData.networkProxy = kyberOpts.networkProxy;
|
fillData.networkProxy = kyberOpts.networkProxy;
|
||||||
@@ -331,16 +331,16 @@ export class SamplerOperations {
|
|||||||
public getKyberDmmBuyQuotes(
|
public getKyberDmmBuyQuotes(
|
||||||
router: string,
|
router: string,
|
||||||
tokenAddressPath: string[],
|
tokenAddressPath: string[],
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<KyberDmmFillData> {
|
): SourceQuoteOperation<KyberDmmFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.KyberDmm,
|
source: ERC20BridgeSource.KyberDmm,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromKyberDmm,
|
function: this._samplerContract.sampleBuysFromKyberDmmGlobal,
|
||||||
params: [router, tokenAddressPath, makerFillAmounts],
|
params: [router, tokenAddressPath],
|
||||||
callback: (callResults: string, fillData: KyberDmmFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: KyberDmmFillData): BigNumber[] => {
|
||||||
const [pools, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
|
const [pools, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
|
||||||
'sampleBuysFromKyberDmm',
|
'sampleBuysFromKyberDmmGlobal',
|
||||||
callResults,
|
callResults,
|
||||||
);
|
);
|
||||||
fillData.poolsPath = pools;
|
fillData.poolsPath = pools;
|
||||||
@@ -373,7 +373,7 @@ export class SamplerOperations {
|
|||||||
router: string,
|
router: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<GenericRouterFillData> {
|
): SourceQuoteOperation<GenericRouterFillData> {
|
||||||
// Uniswap uses ETH instead of WETH, represented by address(0)
|
// Uniswap uses ETH instead of WETH, represented by address(0)
|
||||||
const uniswapTakerToken = takerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : takerToken;
|
const uniswapTakerToken = takerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : takerToken;
|
||||||
@@ -382,8 +382,8 @@ export class SamplerOperations {
|
|||||||
source: ERC20BridgeSource.Uniswap,
|
source: ERC20BridgeSource.Uniswap,
|
||||||
fillData: { router },
|
fillData: { router },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromUniswap,
|
function: this._samplerContract.sampleBuysFromUniswapGlobal,
|
||||||
params: [router, uniswapTakerToken, uniswapMakerToken, makerFillAmounts],
|
params: [router, uniswapTakerToken, uniswapMakerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,15 +405,15 @@ export class SamplerOperations {
|
|||||||
public getUniswapV2BuyQuotes(
|
public getUniswapV2BuyQuotes(
|
||||||
router: string,
|
router: string,
|
||||||
tokenAddressPath: string[],
|
tokenAddressPath: string[],
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
source: ERC20BridgeSource = ERC20BridgeSource.UniswapV2,
|
source: ERC20BridgeSource = ERC20BridgeSource.UniswapV2,
|
||||||
): SourceQuoteOperation<UniswapV2FillData> {
|
): SourceQuoteOperation<UniswapV2FillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source,
|
source,
|
||||||
fillData: { tokenAddressPath, router },
|
fillData: { tokenAddressPath, router },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromUniswapV2,
|
function: this._samplerContract.sampleBuysFromUniswapV2Global,
|
||||||
params: [router, tokenAddressPath, makerFillAmounts],
|
params: [router, tokenAddressPath],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ export class SamplerOperations {
|
|||||||
providerAddress: string,
|
providerAddress: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
gasCost: number,
|
gasCost: number,
|
||||||
source: ERC20BridgeSource = ERC20BridgeSource.LiquidityProvider,
|
source: ERC20BridgeSource = ERC20BridgeSource.LiquidityProvider,
|
||||||
): SourceQuoteOperation<LiquidityProviderFillData> {
|
): SourceQuoteOperation<LiquidityProviderFillData> {
|
||||||
@@ -452,8 +452,8 @@ export class SamplerOperations {
|
|||||||
gasCost,
|
gasCost,
|
||||||
},
|
},
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromLiquidityProvider,
|
function: this._samplerContract.sampleBuysFromLiquidityProviderGlobal,
|
||||||
params: [providerAddress, takerToken, makerToken, makerFillAmounts],
|
params: [providerAddress, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ export class SamplerOperations {
|
|||||||
pool: CurveInfo,
|
pool: CurveInfo,
|
||||||
fromTokenIdx: number,
|
fromTokenIdx: number,
|
||||||
toTokenIdx: number,
|
toTokenIdx: number,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
source: ERC20BridgeSource = ERC20BridgeSource.Curve,
|
source: ERC20BridgeSource = ERC20BridgeSource.Curve,
|
||||||
): SourceQuoteOperation<CurveFillData> {
|
): SourceQuoteOperation<CurveFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
@@ -500,7 +500,7 @@ export class SamplerOperations {
|
|||||||
toTokenIdx,
|
toTokenIdx,
|
||||||
},
|
},
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromCurve,
|
function: this._samplerContract.sampleBuysFromCurveGlobal,
|
||||||
params: [
|
params: [
|
||||||
{
|
{
|
||||||
poolAddress: pool.poolAddress,
|
poolAddress: pool.poolAddress,
|
||||||
@@ -509,7 +509,6 @@ export class SamplerOperations {
|
|||||||
},
|
},
|
||||||
new BigNumber(fromTokenIdx),
|
new BigNumber(fromTokenIdx),
|
||||||
new BigNumber(toTokenIdx),
|
new BigNumber(toTokenIdx),
|
||||||
makerFillAmounts,
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -545,7 +544,7 @@ export class SamplerOperations {
|
|||||||
pool: CurveInfo,
|
pool: CurveInfo,
|
||||||
fromTokenIdx: number,
|
fromTokenIdx: number,
|
||||||
toTokenIdx: number,
|
toTokenIdx: number,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<CurveFillData> {
|
): SourceQuoteOperation<CurveFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Smoothy,
|
source: ERC20BridgeSource.Smoothy,
|
||||||
@@ -555,7 +554,7 @@ export class SamplerOperations {
|
|||||||
toTokenIdx,
|
toTokenIdx,
|
||||||
},
|
},
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromSmoothy,
|
function: this._samplerContract.sampleBuysFromSmoothyGlobal,
|
||||||
params: [
|
params: [
|
||||||
{
|
{
|
||||||
poolAddress: pool.poolAddress,
|
poolAddress: pool.poolAddress,
|
||||||
@@ -564,7 +563,6 @@ export class SamplerOperations {
|
|||||||
},
|
},
|
||||||
new BigNumber(fromTokenIdx),
|
new BigNumber(fromTokenIdx),
|
||||||
new BigNumber(toTokenIdx),
|
new BigNumber(toTokenIdx),
|
||||||
makerFillAmounts,
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -589,15 +587,15 @@ export class SamplerOperations {
|
|||||||
poolInfo: BalancerV2PoolInfo,
|
poolInfo: BalancerV2PoolInfo,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
source: ERC20BridgeSource,
|
source: ERC20BridgeSource,
|
||||||
): SourceQuoteOperation<BalancerV2FillData> {
|
): SourceQuoteOperation<BalancerV2FillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source,
|
source,
|
||||||
fillData: poolInfo,
|
fillData: poolInfo,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromBalancerV2,
|
function: this._samplerContract.sampleBuysFromBalancerV2Global,
|
||||||
params: [poolInfo, takerToken, makerToken, makerFillAmounts],
|
params: [poolInfo, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,15 +619,15 @@ export class SamplerOperations {
|
|||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
source: ERC20BridgeSource,
|
source: ERC20BridgeSource,
|
||||||
): SourceQuoteOperation<BalancerFillData> {
|
): SourceQuoteOperation<BalancerFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source,
|
source,
|
||||||
fillData: { poolAddress },
|
fillData: { poolAddress },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromBalancer,
|
function: this._samplerContract.sampleBuysFromBalancerGlobal,
|
||||||
params: [poolAddress, takerToken, makerToken, makerFillAmounts],
|
params: [poolAddress, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,14 +650,14 @@ export class SamplerOperations {
|
|||||||
router: string,
|
router: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<GenericRouterFillData> {
|
): SourceQuoteOperation<GenericRouterFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.MStable,
|
source: ERC20BridgeSource.MStable,
|
||||||
fillData: { router },
|
fillData: { router },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromMStable,
|
function: this._samplerContract.sampleBuysFromMStableGlobal,
|
||||||
params: [router, takerToken, makerToken, makerFillAmounts],
|
params: [router, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,17 +689,17 @@ export class SamplerOperations {
|
|||||||
registry: string,
|
registry: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<BancorFillData> {
|
): SourceQuoteOperation<BancorFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Bancor,
|
source: ERC20BridgeSource.Bancor,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromBancor,
|
function: this._samplerContract.sampleBuysFromBancorGlobal,
|
||||||
params: [{ registry, paths: [] }, takerToken, makerToken, makerFillAmounts],
|
params: [{ registry, paths: [] }, takerToken, makerToken],
|
||||||
callback: (callResults: string, fillData: BancorFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: BancorFillData): BigNumber[] => {
|
||||||
const [networkAddress, path, samples] = this._samplerContract.getABIDecodedReturnData<
|
const [networkAddress, path, samples] = this._samplerContract.getABIDecodedReturnData<
|
||||||
[string, string[], BigNumber[]]
|
[string, string[], BigNumber[]]
|
||||||
>('sampleBuysFromBancor', callResults);
|
>('sampleBuysFromBancorGlobal', callResults);
|
||||||
fillData.networkAddress = networkAddress;
|
fillData.networkAddress = networkAddress;
|
||||||
fillData.path = path;
|
fillData.path = path;
|
||||||
return samples;
|
return samples;
|
||||||
@@ -740,7 +738,7 @@ export class SamplerOperations {
|
|||||||
registry: string,
|
registry: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<MooniswapFillData> {
|
): SourceQuoteOperation<MooniswapFillData> {
|
||||||
// Mooniswap uses ETH instead of WETH, represented by address(0)
|
// Mooniswap uses ETH instead of WETH, represented by address(0)
|
||||||
const mooniswapTakerToken =
|
const mooniswapTakerToken =
|
||||||
@@ -750,11 +748,11 @@ export class SamplerOperations {
|
|||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Mooniswap,
|
source: ERC20BridgeSource.Mooniswap,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromMooniswap,
|
function: this._samplerContract.sampleBuysFromMooniswapGlobal,
|
||||||
params: [registry, mooniswapTakerToken, mooniswapMakerToken, makerFillAmounts],
|
params: [registry, mooniswapTakerToken, mooniswapMakerToken],
|
||||||
callback: (callResults: string, fillData: MooniswapFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: MooniswapFillData): BigNumber[] => {
|
||||||
const [poolAddress, samples] = this._samplerContract.getABIDecodedReturnData<[string, BigNumber[]]>(
|
const [poolAddress, samples] = this._samplerContract.getABIDecodedReturnData<[string, BigNumber[]]>(
|
||||||
'sampleBuysFromMooniswap',
|
'sampleBuysFromMooniswapGlobal',
|
||||||
callResults,
|
callResults,
|
||||||
);
|
);
|
||||||
fillData.poolAddress = poolAddress;
|
fillData.poolAddress = poolAddress;
|
||||||
@@ -801,11 +799,11 @@ export class SamplerOperations {
|
|||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source,
|
source,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromUniswapV3,
|
function: this._samplerContract.sampleBuysFromUniswapV3Global,
|
||||||
params: [quoter, tokenAddressPath, makerFillAmounts],
|
params: [quoter, tokenAddressPath],
|
||||||
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
|
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
|
||||||
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
|
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
|
||||||
'sampleBuysFromUniswapV3',
|
'sampleBuysFromUniswapV3Global',
|
||||||
callResults,
|
callResults,
|
||||||
);
|
);
|
||||||
fillData.router = router;
|
fillData.router = router;
|
||||||
@@ -952,15 +950,15 @@ export class SamplerOperations {
|
|||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
source: ERC20BridgeSource = ERC20BridgeSource.Shell,
|
source: ERC20BridgeSource = ERC20BridgeSource.Shell,
|
||||||
): SourceQuoteOperation {
|
): SourceQuoteOperation {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source,
|
source,
|
||||||
fillData: { poolAddress },
|
fillData: { poolAddress },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromShell,
|
function: this._samplerContract.sampleBuysFromShellGlobal,
|
||||||
params: [poolAddress, takerToken, makerToken, makerFillAmounts],
|
params: [poolAddress, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,7 +976,7 @@ export class SamplerOperations {
|
|||||||
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
||||||
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
||||||
[boolean, string, BigNumber[]]
|
[boolean, string, BigNumber[]]
|
||||||
>('sampleSellsFromDODO', callResults);
|
>('sampleSellsFromDODOGlobal', callResults);
|
||||||
fillData.isSellBase = isSellBase;
|
fillData.isSellBase = isSellBase;
|
||||||
fillData.poolAddress = pool;
|
fillData.poolAddress = pool;
|
||||||
fillData.helperAddress = opts.helper;
|
fillData.helperAddress = opts.helper;
|
||||||
@@ -991,17 +989,17 @@ export class SamplerOperations {
|
|||||||
opts: { registry: string; helper: string },
|
opts: { registry: string; helper: string },
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<DODOFillData> {
|
): SourceQuoteOperation<DODOFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Dodo,
|
source: ERC20BridgeSource.Dodo,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromDODO,
|
function: this._samplerContract.sampleBuysFromDODOGlobal,
|
||||||
params: [opts, takerToken, makerToken, makerFillAmounts],
|
params: [opts, takerToken, makerToken],
|
||||||
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
||||||
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
||||||
[boolean, string, BigNumber[]]
|
[boolean, string, BigNumber[]]
|
||||||
>('sampleBuysFromDODO', callResults);
|
>('sampleBuysFromDODOGlobal', callResults);
|
||||||
fillData.isSellBase = isSellBase;
|
fillData.isSellBase = isSellBase;
|
||||||
fillData.poolAddress = pool;
|
fillData.poolAddress = pool;
|
||||||
fillData.helperAddress = opts.helper;
|
fillData.helperAddress = opts.helper;
|
||||||
@@ -1038,17 +1036,17 @@ export class SamplerOperations {
|
|||||||
offset: BigNumber,
|
offset: BigNumber,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<DODOFillData> {
|
): SourceQuoteOperation<DODOFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.DodoV2,
|
source: ERC20BridgeSource.DodoV2,
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromDODOV2,
|
function: this._samplerContract.sampleBuysFromDODOV2Global,
|
||||||
params: [registry, offset, takerToken, makerToken, makerFillAmounts],
|
params: [registry, offset, takerToken, makerToken],
|
||||||
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
callback: (callResults: string, fillData: DODOFillData): BigNumber[] => {
|
||||||
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
const [isSellBase, pool, samples] = this._samplerContract.getABIDecodedReturnData<
|
||||||
[boolean, string, BigNumber[]]
|
[boolean, string, BigNumber[]]
|
||||||
>('sampleSellsFromDODOV2', callResults);
|
>('sampleSellsFromDODOV2Global', callResults);
|
||||||
fillData.isSellBase = isSellBase;
|
fillData.isSellBase = isSellBase;
|
||||||
fillData.poolAddress = pool;
|
fillData.poolAddress = pool;
|
||||||
return samples;
|
return samples;
|
||||||
@@ -1080,7 +1078,7 @@ export class SamplerOperations {
|
|||||||
psmInfo: PsmInfo,
|
psmInfo: PsmInfo,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<MakerPsmFillData> {
|
): SourceQuoteOperation<MakerPsmFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.MakerPsm,
|
source: ERC20BridgeSource.MakerPsm,
|
||||||
@@ -1091,8 +1089,8 @@ export class SamplerOperations {
|
|||||||
...psmInfo,
|
...psmInfo,
|
||||||
},
|
},
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromMakerPsm,
|
function: this._samplerContract.sampleBuysFromMakerPsmGlobal,
|
||||||
params: [psmInfo, takerToken, makerToken, makerFillAmounts],
|
params: [psmInfo, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1118,7 +1116,7 @@ export class SamplerOperations {
|
|||||||
lidoInfo: LidoInfo,
|
lidoInfo: LidoInfo,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<LidoFillData> {
|
): SourceQuoteOperation<LidoFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Lido,
|
source: ERC20BridgeSource.Lido,
|
||||||
@@ -1127,8 +1125,8 @@ export class SamplerOperations {
|
|||||||
stEthTokenAddress: lidoInfo.stEthToken,
|
stEthTokenAddress: lidoInfo.stEthToken,
|
||||||
},
|
},
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromLido,
|
function: this._samplerContract.sampleBuysFromLidoGlobal,
|
||||||
params: [lidoInfo, takerToken, makerToken, makerFillAmounts],
|
params: [lidoInfo, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1179,14 +1177,14 @@ export class SamplerOperations {
|
|||||||
cToken: string,
|
cToken: string,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
makerFillAmounts: BigNumber[],
|
_makerFillAmounts: BigNumber[],
|
||||||
): SourceQuoteOperation<CompoundFillData> {
|
): SourceQuoteOperation<CompoundFillData> {
|
||||||
return new SamplerContractOperation({
|
return new SamplerContractOperation({
|
||||||
source: ERC20BridgeSource.Compound,
|
source: ERC20BridgeSource.Compound,
|
||||||
fillData: { cToken, takerToken, makerToken },
|
fillData: { cToken, takerToken, makerToken },
|
||||||
contract: this._samplerContract,
|
contract: this._samplerContract,
|
||||||
function: this._samplerContract.sampleBuysFromCompound,
|
function: this._samplerContract.sampleBuysFromCompoundGlobal,
|
||||||
params: [cToken, takerToken, makerToken, makerFillAmounts],
|
params: [cToken, takerToken, makerToken],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user