Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Add MultiBridge support to AssetSwapper #2593

Merged
merged 2 commits into from
Jun 11, 2020

Conversation

moodlezoup
Copy link
Contributor

@moodlezoup moodlezoup commented Jun 2, 2020

Description

  • Adds a function to the Sampler contract to sample from MultiBridge
  • Adds corresponding sampler operation to AS
  • Some other MB-specific logic in AS
  • Regenerates contract artifacts/wrappers

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch 2 times, most recently from a36c407 to 7579451 Compare June 3, 2020 18:22
@moodlezoup moodlezoup changed the title Feature/multibridge/asset swapper Add MultiBridge support to AssetSwapper Jun 3, 2020
@moodlezoup moodlezoup marked this pull request as ready for review June 3, 2020 18:30
@moodlezoup moodlezoup requested review from dorothy-zbornak and dekz and removed request for BMillman19, fragosti, hysz, dave4506 and abandeali1 June 3, 2020 18:30
@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch from 7579451 to d3cbdf1 Compare June 3, 2020 18:47
@@ -648,14 +651,14 @@ describe('MarketOperationUtils tests', () => {
{ excludedSources: SELL_SOURCES, numSamples: 4, bridgeSlippage: 0, shouldBatchBridgeOrders: false },
);
expect(result.length).to.eql(1);
expect(result[0].makerAddress).to.eql(liquidityProviderAddress);
expect(result[0].makerAddress).to.eql(DEX_FORWARDER_BRIDGE_ADDRESS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this happen? shouldBatchBridgeOrders is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes that would explain the failing test, idk how this slipped in

@dorothy-zbornak
Copy link
Contributor

Can you explain to me the reasoning behind the MB registry? Will there be different MB contracts for different pairs?

@moodlezoup
Copy link
Contributor Author

moodlezoup commented Jun 5, 2020

Can you explain to me the reasoning behind the MB registry? Will there be different MB contracts for different pairs?

probably not –– I decided on the registry layer so we could swap out MB implementations without disrupting the API. Also considered using a proxy pattern, but decided against it for PLP-related security reasons

@dorothy-zbornak
Copy link
Contributor

Can you explain to me the reasoning behind the MB registry? Will there be different MB contracts for different pairs?

probably not –– I decided on the registry layer so we could swap out MB implementations without disrupting the API. Also considered using a proxy pattern, but decided against it for PLP-related security reasons

I can appreciate seamless updates, but I wonder if it's easier to update AS + API than hunt down the person with the MB registry private key. I guess it could be worth it if MB is getting frequent updates. Not a blocker, either way.

@dorothy-zbornak
Copy link
Contributor

Can you explain to me the reasoning behind the MB registry? Will there be different MB contracts for different pairs?

probably not –– I decided on the registry layer so we could swap out MB implementations without disrupting the API. Also considered using a proxy pattern, but decided against it for PLP-related security reasons

I can appreciate seamless updates, but I wonder if it's easier to update AS + API than hunt down the person with the MB registry private key. I guess it could be worth it if MB is getting frequent updates. Not a blocker, either way.

Actually now I'm slightly leaning against the registry. I think there might be value in AS/API opting into a version of MB. This gives us the ability to easily rollback to an older MB if necessary and also makes it easier to AB test one MB integration vs another.

@moodlezoup
Copy link
Contributor Author

yeah that makes sense. will update

Copy link
Member

@dekz dekz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the registry seems unnecessary, unless theres the case where there's many of them and they're different.

Down to keep passing in the address as a param (rather than hard code like Kyber/Uniswap) to save us re-deploying the Sampler contract with an updated MultiBridge address.

@@ -20,7 +20,7 @@
"devUtils": "0x74134cf88b21383713e096a5ecf59e297dc7f547",
"erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0",
"uniswapBridge": "0x36691c4f426eb8f42f150ebde43069a31cb080ad",
"erc20BridgeSampler": "0xc0154b14cc60a6661171fdc817f759429a57e184",
"erc20BridgeSampler": "0xd7223e59a11bbeb663c77625f06963ff42fdf97d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this source verified or redeploy if the artifact is lost prior to merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll redeploy, verify, and update before merging

@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch 3 times, most recently from dbba8b0 to 213be97 Compare June 10, 2020 02:29
@@ -75,35 +77,37 @@ export class MarketOperationUtils {
}
const _opts = { ...DEFAULT_GET_MARKET_ORDERS_OPTS, ...opts };
const [makerToken, takerToken] = getNativeOrderTokens(nativeOrders[0]);
const optionalSources = (this._liquidityProviderRegistry ? [ERC20BridgeSource.LiquidityProvider] : []).concat(
this._multiBridge === NULL_ADDRESS ? [ERC20BridgeSource.MultiBridge] : [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be

Suggested change
this._multiBridge === NULL_ADDRESS ? [ERC20BridgeSource.MultiBridge] : [],
this._multiBridge !== NULL_ADDRESS ? [ERC20BridgeSource.MultiBridge] : [],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah shit 🙈


constructor(
private readonly _sampler: DexOrderSampler,
private readonly contractAddresses: ContractAddresses,
private readonly _orderDomain: OrderDomain,
private readonly _liquidityProviderRegistry: string = NULL_ADDRESS,
private readonly _liquidityProviderRegistry?: string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does seem a little inconsistent with the following multiBridge. What are your thoughts on this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm this must be a relic of some older changes; this branch is pretty old. good catch, will fix

@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch from 213be97 to 1b5746b Compare June 10, 2020 18:52
@moodlezoup moodlezoup requested a review from dekz June 10, 2020 18:54
Copy link
Contributor

@dorothy-zbornak dorothy-zbornak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya looks good!

@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch from 1b5746b to ce5ec62 Compare June 11, 2020 18:10
@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch 3 times, most recently from fc482ef to 8609514 Compare June 11, 2020 19:24
@moodlezoup moodlezoup force-pushed the feature/multibridge/asset-swapper branch from 8609514 to cd14a45 Compare June 11, 2020 19:48
if (source === ERC20BridgeSource.Kyber) {
return FillFlags.Kyber;
switch (source) {
case ERC20BridgeSource.Uniswap:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we intentionally excluding ERC20BridgeSource.UniswapV2 and ERC20BridgeSource.UniswapV2Eth here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, MultiBridge is not yet integrated with v2

@moodlezoup moodlezoup merged commit e936c7c into development Jun 11, 2020
@moodlezoup moodlezoup deleted the feature/multibridge/asset-swapper branch June 11, 2020 21:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants