Deployed CreamBridge, refactor to simplify code
This commit is contained in:
parent
bbfa9c34ab
commit
07ab10b000
@ -136,7 +136,7 @@ contract BridgeAdapter is
|
||||
sellAmount,
|
||||
bridgeData
|
||||
);
|
||||
} else if (bridgeAddress == BALANCER_BRIDGE_ADDRESS) {
|
||||
} else if (bridgeAddress == BALANCER_BRIDGE_ADDRESS || bridgeAddress == CREAM_BRIDGE_ADDRESS) {
|
||||
boughtAmount = _tradeBalancer(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
@ -172,12 +172,6 @@ contract BridgeAdapter is
|
||||
sellAmount,
|
||||
bridgeData
|
||||
);
|
||||
} else if (bridgeAddress == CREAM_BRIDGE_ADDRESS) {
|
||||
boughtAmount = _tradeBalancer(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
bridgeData
|
||||
);
|
||||
} else {
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
bridgeAddress,
|
||||
|
@ -132,7 +132,6 @@ export {
|
||||
CurveFillData,
|
||||
CurveFunctionSelectors,
|
||||
CurveInfo,
|
||||
CreamFillData,
|
||||
DexSample,
|
||||
DODOFillData,
|
||||
ERC20BridgeSource,
|
||||
|
@ -159,13 +159,10 @@ export class MarketOperationUtils {
|
||||
quoteSourceFilters.isAllowed(ERC20BridgeSource.Cream),
|
||||
);
|
||||
|
||||
let excludedSources: ERC20BridgeSource[] = [];
|
||||
if (!sampleCreamOnChain) {
|
||||
excludedSources = excludedSources.concat(ERC20BridgeSource.Cream);
|
||||
}
|
||||
if (!sampleBalancerOnChain) {
|
||||
excludedSources = excludedSources.concat(ERC20BridgeSource.Balancer);
|
||||
}
|
||||
const excludedSources = [
|
||||
...(!sampleCreamOnChain ? [ERC20BridgeSource.Cream] : []),
|
||||
...(!sampleBalancerOnChain ? [ERC20BridgeSource.Balancer] : []),
|
||||
];
|
||||
|
||||
// Call the sampler contract.
|
||||
const samplerPromise = this._sampler.executeAsync(
|
||||
@ -303,13 +300,10 @@ export class MarketOperationUtils {
|
||||
quoteSourceFilters.isAllowed(ERC20BridgeSource.Cream),
|
||||
);
|
||||
|
||||
let excludedSources: ERC20BridgeSource[] = [];
|
||||
if (!sampleCreamOnChain) {
|
||||
excludedSources = excludedSources.concat(ERC20BridgeSource.Cream);
|
||||
}
|
||||
if (!sampleBalancerOnChain) {
|
||||
excludedSources = excludedSources.concat(ERC20BridgeSource.Balancer);
|
||||
}
|
||||
const excludedSources = [
|
||||
...(!sampleCreamOnChain ? [ERC20BridgeSource.Cream] : []),
|
||||
...(!sampleBalancerOnChain ? [ERC20BridgeSource.Balancer] : []),
|
||||
];
|
||||
|
||||
// Call the sampler contract.
|
||||
const samplerPromise = this._sampler.executeAsync(
|
||||
|
@ -22,7 +22,6 @@ import {
|
||||
BalancerFillData,
|
||||
BancorFillData,
|
||||
CollapsedFill,
|
||||
CreamFillData,
|
||||
CurveFillData,
|
||||
DexSample,
|
||||
DODOFillData,
|
||||
@ -179,7 +178,7 @@ function getBridgeAddressFromFill(fill: CollapsedFill, opts: CreateOrderFromPath
|
||||
case ERC20BridgeSource.Balancer:
|
||||
return opts.contractAddresses.balancerBridge;
|
||||
case ERC20BridgeSource.Cream:
|
||||
return opts.contractAddresses.balancerBridge;
|
||||
return opts.contractAddresses.creamBridge;
|
||||
case ERC20BridgeSource.LiquidityProvider:
|
||||
return (fill.fillData as LiquidityProviderFillData).poolAddress;
|
||||
case ERC20BridgeSource.MultiBridge:
|
||||
@ -245,7 +244,7 @@ export function createBridgeOrder(
|
||||
);
|
||||
break;
|
||||
case ERC20BridgeSource.Cream:
|
||||
const creamFillData = (fill as CollapsedFill<CreamFillData>).fillData!; // tslint:disable-line:no-non-null-assertion
|
||||
const creamFillData = (fill as CollapsedFill<BalancerFillData>).fillData!; // tslint:disable-line:no-non-null-assertion
|
||||
makerAssetData = assetDataUtils.encodeERC20BridgeAssetData(
|
||||
makerToken,
|
||||
bridgeAddress,
|
||||
|
@ -19,7 +19,6 @@ import {
|
||||
BalancerFillData,
|
||||
BancorFillData,
|
||||
BatchedOperation,
|
||||
CreamFillData,
|
||||
CurveFillData,
|
||||
CurveInfo,
|
||||
DexSample,
|
||||
@ -413,9 +412,10 @@ export class SamplerOperations {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
source: ERC20BridgeSource,
|
||||
): SourceQuoteOperation<BalancerFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Balancer,
|
||||
source,
|
||||
fillData: { poolAddress },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromBalancer,
|
||||
@ -428,9 +428,10 @@ export class SamplerOperations {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
source: ERC20BridgeSource,
|
||||
): SourceQuoteOperation<BalancerFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Balancer,
|
||||
source,
|
||||
fillData: { poolAddress },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleBuysFromBalancer,
|
||||
@ -470,41 +471,11 @@ export class SamplerOperations {
|
||||
);
|
||||
}
|
||||
|
||||
public getCreamSellQuotes(
|
||||
poolAddress: string,
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<CreamFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Cream,
|
||||
fillData: { poolAddress },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromBalancer,
|
||||
params: [poolAddress, takerToken, makerToken, takerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public getCreamBuyQuotes(
|
||||
poolAddress: string,
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<CreamFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Cream,
|
||||
fillData: { poolAddress },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleBuysFromBalancer,
|
||||
params: [poolAddress, takerToken, makerToken, makerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public async getCreamSellQuotesOffChainAsync(
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
): Promise<Array<Array<DexSample<CreamFillData>>>> {
|
||||
): Promise<Array<Array<DexSample<BalancerFillData>>>> {
|
||||
const pools = await this.creamPoolsCache.getPoolsForPairAsync(takerToken, makerToken);
|
||||
return pools.map(pool =>
|
||||
takerFillAmounts.map(amount => ({
|
||||
@ -520,7 +491,7 @@ export class SamplerOperations {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
): Promise<Array<Array<DexSample<CreamFillData>>>> {
|
||||
): Promise<Array<Array<DexSample<BalancerFillData>>>> {
|
||||
const pools = await this.creamPoolsCache.getPoolsForPairAsync(takerToken, makerToken);
|
||||
return pools.map(pool =>
|
||||
makerFillAmounts.map(amount => ({
|
||||
@ -1103,13 +1074,13 @@ export class SamplerOperations {
|
||||
return this.balancerPoolsCache
|
||||
.getCachedPoolAddressesForPair(takerToken, makerToken)!
|
||||
.map(poolAddress =>
|
||||
this.getBalancerSellQuotes(poolAddress, makerToken, takerToken, takerFillAmounts),
|
||||
this.getBalancerSellQuotes(poolAddress, makerToken, takerToken, takerFillAmounts, ERC20BridgeSource.Balancer),
|
||||
);
|
||||
case ERC20BridgeSource.Cream:
|
||||
return this.creamPoolsCache
|
||||
.getCachedPoolAddressesForPair(takerToken, makerToken)!
|
||||
.map(poolAddress =>
|
||||
this.getCreamSellQuotes(poolAddress, makerToken, takerToken, takerFillAmounts),
|
||||
this.getBalancerSellQuotes(poolAddress, makerToken, takerToken, takerFillAmounts, ERC20BridgeSource.Cream),
|
||||
);
|
||||
case ERC20BridgeSource.Shell:
|
||||
return this.getShellSellQuotes(makerToken, takerToken, takerFillAmounts);
|
||||
@ -1200,13 +1171,13 @@ export class SamplerOperations {
|
||||
return this.balancerPoolsCache
|
||||
.getCachedPoolAddressesForPair(takerToken, makerToken)!
|
||||
.map(poolAddress =>
|
||||
this.getBalancerBuyQuotes(poolAddress, makerToken, takerToken, makerFillAmounts),
|
||||
this.getBalancerBuyQuotes(poolAddress, makerToken, takerToken, makerFillAmounts, ERC20BridgeSource.Balancer),
|
||||
);
|
||||
case ERC20BridgeSource.Cream:
|
||||
return this.creamPoolsCache
|
||||
.getCachedPoolAddressesForPair(takerToken, makerToken)!
|
||||
.map(poolAddress =>
|
||||
this.getCreamBuyQuotes(poolAddress, makerToken, takerToken, makerFillAmounts),
|
||||
this.getBalancerBuyQuotes(poolAddress, makerToken, takerToken, makerFillAmounts, ERC20BridgeSource.Cream),
|
||||
);
|
||||
case ERC20BridgeSource.Shell:
|
||||
return this.getShellBuyQuotes(makerToken, takerToken, makerFillAmounts);
|
||||
|
@ -105,10 +105,6 @@ export interface BalancerFillData extends FillData {
|
||||
poolAddress: string;
|
||||
}
|
||||
|
||||
export interface CreamFillData extends FillData {
|
||||
poolAddress: string;
|
||||
}
|
||||
|
||||
export interface UniswapV2FillData extends FillData {
|
||||
tokenAddressPath: string[];
|
||||
}
|
||||
|
@ -57,6 +57,10 @@
|
||||
{
|
||||
"note": "Deploy `DodoBridge` on Mainnet",
|
||||
"pr": 2701
|
||||
},
|
||||
{
|
||||
"note": "Deploy `CreamBridge` on Mainnet",
|
||||
"pr": 2715
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -45,6 +45,7 @@
|
||||
"sushiswapBridge": "0x47ed0262a0b688dcb836d254c6a2e96b6c48a9f5",
|
||||
"shellBridge": "0x21fb3862eed7911e0f8219a077247b849846728d",
|
||||
"dodoBridge": "0xe9da66965a9344aab2167e6813c03f043cc7a6ca",
|
||||
"creamBridge": "0xb9d4bf2c8dab828f4ffb656acdb6c2b497d44f25",
|
||||
"transformers": {
|
||||
"wethTransformer": "0x68c0bb685099dc7cb5c5ce2b26185945b357383e",
|
||||
"payTakerTransformer": "0x49b9df2c58491764cf40cb052dd4243df63622c7",
|
||||
@ -98,6 +99,7 @@
|
||||
"sushiswapBridge": "0x0000000000000000000000000000000000000000",
|
||||
"shellBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dodoBridge": "0x0000000000000000000000000000000000000000",
|
||||
"creamBridge": "0x0000000000000000000000000000000000000000",
|
||||
"transformers": {
|
||||
"wethTransformer": "0x8d822fe2b42f60531203e288f5f357fa79474437",
|
||||
"payTakerTransformer": "0x150652244723102faeaefa4c79597d097ffa26c6",
|
||||
@ -151,6 +153,7 @@
|
||||
"sushiswapBridge": "0x0000000000000000000000000000000000000000",
|
||||
"shellBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dodoBridge": "0x0000000000000000000000000000000000000000",
|
||||
"creamBridge": "0x0000000000000000000000000000000000000000",
|
||||
"transformers": {
|
||||
"wethTransformer": "0x8d822fe2b42f60531203e288f5f357fa79474437",
|
||||
"payTakerTransformer": "0x150652244723102faeaefa4c79597d097ffa26c6",
|
||||
@ -204,6 +207,7 @@
|
||||
"sushiswapBridge": "0x0000000000000000000000000000000000000000",
|
||||
"shellBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dodoBridge": "0x0000000000000000000000000000000000000000",
|
||||
"creamBridge": "0x0000000000000000000000000000000000000000",
|
||||
"transformers": {
|
||||
"wethTransformer": "0x9ce35b5ee9e710535e3988e3f8731d9ca9dba17d",
|
||||
"payTakerTransformer": "0x5a53e7b02a83aa9f60ccf4e424f0442c255bc977",
|
||||
@ -257,6 +261,7 @@
|
||||
"sushiswapBridge": "0x0000000000000000000000000000000000000000",
|
||||
"shellBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dodoBridge": "0x0000000000000000000000000000000000000000",
|
||||
"creamBridge": "0x0000000000000000000000000000000000000000",
|
||||
"transformers": {
|
||||
"wethTransformer": "0xc6b0d3c45a6b5092808196cb00df5c357d55e1d5",
|
||||
"payTakerTransformer": "0x7209185959d7227fb77274e1e88151d7c4c368d3",
|
||||
|
@ -46,6 +46,7 @@ export interface ContractAddresses {
|
||||
sushiswapBridge: string;
|
||||
shellBridge: string;
|
||||
dodoBridge: string;
|
||||
creamBridge: string;
|
||||
transformers: {
|
||||
wethTransformer: string;
|
||||
payTakerTransformer: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user