Compare commits

...

6 Commits

Author SHA1 Message Date
Github Actions
d3ca1fe96b Publish
- @0x/contracts-integrations@2.7.21
 - @0x/asset-swapper@5.6.1
2020-12-31 04:02:02 +00:00
Github Actions
9e4f5815e4 Updated CHANGELOGS & MD docs 2020-12-31 04:01:53 +00:00
Jacob Evans
c3c27eaedc fix: [asset-swapper] Encoded Buy fillAmount (#106) 2020-12-31 13:18:25 +10:00
Github Actions
4bf6a23d23 Publish
- @0x/contracts-integrations@2.7.20
 - @0x/asset-swapper@5.6.0
2020-12-27 23:59:31 +00:00
Github Actions
aaaf0d02de Updated CHANGELOGS & MD docs 2020-12-27 23:59:23 +00:00
Jacob Evans
825cc4d035 feat: [asset-swapper] Added Mooniswap V2 factory address (#100) 2020-12-28 09:23:52 +10:00
8 changed files with 82 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-integrations",
"version": "2.7.19",
"version": "2.7.21",
"private": true,
"engines": {
"node": ">=6.12"
@@ -93,7 +93,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/asset-swapper": "^5.5.3",
"@0x/asset-swapper": "^5.6.1",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-asset-proxy": "^3.7.2",
"@0x/contracts-erc1155": "^2.1.20",

View File

@@ -1,4 +1,23 @@
[
{
"version": "5.6.1",
"changes": [
{
"note": "Fix fillAmount `ExchangeProxySwapQuoteConsumer` encoding when quote is a BuyQuote"
}
],
"timestamp": 1609387311
},
{
"version": "5.6.0",
"changes": [
{
"note": "Added Mooniswap V2 factory address",
"pr": 100
}
],
"timestamp": 1609113560
},
{
"timestamp": 1608692071,
"version": "5.5.3",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.6.1 - _December 31, 2020_
* Fix fillAmount `ExchangeProxySwapQuoteConsumer` encoding when quote is a BuyQuote
## v5.6.0 - _December 27, 2020_
* Added Mooniswap V2 factory address (#100)
## v5.5.3 - _December 23, 2020_
* Dependencies updated

View File

@@ -34,6 +34,7 @@ contract MooniswapSampler is
uint256 constant private MOONISWAP_CALL_GAS = 150e3; // 150k
/// @dev Sample sell 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).
/// @param takerTokenAmounts Taker token sell amount for each sample.
@@ -41,6 +42,7 @@ contract MooniswapSampler is
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromMooniswap(
address registry,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
@@ -58,6 +60,7 @@ contract MooniswapSampler is
for (uint256 i = 0; i < numSamples; i++) {
uint256 buyAmount = sampleSingleSellFromMooniswapPool(
registry,
mooniswapTakerToken,
mooniswapMakerToken,
takerTokenAmounts[i]
@@ -70,11 +73,12 @@ contract MooniswapSampler is
}
pool = IMooniswap(
IMooniswapRegistry(_getMooniswapAddress()).pools(mooniswapTakerToken, mooniswapMakerToken)
IMooniswapRegistry(registry).pools(mooniswapTakerToken, mooniswapMakerToken)
);
}
function sampleSingleSellFromMooniswapPool(
address registry,
address mooniswapTakerToken,
address mooniswapMakerToken,
uint256 takerTokenAmount
@@ -85,7 +89,7 @@ contract MooniswapSampler is
{
// Find the pool for the pair.
IMooniswap pool = IMooniswap(
IMooniswapRegistry(_getMooniswapAddress()).pools(mooniswapTakerToken, mooniswapMakerToken)
IMooniswapRegistry(registry).pools(mooniswapTakerToken, mooniswapMakerToken)
);
// If there is no pool then return early
if (address(pool) == address(0)) {
@@ -113,6 +117,7 @@ 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).
/// @param makerTokenAmounts Maker token sell amount for each sample.
@@ -120,6 +125,7 @@ contract MooniswapSampler is
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromMooniswap(
address registry,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
@@ -137,15 +143,15 @@ contract MooniswapSampler is
takerTokenAmounts = _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
makerTokenData: abi.encode(mooniswapMakerToken),
takerTokenData: abi.encode(mooniswapTakerToken),
makerTokenData: abi.encode(registry, mooniswapMakerToken),
takerTokenData: abi.encode(registry, mooniswapTakerToken),
getSellQuoteCallback: _sampleSellForApproximateBuyFromMooniswap
}),
makerTokenAmounts
);
pool = IMooniswap(
IMooniswapRegistry(_getMooniswapAddress()).pools(mooniswapTakerToken, mooniswapMakerToken)
IMooniswapRegistry(registry).pools(mooniswapTakerToken, mooniswapMakerToken)
);
}
@@ -158,9 +164,10 @@ contract MooniswapSampler is
view
returns (uint256 buyAmount)
{
address mooniswapTakerToken = abi.decode(takerTokenData, (address));
address mooniswapMakerToken = abi.decode(makerTokenData, (address));
(address registry, address mooniswapTakerToken) = abi.decode(takerTokenData, (address, address));
(address _registry, address mooniswapMakerToken) = abi.decode(makerTokenData, (address, address));
return sampleSingleSellFromMooniswapPool(
registry,
mooniswapTakerToken,
mooniswapMakerToken,
sellAmount

View File

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

View File

@@ -205,7 +205,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
buyToken,
refundReceiver: refundReceiver || NULL_ADDRESS,
side: isBuyQuote(quote) ? FillQuoteTransformerSide.Buy : FillQuoteTransformerSide.Sell,
fillAmount: shouldSellEntireBalance ? MAX_UINT256 : fillAmount,
fillAmount: !isBuyQuote(quote) && shouldSellEntireBalance ? MAX_UINT256 : fillAmount,
maxOrderFillAmounts: [],
rfqtTakerAddress: NULL_ADDRESS,
orders: quote.orders,

View File

@@ -357,6 +357,9 @@ export const LIQUIDITY_PROVIDER_REGISTRY: LiquidityProviderRegistry = {};
export const MAINNET_SUSHI_SWAP_ROUTER = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F';
export const MAINNET_CRYPTO_COM_ROUTER = '0xCeB90E4C17d626BE0fACd78b79c9c87d7ca181b3';
export const MAINNET_MOONISWAP_REGISTRY = '0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303';
export const MAINNET_MOONISWAP_V2_REGISTRY = '0xc4a8b7e29e3c8ec560cd4945c1cf3461a85a148d';
export const MAINNET_SHELL_POOLS = {
StableCoins: {
poolAddress: '0x2E703D658f8dd21709a7B458967aB4081F8D3d05',

View File

@@ -9,6 +9,8 @@ import { BancorService } from './bancor_service';
import {
LIQUIDITY_PROVIDER_REGISTRY,
MAINNET_CRYPTO_COM_ROUTER,
MAINNET_MOONISWAP_REGISTRY,
MAINNET_MOONISWAP_V2_REGISTRY,
MAINNET_SUSHI_SWAP_ROUTER,
MAX_UINT256,
ZERO_AMOUNT,
@@ -623,6 +625,7 @@ export class SamplerOperations {
}
public getMooniswapSellQuotes(
registry: string,
makerToken: string,
takerToken: string,
takerFillAmounts: BigNumber[],
@@ -631,7 +634,7 @@ export class SamplerOperations {
source: ERC20BridgeSource.Mooniswap,
contract: this._samplerContract,
function: this._samplerContract.sampleSellsFromMooniswap,
params: [takerToken, makerToken, takerFillAmounts],
params: [registry, takerToken, makerToken, takerFillAmounts],
callback: (callResults: string, fillData: MooniswapFillData): BigNumber[] => {
const [poolAddress, samples] = this._samplerContract.getABIDecodedReturnData<[string, BigNumber[]]>(
'sampleSellsFromMooniswap',
@@ -644,6 +647,7 @@ export class SamplerOperations {
}
public getMooniswapBuyQuotes(
registry: string,
makerToken: string,
takerToken: string,
makerFillAmounts: BigNumber[],
@@ -652,7 +656,7 @@ export class SamplerOperations {
source: ERC20BridgeSource.Mooniswap,
contract: this._samplerContract,
function: this._samplerContract.sampleBuysFromMooniswap,
params: [takerToken, makerToken, makerFillAmounts],
params: [registry, takerToken, makerToken, makerFillAmounts],
callback: (callResults: string, fillData: MooniswapFillData): BigNumber[] => {
const [poolAddress, samples] = this._samplerContract.getABIDecodedReturnData<[string, BigNumber[]]>(
'sampleBuysFromMooniswap',
@@ -1093,7 +1097,20 @@ export class SamplerOperations {
case ERC20BridgeSource.MStable:
return this.getMStableSellQuotes(makerToken, takerToken, takerFillAmounts);
case ERC20BridgeSource.Mooniswap:
return this.getMooniswapSellQuotes(makerToken, takerToken, takerFillAmounts);
return [
this.getMooniswapSellQuotes(
MAINNET_MOONISWAP_REGISTRY,
makerToken,
takerToken,
takerFillAmounts,
),
this.getMooniswapSellQuotes(
MAINNET_MOONISWAP_V2_REGISTRY,
makerToken,
takerToken,
takerFillAmounts,
),
];
case ERC20BridgeSource.Balancer:
return this.balancerPoolsCache
.getCachedPoolAddressesForPair(takerToken, makerToken)!
@@ -1218,7 +1235,20 @@ export class SamplerOperations {
case ERC20BridgeSource.MStable:
return this.getMStableBuyQuotes(makerToken, takerToken, makerFillAmounts);
case ERC20BridgeSource.Mooniswap:
return this.getMooniswapBuyQuotes(makerToken, takerToken, makerFillAmounts);
return [
this.getMooniswapBuyQuotes(
MAINNET_MOONISWAP_REGISTRY,
makerToken,
takerToken,
makerFillAmounts,
),
this.getMooniswapBuyQuotes(
MAINNET_MOONISWAP_V2_REGISTRY,
makerToken,
takerToken,
makerFillAmounts,
),
];
case ERC20BridgeSource.Balancer:
return this.balancerPoolsCache
.getCachedPoolAddressesForPair(takerToken, makerToken)!