Skip to content

Commit 3cdbc56

Browse files
authored
Merge branch 'main' into feature/dvxsdk-65-add-sdk-stable-support
2 parents 15f1952 + 03a9a9e commit 3cdbc56

File tree

18 files changed

+361
-238
lines changed

18 files changed

+361
-238
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"lint-staged": "^15.4.3",
4343
"semver": "^7.7.1",
4444
"typescript": "^5.7.2",
45-
"viem": "^2.33.3",
45+
"viem": "^2.39.0",
4646
"vitest": "^3.0.5"
4747
},
4848
"lint-staged": {

packages/blue-sdk-viem/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@morpho-org/test": "workspace:^",
3131
"hardhat": "^2.22.18",
3232
"typescript": "^5.7.2",
33-
"viem": "^2.33.3",
33+
"viem": "^2.39.0",
3434
"vitest": "^3.0.5"
3535
},
3636
"publishConfig": {

packages/blue-sdk-wagmi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"react": "^19.0.0",
4444
"react-dom": "^19.0.0",
4545
"typescript": "^5.7.2",
46-
"viem": "^2.33.3",
46+
"viem": "^2.39.0",
4747
"vitest": "^3.0.5",
4848
"wagmi": "^2.14.10"
4949
},

packages/blue-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@morpho-org/morpho-ts": "workspace:^",
3333
"@morpho-org/test": "workspace:^",
3434
"typescript": "^5.7.2",
35-
"viem": "^2.33.3",
35+
"viem": "^2.39.0",
3636
"vitest": "^3.0.5"
3737
},
3838
"publishConfig": {

packages/blue-sdk/test/e2e/Market.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe("Market", () => {
129129
sender: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
130130
131131
Docs: https://viem.sh/docs/contract/writeContract
132-
Version: viem@2.33.3]
132+
Version: viem@2.39.0]
133133
`);
134134

135135
const hash = await client.writeContract({

packages/bundler-sdk-viem/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/lodash": "^4.17.12",
4141
"lodash": "^4.17.21",
4242
"typescript": "^5.7.2",
43-
"viem": "^2.33.3",
43+
"viem": "^2.39.0",
4444
"vitest": "^3.0.5"
4545
},
4646
"publishConfig": {

packages/bundler-sdk-viem/src/actions.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,9 @@ export const encodeOperation = (
607607
actions.push({
608608
type: "morphoSupply",
609609
args: [
610-
market.params,
610+
// Avoid passing the reference of a revokable proxy that would fail
611+
// accessing its underlying value after revocation.
612+
getCurrent(market.params),
611613
assets,
612614
shares,
613615
maxSharePrice,
@@ -644,7 +646,9 @@ export const encodeOperation = (
644646
actions.push({
645647
type: "morphoWithdraw",
646648
args: [
647-
market.params,
649+
// Avoid passing the reference of a revokable proxy that would fail
650+
// accessing its underlying value after revocation.
651+
getCurrent(market.params),
648652
assets,
649653
shares,
650654
minSharePrice,
@@ -682,7 +686,9 @@ export const encodeOperation = (
682686
actions.push({
683687
type: "morphoBorrow",
684688
args: [
685-
market.params,
689+
// Avoid passing the reference of a revokable proxy that would fail
690+
// accessing its underlying value after revocation.
691+
getCurrent(market.params),
686692
assets,
687693
shares,
688694
minSharePrice,
@@ -723,7 +729,9 @@ export const encodeOperation = (
723729
actions.push({
724730
type: "morphoRepay",
725731
args: [
726-
market.params,
732+
// Avoid passing the reference of a revokable proxy that would fail
733+
// accessing its underlying value after revocation.
734+
getCurrent(market.params),
727735
assets,
728736
shares,
729737
maxSharePrice,
@@ -761,7 +769,9 @@ export const encodeOperation = (
761769
actions.push({
762770
type: "morphoSupplyCollateral",
763771
args: [
764-
params,
772+
// Avoid passing the reference of a revokable proxy that would fail
773+
// accessing its underlying value after revocation.
774+
getCurrent(params),
765775
assets,
766776
onBehalf,
767777
callbackBundle?.actions ?? [],
@@ -778,7 +788,14 @@ export const encodeOperation = (
778788

779789
actions.push({
780790
type: "morphoWithdrawCollateral",
781-
args: [params, assets, receiver, operation.skipRevert],
791+
args: [
792+
// Avoid passing the reference of a revokable proxy that would fail
793+
// accessing its underlying value after revocation.
794+
getCurrent(params),
795+
assets,
796+
receiver,
797+
operation.skipRevert,
798+
],
782799
});
783800

784801
break;
@@ -906,10 +923,14 @@ export const encodeOperation = (
906923
operation.address,
907924
fee,
908925
withdrawals.map(({ id, assets }) => ({
909-
marketParams: dataBefore.getMarket(id).params,
926+
// Avoid passing the reference of a revokable proxy that would fail
927+
// accessing its underlying value after revocation.
928+
marketParams: getCurrent(dataBefore.getMarket(id).params),
910929
amount: assets,
911930
})),
912-
dataBefore.getMarket(supplyMarketId).params,
931+
// Avoid passing the reference of a revokable proxy that would fail
932+
// accessing its underlying value after revocation.
933+
getCurrent(dataBefore.getMarket(supplyMarketId).params),
913934
operation.skipRevert,
914935
],
915936
});

packages/bundler-sdk-viem/test/helpers.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,33 @@ export const setupTestBundle = async <chain extends Chain = Chain>(
116116
);
117117
const users = new Set(keys(startData.users).filter(isDefined));
118118

119+
const { morpho, permit2, bundler3 } = getChainAddresses(startData.chainId);
120+
const bundler3Adapters = values(bundler3).filter(isDefined);
121+
const balancesBefore = new Map(
122+
await Promise.all(
123+
[...tokens].map(
124+
async (token) =>
125+
[
126+
token,
127+
new Map(
128+
await Promise.all(
129+
bundler3Adapters.map(
130+
async (adapter) =>
131+
[
132+
adapter,
133+
await client.balanceOf({
134+
erc20: token,
135+
owner: adapter,
136+
}),
137+
] as const,
138+
),
139+
),
140+
),
141+
] as const,
142+
),
143+
),
144+
);
145+
119146
await onBundleTx?.(startData);
120147

121148
await bundle.requirements.sign(client, account);
@@ -127,17 +154,14 @@ export const setupTestBundle = async <chain extends Chain = Chain>(
127154
);
128155
}
129156

130-
const { morpho, permit2, bundler3 } = getChainAddresses(startData.chainId);
131-
132-
const bundler3Adapters = values(bundler3).filter(isDefined);
133-
134157
await Promise.all(
135158
[...tokens].map(async (token) => {
136159
const [balances, allowances, authorizations] = await Promise.all([
137160
Promise.all(
138161
bundler3Adapters.map(async (adapter) => ({
139162
adapter,
140163
balance: await client.balanceOf({ erc20: token, owner: adapter }),
164+
balanceBefore: balancesBefore.get(token)!.get(adapter)!,
141165
})),
142166
),
143167
Promise.all(
@@ -180,11 +204,11 @@ export const setupTestBundle = async <chain extends Chain = Chain>(
180204
),
181205
]);
182206

183-
for (const { balance, adapter } of balances)
207+
for (const { balance, balanceBefore, adapter } of balances)
184208
expect(
185209
balance,
186210
`balance of "${adapter}" for token "${token}"`,
187-
).toBeLessThanOrEqual(5n);
211+
).toBeLessThanOrEqual(balanceBefore + 5n);
188212

189213
for (const { adapter, erc20Allowance, permit2Allowance } of allowances) {
190214
if (token !== NATIVE_ADDRESS && adapter !== bundler3.generalAdapter1)

0 commit comments

Comments
 (0)