Skip to content

Commit

Permalink
feat(bundler3): replace encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Jan 27, 2025
1 parent 84132ba commit b4b1df6
Show file tree
Hide file tree
Showing 15 changed files with 854 additions and 571 deletions.
7 changes: 5 additions & 2 deletions packages/blue-sdk-ethers/src/fetch/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ export async function fetchUser(
chainId ?? (await runner.provider.getNetwork()).chainId,
);

const { morpho, bundler } = getChainAddresses(chainId);
const {
morpho,
bundler3: { generalAdapter1 },
} = getChainAddresses(chainId);
const blue = MorphoBlue__factory.connect(morpho, runner);

const [isBundlerAuthorized, morphoNonce] = await Promise.all([
blue.isAuthorized(address, bundler, overrides),
blue.isAuthorized(address, generalAdapter1, overrides),
blue.nonce(address, overrides),
]);

Expand Down
17 changes: 11 additions & 6 deletions packages/blue-sdk-ethers/test/e2e/Holding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import { maxUint256 } from "viem";
import { Holding } from "../../src/augment/Holding";
import { permit2Abi } from "./abis";

const { morpho, bundler, permit2, wNative, wbC3M } =
addresses[ChainId.EthMainnet];
const {
morpho,
bundler3: { generalAdapter1 },
permit2,
wNative,
wbC3M,
} = addresses[ChainId.EthMainnet];

describe("augment/Holding", async () => {
test("should fetch user WETH data ", async ({ client, wallet }) => {
Expand Down Expand Up @@ -50,7 +55,7 @@ describe("augment/Holding", async () => {
});
await client.approve({
address: wNative,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wNative,
Expand All @@ -73,7 +78,7 @@ describe("augment/Holding", async () => {
functionName: "approve",
args: [
wNative,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down Expand Up @@ -152,7 +157,7 @@ describe("augment/Holding", async () => {
});
await client.approve({
address: wbC3M,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wbC3M,
Expand All @@ -175,7 +180,7 @@ describe("augment/Holding", async () => {
functionName: "approve",
args: [
wbC3M,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down
7 changes: 5 additions & 2 deletions packages/blue-sdk-ethers/test/e2e/User.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import { ChainId, addresses } from "@morpho-org/blue-sdk";
import { User } from "../../src/augment/User";
import { blueAbi } from "./abis";

const { morpho, bundler } = addresses[ChainId.EthMainnet];
const {
morpho,
bundler3: { generalAdapter1 },
} = addresses[ChainId.EthMainnet];

describe("augment/User", () => {
test("should fetch user data", async ({ client, wallet }) => {
await client.writeContract({
address: morpho,
abi: blueAbi,
functionName: "setAuthorization",
args: [bundler, true],
args: [generalAdapter1, true],
});

const expectedData = new User({
Expand Down
8 changes: 6 additions & 2 deletions packages/blue-sdk-viem/src/fetch/Holding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export async function fetchHolding(
});

if (deployless) {
const { morpho, permit2, bundler } = addresses[parameters.chainId];
const {
morpho,
permit2,
bundler3: { generalAdapter1 },
} = addresses[parameters.chainId];
try {
const {
balance,
Expand All @@ -79,7 +83,7 @@ export async function fetchHolding(
user,
morpho,
permit2,
bundler,
generalAdapter1,
permissionedBackedTokens[parameters.chainId].has(token),
permissionedWrapperTokens[parameters.chainId].has(token),
],
Expand Down
7 changes: 5 additions & 2 deletions packages/blue-sdk-viem/src/fetch/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ export async function fetchUser(
parameters.chainId ?? (await getChainId(client)),
);

const { morpho, bundler } = addresses[parameters.chainId];
const {
morpho,
bundler3: { generalAdapter1 },
} = addresses[parameters.chainId];

const [isBundlerAuthorized, morphoNonce] = await Promise.all([
readContract(client, {
...parameters,
address: morpho,
abi: blueAbi,
functionName: "isAuthorized",
args: [address, bundler],
args: [address, generalAdapter1],
}),
readContract(client, {
...parameters,
Expand Down
25 changes: 15 additions & 10 deletions packages/blue-sdk-viem/test/Holding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import { permit2Abi } from "../src";
import { Holding } from "../src/augment/Holding";
import { test } from "./setup";

const { morpho, bundler, permit2, wNative, wbC3M } =
addresses[ChainId.EthMainnet];
const {
morpho,
bundler3: { generalAdapter1 },
permit2,
wNative,
wbC3M,
} = addresses[ChainId.EthMainnet];

describe("augment/Holding", () => {
test("should fetch user WETH data with deployless", async ({ client }) => {
Expand Down Expand Up @@ -50,7 +55,7 @@ describe("augment/Holding", () => {
});
await client.approve({
address: wNative,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wNative,
Expand All @@ -73,7 +78,7 @@ describe("augment/Holding", () => {
functionName: "approve",
args: [
wNative,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down Expand Up @@ -119,7 +124,7 @@ describe("augment/Holding", () => {
});
await client.approve({
address: wNative,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wNative,
Expand All @@ -142,7 +147,7 @@ describe("augment/Holding", () => {
functionName: "approve",
args: [
wNative,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down Expand Up @@ -225,7 +230,7 @@ describe("augment/Holding", () => {
});
await client.approve({
address: wbC3M,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wbC3M,
Expand All @@ -248,7 +253,7 @@ describe("augment/Holding", () => {
functionName: "approve",
args: [
wbC3M,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down Expand Up @@ -297,7 +302,7 @@ describe("augment/Holding", () => {
});
await client.approve({
address: wbC3M,
args: [bundler, expectedData.erc20Allowances.bundler],
args: [generalAdapter1, expectedData.erc20Allowances.bundler],
});
await client.approve({
address: wbC3M,
Expand All @@ -320,7 +325,7 @@ describe("augment/Holding", () => {
functionName: "approve",
args: [
wbC3M,
bundler,
generalAdapter1,
expectedData.permit2Allowances.bundler.amount,
Number(expectedData.permit2Allowances.bundler.expiration),
],
Expand Down
7 changes: 5 additions & 2 deletions packages/blue-sdk-viem/test/User.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import { ChainId, addresses } from "@morpho-org/blue-sdk";
import { blueAbi } from "../src";
import { User } from "../src/augment/User";

const { morpho, bundler } = addresses[ChainId.EthMainnet];
const {
morpho,
bundler3: { generalAdapter1 },
} = addresses[ChainId.EthMainnet];

describe("augment/User", () => {
test("should fetch user data", async ({ client }) => {
await client.writeContract({
address: morpho,
abi: blueAbi,
functionName: "setAuthorization",
args: [bundler, true],
args: [generalAdapter1, true],
});

const expectedData = new User({
Expand Down
Loading

0 comments on commit b4b1df6

Please sign in to comment.