<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Operate: Borrow or payback on</title><link>https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/</link><description>Recent content in Operate: Borrow or payback on</description><generator>Hugo -- 0.152.2</generator><language>en-us</language><atom:link href="https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/index.xml" rel="self" type="application/rss+xml"/><item><title>Borrow or payback</title><link>https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/borrow-or-payback/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/borrow-or-payback/</guid><description>&lt;p&gt;This is the complete body of the function we are analyzing.&lt;/p&gt;
&lt;figure&gt;
&lt;img loading="lazy" src="https://rajkoz.com/fluid-vault/liquidity-layer/borrow-or-payback-full.png"
alt="Liquidity layer" width="100%"/&gt;
&lt;/figure&gt;
&lt;p&gt;Construction is similar to the supply or withdraw flow, but the code is simplified because we don&amp;rsquo;t have decay amounts.&lt;/p&gt;
&lt;p&gt;We first perform validation:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-solidity" data-lang="solidity"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;uint256&lt;/span&gt; userBorrowData_ &lt;span style="color:#f92672"&gt;=&lt;/span&gt; _userBorrowData[msg.sender][token_];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (userBorrowData_ &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; revert FluidLiquidityError(ErrorTypes.UserModule__UserNotDefined);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ((userBorrowData_ &lt;span style="color:#f92672"&gt;&amp;gt;&amp;gt;&lt;/span&gt; LiquiditySlotsLink.BITS_USER_BORROW_IS_PAUSED) &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; revert FluidLiquidityError(ErrorTypes.UserModule__UserPaused);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol&gt;
&lt;li&gt;User presence check. We revert if the user is not defined&lt;/li&gt;
&lt;li&gt;If user borrow is paused&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then we extract the borrow amount and calculate the current borrow limit by calling the function we explained on the previous page:&lt;/p&gt;</description></item><item><title>Borrow limits</title><link>https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/borrow-limits/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://rajkoz.com/posts/fluid-vault-smart-contracts-deep-dive/3-liquidity-layer/8-borrow-or-payback/borrow-limits/</guid><description>&lt;p&gt;Just like withdrawal limits, Fluid imposes restrictions on borrow amounts for protocols using the liquidity layer.&lt;/p&gt;
&lt;p&gt;Borrow limit is the maximum amount that can be borrowed, and like withdrawals, this amount can expand over some time duration by a predefined percentage.&lt;/p&gt;
&lt;p&gt;There is also a base borrow limit, which users can freely borrow up to. Up to the base limit, no limits are applied.&lt;/p&gt;
&lt;p&gt;And one addition to this borrow limit is the hard cap value, which is the absolute maximum one user can have as borrow amount. After this value, no expansion is possible. This can be viewed as a hard cap in some other protocols.&lt;/p&gt;</description></item></channel></rss>