Skip to main content

Blend

Let's modify the Blend contract to emit detailed events

Blend is an onchain NFT-lending protocol, developed by the BLUR team. The contract is quite gas-efficient, which it achieves by:

  1. not storing loan state onchain, and
  2. emitting less information from event logs

With GhostLogs we can inject custom, gasless events into the contract which gives us observability while still being gas-efficient since no modifications are actually deployed onchain. Instead our modified versions run in an offchain context.

Maximum observability 🤝 Maximum gas-efficiency

The Repay event is a bit thin since it only emits the lienId and the collection of the loan being repaid. So let's use GhostLogs to create a new event with a lot more details and then emit it.

Declare the event in IBlend.sol with all the properties that we want to surface.

BlendDeclare

In Blend.sol, update the _repay internal function to also emit our newly declared RepayDetails event.

We can access local context (lien data) and even call helper methods to perform calculations (computeCurrentDebt) to expose the debt that was repaid. We could also read private variables and make calls to external contracts if we wanted.

BlendUse