KYT Sessions #2: Know Your zkLend Transactions — 31/08/2023

zkLend
zkLend
Published in
5 min readSep 12, 2023

Zenders,

In our latest KYT Sessions #2: Know Your zkLend Transactions, Co-Founder Brian went through everything you need to know when it comes to using Starknet’s block explorers StarkScan and Voyager to read and understand your transaction on zkLend. If you didn’t get a chance to join the session, don’t worry we’ve got you covered with our full recap below.

Key Contracts

When interacting with zkLend, it’s crucial to be familiar with the key contracts involved. These contracts include the 5 StarkGate asset token addresses (ETH, WBTC, USDT, USDC, and DAI) and their corresponding zToken addresses (zETH, zWBTC, zUSDT, zUSDC).

Additionally, the zkLend Markets contract address plays a central role in the zkLend ecosystem. This is where users can locate all transactions that occur on zkLend such as deposit, collateral enabling, borrow, repay and withdraw to name a few. You can find more info on zkLend’s contract addresses on our GitBook.

Demystifying zTokens

When a user deposits on zkLend, they will receive a proportional amount of zTokens directly into their wallet. These zTokens represent the deposited assets, such as zDAI, for example. Each zToken holds a value that reflects the prevailing exchange rate compared to the underlying asset. This value encompasses both the principal amount and any interest that has accumulated over time in the pool.

zTokens are non-rebasing tokens (i.e. the “price” of zTokens increases to account for the accumulation of financing interest over time.) To account for the interest accumulation of the various assets, zkLend protocol grows the “Accumulators” of each asset, in line with the prevailing lending & borrowing rates. The Accumulators would expand continuously through time since the inception of zkLend protocol.

For example, whenever users deposit fund to zkLend, the zTokens’ value would be rebased back by the Accumulator to the “raw_value”; and when the users withdraw some time later, the “raw_value” would again be rebased forward by the latest Accumulator value to account for the interest income gained during that time.

The session shed light on zkLend’s interest-bearing token contracts, specifically, zETH was discussed, which has approximately ~3,500 total supply and around 225K unique owners at the time of writing.

Starknet Transaction Lifecycle

The Starknet transaction lifecycle involves two crucial components: Sequencers and the Starknet OS.

Sequencers play a vital role in the transaction processing on Starknet. They receive incoming transactions and are responsible for processing and bundling them into blocks. During this process, Sequencers generate a series of function calls or state changes that reflect the actions performed within the transactions. This mechanism helps prevent double-spending and ensures the network’s state consistency.

On the other hand, the Starknet OS, powered by the Cairo program, serves as the underlying system that runs Starknet. It handles various operations performed on the network, including contract deployment and transaction execution. Additionally, the Starknet OS facilitates communication between Layer 1 (L1) and Layer 2 (L2) through L1<>L2 messages. This comprehensive system ensures the smooth functioning of the Starknet network, enabling efficient contract deployment, execution, and inter-layer communication.

Starknet Transaction Status

  • NOT RECEIVED = transaction not received yet and still in transient memory
  • RECEIVED = transaction in transaction pool, but not picked up by Sequencer
  • PENDING = acknowledged by Sequencer, the transaction is valid and will be put onto the block soon
  • ACCEPTED ON L2 = similar status and the same level of guarantee as PENDING
  • ACCEPTED ON L1 = block received and proved on L1

Sample Transaction- Supplied USDT

To better understand the previous concepts, here is a sample transaction of a 75 USDT deposit to zkLend. Below you can see all 9 events that took place and the details within each.

Read/Write zkLend’s Markets Contract

To finish off the session, we delved into the Read/Write Contract functions available on Starknet’s block explorers, with a specific focus on the Read function for zkLend’s Markets Contract.

Utilizing the Read function offers an array of fascinating insights and statistics. For instance, one can obtain the total protocol debt for each asset, revealing the cumulative amount borrowed by users. Furthermore, by inputting the wallet address and token address of a specific user and asset, one can retrieve the corresponding debt amount on zkLend.

These examples merely scratch the surface, as a comprehensive list of available functionalities can be found in the accompanying image. Through the power of the read function, users can unlock valuable information about borrowing and debt within the zkLend ecosystem.

Source: https://starkscan.co/

NOTE: Please note that while the Write function is accessible for usage, we strongly advise users against interacting with zkLend solely through this method. Instead, we recommend utilizing the zkLend dApp’s user interface (UI) for an optimal and seamless experience when interacting with the zkLend Markets contract.

Closing Comments

To conclude, this second KYT Session covered the following main points:

  1. Key contracts you need to know when interacting with zkLend
  2. How zkLend’s interest-bearing zTokens work
  3. Starknet’s Transactions Lifecycle & Status
  4. We went over all the events that make up a transaction on zkLend
  5. How to use the Read function for zkLend’s Markets contract from a block explorer

Thank you for reading this recap for zkLend’s KYT Sessions #2: Know Your zkLend Transactions with Co-Founder Brian.

Kind regards,

zkLend Team

About KYT Sessions

KYT Sessions are a series of immersive talks and tutorials with a final community challenge that will elevate your transaction tracking skills ahead of our mainnet launch. Community members will dive into the basics of blockchain indexing, master the art of navigating block explorers, and all with with visionary Starknet leaders who’ll guide you through this experience.

About zkLend

zkLend is an L2 money-market protocol built on Starknet, combining zk-rollup scalability, superior transaction speed, and cost-savings with Ethereum’s security. The protocol offers a dual solution: a permissioned and compliance-focused solution for institutional clients, and a permissionless service for DeFi users — all without sacrificing decentralisation.

Website | Twitter | Telegram | Discord | Spotify

--

--

zkLend
zkLend

zkLend is an L2 money-market protocol built on StarkNet, combining zk-rollup scalability, superior transaction speed, and cost-savings with Ethereum’s security.