Compare commits

...

3 Commits

Author SHA1 Message Date
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
7 changed files with 68 additions and 14 deletions

View File

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

View File

@@ -1,4 +1,14 @@
[ [
{
"version": "5.6.0",
"changes": [
{
"note": "Added Mooniswap V2 factory address",
"pr": 100
}
],
"timestamp": 1609113560
},
{ {
"timestamp": 1608692071, "timestamp": 1608692071,
"version": "5.5.3", "version": "5.5.3",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v5.6.0 - _December 27, 2020_
* Added Mooniswap V2 factory address (#100)
## v5.5.3 - _December 23, 2020_ ## v5.5.3 - _December 23, 2020_
* Dependencies updated * Dependencies updated

View File

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

View File

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

View File

@@ -357,6 +357,9 @@ export const LIQUIDITY_PROVIDER_REGISTRY: LiquidityProviderRegistry = {};
export const MAINNET_SUSHI_SWAP_ROUTER = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'; export const MAINNET_SUSHI_SWAP_ROUTER = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F';
export const MAINNET_CRYPTO_COM_ROUTER = '0xCeB90E4C17d626BE0fACd78b79c9c87d7ca181b3'; 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 = { export const MAINNET_SHELL_POOLS = {
StableCoins: { StableCoins: {
poolAddress: '0x2E703D658f8dd21709a7B458967aB4081F8D3d05', poolAddress: '0x2E703D658f8dd21709a7B458967aB4081F8D3d05',

View File

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