# GnoLend (UI & more) - [@matijamarjanovic](https://hackmd.io/yw61Tg4OTPWOY3d0U9UU4Q?both) - matijamarjanovic69@gmail.com - https://www.linkedin.com/in/matijamarjanovic/ ## Project summary As you may already know, @stefann-01 has initiated work on [GnoLend](https://github.com/gnoverse/GnoLend), and I have joined him toward the end of the SCP to contribute to its development. We’ve developed a strong interest in DeFi and are excited about the opportunity to integrate decentralized finance concepts with our ongoing work on the gno.land ecosystem. [GnoLend](https://github.com/gnoverse/GnoLend) is the first lending protocol built using Gnolang, implementing financial primitives for decentralized lending and borrowing. The protocol features lending markets with configurable parameters, variable interest rate models, collateralized borrowing with health monitoring, and liquidation mechanisms for undercollateralized positions. It employs a shares-based accounting system to track user positions, calculates interest based on utilization metrics, and maintains system solvency through real-time risk assessment. For price determination, GnoLend integrates with [Gnoswap](https://github.com/gnoswap-labs/gnoswap)'s liquidity pools, using them as price oracles in the absence of dedicated oracle infrastructure. This approach enables the protocol to obtain reliable price data directly from on-chain sources without requiring external oracle networks, demonstrating how essential financial primitives can be implemented within the current gno.land ecosystem. The system calculates borrowing capacity based on collateral values derived from Gnoswap pool prices. This integration creates a self-contained lending solution that maintains the security guarantees of the underlying blockchain while providing the necessary infrastructure for expanding DeFi capabilities on gno.land. ## Goals and deliverables **Core Refactoring** Update codebase to match recent changes in Gno and Gnoswap. Improve structure, fix inconsistencies, and complete unfinished components. * Codebase Update: Align the existing codebase with recent architectural and functional changes in the Gno (CrossRealms) and Gnoswap protocol (updates introduced after the [commit 5774424](https://github.com/gnoswap-labs/gnoswap/commit/5774424d0c6e83c13fec2fc146a906e10ac75285)). * Code Maintenance: Refactor and reorganize code (e.g., periphery calls, reusable logic extraction, constants cleanup, `onBehalf` support, LLTV/IRM checks fixes, market ID creation refactor) **Flashloans Implementation** Implement logic for uncollateralized loans within single transactions. * Borrow any amount without collateral, as long as it's returned in the same transaction * Execute complex operations like arbitrage or collateral swaps in one atomic transaction * Fail-safe mechanism - if the borrowed amount isn't returned, the entire transaction reverts **Governance Implementation** Implementation of the [Common DAO](https://github.com/gnolang/gno/pull/3882) Governance mechanisms for protocol parameter updates * Customized version of the Common DAO package following [AtomOne Constitution specifications](https://github.com/atomone-hub/genesis/blob/main/CONSTITUTION.md#section-4a-common-dao-spec) * Governance token enabling holders to create proposals and cast votes * Defined tokenomics for distribution and participation requirements * Direct contract integration for automatic parameter updates * Configurable parameters for interest rates, liquidation thresholds, and protocol fees * Emergency controls and time-locked parameter changes for security **Testing & Optimization** * Tests: Comprehensive test coverage for all smart contract functionality * Gas Optimization: Optimize code for efficient gas usage * Deployment Scripts: Automate contract deployment **Frontend Development** Develop full-featured web interface for protocol usage. * Custom Frontend: Dedicated web interface for the lending protocol, including: * Market overview dashboard * Position management interface * Risk monitoring tools * Governance Managment interface etc. * Contract Integration: Connect frontend with contracts and refine interactions for reliability and precision * Gnoweb UI: Build a extensive Gnoweb interface covering full protocol functionality **Documentation** Deliver complete documentation for users, developers, and contributors. * User Docs: Provides guides for protocol interaction, including market creation, position management for lenders and borrowers, liquidation procedures etc. * Technical Docs: Covers protocol architecture, smart contract interfaces, integration guides, event handling, security best practices, contract interactions, testing procedures etc. * Protocol Docs: Outlines the economic model, risk parameters, interest rate models, liquidation procedures, governance mechanisms etc. **Additional Contribution** I will also continue to actively contribute to the monorepo GitHub, providing assistance wherever needed—something I’ve been consistently doing, as well as continue working on active PRs (more details in the *Timeline and milestones* section). ## Impact on gno.land’s developer ecosystem As one of the pioneering projects to adopt Common DAO as governance, GnoLend will help advance governance standards within the ecosystem while serving as a practical implementation reference for other developers. This will promote broader adoption of standardized governance mechanisms on gno.land, strengthening the community-driven development approach. The protocol will offer a dual-interface approach to user experience, providing both a comprehensive custom UI for advanced users and a minimal Gnoweb UI for simplicity. GnoLend will be one of the most sophisticated dApps fully functional through Gnoweb, demonstrating that complex financial applications can operate effectively using gno.land's native interface despite its minimalist design. This showcases Gnoweb's potential to replace traditional UIs for even complex DeFi applications. By implementing financial primitives that integrate with existing ecosystem components like Gnoswap, GnoLend demonstrates how developers can build advanced applications even with current infrastructure limitations. This approach of creating composable DeFi building blocks encourages developers to construct interdependent systems, accelerating the maturation of gno.land's DeFi ecosystem. Our vision is to position GnoLend as a widely adopted lending protocol — comparable in utility and importance to similar protocols on other blockchain ecosystems. By doing so, we aim not only to advance the use of DeFi on gno.land but also to contribute to the expansion and diversification of its broader community. ## Timeline and milestones The following is a rough timeline outlining, the key milestones and estimated timeframes for completion: ### **Week 1–4 : Custom Frontend Implementation** - Develop the complete web frontend using Next.js and TypeScript. - Integrate wallet operations via the Adena SDK (connecting and disconnecting are already implemented, so transaction handling). - Implement core interactions with `gno-js` - Tx indexer integration to track historic data to be used for analytics (e.g. positions, markets, prices, etc.) - Initial UI/UX scaffolding and internal testing --- ### **Week 5 : Gnoweb UI** - Develop a simplified, functional version of the protocol UI for use on `gnoweb`, aligning with gno.land’s minimalistic design philosophy. - Ensure feature parity (where possible) with the main frontend in terms of core functionality by using txlink, charts and similar packages. --- ### **Week 6-8 : Common DAO Integration** - Assuming Common DAO is ready for integration at this point, the governance layer will be implemented. - Tasks include: - Setting up the datasource library with existing data types and the proposal flow. - Consulting with @stefann-01 and core contributors to align on best practices for implementing governance tool such as this in general, as well as what's the best embodiment of gno.land's core values. - Full technical implementation and basic testing of DAO interactions. > Estimated time in this part is most likely to vary since this is to be one of the first projects to incorporate Common DAO, which might result in a lot of trial and error and some best practices definitions for future projects. --- ### **Additional Tasks (Ongoing)** - Finalization and potential continuation of side projects including: - [AwesomeGno](https://github.com/gnolang/gno/pull/3963) - currently missing integration of governence (working with DevRel Authority through `authz` package) - [The GRC721 standard remake](https://github.com/gnolang/gno/pull/3973) - waiting for reviews; provides a `Teller` approach but more importantly introduces `Hooks` which provide a way for developers to use the basic definition of nft standard and customize it at the same time - [gnoXchange](https://github.com/gnolang/gno/pull/3793) - was marked as *Ready for review* at a time but needs improvements in terms of more rotree exposures and less getters; also has a fully operating frontend which might make it a candidate to be the first project presented on Awesome Gno - [gno.land/r/gnoland/coins](https://github.com/gnolang/gno/pull/3844) - waiting for implementation of Total Supply of coins - [charts package](https://github.com/gnolang/gno/pull/4253) - Active participation in the gno.land monorepo (support, contributions) - Coordination and assistance with Stefan on backend or protocol-layer tasks as needed. > As this works timeline will overlapping with the development of GnoLend the time needed for these tasks has been included in the estimations addressed above. > I am also open to collaborating with Stefan on the realm side of the project if any part of it proves particularly challenging. Since this project is a team effort, we do not consider our individual scopes of work to be rigidly fixed. > --- ### **Estimated Project Duration: ~2 Months** This timeframe includes buffer for: - Testing and debugging across components - Cross-collaboration and feedback loops - Unexpected complexity in governance-related features ## Contributions or related work for gno.land You can check out all of my work on gno.land since October 2024 on these issues : - [Hackerspace - My builder's journey](https://github.com/gnolang/hackerspace/issues/95) - [SCP Updates](https://github.com/gnolang/meetings/issues/39) ## Why are you and your team well-suited for this project? Given our experience on the monorepo, especially with our interest with token standards and DeFi related issues from the very beginning of our SCP we became vastly familiar with these concepts on gno.land. In fact, we have managed to find some possible issues with current token implementations as well as possible solutions for those (e.g. token extension and hook usage). References (token related contributions): - `r/matijamajranovic/tokenhub` - a registry for all token types (examples) - [grc20 related issue](https://github.com/gnolang/gno/issues/3692) - `grc721 remake` - hooks introductions - `gnoXchange` - first public fee-less trading system & nft market on gno.land