-
Notifications
You must be signed in to change notification settings - Fork 465
Add MultiBridge support to AssetSwapper #2593
Conversation
a36c407
to
7579451
Compare
7579451
to
d3cbdf1
Compare
packages/asset-swapper/src/utils/market_operation_utils/multibridge_utils.ts
Outdated
Show resolved
Hide resolved
packages/asset-swapper/src/utils/market_operation_utils/constants.ts
Outdated
Show resolved
Hide resolved
packages/asset-swapper/src/utils/market_operation_utils/index.ts
Outdated
Show resolved
Hide resolved
packages/asset-swapper/src/utils/market_operation_utils/index.ts
Outdated
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
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. |
yeah that makes sense. will update |
There was a problem hiding this 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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
dbba8b0
to
213be97
Compare
@@ -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] : [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
this._multiBridge === NULL_ADDRESS ? [ERC20BridgeSource.MultiBridge] : [], | |
this._multiBridge !== NULL_ADDRESS ? [ERC20BridgeSource.MultiBridge] : [], |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
213be97
to
1b5746b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya looks good!
packages/asset-swapper/src/utils/market_operation_utils/index.ts
Outdated
Show resolved
Hide resolved
1b5746b
to
ce5ec62
Compare
fc482ef
to
8609514
Compare
8609514
to
cd14a45
Compare
if (source === ERC20BridgeSource.Kyber) { | ||
return FillFlags.Kyber; | ||
switch (source) { | ||
case ERC20BridgeSource.Uniswap: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Description
Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.