Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts-v2",
"version": "0.0.15",
"version": "0.0.17",
"author": "UMA Team",
"license": "AGPL-3.0",
"repository": {
Expand Down
67 changes: 64 additions & 3 deletions test/fixtures/SpokePool.Fixture.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { originChainId } from "./../constants";
import { TokenRolesEnum } from "@uma/common";
import { getContractFactory, SignerWithAddress, Contract, hre, ethers, BigNumber, defaultAbiCoder } from "../utils";
import * as consts from "../constants";
Expand Down Expand Up @@ -48,17 +49,19 @@ export async function deposit(
token: Contract,
recipient: SignerWithAddress,
depositor: SignerWithAddress,
destinationChainId: number = consts.destinationChainId
destinationChainId: number = consts.destinationChainId,
amountToDeposit: BigNumber = consts.amountToDeposit,
depositRelayerFeePct: BigNumber = consts.depositRelayerFeePct
) {
await spokePool
.connect(depositor)
.deposit(
...getDepositParams(
recipient.address,
token.address,
consts.amountToDeposit,
amountToDeposit,
destinationChainId,
consts.depositRelayerFeePct,
depositRelayerFeePct,
await spokePool.getCurrentTime()
)
);
Expand All @@ -81,6 +84,64 @@ export async function deposit(
};
return null;
}

export async function fillRelay(
spokePool: Contract,
destErc20: Contract,
recipient: SignerWithAddress,
depositor: SignerWithAddress,
relayer: SignerWithAddress,
depositId: number = consts.firstDepositId,
originChainId: number = consts.originChainId,
depositAmount: BigNumber = consts.amountToDeposit,
amountToRelay: BigNumber = consts.amountToRelay,
realizedLpFeePct: BigNumber = consts.realizedLpFeePct,
relayerFeePct: BigNumber = consts.depositRelayerFeePct
) {
await spokePool
.connect(relayer)
.fillRelay(
...getFillRelayParams(
getRelayHash(
depositor.address,
recipient.address,
depositId,
originChainId,
destErc20.address,
depositAmount.toString(),
realizedLpFeePct.toString(),
relayerFeePct.toString()
).relayData,
amountToRelay,
consts.repaymentChainId
)
);
const [events, networkInfo] = await Promise.all([
spokePool.queryFilter(spokePool.filters.FilledRelay()),
spokePool.provider.getNetwork(),
]);
const lastEvent = events[events.length - 1];
if (lastEvent.args)
return {
relayHash: lastEvent.args.relayHash,
amount: lastEvent.args.amount,
totalFilledAmount: lastEvent.args.totalFilledAmount,
fillAmount: lastEvent.args.fillAmount,
repaymentChainId: Number(lastEvent.args.repaymentChainId),
originChainId: Number(lastEvent.args.originChainId),
relayerFeePct: lastEvent.args.relayerFeePct,
realizedLpFeePct: lastEvent.args.realizedLpFeePct,
depositId: lastEvent.args.depositId,
destinationToken: lastEvent.args.destinationToken,
relayer: lastEvent.args.relayer,
depositor: lastEvent.args.depositor,
recipient: lastEvent.args.recipient,
isSlowRelay: lastEvent.args.isSlowRelay,
destinationChainId: networkInfo.chainId,
};
else return null;
}

export interface RelayData {
depositor: string;
recipient: string;
Expand Down