Interdependent shadow contracts

You can make interdependent shadow contract changes across multiple contracts by editing and deploying each contract separately.

In this example, we’ll be making interdependent changes to Blur’s Blend and BlurPool contracts.

We’ll be making changes so that the BlurPool contract will emit a new shadow event TransferForLien every time some ETH in the pool gets transferred due to an action taken on a given lien (e.g. borrow, repay, refinance). The TransferForLien shadow event will include metadata about the lien.

Step 1 – Edit the BlurPool contract

Open the example on the Shadow Playground: https://app.shadow.xyz/demo?example=blur_interdependent_contracts, which will open the playground editor at the BlurPool contract.

In BlurPool.sol on L115, we’ve introduced a new function called transferFromForLien:

function transferFromForLien(address from, address to, uint256 amount, uint256 lienId, Lien calldata lien, string calldata annotation) external returns (bool) {
    bool result = transferFrom(from, to, amount);
    emit TransferForLien(from, to, amount, lienId, lien, annotation);
    return result;
}

You can see the schema of the TransferForLien event in the IBlurPool.sol file:

event TransferForLien(
    address indexed from,
    address indexed to,
    uint256 amount,
    uint256 lienId,
    Lien lien,
    string annotation
);

Step 2 – Deploy the BlurPool changes to your fork (optional)

If you want to apply these changes on your shadow fork, click the button on the top right corner that says “Apply to your shadow fork”. This will take you to the editor for your shadow fork, where you can deploy the changes by hitting “Compile > Deploy”.

Step 3 – Edit the Blend contract

Go to the following URL to open the Blend contract in the Shadow Playground for this example.:

https://app.shadow.xyz/demo/0xb258ca5559b11cd702f363796522b04d7722ea56?example=blur_interdependent_contracts

In Blend.sol, you’ll see that we updated all BlurPool.transferFrom() call sites to call the new transferFromForLien function we added earlier.

Step 4 – Test run your changes

Click “Compile” > “Test Run” in the top right corner, and paste in the following transaction hashes to see these shadow changes in action:

You should see your custom TransferForLien event in the output for each transaction!

Step 5 – Deploy the Blend changes to your fork (optional)

If you want to apply these changes on your shadow fork, click the button on the top right corner that says “Apply to your shadow fork”.

This will take you to the editor for your shadow fork, where you can deploy the changes by hitting “Compile > Deploy”.

Last updated