<?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 Valha on Medium]]></title>
        <description><![CDATA[Stories by Valha on Medium]]></description>
        <link>https://medium.com/@valha?source=rss-729b6a005feb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Mh6AByFBOZnPUSdMwmdpuw.png</url>
            <title>Stories by Valha on Medium</title>
            <link>https://medium.com/@valha?source=rss-729b6a005feb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:28:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@valha/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[Valha — Interact with DeFi on top of Zodia API]]></title>
            <link>https://medium.com/@valha/valha-interact-with-defi-on-top-of-zodia-api-3a9cf94ce1ba?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a9cf94ce1ba</guid>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[custodian]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 11:03:58 GMT</pubDate>
            <atom:updated>2023-12-08T11:03:58.336Z</atom:updated>
            <content:encoded><![CDATA[<h3>Valha — Interact with DeFi on top of Zodia API</h3><p>Valha API cater the need for developers to interact with DeFi protocols in a seamless way.</p><p>This article shows how to use Valha on top of Zodia API in order to build native DeFi experience, increase user stickiness and get rid of external extensions like MMI.</p><p>To build a native DeFi experience, two components are needed. First, being able to craft onchain transaction. Second, getting all needed analytics to provide to the users (strategies informations, user balances).</p><p>We will cover everything, with technical specifications as follows:</p><ol><li><strong>Zodia API — Without Valha</strong><br>A. For transaction crafting<br>B. For analytics</li><li><strong>Zodia API — Using Valha</strong><br>A. For transaction crafting<br>B. For analytics</li></ol><p><strong>Caveat 1:</strong> <em>Be aware that this example contains pseudo-code. Scripts should be adapted for your own usecases.</em></p><p><strong>Caveat 2:</strong> <em>This documentation is adressed to programming-friendly persons.</em></p><p><strong>Caveat 3:</strong> <em>We assume Zodia API would support an agnostic API route to execute any payload onchain as an extension of the “</em><strong><em>create new outgoing transaction</em></strong><em>”.<br>It generalises wallet transfers to any possible onchain action on the EVM ecosystem.</em></p><h3>1. Zodia API — Without Valha</h3><h4>A. For transaction crafting</h4><p>Crafting transactions in the EVM ecosystem require different things:</p><ul><li>Manually retrieving the interaction contract address <strong>“to”</strong></li><li>Manually getting the gas limit</li><li>Manually crafting the calldata to execute including: retrieving the contract address ABI, the function to call and parameters to put, token decimals etc.</li></ul><p>This process is intensive and also require considerable maintenance cost, given new integrations are often needed, ABI are likely to change etc.</p><pre>##### Whitelist address<br><br>fetch(&#39;https://hostname.zodia.io/v3/api/servicedesk/create&#39;, {<br>    method: &#39;POST&#39;,<br>    headers: {<br>        &#39;submitter-id&#39;: &#39;maker@zodia.io&#39;,<br>        &#39;Content-Type&#39;: &#39;application/json&#39;<br>    },<br>    body: JSON.stringify({<br>        serviceId: &quot;0x0007-007&quot;,<br>        payload: {<br>            address: &quot;0x8dC847Af872947Ac18d5d63fA646EB65d4D99560&quot;,<br>            blockchain: &quot;ETH&quot;,<br>            addressPurpose: [&quot;INCOMING&quot;, &quot;OUTGOING&quot;]<br>        }<br>    })<br>})<br>.then(response =&gt; response.json())<br>.then(data =&gt; console.log(data))<br>.catch(error =&gt; console.error(&#39;Error:&#39;, error));<br><br>##### Build the transaction<br><br>const tx = {<br>    &quot;from&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;to&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;value&quot;: &quot;100000000000000000&quot;,  # in Wei<br>    &quot;gas&quot;: gasLimit,<br>    &quot;gasPrice&quot;: &quot;1000&quot;,<br>    # &quot;data&quot;: &quot;0xsomething&quot;,<br>}<br><br><br>const url = &#39;https://hostname.zodia.io/v3/api/servicedesk/create&#39;;<br>const data = {<br>  serviceId: &quot;0x0014-007&quot;,<br>  payload: {<br>    sender: {<br>      type: &quot;WALLETID&quot;,<br>      value: &quot;ZODCS-NOBENF-E3WB8MB4EI&quot;<br>    },<br>    transaction: {<br>      tx: tx // Assuming &#39;tx&#39; is a variable defined elsewhere in your code<br>    },<br>  }<br>};<br><br>fetch(url, {<br>  method: &#39;POST&#39;,<br>  headers: {<br>    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>  },<br>  body: JSON.stringify(data)<br>})<br>.then(response =&gt; response.json())<br>.then(data =&gt; {<br>  console.log(&#39;Success:&#39;, data);<br>})<br>.catch((error) =&gt; {<br>  console.error(&#39;Error:&#39;, error);<br>});<br></pre><p>Source: <a href="https://www.zodia.io/zodia-custody-api-doc.html#section/Digital-Asset-Service-Desk-Usage/Step-4:-Instruct-a-transfer-from-a-wallet-to-a-whitelisted-address">https://www.zodia.io/zodia-custody-api-doc.html#section/Digital-Asset-Service-Desk-Usage/Step-4:-Instruct-a-transfer-from-a-wallet-to-a-whitelisted-address</a></p><p>B. For analytics</p><p>Sweet, you have built an onchain transaction. Now, you need to manually access several information in order to satisfy all your users needs.</p><ol><li>Position balance so as to monitor users pools’ balance</li><li>Claimable rewards balance so as to monitor users rewards</li><li>Pool analytics: to monitor pools liquidity and performance</li></ol><h3>Zodia API — With Valha</h3><h4>A. For transaction crafting</h4><p>When using Valha API, all the three problems you were facing when crafting onchain transactions could be resolved in the following way:</p><ul><li>Interaction address “to” could be retrieved from this route: <a href="https://valha.readme.io/reference/poolscontroller_listallpools">https://valha.readme.io/reference/poolscontroller_listallpools</a></li><li>Gas limit and calldata are crafted directly using this endpoint: <br><a href="https://valha.readme.io/reference/interactionscontroller_createdeposittx">https://valha.readme.io/reference/interactionscontroller_createdeposittx</a></li></ul><p>You do not need to know more than the DeFi pool name to build an EVM transaction.</p><pre>// get DeFi CallData from Valha API<br>async function getDeFiCallData(<br>  chain: string,<br>  poolAddress: string,<br>  userAddress: string,<br>  action: string,<br>  amountForAction: number<br>): Promise&lt;AxiosResponse&lt;any&gt;&gt; {<br>  const url = `https://api.valha.xyz/v0/${chain}/pools/${poolAddress}/${action}`;<br>  const payload = {<br>    user: userAddress,<br>    amount: amountForAction,<br>    disable_check: true,<br>    maximum_approval: false,<br>    estimate_gas: true, // Change to &#39;true&#39; if it&#39;s a boolean<br>  };<br>  const headers = {<br>    accept: &#39;application/json&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;,<br>    authorization: &#39;Bearer test&#39;,<br>  };<br>  try {<br>    const response = await axios.post(url, payload, { headers });<br>    return response;<br>  } catch (error) {<br>    // Handle error here<br>    throw error;<br>  }<br>}<br><br><br>async function getZodiaWallet(<br>  walletId: string,<br>): Promise&lt;AxiosResponse&lt;any&gt;&gt; {<br>  const url = `https://api.custody.api-zodia.io/v3/api/custody/wallets/addresses/generate`;<br>  const payload = {<br>     walletId : walletId<br>}<br>  const headers = {<br>    accept: &#39;application/json&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;,<br>    authorization: &#39;Bearer test&#39;,<br>  };<br>  try {<br>    const response = await axios.post(url, payload, { headers });<br>    return response;<br>  } catch (error) {<br>    // Handle error here<br>    throw error;<br>  }<br>}<br><br>##### Whitelist address<br><br>// poolAddress and interactionAddress could be retrieved from Valha API too (https://valha.readme.io/reference/poolscontroller_listallpools)<br>const poolAddress = &#39;0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84&#39;;<br>const interactionAddress = &#39;0xbe9a11B5EaA1312D7fE84b09596520DE3Ab8E5e1&#39;;<br>const chain = ChainId.MAINNET;<br>const walletId = &quot;ZODCS-NOBENF-E3WB8MB4EI&quot;<br><br>fetch(&#39;https://hostname.zodia.io/v3/api/servicedesk/create&#39;, {<br>    method: &#39;POST&#39;,<br>    headers: {<br>        &#39;submitter-id&#39;: &#39;maker@zodia.io&#39;,<br>        &#39;Content-Type&#39;: &#39;application/json&#39;<br>    },<br>    body: JSON.stringify({<br>        serviceId: &quot;0x0007-007&quot;,<br>        payload: {<br>            address: interactionAddress,<br>            blockchain: chain,<br>            addressPurpose: [&quot;INCOMING&quot;, &quot;OUTGOING&quot;]<br>        }<br>    })<br>})<br>.then(response =&gt; response.json())<br>.then(data =&gt; console.log(data))<br>.catch(error =&gt; console.error(&#39;Error:&#39;, error));<br><br>##### Build the transaction<br><br>// GET THE CALLDATA FROM VALHA<br><br>const amount = 5;<br>const action = &#39;deposit&#39;;<br>const userAddress = await getZodiaWallet(walletId)<br>const tx = await getDeFiCallDataFromValha(<br>      chain, <br>      poolAddress, <br>      userAddress, <br>      action, <br>      amount);<br><br>const url = &#39;https://hostname.zodia.io/v3/api/servicedesk/create&#39;;<br>const data = {<br>  serviceId: &quot;0x0014-007&quot;,<br>  payload: {<br>    sender: {<br>      type: &quot;WALLETID&quot;,<br>      value: ${walletId}<br>    },<br>    transaction: {<br>      tx: tx // Assuming &#39;tx&#39; is a variable defined elsewhere in your code<br>    },<br>  }<br>};<br><br>fetch(url, {<br>  method: &#39;POST&#39;,<br>  headers: {<br>    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>  },<br>  body: JSON.stringify(data)<br>})<br>.then(response =&gt; response.json())<br>.then(data =&gt; {<br>  console.log(&#39;Success:&#39;, data);<br>})<br>.catch((error) =&gt; {<br>  console.error(&#39;Error:&#39;, error);<br>});</pre><h4>B. For analytics</h4><p>From an analytical standpoint, using Valha you can also:</p><ol><li>Access user balances within a pool using <a href="https://valha.readme.io/reference/positionscontroller_walletpoolposition">https://valha.readme.io/reference/positionscontroller_walletpoolposition</a></li><li>Access claimable user rewards using: <a href="https://valha.readme.io/reference/positionscontroller_getwalletclaimablerewardsforpool">https://valha.readme.io/reference/positionscontroller_getwalletclaimablerewardsforpool</a></li><li>Get current and historical pool performance and TVL using: <a href="https://valha.readme.io/reference/poolscontroller_retrievepoolhistory">https://valha.readme.io/reference/poolscontroller_retrievepoolhistory</a></li><li>Please note that the transaction history routes is not opened yet but available within our servers.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a9cf94ce1ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello Kook]]></title>
            <link>https://medium.com/@valha/hello-kook-11cec328dec2?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/11cec328dec2</guid>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[investment]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Thu, 09 Nov 2023 10:51:30 GMT</pubDate>
            <atom:updated>2023-11-09T10:57:47.000Z</atom:updated>
            <content:encoded><![CDATA[<h4>Your DeFi Yield Hub</h4><p>James Cook was an English navigator, explorer and cartographer.<br><a href="https://www.kook.exchange/">Kook</a> will help you navigate the world of DeFi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDP1-SRzNRxZE2Z9ZvDmvQ.png" /></figure><p><strong>Why Kook</strong></p><p>Our experience in DeFi is cumbersome.</p><p>As regular users we have to navigate from front-ends to front-ends to bridge, swap and manage DeFi positions and use different interfaces to discover new DeFi protocols, check analytics and make your investment decisions.</p><p>Being a DeFi user mean spending several hours a week on socials and websites to manage your positions.</p><p>We dont want this anymore and DeFi transparent and composable nature enable us to do so.</p><h4>Kook Kook Kook</h4><p>We love the DeFiLlama Yield Dashboard and we wanted to extend the experience by offering a platform where you can:</p><ol><li><strong>Benchmark DeFi opportunities through our Pools view</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Frwpp0-wM8rs5pU5XHYZ0w.png" /></figure><p>You can filter opportunities by strategies and underlying tokens.<br>You can sort them by APY or TVL.</p><p>Data is exclusively onchain data. It gives the ability to display real and historical performance numbers with a standardised methodology.</p><p>2. <strong>Invest in pools with ANY token through Investment view</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BjddFxlmwwrAf2YfyFv8g.png" /></figure><p>Enter in yield-bearing pools with ANY token so that your friction to invest is reduced.</p><p>We are using <a href="http://li.fi/">Li.fi</a> and <a href="https://swap.cow.fi/#/swap">cowswap</a> infrastructure to zap.</p><p><strong>3. Monitor your assets through Position view</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57ndMMDDnD0a730PjTsIeA.png" /></figure><p>You can also check all your DeFi positions from one single page.</p><h4><strong>The special thing about Kook</strong></h4><p>We want to treat each user decently, as a matter of fact:</p><ol><li>You will not pay any additional fees using Kook compared to the protocols’ interfaces.</li><li>You will not get exposed to our infrastructure as we do not bear additional smart contract risks. <br>Kook interface either interacts directly with the protocol contracts or is using multiply-audited smart contracts (Li.fi, Cowswap) for the zap feature.</li></ol><p><a href="https://www.kook.exchange/"><strong>Kook</strong></a> is live on 6 chains (ethereum, arbitrum, optimism, base, zksync, gnosis) and with 30 protocols.</p><h4><strong>Kook ambassador program</strong></h4><p>To become a Kook ambassador, please join <a href="https://t.me/+9UHkptkGIZNhNzA8">Kook telegram group</a> where we will detail everything.</p><p>Follow <a href="https://twitter.com/kookexchange">Kook</a> on twitter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E_TlrXzuVzJQLfQP" /><figcaption>Good luck Kook sailor</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11cec328dec2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Valha — Interact with DeFi on top of Fireblocks API]]></title>
            <link>https://medium.com/@valha/valha-interact-with-defi-on-top-of-fireblocks-api-fc9ada008451?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc9ada008451</guid>
            <category><![CDATA[valha]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[swap]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[fireblocks]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Thu, 14 Sep 2023 12:49:38 GMT</pubDate>
            <atom:updated>2023-09-14T12:50:29.843Z</atom:updated>
            <content:encoded><![CDATA[<h3>Valha — Interact with DeFi on top of Fireblocks SDK</h3><p>Valha API cater the need for developers to develop custom DeFi products in a seamless way.</p><p>Let me show you a concrete example on using Valha on top of Fireblocks SDK in order to interact seamlessly with DeFi protocols to enter strategies, swap tokens etc.</p><p>Be aware that this is only an example with pseudo-code. Scripts should be adapted for your own usecases.</p><h3>Fireblocks SDK — Without Valha</h3><pre>const {<br>  FireblocksWeb3Provider,<br>  ChainId,<br>} = require(&#39;@fireblocks/fireblocks-web3-provider&#39;);<br>const ethers = require(&#39;ethers&#39;);<br>const axios = require(&#39;axios&#39;);<br><br>const FIREBLOCKS = new FireblocksWeb3Provider({<br>  privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,<br>  apiKey: process.env.FIREBLOCKS_API_KEY,<br>  vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,<br>  chainId: ChainId.MAINET,<br>  // apiBaseUrl: ApiBaseUrl.Sandbox // If using a sandbox workspace<br>});<br><br>// SIGNING AND EXECUTING THE TRANSACTIONS<br>const SignAndExecute = async (): Promise&lt;any&gt; =&gt; {<br>  try {<br>    // CONNECT TO FIREBLOCKS<br>    const provider = new ethers.providers.Web3Provider(FIREBLOCKS);<br>    const walletWithProvider = await provider.getSigner();<br><br>    // MANUALLY BUILD THE CALLDATA<br>    const userAddress = await walletWithProvider.getAddress();<br>    const txs = {<br>    &quot;from&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;to&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;value&quot;: &quot;100000000000000000&quot;,  # in Wei<br>    &quot;gas&quot;: &quot;21000&quot;,<br>    &quot;gasPrice&quot;: &quot;1000&quot;,<br>    # &quot;data&quot;: &quot;0xsomething&quot;,<br>    # &quot;type&quot;: &quot;2&quot;<br>    # &quot;maxPriorityFeePerGas&quot;: &quot;12321321&quot;,<br>    # &quot;maxFeePerGas&quot;: &quot;12321321&quot;,<br>}<br><br>    // START THE EXECUTION<br><br>    ////approve the token for the specific amount<br>    const approveTx = txs[0];<br>    const approvalTx = await walletWithProvider.sendTransaction({<br>      ...approveTx,<br>    });<br>    approvalTx.wait();<br>    console.log(approvalTx);<br>    console.log(&#39;approval went through&#39;);<br><br>    ////execute the transaction<br>    const executeTx = txs[1];<br>    const executionTx = await walletWithProvider.sendTransaction({<br>      ...executeTx,<br>    });<br>    await executionTx.wait();<br>    console.log(executionTx);<br>    console.log(&#39;call was successful&#39;);<br>  } catch (err: any) {<br>    console.log(err);<br>    console.log(err.message);<br>  }<br>};</pre><p>Source: <a href="https://developers.fireblocks.com/docs/ethereum-development#ethersjs-integration">Ethereum Development (fireblocks.com)</a></p><h3>The problem</h3><p>As a developer, you need to retrieve manually the “to” contract address that you want to interact with and build manually the “gas” as well the “data” to generate.</p><p>It means that you should know exactly which contract address to call, the function and the parameters to select.</p><p>That the hardest thing to do.</p><h3>Fireblocks SDK — With Valha</h3><pre><br>// get DeFi CallData from Valha API<br><br>async function getDeFiCallData(<br>  chain: string,<br>  poolAddress: string,<br>  userAddress: string,<br>  action: string,<br>  amountForAction: number<br>): Promise&lt;AxiosResponse&lt;any&gt;&gt; {<br>  const url = `https://api.valha.xyz/v0/${chain}/pools/${poolAddress}/${action}`;<br><br>  const payload = {<br>    user: userAddress,<br>    amount: amountForAction,<br>    disable_check: true,<br>    maximum_approval: false,<br>    estimate_gas: true, // Change to &#39;true&#39; if it&#39;s a boolean<br>  };<br><br>  const headers = {<br>    accept: &#39;application/json&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;,<br>    authorization: &#39;Bearer test&#39;,<br>  };<br><br>  try {<br>    const response = await axios.post(url, payload, { headers });<br>    return response;<br>  } catch (error) {<br>    // Handle error here<br>    throw error;<br>  }<br>}</pre><pre><br>// SIGNING AND EXECUTING THE TRANSACTIONS<br>const SignAndExecute = async (): Promise&lt;any&gt; =&gt; {<br>  try {<br>    // CONNECT TO FIREBLOCKS<br>    const provider = new ethers.providers.Web3Provider(FIREBLOCKS);<br>    const walletWithProvider = await provider.getSigner();<br><br>    // GET THE CALLDATA FROM VALHA<br>    const poolAddress = &#39;0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84&#39;; <br>       // poolAddress could be retrieved from Valha API too (https://valha.readme.io/reference/poolscontroller_listallpools)<br>    const amount = 5;<br>    const action = &#39;deposit&#39;;<br>    const chain = ChainId.MAINET;<br>    const userAddress = await walletWithProvider.getAddress();<br>    const txs = await getDeFiCallDataFromValha(<br>      chain, <br>      poolAddress, <br>      userAddress, <br>      action, <br>      amount);<br><br>    // START THE EXECUTION<br><br>    ////approve the token for the specific amount<br>    const approveTx = txs[0];<br>    const approvalTx = await walletWithProvider.sendTransaction({<br>      ...approveTx,<br>    });<br>    approvalTx.wait();<br>    console.log(approvalTx);<br>    console.log(&#39;approval went through&#39;);<br><br>    ////execute the transaction<br>    const executeTx = txs[1];<br>    const executionTx = await walletWithProvider.sendTransaction({<br>      ...executeTx,<br>    });<br>    await executionTx.wait();<br>    console.log(executionTx);<br>    console.log(&#39;call was successful&#39;);<br>  } catch (err: any) {<br>    console.log(err);<br>    console.log(err.message);<br>  }<br>};</pre><p>Source: <a href="https://developers.fireblocks.com/docs/ethereum-development#ethersjs-integration">Ethereum Development (fireblocks.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc9ada008451" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Valha — Module on top of custodians API]]></title>
            <link>https://medium.com/@valha/valha-module-on-top-of-custodians-api-f311aa1f0e16?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f311aa1f0e16</guid>
            <category><![CDATA[safe]]></category>
            <category><![CDATA[metamask]]></category>
            <category><![CDATA[valha]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 11:48:59 GMT</pubDate>
            <atom:updated>2023-07-07T16:40:14.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>Valha — Module on top of custodians API</h3><p>Valha API cater the need for developers to develop custom DeFi products in a seamless way.</p><p>Let me show you a concrete example on using Valha on top of Metamask Institutional SDK and Safe in order to build custom DeFi features.</p><p>Be aware that this is only pseudo-code and that it should be adapted to work for you.</p><h3>Metamask SDK — Without Valha</h3><pre>import os<br>from metamask_institutional.sdk import CustodianFactory<br><br># Instantiate the factory<br>factory = CustodianFactory()<br><br># Grab your token from the environment, or anywhere else<br>token = os.environ[&quot;MMISDK_TOKEN_QREDO&quot;]<br><br># Create the custodian, using the factory<br>custodian = factory.create_for(&quot;qredo&quot;, token)<br><br># Build tx details<br>tx_params = {<br>    &quot;from&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;to&quot;: &quot;0x62468FD916bF27A3b76d3de2e5280e53078e13E1&quot;,<br>    &quot;value&quot;: &quot;100000000000000000&quot;,  # in Wei<br>    &quot;gas&quot;: &quot;21000&quot;,<br>    &quot;gasPrice&quot;: &quot;1000&quot;,<br>    # &quot;data&quot;: &quot;0xsomething&quot;,<br>    # &quot;type&quot;: &quot;2&quot;<br>    # &quot;maxPriorityFeePerGas&quot;: &quot;12321321&quot;,<br>    # &quot;maxFeePerGas&quot;: &quot;12321321&quot;,<br>}<br>qredo_extra_params = {<br>    &quot;chainID&quot;: &quot;3&quot;,<br>}<br><br># Create the tx from details and send it to the custodian<br>transaction = custodian.create_transaction(tx_params, qredo_extra_params)<br><br>print(transaction)</pre><h4>The problem</h4><p>As a developer, you need to retrieve manually the “to” contract address that you want to interact with and build manually the “gas” as well the “data” to generate.</p><p>It means that you should know exactly which contract address to call, the function and the parameters to select.</p><p>That the hardest thing to do.</p><p>And it worsen if you wish to do multiple actions at once. i.e. deposit and stake, swap and deposit, redeem and swap etc.</p><h3>Metamask SDK — With Valha</h3><pre>import os<br>import requests<br>from metamask_institutional.sdk import CustodianFactory<br><br># Instantiate the factory<br>factory = CustodianFactory()<br><br># Grab your token from the environment, or anywhere else<br>token = os.environ[&quot;MMISDK_TOKEN_QREDO&quot;]<br><br># Create the custodian, using the factory<br>custodian = factory.create_for(&quot;qredo&quot;, token)<br><br><br># Retrieve pool address - &quot;to&quot;<br><br>def get_pool_address(json_data, pool_name):<br>    data = json.loads(json_data)<br>    for item in data[&#39;data&#39;]:<br>        if &#39;name&#39; in item[&#39;data&#39;] and item[&#39;data&#39;][&#39;name&#39;] == pool_name:<br>            return item[&#39;data&#39;][&#39;pool_address&#39;]<br>    return None<br><br>poolName = &quot;aave USDC&quot;<br>poolAddress = get_pool_address(json_data, poolName)<br><br># Build Tx params for a speific protocol<br><br>def getDeFiCallData(chain,poolAddress,userAddress,action,amountForAction):<br>  import requests<br><br>  url = &quot;https://api.valha.xyz/v0/&quot; + chain + &quot;/pools/&quot; + poolAddress + &quot; / &quot; + action<br><br>  payload = {<br>    &quot;user&quot;: userAddress,<br>    &quot;amount&quot;: amountForAction,<br>    &quot;disable_check&quot;: True,<br>    &quot;maximum_approval&quot;: False,<br>    &quot;estimate_gas&quot;: Yes}<br><br>  headers = {<br>    &quot;accept&quot;: &quot;application/json&quot;,<br>    &quot;content-type&quot;: &quot;application/json&quot;,<br>    &quot;authorization&quot;: &quot;Bearer test&quot;}<br><br>  response = requests.post(url, json=payload, headers=headers)<br>return response<br><br><br># Build tx details<br>qredo_extra_params = {<br>    &quot;chainID&quot;: &quot;3&quot;,<br>}<br><br>tx_params = getDeFiCallData(&quot;ethereum&quot;, &quot;0x000&quot;, &quot;0x&quot;, &quot;deposit&quot;, 20)<br><br># Create the tx from details and send it to the custodian<br>transaction = custodian.create_transaction(tx_params, qredo_extra_params)<br><br>print(transaction)</pre><h3>Safe — With and without Valha</h3><pre>import { AbiItem } from &#39;web3-utils&#39;<br>import { TransactionReceipt } from &#39;web3-core&#39;<br>import { Transaction } from &#39;ethereumjs-tx&#39;<br><br>const execTransaction = async (<br>  to: string,<br>  value: string,<br>  data: string,<br>): Promise&lt;TransactionReceipt&gt; =&gt; {<br>  const web3 = new Web3(provider)<br>  const abi = [{<br>    inputs: [{<br>      internalType: &#39;address&#39;,<br>      name: &#39;to&#39;,<br>      type: &#39;address&#39;,<br>    }, {<br>      internalType: &#39;uint256&#39;,<br>      name: &#39;value&#39;,<br>      type: &#39;uint256&#39;,<br>    }, {<br>      internalType: &#39;bytes&#39;,<br>      name: &#39;data&#39;,<br>      type: &#39;bytes&#39;,<br>    }],<br>    name: &#39;execTransaction&#39;,<br>    outputs: [],<br>    stateMutability: &#39;nonpayable&#39;,<br>    type: &#39;function&#39;,<br>  }]<br>  <br>#Instead of selecting the correct method and contract yourself you can call Valha PI<br><br>#const contract = new web3.eth.Contract(abi as AbiItem[], moduleAddress)<br>#const encodedData = contract.methods.execTransaction(to,value,data,).encodeABI()&#39;<br><br><br># Function to get pools from its name and chain<br><br>const axios = require(&#39;axios&#39;);<br><br>async function getPools(protocol, chain) {<br>  const url = &#39;https://api.valha.xyz/v0/${chain}/pools/${protocol}&#39;;<br>  const headers = {<br>    &#39;accept&#39;: &#39;application/json&#39;,<br>    &#39;authorization&#39;: &#39;Bearer YOUR_KEY&#39;<br>  };<br>  try {<br>    const response = await axios.get(url, { headers });<br>    return response.data;<br>  } catch (error) {<br>    console.error(&#39;Error retrieving API results:&#39;, error);<br>    return null;<br>  }<br>}<br><br>#getDeFiCallData function from Valha<br><br>async function getDeFiCallData(<br>  chain,<br>  poolAddress,<br>  userAddress,<br>  action,<br>  amountForAction,)<br>  // action is &#39;deposit&#39; here<br>  {<br>  const url = &#39;https://api.valha.xyz/v0/${chain}/pools/${poolAddress}/${action}&#39;;<br>  const headers = {<br>    &#39;accept&#39;: &#39;application/json&#39;,<br>    &#39;authorization&#39;: &#39;Bearer YOUR_KEY&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;<br>  };<br>  const data = {<br>    &quot;user&quot;: userAddress,<br>    &quot;amount&quot;: amountForAction,<br>    &quot;disable_check&quot;: true,<br>  };<br><br>  try {<br>    const response = await axios.post(url, data, { headers });<br>    return response.data;<br>  } catch (error) {<br>    console.error(&#39;Error performing the action:&#39;, error);<br>    return null;<br>  }<br>}<br><br>  #Generate and execute the tx<br><br><br>  const nonce = await web3.eth.getTransactionCount(senderAddress)<br><br>  #rawTx is directly generated from Valha API<br>  const rawTx= await getDeFiCallData(&quot;ethereum&quot;, getPools(convex, &quot;ethereum&quot;), &quot;0x&quot;, &quot;deposit&quot;, 20);<br>  <br><br>#const rawTx = {<br>  #nonce,<br>  #to: moduleAddress,<br>   # data: encodedData,<br>    #gasPrice: 2162230808,<br>    #gasLimit: 256312,<br>    #value: 0,<br>  #}<br>  const tx = new Transaction(rawTx, { chain: &#39;rinkeby&#39; })<br>  tx.sign(privateKey)<br>  const serializedTx = tx.serialize()<br>  return (<br>    web3.eth.sendSignedTransaction(&#39;0x&#39; + serializedTx.toString(&#39;hex&#39;))<br>      .once(&#39;sending&#39;, function(payload){ console.log(&#39;sending transaction&#39;) })<br>      .once(&#39;sent&#39;, function(payload){ console.log(&#39;sent transaction&#39;) })<br>      .once(&#39;transactionHash&#39;, function(hash){ console.log(&#39;transactionHash: &#39;, hash) })<br>  )<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f311aa1f0e16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Valha API — Interact with DeFi protocols]]></title>
            <link>https://medium.com/@valha/valha-api-interact-with-defi-protocols-47399bf0339b?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/47399bf0339b</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[valha]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 13:21:21 GMT</pubDate>
            <atom:updated>2023-06-26T13:21:21.635Z</atom:updated>
            <content:encoded><![CDATA[<h3>Valha API — Interact with DeFi protocols</h3><p>We want Valha API to be a heaven gift for developers.</p><p>No need to integrate individually to each protocols, our standardised API makes it easy to interact with 25 protocols and more than 2000 DeFi pools to perform deposit, zaps and cross-chain zaps.</p><p>Let’s do a walkthrough to show how you can leverage Valha API in order to give your users the ability to enter DeFi pools.</p><h3>1- Simple deposit</h3><h4>a. Find the correct pool</h4><pre>const axios = require(&#39;axios&#39;);<br><br>async function getPools(protocol, chain) {<br>  const url = &#39;https://api.valha.xyz/v0/${chain}/pools/${protocol}&#39;;<br>  const headers = {<br>    &#39;accept&#39;: &#39;application/json&#39;,<br>    &#39;authorization&#39;: &#39;Bearer YOUR_KEY&#39;<br>  };<br><br>  try {<br>    const response = await axios.get(url, { headers });<br>    return response.data;<br>  } catch (error) {<br>    console.error(&#39;Error retrieving API results:&#39;, error);<br>    return null;<br>  }<br>}<br><br>// Usage<br>const protocol = &#39;aave&#39;;<br>const chain = &#39;polygon&#39;;<br><br>getPools(protocol, chain)<br>  .then(data =&gt; {<br>    if (data) {<br>      console.log(data);<br>      // Process the API results here<br>    }<br>  })<br>  .catch(error =&gt; {<br>    console.error(&#39;Error:&#39;, error);<br>  });</pre><p>You can then filter on a specific pool based on the underlying token.</p><h4>b. Calldata generation function</h4><p>Now that we have the pool address, we can write the function to generate calldata to deposit.</p><pre>async function getDeFiCallData(<br>  chain,<br>  poolAddress,<br>  userAddress,<br>  action,<br>  amountForAction,)<br>  // action is &#39;deposit&#39; here<br>  {<br>  const url = &#39;https://api.valha.xyz/v0/${chain}/pools/${poolAddress}/${action}&#39;;<br>  const headers = {<br>    &#39;accept&#39;: &#39;application/json&#39;,<br>    &#39;authorization&#39;: &#39;Bearer YOUR_KEY&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;<br>  };<br>  const data = {<br>    &quot;user&quot;: userAddress,<br>    &quot;amount&quot;: amountForAction,<br>    &quot;disable_check&quot;: true,<br>  };<br><br>  try {<br>    const response = await axios.post(url, data, { headers });<br>    return response.data;<br>  } catch (error) {<br>    console.error(&#39;Error performing the action:&#39;, error);<br>    return null;<br>  }<br>}</pre><h4>c. Generate calldata and execute transaction</h4><p>Now that calldata generation function is written, it is fairly easy to execute the transaction.</p><pre>// THIS is a high level description inspired using Ethers: https://docs.ethers.org/v5/<br>// You can adapt this function based on your wallet setup and it would work on top of any custodian solution.<br>import { ethers } from &#39;ethers&#39;;<br><br>const RPC_NODE = &#39;&#39;; //Url address provided by your RPC provider (https://beincrypto.com/learn/rpc-node-providers/).<br>const PRIVATE_KEY = &#39;&#39;; //Your private key in order to sign the transaction. /!\ Be careful to never share your private key or to expose it to the outside world.<br><br>async function SignAndExecute() {<br>  try {<br>    ////get the calldata for the specified action and specified pool.<br>    const txs = await getDeFiCallData();<br>    const provider = new ethers.providers.JsonRpcProvider(RPC_NODE);<br>    const walletWithProvider = new ethers.Wallet(PRIVATE_KEY, provider);<br><br>    ////approve the token for the specific amount<br>    const approveTx = txs.approveTx[0];<br>    const approvalTx = await walletWithProvider.sendTransaction(approveTx);<br>    approvalTx.wait();<br><br>    ////execute the transaction<br>    const executeTx = txs.interactionTx;<br>    const executionTx = await walletWithProvider.sendTransaction(executeTx);<br>    await executionTx.wait();<br>  } catch (err) {<br>    console.log(err);<br>    console.log(err.message);<br>  }<br>};</pre><h3>2- Cross-chain deposit</h3><p>To perform cross-chain deposit, step a. and c. are similar.</p><p>For step b., you have to specify the bridge object like described in the documentation <a href="https://valha.readme.io/reference/interactionscontroller_createdeposittx">here</a>.</p><pre>async function getDeFiCrossChainCallData(<br>  destinationChain,<br>  poolAddress,<br>  userAddress,<br>  action,<br>  startChain,<br>  startToken,<br>  destinationAmount, <br>  slippage)<br>  {<br>  const url = &#39;https://api.valha.xyz/v0/${destinationChain}/pools/${poolAddress}/${action}&#39;<br>  const headers = {<br>    &#39;accept&#39;: &#39;application/json&#39;,<br>    &#39;authorization&#39;: &#39;Bearer YOUR_KEY&#39;,<br>    &#39;content-type&#39;: &#39;application/json&#39;<br>  };<br>  const data = {<br>    &quot;user&quot;: userAddress,<br>    &quot;disable_check&quot;: true,<br>    &quot;bridge&quot;: <br>    {<br>    &quot;from_chain&quot;: startChain,<br>    &quot;from_token&quot;: startToken,<br>    &quot;destination_amount&quot;: destinationAmount,<br>    &quot;swap_slippage&quot;: slippage<br>      }<br>     }<br>  };<br><br>  try {<br>    const response = await axios.post(url, data, { headers });<br>    return response.data;<br>  } catch (error) {<br>    console.error(&#39;Error performing the action:&#39;, error);<br>    return null;<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47399bf0339b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to embed Valha widget in your dApp]]></title>
            <link>https://medium.com/@valha/how-to-embed-valha-widget-in-your-dapp-d387198b7b11?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d387198b7b11</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[widget]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Wed, 21 Jun 2023 17:05:02 GMT</pubDate>
            <atom:updated>2023-06-21T17:05:02.000Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Choose the protocols and chains you would like to display</li><li>Copy &amp; paste this line of code in your front-end with the chains and protocols that you want</li></ol><p>&lt;iframe<br> src=”<a href="https://widget.valha.xyz/?apiKey=abc&amp;authorizedChains=optimism,arbitrum">https://widget.valha.xyz/?apiKey=abc&amp;authorizedChains=optimism,arbitrum</a>&amp;authorizedProtocols=aave&quot;<br> frameBorder=”0&quot;<br> scrolling=”no”<br> width=”700px”<br> height=”640px”<br> /&gt;</p><p>3. Change the width and the height accordingly</p><p>4. Tadam, it’s implemented in your dApp!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*yo-DzCKOOwI0zHsM_jZMLw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d387198b7b11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DeFi in 1-click]]></title>
            <link>https://medium.com/@valha/defi-in-1-click-25245bbcccfe?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/25245bbcccfe</guid>
            <category><![CDATA[soulwallet]]></category>
            <category><![CDATA[valha]]></category>
            <category><![CDATA[erc-4337]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[account-abstraction]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 07:32:43 GMT</pubDate>
            <atom:updated>2023-06-01T07:32:43.650Z</atom:updated>
            <content:encoded><![CDATA[<p>How bundling transactions together make DeFi more user-friendly. An illustration with <a href="https://www.soulwallet.io/">Soul wallet</a> and <a href="https://www.valha.xyz/">Valha</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3keV4u9hSvGCgMVv0dw8jQ.png" /></figure><p>From an user perspective, the whole onchain <strong><em>approval + execution</em></strong><em> </em>experience is a step backwards compared to the <strong><em>internet/credit card/cash</em></strong><em> </em>payment experience. The banking applications and investment apps you might use in your daily life never ask you to approve making a transaction before actually carrying out the transaction.</p><p>Transaction bundling is one the many facet that comes with account abstraction and that can improve a lot the user experience.</p><h3><strong>The issue: approve + execute</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*YiSjcfKvyqan6_dY" /><figcaption>M. Degen waiting for its transaction approval before the execution at the bank</figcaption></figure><p>Today, for any action you want to do in DeFi, you must first approve (1) the action you are about to make, (2) before executing the transaction. This is because of core security and usability reasons of the ERC-20 standard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1ujRJvjpESCisVxwc6mWQ.png" /></figure><p>This is coupled to the fact that token allowances should be removed manually using tools like <a href="https://revoke.cash/">revoke.cash</a>.</p><h3>The other issue: multiple actions</h3><p>That is not great and it becomes even more frustrating when you are doing multiple onchain actions:</p><ul><li><strong>Enter a Convex pool</strong></li></ul><p>This action require usually at least four clicks and can require two mores if you do not have the accurate underlying token (approve token + swap token to USDC).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HC37R2JSHGQDhCfL38hirA.png" /></figure><ul><li><strong>Enter an AMM LP position</strong></li></ul><p>This action require usually at least five clicks and can require two mores if you do not have the accurate underlying token (no USDC nor DAI) as you need to approve the token and swap it to USDC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DwMxbC6fu7v-iDta5lXP9g.png" /></figure><h3>Soul Wallet: Native transaction bundle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WRFCMMX0rdqKu55z.jpg" /></figure><p><a href="https://www.soulwallet.io/">Soul Wallet</a> is a smart contract wallet that makes batch actions a reality. DAPPs can make batch actions request to the wallet. Soul Wallet will bundle multiple actions into one UserOperation. Then the bundled actions will be executed with one transaction onchain.</p><h3>Valha: complementary tool for new level DeFi experience</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*NtCyP0WX4d661JpSyoFm1w.png" /></figure><p><a href="https://www.valha.xyz/">Valha</a> acts by feeding transaction bundler with accurate generated calldata to bundle multiple actions at once.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJRiz4u-osqg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJRiz4u-osqg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJRiz4u-osqg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/728ad990c682d026260f49bc7692a044/href">https://medium.com/media/728ad990c682d026260f49bc7692a044/href</a></iframe><p>Thus many use cases are possible and could be implemented natively within any kind of interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Huw4sMKkL62iyTso" /></figure><p>You can drop a DM to <a href="https://twitter.com/ValhaHQ">Valha</a> if you want to experiment it. <br>You can also visit <a href="https://twitter.com/soulwallet_eth">Soul Wallet</a> to get more information about their AA wallet.</p><h4>Disclaimer:</h4><p>It should be noted that AA bundlers is not the only way to solve the differenciation between spending allowance and transaction execution as <a href="https://blog.uniswap.org/permit2-and-universal-router">Uniswap Permit2</a> solves it for EOA.<br>Moreover, it is possible to bundle multiple transactions for EOA with <a href="https://docs.uniswap.org/contracts/v3/reference/periphery/base/Multicall">multicall contracts.</a><br>We highlight the fact that AA include all of these features natively among others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25245bbcccfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#2 Valha insights — LP analysis]]></title>
            <link>https://medium.com/@valha/2-valha-insights-lp-analysis-ae13de9c8f68?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae13de9c8f68</guid>
            <category><![CDATA[liquidity-provider]]></category>
            <category><![CDATA[liquidity-pool]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[defi-tvl]]></category>
            <category><![CDATA[dex]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 17:39:14 GMT</pubDate>
            <atom:updated>2023-03-31T12:54:19.692Z</atom:updated>
            <content:encoded><![CDATA[<h3>#2 Valha insights — LP analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*C7NRAJeJkkfZxuKl.png" /></figure><p>Decentralised finance is still in its infancy. Its use is still limited the use, but also promising. <br>I will measure its activity and putting it in perspective with first-order proxy metrics of crypto activities adoption (NFT, DEX trading, DeFi TVL).</p><p>There are three questions I want to answer</p><blockquote>How many unique addresses interact with DeFi pools?</blockquote><blockquote>How many transactions are operated by those addresses?</blockquote><blockquote>What is the scope of invested volume in DeFi pools?</blockquote><p>I built <a href="https://dune.com/octavionotpunk/lp-analysis">queries and a dashboard on Dune analytics</a> to answer (partially) those questions.</p><h3><strong>The Scope</strong></h3><ul><li>GMX (GLP), Velodrome (Market-Making), Instadapp (Yield), Lido (Staking), Stargate (Bridge), Aave V3 (Lending). I only selected top pools in terms of TVL.</li><li>5 chains (Ethereum, Polygon, Optimism, Arbitrum, Avalanche)</li><li>A perspective with DeFi TVL and decentralized exchanges (DEX) and NFT marketplaces activity.</li></ul><h3>First order adoption metrics</h3><h4>For DeFi</h4><p>There is many away to account for the adoption of DeFi. The most common metrics known is TVL (total value locked). It stands for the total amount of tokens (denominated in $) locked on on-chain smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uyDO0jiQzZHz7ROPYV_ew.png" /></figure><h4><a href="https://dune.com/rchen8/defi-users-over-time">DEX</a></h4><p>DeFi adoption could also be summed up in the number and volume of transactions that take place on decentralised exchanges.</p><p>It is an interesting metric that could be used as a first-order proxy to DeFi adoption.</p><p>Surprisingly, the number of addresses using DEXes has reached an all time high recently. The reason? The extensive use of layer 2 blockchains since June 2022 makes up for the stagnation of DEX Ethereum usage.</p><p>Transaction volume has suffered a slight decrease between April 2022 to January 2023 with a $10Bn to $20Bn weekly volume. From time to time, transaction volume peaks happen related to super important events (Luna in May 2022, FTX in November 2022, SVB bankrupt and USDC depeg in the last weeks).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*xLMjrrPloYG3z6mfMa-ToA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*fdxlSanEIOfRq1lhLYGFAA.png" /></figure><p>However, these metrics are not sufficient. TVL represents the overall amount deposited in smart contracts, but it does not indicate the usage of these contracts in terms of the number and volume of transactions. The number and amount of trades on decentralized exchanges are suggestive, but trading is only the first step before many others</p><h3>DeFi — Second order proxy</h3><p>Sources: <a href="https://dune.com/octavionotpunk/lp-analysis">https://dune.com/octavionotpunk/lp-analysis</a></p><ul><li><strong>Raw figures</strong></li></ul><p>Aave leads 20 to 200k transactions every week that corresponds to a $150Mn to $2Bn volume.</p><p>Lido generates less transactions 1,500 to 7,000 every weeks with a $10Mn to $1Bn volume..</p><ul><li><strong>More transactions on L2s …</strong></li></ul><p>A large portion of DeFi activity occurs on L2 or side-chains such as Polygon. More than 95% of transactions on Aave and Stargate take place on Arbitrum, Optimism, or Polygon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*ZUMUp5XPS_QVzFPbprZb4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*CrTosR86TXw3dc5TQRAT4w.png" /></figure><ul><li><strong>… But bigger volumes on Mainnet</strong></li></ul><p>In terms of transaction volume, the situation is reversed. Ethereum accounts for 50 to 70% of transaction volume lately since the release of AaveV3 and 50% on average on Stargate.</p><p>This also means that the average transaction amount is much higher on Ethereum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*tywJ9Lam4SD5w54W9GGmkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*nlmniCgHDx52xqJ1c_Vcog.png" /></figure><ul><li><strong>Liquidity mining boosted activity</strong></li></ul><p>This passage describes how the activity on the Velodrome protocol demonstrates that many users are motivated by the speculative aspect. After the announcement and distribution of the OP token, several protocols like Velodrome redistributed it in the form of liquidity tokens to their users, resulting in significant gains for some, driving volume and user activity.</p><p>Then the faucet turned off, and the number of users decreased significantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*m3XsUAeHoEnozKpW5eCkiQ.png" /></figure><ul><li><strong>Investment volume dependent on macro-events</strong></li></ul><p>The collapse of the Terra blockchain led to a capital flight, as we saw with the TVL (total value locked). This is also reflected in the decline in volumes on Instadapp and Lido from early May, followed by a timid recovery a few months later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*Z1A-g1JWmPS5VuZmyUttyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*iStqJPc3y9MvRcf7-5LO-w.png" /></figure><ul><li><strong>Variable transactions to addresses ratio</strong></li></ul><p>It is interesting to note how addresses interact with DeFi protocols. For certain protocols (such as Aave), addresses will make approximately 4 transactions per month. For the rest (GMX, Lido, Instadapp), the ratio is between 1 and 1.5 transactions per month.</p><p>This can be explained by the leverage effects on Aave, which involve systematic borrowing and withdrawing, and which multiply the number of transactions by a factor of 3 to 4.</p><h4>Comparison to <a href="https://dune.com/hildobby/NFTs">NFT</a> activity</h4><p>Similarly to DeFi, you can sum up the activity by looking at the number of traders and volume.</p><p>The weekly volume fluctuates greatly depending on the market conditions (bearish or bullish). Volumes reached $1 billion several times between January and April 2022, while they barely exceed $300 million between June and December 2022</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*o1oZvQFFjJhyNuj0XbaVvg.png" /></figure><p>The number of traders remains much more constant, as the number of active traders per month has decreased by less than 30% compared to the peak in January 2022. This proves that the ecosystem is dynamic, with active participants despite lower trading volumes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*XA-7VR1DF3OAZnrNBPgTyA.png" /></figure><p>The number of active addresses is x2.5 lower than for DeFi traders and are in the same order of magnitude/slightly higher than DeFi pools investors (incl. GMX, Velodrome, Aave, Lido, Curve, Uniswap)</p><p>However NFT volumes are less important than for DeFi activity (x20 to x60 less than DeFi trades, x3 to x10 less than DeFi pool investments).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae13de9c8f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#5 Valha integrations — How to deal with Uniswap V2?]]></title>
            <link>https://medium.com/@valha/5-valha-integrations-how-to-deal-with-uniswap-v2-dd69e5d39855?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd69e5d39855</guid>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[liquidity-provider]]></category>
            <category><![CDATA[uniswap-v2]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 17:41:29 GMT</pubDate>
            <atom:updated>2023-03-09T17:41:29.085Z</atom:updated>
            <content:encoded><![CDATA[<h3>#5 Valha integrations — How to deal with Uniswap V2?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*WYg9Az1H5nXW6BsS.png" /></figure><p>At Valha we are building a DeFi abstraction layer for developers in order to easily deal with integrations.</p><p>These articles explain for developers how to easily interact with some of the protocols in DeFi especially to deposit/redeem/stake funds in yield generating pools.</p><p>These explanations are an appetizer for integration. Valha offers comprehensive resources to leverage them in a more complete and detailed way.</p><p>In this fourth episode, we are looking at <strong>Uniswap V2.</strong></p><h3>Uniswap V2 presentation</h3><p>Uniswap V2 is a fully decentralized protocol for automated liquidity provision on Ethereum, it is more broadly referenced as a decentralized exchange (DEX).</p><p>Uniswap relies on two groups of stakeholders: 1) Traders and 2) Liquidity Providers</p><ul><li><strong>Traders: </strong>they can exchange their tokens against other without the action of centralized entity (market-maker, centralized exchange).</li><li><strong>Liquidity Providers: </strong>they act as market makers to enable traders to swap their tokens. They provide the capital that makes AMM (<a href="https://medium.com/balancer-protocol/what-is-an-automated-market-maker-amm-588954fc5ff7">Automated Market Making</a>) to work. Indeed, the price of one token relative to another is determined by the reserve balance deposited by liquidity providers.</li></ul><h3>Integration focus</h3><ul><li>Protocol: Uniswap</li><li>Scope: Ethereum</li><li>Version: V2</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*WVYHYYsn2PcGIsah.png" /></figure><h3>High Level Design</h3><ol><li><strong>Pool Contract</strong></li></ol><p>These contract are the main entry points for people willing to add liquidity to pools and earn trading fees rewards. A contract address could be found by calling the <a href="https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory#getpair">getPair function</a> with the underlying tokens.</p><pre>function getPair(address tokenA, address tokenB) external view returns (address pair);</pre><p><strong>2.Liquidity Pool Tokens</strong></p><p>“Liquidity Pool Tokens” or “LP Tokens” are tokens representing the share of a liquidity provider into a pool.</p><p><strong>3.Underlying Tokens</strong></p><p>“Underlying Tokens” are the tokens used to enter liquidity pools. It is a pair of tokens.</p><h3>Specifications</h3><ul><li><strong>Forks:</strong></li></ul><p>There is more than <a href="https://defillama.com/forks/Uniswap">350 forks of Uniswap V2</a> on every EVM chains.</p><p>The most famous are PancakeSwap and BiSwap on BSC, TraderJoe on Avalanche, Quickswap on Polygon.<br>The most notorious fork is othe <a href="https://www.gemini.com/cryptopedia/sushiswap-uniswap-vampire-attack#section-what-is-a-vampire-attack">SushiSwap protocol</a>, deployed on a dozen chains, which caused a huge stir in during the 2020 DeFi summer because of the subsequent vampire attack to attract liquidity from Uniswap.</p><p>It also means that if you can integrate Uniswap, you can integrate many other protocols easily.</p><ul><li><strong>Risks:</strong></li></ul><p>The biggest risk facing liquidity provider is <a href="https://medium.com/coinmonks/understanding-impermanent-loss-9ac6795e5baa">impermanent loss</a>:</p><blockquote><em>Let’s say a liquidity provider adds 1 ETH and 100 USDC to the liquidity pool, this is for an equal value of both tokens. The dollar amount of their deposit is $200 because their ETH and USDC are both worth $100 each. Currently, there is 10 ETH and 1,000 USDC in the liquidity pool, a 50/50 ratio, which gives the liquidity provider a 10% share of the pool. They will receive LP tokens that they can use to redeem their 10% share of the pool at any time.</em></blockquote><blockquote><em>Since the price of tokens relies on the ratios of their liquidity pools their prices can separate from the prices on other exchanges. If the price of ETH increases by 100%, now worth $200 per ETH, the liquidity pool would have changed to 7.071 ETH and 1,414.21 USDC. This is because the ratio of the pool has changed, it is no longer 50/50, which affected the price of ETH.</em></blockquote><blockquote><em>Since the liquidity provider has a 10% share of the liquidity pool, they can withdraw 0.7071 ETH and 141 USDC, which equals $282. However, if the liquidity provider simply held their 1 ETH and 100 USDC, they would be worth $300. The difference between the two, $18, is the amount of impermanent loss the liquidity provider experienced</em></blockquote><p>In summary providing liquidity to a volatile pair could be risky and could lead to capital loss in comparison with holding the assets. Sometimes, even transaction fees does not make up for this loss.</p><p>One strategy is to actively manage your positions as a true market maker, or to put liquidity on pools of two tokens with the same base (stablecoins, liquid staked eth, bridged and wrapped assets).</p><ul><li>New version:</li></ul><p><strong>Uniswap V3</strong> design is different from the V2 version. Stay in touch with us if you want to better understand the integration process.</p><h3>Interactions</h3><p>☝️☝️☝️In the following snippets, we consider that the contract implementing the functions has <strong>enough ERC20 balance to execute the function</strong>.</p><p>NB: There are other ways to integrate with Stargate protocol, if you think that there is better way to achieve some of the interactions above, feel free to jump in the <a href="https://discord.com/invite/mrwsC5SQg7">Discord</a> to discuss it with the team!</p><p><strong>A) Deposit</strong></p><pre>// SPDX-License-Identifier: GPL-3.0<br>pragma solidity ^0.8.9;<br>interface IUPool {<br>    function addLiquidity(<br>        address tokenA,<br>        address tokenB,<br>        uint amountADesired,<br>        uint amountBDesired,<br>        uint amountAMin,<br>        uint amountBMin,<br>        address to,<br>        uint deadline<br>    ) external returns (uint amountA, uint amountB, uint liquidity);<br>    function removeLiquidity(<br>        address tokenA,<br>        address tokenB,<br>        uint liquidity,<br>        uint amountAMin,<br>        uint amountBMin,<br>        address to,<br>        uint deadline<br>    ) external returns (uint amountA, uint amountB);<br>}<br>interface IERC20 {<br>    function approve(address spender, uint256 value) external;<br>}<br>contract Example {<br>    address constant ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;<br>    constructor() {}<br>    /// @notice External function to deposit two underlying tokens into an Uni V2 pool.<br>    /// @dev Once this function is called, LP token will be minted for the corresponding<br>    /// amount of underlying tokens and distributed to the msg.sender<br>    function deposit(<br>        address                 _to,<br>        uint256                 _deadline,<br>        address[2] calldata     _underlyingTokens,<br>        uint256[2] calldata     _amountsDesired,<br>        uint256[2] calldata     _amountsMinimum<br>    ) external {<br>        IERC20(_underlyingTokens[0]).approve(ROUTER, _amountsDesired[0]);<br>        IERC20(_underlyingTokens[1]).approve(ROUTER, _amountsDesired[1]);<br>        IUPool(ROUTER).addLiquidity(<br>            _underlyingTokens[0],<br>            _underlyingTokens[1],<br>            _amountsDesired[0],<br>            _amountsDesired[1],<br>            _amountsMinimum[0],<br>            _amountsMinimum[1],<br>            _to,<br>            _deadline<br>        );<br>    }<br>}<br></pre><p><strong>B) Redeem</strong></p><pre>// SPDX-License-Identifier: GPL-3.0<br>pragma solidity ^0.8.9;<br>interface IUPool {<br>    function addLiquidity(<br>        address tokenA,<br>        address tokenB,<br>        uint amountADesired,<br>        uint amountBDesired,<br>        uint amountAMin,<br>        uint amountBMin,<br>        address to,<br>        uint deadline<br>    ) external returns (uint amountA, uint amountB, uint liquidity);<br>    function removeLiquidity(<br>        address tokenA,<br>        address tokenB,<br>        uint liquidity,<br>        uint amountAMin,<br>        uint amountBMin,<br>        address to,<br>        uint deadline<br>    ) external returns (uint amountA, uint amountB);<br>}<br>interface IERC20 {<br>    function approve(address spender, uint256 value) external;<br>}<br>contract Example {<br>    address constant ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;<br>    constructor() {}<br>    /// @notice External function to redeem LP tokens and get back two underlying tokens from an Uni V2 pool.<br>    /// @dev Once this function is called, underlying tokens will be distributed back to the msg.sender <br>    /// while LP token will be burnt<br>    function redeem(<br>        address                 _lpToken,<br>        address                 _to,<br>        uint256                 _deadline,<br>        uint256                 _lpAmount,<br>        address[2] calldata     _underlyingTokens,<br>        uint256[2] calldata     _amountsMinimum<br>    ) external  {<br>        IERC20(_lpToken).approve(ROUTER, _lpAmount);<br>        IUPool(ROUTER).removeLiquidity(<br>            _underlyingTokens[0],<br>            _underlyingTokens[1],<br>            _lpAmount,<br>            _amountsMinimum[0],<br>            _amountsMinimum[1],<br>            _to,<br>            _deadline<br>        );<br>    }<br>}</pre><h3>To go further</h3><p><strong><em>At Valha, we have the mission to make DeFi easier for developers. We want to make the promise of composability more tangible than ever by creating an abstraction layer on top of which it is intuitive, secure and efficient to integrate with any protocol in DeFi.</em></strong></p><p><strong><em>If you do not want to maintain all your integrations yourself, check our </em></strong><a href="https://valha.readme.io/reference/introduction"><strong><em>documentation</em></strong></a><strong><em> or jump into our </em></strong><a href="https://discord.gg/mrwsC5SQg7"><strong><em>Discord</em></strong></a><strong><em> to discuss it.</em></strong></p><p><strong><em>We also maintain an open-source repository of many DeFi integrations and are always for the lookup for new contributors, so feel free to explore or </em></strong><a href="https://github.com/Valha-xyz/valha-defi-connectors"><strong><em>Github</em></strong></a><strong><em>. Reach out to us on </em></strong><a href="https://twitter.com/ValhaHQ"><strong><em>Twitter</em></strong></a><strong><em> or in our </em></strong><a href="https://discord.gg/mrwsC5SQg7"><strong><em>Discord</em></strong></a><strong><em> for potential collaboration in the future.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd69e5d39855" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#4 Valha integrations — How to deal with Flux Finance]]></title>
            <link>https://medium.com/@valha/4-valha-integrations-how-to-deal-with-flux-finance-378e910dbae1?source=rss-729b6a005feb------2</link>
            <guid isPermaLink="false">https://medium.com/p/378e910dbae1</guid>
            <category><![CDATA[treasury-yield]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[flux-protocol]]></category>
            <dc:creator><![CDATA[Valha]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 09:57:29 GMT</pubDate>
            <atom:updated>2023-03-09T09:57:29.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>#4 Valha integrations — How to deal with Flux Finance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*n4P3pdUo-y5cvyNB.jpeg" /><figcaption>Flows or Flux</figcaption></figure><p>At <a href="https://www.valha.xyz/">Valha</a> we are building a DeFi abstraction layer for developers in order to easily deal with integrations.</p><p>These articles explain for developers how to easily interact with some of the protocols in DeFi especially to deposit/redeem/stake funds in yield generating pools.</p><p>These explanations are an appetizer for integration. Valha offers comprehensive resources to leverage them in a more complete and detailed way.</p><p>In this episode, we are looking at <a href="https://fluxfinance.com/markets"><strong>Flux Finance</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*4_dObF180J88g9oQiY1msw.png" /></figure><h3>Flux Finance presentation</h3><p>Flux is a decentralized lending protocol on Ethereum mainnet built by the <a href="https://ondo.finance/about">Ondo Finance team</a>.</p><p>It follows a peer-to-pool model (like Aave, Compound Finance or Euler) and is designed to always quote a lend and borrow rate based on the pool utilisation rate (borrowed amount/lent amount).</p><p>Flux is a fork of Compound V2, with some modifications to enable support for assets that must have transfer restrictions, like many tokenized securities.</p><p>The particularity of Flux Finance is that it is closely linked to <a href="https://ondo.finance/">Ondo Finance</a>. Flux supports OUSG, a tokenised t-bill launched by Ondo, as a collateral.</p><p>Flux Finance relies on two groups of stakeholders:</p><ul><li><strong>Lenders (LPs): </strong>Lenders contribute assets (USDC, DAI) to a marketplace by depositing them into a shared pool, which generates interest through the supply rate. They mint fToken by depositing assets.</li><li><strong>Borrowers: </strong>Borrowers can borrow stablecoins against deposited collateral. They mint fTokens (link lenders) and utilize them as collateral by depositing them. Despite using the assets as collateral, they can still earn interest through the supply rate, which may help counterbalance the borrow rate.</li></ul><h3>Integration focus</h3><ul><li>Protocol: Flux Finance</li><li>Scope: Ethereum mainnet</li><li>Version: V1</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4F7AxLHgjkttWu171LxgQ.png" /></figure><h3>High Level Design</h3><ol><li><strong>Pool Contract</strong></li></ol><p>These contracts are the main entry points for people willing to add liquidity to pools and earn interests.</p><p>Each investment opportunity is a pool with the following contracts:</p><pre>address fluxUSDC = 0x465a5a630482f3abd6d3b84b39b29b07214d19e5<br>address fluxDAI = 0xe2ba8693ce7474900a045757fe0efca900f6530b</pre><p><strong>2. Liquidity Pool Tokens</strong></p><p>“Liquidity Pool Tokens” or “LP Tokens” are tokens representing the share of a liquidity provider into a pool.</p><p>LP Tokens addresses are similar to pool contracts.</p><p><strong>3. Underlying Tokens</strong></p><p>“Underlying Tokens” are the tokens used to enter liquidity pools.</p><pre>address USDC = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48<br>address DAI = 0x6b175474e89094c44da98b954eedeac495271d0f</pre><h3>Interactions</h3><p>☝️☝️☝️In the following snippets, we consider that the contract implementing the functions has <strong>enough ERC20 balance to execute the function</strong>.</p><p>The integration of Flux is quite simple as the investment contract is similar to the pool token which is based on the ERC-20 standard.</p><p>NB: There are other ways to integrate with Flux Finance protocol, if you think that there is better way to achieve some of the interactions above, feel free to jump in the <a href="https://discord.com/invite/mrwsC5SQg7">Discord</a> to discuss it with the team!</p><p><strong>A) Deposit</strong></p><pre>interface IERC20 {<br>    function approve(address spender, uint256 value) external;<br>}<br><br>interface CErc20Interface {<br>    function mint(uint mintAmount) external virtual returns (uint);<br>}<br><br>/// @notice External function to deposit USDC into Flux Finance USDC lending pool<br>/// @dev Once this function is called, LP token will be minted for the corresponding amount of underlying token and distributed to the msg.sender<br>function deposit(uint256 _amount) external payable {<br>    address POOL_ADDRESS = 0x465a5a630482f3abd6d3b84b39b29b07214d19e5;<br>    address TOKEN  = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48;<br>    IERC20(TOKEN).approve(POOL_ADDRESS, _amount);<br>    CErc20Interface(POOL_ADDRESS).mint(_amount);<br>}</pre><p><strong>B) Redeem</strong></p><pre>interface IERC20 {<br>    function approve(address spender, uint256 value) external;<br>}<br><br>interface CErc20Interface {<br>    function redeem(uint mintAmount) external virtual returns (uint);<br>}<br><br>/// @notice External function to redeem USDC from Flux Finance Pool.<br>/// @dev Once this function is called, LP token will be burnt for the corresponding amount of underlying token and distributed to the msg.sender.<br>function redeem(uint256 _amount) external payable {<br>    address POOL_ADDRESS = 0x465a5a630482f3abd6d3b84b39b29b07214d19e5;<br>    IERC20(POOL_ADDRESS).approve(POOL_ADDRESS, _amount);<br>    CErc20Interface(POOL_ADDRESS).redeem(_amount);<br>}</pre><h3>To go further</h3><p><strong><em>At Valha, we have the mission to make DeFi easier for developers. We want to make the promise of composability more tangible than ever by creating an abstraction layer on top of which it is intuitive, secure and efficient to integrate with any protocol in DeFi.</em></strong></p><p><strong><em>If you do not want to maintain all your integrations yourself, check our </em></strong><a href="https://valha.readme.io/reference/introduction"><strong><em>documentation</em></strong></a><strong><em> or jump into our </em></strong><a href="https://discord.gg/mrwsC5SQg7"><strong><em>Discord</em></strong></a><strong><em> to discuss it.</em></strong></p><p><strong><em>We also maintain an open-source repository of many DeFi integrations and are always for the lookup for new contributors, so feel free to explore or </em></strong><a href="https://github.com/Valha-xyz/valha-defi-connectors"><strong><em>Github</em></strong></a><strong><em>. Reach out to us on </em></strong><a href="https://twitter.com/ValhaHQ"><strong><em>Twitter</em></strong></a><strong><em> or in our </em></strong><a href="https://discord.gg/mrwsC5SQg7"><strong><em>Discord</em></strong></a><strong><em> for potential collaboration in the future.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=378e910dbae1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>