-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add multicall transaction processing logic Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * Update test/Relayer.IterativeFill.ts Co-authored-by: nicholaspai <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * review nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> * nit Signed-off-by: chrismaree <[email protected]> Co-authored-by: nicholaspai <[email protected]>
- Loading branch information
1 parent
6c80b5d
commit 05bb17a
Showing
9 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
import { BigNumber } from "../utils"; | ||
// @notice Passed as input to HubPool.proposeRootBundle | ||
export type BundleEvaluationBlockNumbers = number[]; | ||
|
||
export interface PoolRebalanceLeaf { | ||
chainId: BigNumber; | ||
groupIndex: BigNumber; | ||
bundleLpFees: BigNumber[]; | ||
netSendAmounts: BigNumber[]; | ||
runningBalances: BigNumber[]; | ||
leafId: BigNumber; | ||
l1Tokens: string[]; | ||
} | ||
|
||
export interface RelayerRefundLeaf { | ||
amountToReturn: BigNumber; | ||
chainId: BigNumber; | ||
refundAmounts: BigNumber[]; | ||
leafId: BigNumber; | ||
l2TokenAddress: string; | ||
refundAddresses: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./SpokePool"; | ||
export * from "./HubPool"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { getParamType, utils } from "."; | ||
import { RelayData, PoolRebalanceLeaf, RelayerRefundLeaf } from "../interfaces"; | ||
import { MerkleTree } from "@across-protocol/contracts-v2"; | ||
|
||
export async function buildSlowRelayTree(relays: RelayData[]) { | ||
const paramType = await getParamType("MerkleLibTest", "verifySlowRelayFulfillment", "slowRelayFulfillment"); | ||
const hashFn = (input: RelayData) => { | ||
return utils.keccak256(utils.defaultAbiCoder.encode([paramType!], [input])); | ||
}; | ||
return new MerkleTree(relays, hashFn); | ||
} | ||
|
||
export async function buildPoolRebalanceLeafTree(poolRebalanceLeaves: PoolRebalanceLeaf[]) { | ||
for (let i = 0; i < poolRebalanceLeaves.length; i++) { | ||
// The 4 provided parallel arrays must be of equal length. | ||
if ( | ||
poolRebalanceLeaves[i].l1Tokens.length !== poolRebalanceLeaves[i].bundleLpFees.length || | ||
poolRebalanceLeaves[i].netSendAmounts.length !== poolRebalanceLeaves[i].runningBalances.length | ||
) | ||
throw new Error("Provided lef arrays are not of equal length"); | ||
} | ||
|
||
const paramType = await getParamType("MerkleLibTest", "verifyPoolRebalance", "rebalance"); | ||
const hashFn = (input: PoolRebalanceLeaf) => utils.keccak256(utils.defaultAbiCoder.encode([paramType!], [input])); | ||
return new MerkleTree<PoolRebalanceLeaf>(poolRebalanceLeaves, hashFn); | ||
} | ||
|
||
export async function buildRelayerRefundTree(relayerRefundLeaves: RelayerRefundLeaf[]) { | ||
for (let i = 0; i < relayerRefundLeaves.length; i++) { | ||
// The 2 provided parallel arrays must be of equal length. | ||
if (relayerRefundLeaves[i].refundAddresses.length != relayerRefundLeaves[i].refundAmounts.length) | ||
throw new Error("Provided lef arrays are not of equal length"); | ||
} | ||
|
||
const paramType = await getParamType("MerkleLibTest", "verifyRelayerRefund", "refund"); | ||
const hashFn = (input: RelayerRefundLeaf) => utils.keccak256(utils.defaultAbiCoder.encode([paramType!], [input])); | ||
return new MerkleTree<RelayerRefundLeaf>(relayerRefundLeaves, hashFn); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters