Shadow
  • 🌗Overview
  • 🏁Quickstart
  • 🎯Use cases
  • ⛓️Supported chains
  • MODIFY CONTRACTS
    • Versioning
    • How to's
      • Proxy contracts
      • Using oracles
      • Factory contracts
      • Interdependent shadow contracts
  • GETTING DATA
    • Shadow RPC
    • Database syncs
    • Recurring exports
    • One-off exports
    • API Keys
  • Integrations
    • Postgres
    • GCS / S3
    • Dune
  • Product Guide
    • Catalog
    • Test runs
    • Subgraphs
  • Tips
    • Proxy contracts
    • Solidity beginners
      • Recommended tools
  • Resources
    • 📚Concepts
    • ❓FAQs
Powered by GitBook
On this page
  • Step 1 – Edit the BlurPool contract
  • Step 2 – Deploy the BlurPool changes to your fork (optional)
  • Step 3 – Edit the Blend contract
  • Step 4 – Test run your changes
  • Step 5 – Deploy the Blend changes to your fork (optional)
Export as PDF
  1. MODIFY CONTRACTS
  2. How to's

Interdependent shadow contracts

PreviousFactory contractsNextShadow RPC

Last updated 8 months ago

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: , 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.:

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”.

Borrow:

Repay:

Refinance:

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