Skip to content

Commit 52dbfc2

Browse files
committed
Update Everclear test
1 parent e7ffbd8 commit 52dbfc2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/Repayer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,14 +1021,20 @@ describe("Repayer", function () {
10211021
maxFee: "200",
10221022
})
10231023
})).json()).data;
1024+
10241025
const newIntentSelector = "0xae9b2bad";
10251026
// API returns selector for a variety of newIntent that takes 'address' as resipient.
10261027
// We are using version that expects a 'bytes32' instead. Encoding other data remains the same.
10271028
const apiTx = everclearFeeAdapter.interface.decodeFunctionData("newIntent", newIntentSelector + apiData.substr(10));
1029+
10281030
const extraData = AbiCoder.defaultAbiCoder().encode(
10291031
["bytes32", "uint256", "uint48", "tuple(uint256, uint256, bytes)"],
10301032
[apiTx[3], apiTx[5], apiTx[6], apiTx[8]]
10311033
);
1034+
const apiAmountIn = apiTx[4];
1035+
const apiFee = apiTx[8][0];
1036+
const apiAmountWithFee = apiAmountIn + apiFee;
1037+
expect(apiAmountWithFee).to.be.lessThanOrEqual(amount);
10321038
await repayer.connect(setTokensUser).setInputOutputTokens(
10331039
[{
10341040
inputToken: weth,
@@ -1040,7 +1046,7 @@ describe("Repayer", function () {
10401046
);
10411047
const tx = repayer.connect(repayUser).initiateRepay(
10421048
weth,
1043-
amount,
1049+
apiAmountWithFee,
10441050
liquidityPool,
10451051
Domain.ETHEREUM,
10461052
Provider.EVERCLEAR,
@@ -1049,13 +1055,13 @@ describe("Repayer", function () {
10491055

10501056
await expect(tx)
10511057
.to.emit(repayer, "InitiateRepay")
1052-
.withArgs(weth.target, amount, liquidityPool.target, Domain.ETHEREUM, Provider.EVERCLEAR);
1058+
.withArgs(weth.target, apiAmountWithFee, liquidityPool.target, Domain.ETHEREUM, Provider.EVERCLEAR);
10531059
await expect(tx)
10541060
.to.emit(weth, "Transfer")
1055-
.withArgs(repayer.target, everclearFeeAdapter.target, amount);
1061+
.withArgs(repayer.target, everclearFeeAdapter.target, apiAmountWithFee);
10561062
await expect(tx)
10571063
.to.emit(everclearFeeAdapter, "IntentWithFeesAdded");
1058-
expect(await weth.balanceOf(repayer)).to.equal(6n * ETH);
1064+
expect(await weth.balanceOf(repayer)).to.equal(10n * ETH - apiAmountWithFee);
10591065
expect(await getBalance(repayer)).to.equal(0n);
10601066
});
10611067

0 commit comments

Comments
 (0)