Skip to content

Commit

Permalink
test(bundler): make them all pass for once
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 17, 2024
1 parent 3700073 commit 17a5905
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/blue-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/node": "^22.1.0",
"typescript": "^5.6.3",
"viem": "^2.21.19",
"viem-deal": "^2.0.0",
"viem-deal": "^2.0.1",
"vitest": "^2.1.3"
},
"publishConfig": {
Expand Down
25 changes: 2 additions & 23 deletions packages/bundler-sdk-viem/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getChainAddresses,
getUnwrappedToken,
} from "@morpho-org/blue-sdk";
import { format, keys } from "@morpho-org/morpho-ts";
import { format } from "@morpho-org/morpho-ts";

import {
type BundlingOptions,
Expand Down Expand Up @@ -141,28 +141,7 @@ export const setupBundle = async <chain extends Chain = Chain>(
}
});

if (onBundleTx != null) {
const balancesBefore = await Promise.all(
[...tokens, ...keys(startData.tokens)].map(async (token) => ({
token,
balance: await client.balanceOf({
erc20: token,
owner: account.address,
}),
})),
);

await onBundleTx(startData);

await Promise.all(
balancesBefore.map(({ token, balance }) =>
client.deal({
erc20: token,
amount: balance,
}),
),
);
}
await onBundleTx?.(startData);

await Promise.all(
bundle.requirements.signatures.map((requirement) =>
Expand Down
15 changes: 7 additions & 8 deletions packages/bundler-sdk-viem/test/populateBundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ describe("populateBundle", () => {
async ({ client, config }) => {
const { id } = usdc_wstEth;
const collateralAssets = parseEther("100");
const loanShares = parseUnits("5000", 12);
const loanShares = parseUnits("50000", 12);
const loanAssets = (await fetchMarket(id, client)).toBorrowAssets(
loanShares,
);
Expand Down Expand Up @@ -2199,7 +2199,6 @@ describe("populateBundle", () => {
const borrowAmount = parseEther("0.5");

await client.deal({ erc20: wstEth, amount: collateralAmount });
await client.deal({ erc20: stEth, amount: 0n });

await client.approve({ address: wstEth, args: [morpho, maxUint256] });
await client.writeContract({
Expand Down Expand Up @@ -2418,7 +2417,7 @@ describe("populateBundle", () => {
).toBe(0n);

expect(await client.balanceOf({ erc20: stEth })).toBe(
wstEthToken.toUnwrappedExactAmountIn(collateralAmount, 0n) - 2n,
wstEthToken.toUnwrappedExactAmountIn(collateralAmount, 0n) - 1n,
);
expect(await client.balanceOf({ erc20: wstEth })).toBe(0n);
expect(await client.balanceOf({ erc20: wNative })).toBe(
Expand Down Expand Up @@ -3628,7 +3627,7 @@ describe("populateBundle", () => {
async ({ client, config }) => {
const { id } = usdc_wstEth;
const collateralAssets = parseEther("100");
const loanShares = parseUnits("5000", 12);
const loanShares = parseUnits("50000", 12);
const loanAssets = (await fetchMarket(id, client)).toBorrowAssets(
loanShares,
);
Expand Down Expand Up @@ -3824,10 +3823,10 @@ describe("populateBundle", () => {
test[ChainId.EthMainnet](
"should redeem all bbETH with slippage + wstETH leverage into bbETH deposit & unwrap remaining WETH",
async ({ client, config }) => {
const id = eth_wstEth.id;
const id = eth_wstEth_2.id;

const collateralAssets = parseEther("100");
const loanAssets = parseEther("95");
const loanAssets = parseEther("5");

await client.deal({ erc20: wstEth, amount: collateralAssets });
await client.deal({ erc20: wNative, amount: loanAssets });
Expand Down Expand Up @@ -3856,7 +3855,7 @@ describe("populateBundle", () => {
eth_rEth.id,
eth_sDai.id,
eth_wbtc.id,
eth_wstEth_2.id,
eth_wstEth.id,
],
users: [client.account.address, bundler, bbEth.address],
tokens: [NATIVE_ADDRESS, wNative, stEth, wstEth, bbEth.address],
Expand Down Expand Up @@ -4935,7 +4934,7 @@ describe("populateBundle", () => {
).toBe(0n);

expect(await client.balanceOf({ erc20: stEth })).toBe(
wstEthToken.toUnwrappedExactAmountIn(collateralAmount, 0n) - 2n,
wstEthToken.toUnwrappedExactAmountIn(collateralAmount, 0n) - 1n,
);
expect(await client.balanceOf({ erc20: wstEth })).toBe(0n);
expect(await client.balanceOf({ erc20: wNative })).toBe(
Expand Down
4 changes: 2 additions & 2 deletions packages/test-viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"peerDependencies": {
"@morpho-org/test": "workspace:^",
"viem": "^2.21.10",
"viem-deal": "^2.0.0",
"viem-deal": "^2.0.1",
"vitest": "^2.1.0"
},
"devDependencies": {
"@morpho-org/test": "workspace:^",
"@types/node": "^22.7.4",
"typescript": "^5.6.3",
"viem": "^2.21.19",
"viem-deal": "^2.0.0",
"viem-deal": "^2.0.1",
"vitest": "^2.1.3"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/test-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@morpho-org/test": "workspace:^",
"@morpho-org/test-viem": "workspace:^",
"viem": "^2.21.10",
"viem-deal": "^2.0.0",
"viem-deal": "^2.0.1",
"vitest": "^2.1.0"
},
"devDependencies": {
Expand All @@ -31,7 +31,7 @@
"react-dom": "^18.3.1",
"typescript": "^5.6.3",
"viem": "^2.21.19",
"viem-deal": "^2.0.0",
"viem-deal": "^2.0.1",
"vitest": "^2.1.3",
"wagmi": "^2.12.17"
},
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17a5905

Please sign in to comment.