<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arnaud Bakyono on Medium]]></title>
        <description><![CDATA[Stories by Arnaud Bakyono on Medium]]></description>
        <link>https://medium.com/@arnaudbakyono?source=rss-f5a96c9af5af------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4tEEIUGzPPV6DFUq.</url>
            <title>Stories by Arnaud Bakyono on Medium</title>
            <link>https://medium.com/@arnaudbakyono?source=rss-f5a96c9af5af------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:13:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arnaudbakyono/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to DeFi Lending for Developers: Key Concepts and Overview of Major Protocols]]></title>
            <link>https://coinsbench.com/introduction-to-defi-lending-for-developers-key-concepts-and-overview-of-major-protocols-19b51c5f79e7?source=rss-f5a96c9af5af------2</link>
            <guid isPermaLink="false">https://medium.com/p/19b51c5f79e7</guid>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[lending]]></category>
            <category><![CDATA[zerolend]]></category>
            <dc:creator><![CDATA[Arnaud Bakyono]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 11:56:29 GMT</pubDate>
            <atom:updated>2025-12-01T11:56:29.127Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><h4>What is DeFi?</h4><p>Decentralized Finance, or DeFi, is an open and global financial system built on top of the blockchain. It’s accessible to anyone, unlike classic banking. It differs from traditional banking because it’s transparent, and no single entity controls the system. Everything is anonymous, no KYC requirements, no waiting for account approval, and you actually control your money. Unlike banks, where you don’t really own your money and can’t withdraw as much as you want, in DeFi, you have complete control.</p><h4><strong>Lending and borrowing in DeFi</strong></h4><p>You can lend and borrow from people with way fewer restrictions — no mountains of paperwork, no weeks of waiting for approval. However, for this to work, there needs to be money available to withdraw.</p><p>That’s where liquidity pools come in. Anyone can deposit money into these pools for others to borrow, earning interest on that amount. <strong>This is where DeFi lending protocols become essential.</strong></p><p>But wait, if anyone can borrow and it’s anonymous, what prevents someone from just not paying back their loan?</p><p>That’s where collateral comes in. You must provide collateral before borrowing, and if you fail to repay, the collateral is used to settle the lender&#39;s debt. So, you need to have money to borrow.</p><p>This may seem odd. If someone already has the money, why borrow at all?</p><h4><strong>The problem DeFi lending solves</strong></h4><p>So why would anyone borrow if they already have the money? Here are a few reasons:</p><ul><li>You may not want to sell your crypto. Let’s say you have $2000 worth of ETH. And you believe it’s going to $5000 next year. You need $1000 for rent. Do you sell your ETH and miss out on potential gains? Or do you borrow $1000 against it, pay some interest, and keep your ETH position? For many people, borrowing makes more sense.</li><li>Taxes. In most countries, selling crypto is a taxable event — you pay capital gains tax. Borrowing? Not taxable. If you need liquidity but don’t want to trigger a tax bill, borrowing is the way.</li></ul><h3>Core concepts of DeFi Lending</h3><h4>Liquidity pools</h4><p>A liquidity pool is a crowdsourced pool of cryptocurrencies or tokens locked in a smart contract that serves multiple purposes, in our case: lending and borrowing.</p><p>People who deposit their money into the pool earn interest in return. Instead of lending directly to a specific person, your funds become part of one big pool that anyone can borrow from. This means you’re not waiting for one particular borrower to repay; you can withdraw at any time there’s available liquidity in the pool.</p><p>With this system and the incentive of earning interest, there is a guarantee that money is always available for borrowing, and the borrowing process is instantaneous: no matching, no waiting, no negotiating terms with individual lenders.</p><h4>Overcollateralization</h4><p>As we briefly explained in the introduction, to borrow, you must provide collateral, and the collateral should be worth more than the amount borrowed; this is called <strong>overcollateralization</strong>.</p><p>Typically, you need to deposit 150–200% of what you want to borrow. For example, to borrow $1,000 in USDC, you might need to deposit $1,500-$2,000 worth of ETH.</p><p>Why? Because the lending protocol has to be able to repay the lenders when your collateral’s value drops, we’re talking about tokens that fluctuate here. Unlike banks that can take legal action if you don’t repay, DeFi protocols have no way to enforce repayment. The collateral is the only guarantee.</p><p><strong>This system serves two purposes:</strong> it reduces risk for lenders (the extra collateral protects them), and it incentivizes borrowers to repay their loans (you don’t want to lose your collateral, which is worth more than what you borrowed).</p><p>The protocol tracks your position using a <strong>health factor</strong>. This ratio indicates the level of risk associated with your loan. If your ETH collateral drops in value and your health factor falls below a certain threshold, your position becomes eligible for <strong>liquidation </strong>(we’ll cover this in more detail later). This protects lenders from losing money.</p><h4>Loans management</h4><p>Unlike traditional loans, where you have a fixed deadline, DeFi ones don’t expire. You can hold your loan for as long as you want (even years) as long as your health factor stays above 1.0.<br>When you want to repay, you pay back the amount borrowed plus the accumulated interest, and your collateral is unlocked and returned to you. You can also repay partially if you prefer, paying back half to improve your health factor and reduce the risk of liquidation (again, bear with me, we’ll cover this in detail).</p><h4>Interest rates</h4><p>Interest rates are calculated using an algorithm built into the smart contract. This is entirely transparent; you can see the exact formulas in the protocol’s source code if you want to learn more. Interest rates are updated automatically in response to changes in supply and demand.</p><p>The primary metric is the <strong>utilization rate</strong>; it may be slightly more sophisticated in some protocols, but this is the core concept: <strong>Utilization Rate = Total Borrowed / Total Supplied.</strong></p><p>Here’s how it works: If a lot of money is being borrowed from the pool (high utilization), interest rates go up. Why? To attract more lenders to supply cash and to incentivize borrowers to repay. If not much is being borrowed (low utilization), rates go down to attract more borrowers.</p><p>For example:</p><ul><li>Pool has $1M USDC total.</li><li>$200K is borrowed =&gt; Utilization = 20% → Interest rates are low (~3–5%)</li><li>$800K is borrowed =&gt; Utilization = 80% → Interest rates are high (~15–25%)</li></ul><p>This creates a natural balance between supply and demand, all without any intervention.</p><h4>Liquidation</h4><p>Liquidation is a mechanism that gets triggered based on certain conditions to ensure lenders don’t lose their money (or at least suffer minimal loss).</p><p>Let’s say there’s a USDC pool and someone borrows by submitting ETH as collateral. Thanks to <strong>overcollateralization</strong>, there’s a certain margin where the collateral is protected even if ETH drops a bit. But past a certain threshold, the loan is no longer safe and needs to be liquidated.</p><p>Here’s what happens: The protocol allows <strong>liquidators</strong> (usually bots monitoring the blockchain) to step in. They repay part or all of the borrower’s debt, and in return, they receive the borrower’s collateral plus a bonus (typically 5–15% of the liquidated amount). This bonus is their incentive to act quickly.</p><p>Note that liquidation can be partial; the borrower may not lose all of their collateral. The liquidator might only repay enough debt to bring the position back to a safe level. For example, if you owe $1000 and your health factor drops too low, a liquidator might repay $500 of your debt, take $550 worth of your collateral (including their 10% bonus), and leave you with the rest. This mechanism protects lenders while giving borrowers a chance to keep some of their collateral if they act quickly to fix their position.</p><h4>Oracles</h4><p>Oracles are systems that bridge off-chain data to on-chain smart contracts. In lending protocols, oracles continuously provide current cryptocurrency prices, particularly for assets used as collateral.</p><p>They’re critical because they enable the protocol to know when to trigger liquidations. Remember, if the ETH collateral you have deposited drops in value, the protocol needs to know the current ETH price to calculate your health factor and determine if liquidation is necessary. Without accurate price data, the protocol can’t protect lenders.</p><p>This makes oracles a potential point of failure. If oracles are compromised or misconfigured, it can lead to disasters. Imagine if an oracle reports the wrong price and triggers mass liquidations when it shouldn’t, or worse, fails to trigger liquidations when collateral values have actually dropped. That’s why most protocols utilize decentralized oracle networks, such as Chainlink or Pyth, which aggregate data from multiple sources to mitigate manipulation risk.</p><h3>Leading lending protocols</h3><h4>Compound: the oldest one</h4><p>Compound is the oldest protocol in this space. V1 launched in 2018, and we’re now on V3. Compound essentially pioneered the entire liquidity pool model, which other lending protocols have adopted.</p><p>Here’s how it works: when you deposit assets into Compound, you get cTokens in return. These are basically receipts showing you supplied money to the pool. For example, deposit 100 ETH, and you get cETH tokens. Deposit USDC, you get cUSDC. These cTokens are ERC-20 compatible, allowing you to transfer them or utilize them in other protocols.</p><p>What’s interesting about cTokens is how they handle interests. Your cToken balance stays the same, but the exchange rate increases over time. So let’s say you deposit 1000 USDC and get 50 cUSDC (exchange rate 1:20). After 30 days, you still have 50 cUSDC, but now each cUSDC is worth more, maybe the exchange rate is now 1:20.6. So when you withdraw, you burn your 50 cUSDC and get back 1030 USDC. That extra 30 USDC is in your interest.</p><p>You can also use your cTokens as collateral to borrow other assets. Everything is tracked automatically by the smart contracts.<br>What makes Compound different from the others? It uses single-asset markets. Each deployment handles one borrowable asset — there’s a USDC market, an ETH market, a DAI market, etc. This is simpler and reduces risk compared to throwing everything in one big pool.</p><p>Finally, Compound also has a governance token called COMP, which is distributed to lenders and borrowers of the protocol. This gives them the power to vote on changes regarding the protocol.</p><h4>Aave: the feature-rich DeFi lending giant</h4><p>Aave is one of, if not the most, feature-rich lending protocols out there. It launched in 2020 (evolved from ETHLend in 2017, last version of Aave if V3) and now has the highest <strong>TVL</strong> (Total Value Locked, the total amount of money deposited in the protocol) in DeFi lending, typically ranging from $10–20 billion depending on market conditions.</p><p>Unlike Compound’s single-asset markets, Aave uses a <strong>unified multi-asset market</strong> where different asset pools interact. You can provide any supported crypto as collateral and borrow any other supported crypto. Want to deposit ETH and borrow USDC? Done. Want to deposit USDC and borrow WBTC? Also possible. This cross-collateralization makes the protocol more complex but also more capital efficient.</p><p>When you deposit into the pool, you get <strong>aTokens</strong>, similar to Compound’s cTokens, but they work differently. In Aave, your aToken balance grows over time through rebasing: the balance itself increases, not the exchange rate.</p><p>Let’s say you deposit 1,000 USDC and get 1,000 aUSDC. After 30 days of earning interest:</p><ul><li>Your aUSDC balance is now 1,030 aUSDC (it has grown!)</li><li>The exchange rate stays 1:1</li><li>When you withdraw: Burn 1030 aUSDC and get 1,030 USDC.</li></ul><p>This makes it easier to see your earnings at a glance, as your balance directly shows how much you’ve earned.</p><p>Aave’s most unique feature is <strong>flash loans</strong>. These are special transactions that let you borrow assets without any collateral, as long as you pay back the borrowed amount plus a fee within the same transaction (that’s why they’re also called “one block borrows”).</p><p>Here’s the catch: if you can’t repay within that same transaction, the entire transaction gets reverted — like it never happened. This may sound unusual at first, but it’s beneficial for arbitrage, collateral swaps, or refinancing positions across protocols, all without requiring upfront capital.</p><h4>ZeroLend: Modern L2 Approach</h4><p>ZeroLend is pretty recent — it came out in 2023 as a fork of Aave V3, but explicitly optimized for Layer 2 networks like zkSync, Linea, Blast, and Manta.</p><p>For those unfamiliar with<strong> Layer 2, </strong>these are scaling solutions built on top of Ethereum that process transactions off the main chain, making them significantly faster and cheaper. We’re talking about 10–100 times cheaper gas fees compared to Ethereum&#39;s mainnet. On Ethereum, a simple lending transaction may cost $20–50 during periods of high traffic.</p><p>Since ZeroLend is a fork of Aave, it utilizes the exact core mechanisms, including aTokens, multi-asset pools, and variable interest rates. However, the key difference lies in where it operates and how it optimizes for L2 costs.</p><p>ZeroLend also introduces modern features, such as account abstraction, which enables functionalities like gas sponsorship (allowing third parties to cover transaction fees) and transaction batching (combining multiple actions into a single transaction to reduce fees further). This makes DeFi more accessible to people who can’t afford high mainnet costs.</p><h3>Conclusion</h3><p>So we covered how DeFi lending actually works — liquidity pools, overcollateralization, how interest rates adjust automatically, liquidations, and the role of oracles. Then, we examined three major protocols: Compound, Aave, and ZeroLend.</p><p>The main thing is they all solve the same problem, but in different ways. Compound keeps things simple with single-asset markets and a proven track record. Aave goes all-in on features, flash loans, multi-asset pools, and all the advanced stuff. ZeroLend takes what Aave built and makes it work on Layer 2, so you’re not paying crazy gas fees.</p><p>You can see how DeFi lending has evolved. Compound pioneered the whole liquidity pool model in 2018. Aave built upon that and added numerous features. Now, ZeroLend is optimizing for L2 and making it more accessible to a broader audience. Each one builds on what came before.</p><p>If you’re a developer wanting to get into DeFi lending, start by playing around on testnets. Try Compound first to understand the basics. Consider Aave if you require advanced features. Alternatively, you can go straight to ZeroLend if you’re building on L2. The docs and Discord communities are pretty helpful for all three.</p><p>DeFi lending is still evolving fast. Aave V4 is coming, more L2S are launching, and new features like RWA lending are being introduced. It’s a good time to get into it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b51c5f79e7" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/introduction-to-defi-lending-for-developers-key-concepts-and-overview-of-major-protocols-19b51c5f79e7">Introduction to DeFi Lending for Developers: Key Concepts and Overview of Major Protocols</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgradable smart contracts with proxy pattern]]></title>
            <link>https://coinsbench.com/upgradable-smart-contracts-with-proxy-pattern-1f805495753c?source=rss-f5a96c9af5af------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f805495753c</guid>
            <category><![CDATA[smartcontractdevelopment]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[proxy]]></category>
            <dc:creator><![CDATA[Arnaud Bakyono]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 14:51:51 GMT</pubDate>
            <atom:updated>2025-08-04T10:16:57.828Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="High level diagramm of proxy pattern" src="https://cdn-images-1.medium.com/max/1024/1*cHlQi7Y_CmcqoaV3rIsDBw.png" /></figure><p>One of the fundamental characteristics of blockchain is <strong>immutability, </strong>once a transaction is validated and added to a block, it becomes permanent and cannot be changed. The same principle applies to smart contracts: once deployed, their code is immutable. Despite thorough development and testing, bugs can still slip through, or new features may need to be added later. This creates a challenge: how do you upgrade a smart contract if you can’t change it? That’s where the <strong>proxy pattern</strong> comes into play.</p><h3>Core concepts or proxy pattern</h3><h4>Separate logic from data</h4><p>The basic idea behind is to separate a contract’s logic from its data, allowing the logic to be “updated” without redeploying or losing state. For that we would need two contracts, the <strong>proxy contract</strong> (hence the name of the pattern) that would hold the state of the whole protocol and an <strong>implementation contract</strong> that would handle all the logic. We can then deploy an updated version (remember, we cannot update the code of a deployed contract) of the implementation contract seemlessly, nothing changes for the contract users as they will only be using the proxy contract directly not the implementation one. Of course the proxy contract would also have to provide a method of changing of the implementation contract address at runtime. Finally, to not loose the state the implementation contract would need a way to access and update the proxy contract state, which brings us to the second core concept.</p><h4>Delegate call</h4><p>I am sure you already know we call a contract from another using the low level function <strong>call, </strong>what you may not know is that there is a similar function <strong>delegatecall </strong>which does basically the same but uses the calling contract context. That means that the called contract would alter the calling contract state and not it’s own. If this is a bit confusing let’s take a look at a simple example.</p><h3>Code example</h3><p>We’ll take a really simple and quite silly example to illustrate. Imagine you’re building a smart contract that lets users <strong>invest Ether, </strong>at least 1 gwei, and you want to <strong>keep track of the total amount received</strong>.</p><p>So you write a simple contract with a function called investMoney Everything works fine… until one day you realize:</p><ul><li>You want to <strong>change the logic</strong>, double the investment (I warned you it was silly).</li><li>The <strong>1 gwei</strong> must be too much and you decide to allow any amount.</li><li>But you <strong>can’t redeploy</strong> without losing the state (totalBalance would reset)</li></ul><p>Let’s build with upgradability in mind</p><pre>contract Proxy {<br>    uint256 public totalBalance;<br>    address public implementation; //Address of the implementation contract<br>    address public owner;<br><br>    constructor(address _implementation) {<br>        implementation = _implementation;<br>        owner = msg.sender;<br>    }<br><br>    function investMyMoney() public payable {<br>        (bool success,) = implementation.delegatecall(<br>            abi.encodeWithSignature(&quot;investMoney(uint256)&quot;, msg.value)<br>        );<br>        require(success, &quot;Call failed&quot;);<br>    }<br><br>    //We provide a way to update implementation address, only owner can do that<br>    function updateImplementationAddress(address _implementation) public {<br>        require(msg.sender == owner);<br>        implementation = _implementation;<br>    }<br><br>}</pre><pre>contract ImplementationV1 {<br>    uint256 public totalBalance;<br><br>    function investMoney(uint256 amount) public payable {<br>        require(amount &gt; 1 gwei, &quot;You have to send more dawg&quot;);<br>        totalBalance += amount;<br>    }<br>}</pre><p>As you see <strong>delegatecall</strong> usage is really similar to call, in this instance since delegatecall executes the implementation contract in the context of the proxy contract, the state of the proxy is updated as the below foundry test is showing.</p><pre>contract ProxyTest is Test {<br>    Proxy public proxy;<br>    ImplementationV1 public implentationV1;<br><br>    function setUp() public {<br>        implentationV1 = new ImplementationV1();<br>        proxy = new Proxy(address(implentationV1));<br>        vm.deal(address(this), 10 ether);<br>    }<br><br>    function testImplementation1() public {<br>        proxy.investMyMoney{value: 1 ether}();<br>        assertEq(proxy.totalBalance(), 1 ether);<br>        assertEq(implentationV1.totalBalance(), 0);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qWry7P9SOqYi77z9GFk6_A.png" /></figure><h4>Use implementation 2</h4><p>We now want to double the amount of money and also emit an event now, for that we just deploy a new implementation and we use that new address by calling the <strong>updateImplementationAddress </strong>function with the new address.</p><pre>contract ImplementationV2 {<br>    uint256 public totalBalance;<br>    <br>    event MoneyDoubledAndInvested();<br><br>    function investMoney(uint256 amount) public payable {<br>        totalBalance += amount * 2;<br>        <br>        emit MoneyDoubledAndInvested();<br>    }<br>}</pre><p>Let’s test everything works</p><pre>function testImplementationChangeAtRuntime() public {<br>    proxy.investMyMoney{value: 1 ether}();<br><br>    //Change implementation<br>    proxy.updateImplementationAddress(address(new ImplementationV2()));<br><br>    //Expect event<br>    vm.expectEmit();<br>    emit ImplementationV2.MoneyDoubledAndInvested();<br><br>    proxy.investMyMoney{value: 1 ether}();<br>    <br>    //The second investment should have doubled<br>    assertEq(proxy.totalBalance(), 3 ether);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKRFNb5x5aVs5OOHEtmHTA.png" /><figcaption>Everything works, yeah!!!</figcaption></figure><h3>delegatecall gotchas</h3><p><strong>delegatecall</strong> is a low-level function, it really operates at … well low level, I mean at <strong>EVM bytecode level</strong>. In our examples, you might think that the variables must have the same <strong>name</strong> in the proxy and the implementation. This is <strong>not required</strong>. In fact, the EVM doesn’t care about variable names at all, it only cares about <strong>storage slot positions</strong>. Typically the first state variable of the contract is stored in slot 1, second state variable in slot 2 and so on (there are cases where this is not entirely true though).</p><p>When using <strong>delegatecall</strong>, the <strong>called contract’s logic</strong> is executed in the <strong>context of the calling contract’s storage</strong>. That means when <strong>ImplementationV1</strong> runs <strong>totalBalance += amount;</strong>, it writes to <strong>slot 0</strong> of the storage — and that slot must correspond to <strong>totalBalance</strong> in the proxy.</p><p>If the implementation and the proxy don’t <strong>perfectly align</strong> their storage layouts (e.g., different types, different ordering), you can easily end up <strong>writing to the wrong slot</strong>, corrupting data, or introducing subtle and dangerous bugs.</p><p>For example if we wrote our proxy like this it would not work, and this would lead to dangerous bugs.</p><pre>contract Proxy {<br>    address public implementation;<br>    uint256 public totalBalance;<br>    address public owner;<br>    //Same code<br>}</pre><p>We can avoid this kind of problems by implementing <strong>EIP 1967 </strong>but this goes beyond the scope of this article<strong>. </strong>The example given here is really for educational purposes, an introduction to proxy pattern, in real life scenario we would need to handle much more. You can learn more with excellent article <a href="https://rareskills.io/proxy-patterns#brxe-ktnuck">https://rareskills.io/proxy-patterns#brxe-ktnuck</a></p><h3>Conclusion</h3><p>The Proxy Pattern is one a powerful tool we can use to make smart contracts upgradeable in an otherwise immutable world. By separating storage and logic (and using delegatecall to bridge the two) we gain the flexibility to evolve our applications over time without sacrificing user data or contract addresses.</p><p>But proxy is a complex subject, we typically use established libraries like OpenZeppelin when possible, and understand the mechanics under the hood.</p><p>I hope this article was at least <em>somewhat useful</em> in demystifying the proxy pattern and the magic behind delegatecall. If you’ve made it this far — thank you, and happy building! 🛠️🚀.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f805495753c" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/upgradable-smart-contracts-with-proxy-pattern-1f805495753c">Upgradable smart contracts with proxy pattern</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>