From bf1b5c42579d24121099d460c2e815c2fa63fd8e Mon Sep 17 00:00:00 2001 From: Noah Khamliche <71143770+dextracker@users.noreply.github.com> Date: Wed, 12 Oct 2022 17:10:16 -0400 Subject: [PATCH] Fix: FQT otc order encoding logic (#596) * swap rfq and otc in fillQuoteTransformerDataEncoder to match our enum * changelog * fix changelog and move otcOrders field to last in fillQuoteTransformerDataEncoder * prettier * move otcOrders array to end of fqtTransformData Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local> --- contracts/erc20/src/artifacts.ts | 2 +- contracts/erc20/test/artifacts.ts | 2 +- .../src/transformers/FillQuoteTransformer.sol | 4 ++-- contracts/zero-ex/test/artifacts.ts | 3 ++- packages/protocol-utils/CHANGELOG.json | 9 +++++++++ packages/protocol-utils/src/transformer_utils.ts | 10 +++++----- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts index 58950e0e05..d8339aaafb 100644 --- a/contracts/erc20/src/artifacts.ts +++ b/contracts/erc20/src/artifacts.ts @@ -15,7 +15,7 @@ export const artifacts = { DummyERC20Token: DummyERC20Token as ContractArtifact, ERC20Token: ERC20Token as ContractArtifact, WETH9: WETH9 as ContractArtifact, - ZRXToken: (ZRXToken as any) as ContractArtifact, + ZRXToken: ZRXToken as any as ContractArtifact, DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, }; diff --git a/contracts/erc20/test/artifacts.ts b/contracts/erc20/test/artifacts.ts index a7249ae38a..54624be41f 100644 --- a/contracts/erc20/test/artifacts.ts +++ b/contracts/erc20/test/artifacts.ts @@ -28,7 +28,7 @@ export const artifacts = { MintableERC20Token: MintableERC20Token as ContractArtifact, UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, WETH9: WETH9 as ContractArtifact, - ZRXToken: (ZRXToken as any) as ContractArtifact, + ZRXToken: ZRXToken as any as ContractArtifact, IERC20Token: IERC20Token as ContractArtifact, IEtherToken: IEtherToken as ContractArtifact, IERC20TokenV06: IERC20TokenV06 as ContractArtifact, diff --git a/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol b/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol index 7430140048..eccf8e4bb3 100644 --- a/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol @@ -90,8 +90,6 @@ contract FillQuoteTransformer is Transformer { IBridgeAdapter.BridgeOrder[] bridgeOrders; // Native limit orders. Sorted by fill sequence. LimitOrderInfo[] limitOrders; - // Otc orders. Sorted by fill sequence. - OtcOrderInfo[] otcOrders; // Native RFQ orders. Sorted by fill sequence. RfqOrderInfo[] rfqOrders; // The sequence to fill the orders in. Each item will fill the next @@ -110,6 +108,8 @@ contract FillQuoteTransformer is Transformer { // `address(1)`: Send to the taker. // `address(2)`: Send to the sender (caller of `transformERC20()`). address payable refundReceiver; + // Otc orders. Sorted by fill sequence. + OtcOrderInfo[] otcOrders; } struct FillOrderResults { diff --git a/contracts/zero-ex/test/artifacts.ts b/contracts/zero-ex/test/artifacts.ts index 82b7284332..d4e7e073aa 100644 --- a/contracts/zero-ex/test/artifacts.ts +++ b/contracts/zero-ex/test/artifacts.ts @@ -389,7 +389,8 @@ export const artifacts = { TestNoEthRecipient: TestNoEthRecipient as ContractArtifact, TestOrderSignerRegistryWithContractWallet: TestOrderSignerRegistryWithContractWallet as ContractArtifact, TestPermissionlessTransformerDeployerSuicidal: TestPermissionlessTransformerDeployerSuicidal as ContractArtifact, - TestPermissionlessTransformerDeployerTransformer: TestPermissionlessTransformerDeployerTransformer as ContractArtifact, + TestPermissionlessTransformerDeployerTransformer: + TestPermissionlessTransformerDeployerTransformer as ContractArtifact, TestPropertyValidator: TestPropertyValidator as ContractArtifact, TestRfqOriginRegistration: TestRfqOriginRegistration as ContractArtifact, TestSimpleFunctionRegistryFeatureImpl1: TestSimpleFunctionRegistryFeatureImpl1 as ContractArtifact, diff --git a/packages/protocol-utils/CHANGELOG.json b/packages/protocol-utils/CHANGELOG.json index 8489b715b9..a421fc3ccb 100644 --- a/packages/protocol-utils/CHANGELOG.json +++ b/packages/protocol-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "11.16.14", + "changes": [ + { + "note": "Fix FQT Otc encoding logic", + "pr": "596" + } + ] + }, { "timestamp": 1665531940, "version": "11.16.13", diff --git a/packages/protocol-utils/src/transformer_utils.ts b/packages/protocol-utils/src/transformer_utils.ts index 18d03cf264..9b8c356167 100644 --- a/packages/protocol-utils/src/transformer_utils.ts +++ b/packages/protocol-utils/src/transformer_utils.ts @@ -74,11 +74,6 @@ export const fillQuoteTransformerDataEncoder = AbiEncoder.create([ type: 'tuple[]', components: LIMIT_ORDER_INFO_ABI_COMPONENTS, }, - { - name: 'otcOrders', - type: 'tuple[]', - components: OTC_ORDER_INFO_ABI_COMPONENTS, - }, { name: 'rfqOrders', type: 'tuple[]', @@ -87,6 +82,11 @@ export const fillQuoteTransformerDataEncoder = AbiEncoder.create([ { name: 'fillSequence', type: 'uint8[]' }, { name: 'fillAmount', type: 'uint256' }, { name: 'refundReceiver', type: 'address' }, + { + name: 'otcOrders', + type: 'tuple[]', + components: OTC_ORDER_INFO_ABI_COMPONENTS, + }, ], }, ]);