Technical Journey

From concept to production - building a decentralized ETF protocol

XTF Vault Lifecycle

XTF Vault Lifecycle Diagram

🛠️ How We Built It

My journey in developing XTF during the hackathon started with creating smart contracts using Solidity, initially as a single-chain protocol. The main aim was quick development and testing of key features. For this, I used mock interfaces for the DataFeed and Hardhat for early testing, ensuring the protocol's foundation was strong.

The protocol first handled defining vault compositions and managing deposits, then progressed to minting tokens in proportion to each user's contribution once a vault was fully funded. To enhance reliability and security, I integrated vetted libraries like Thirdweb's TokenBundle and TokenStore.

Token Minting Formula

Token Minting Formula

Total Tokens Formula

Total Tokens Formula

As XTF evolved, I introduced multi-chain functionality, adding mock contracts for the LinkToken interface and the CCIP router, and incorporated a VRFCoordinator mock for the NFT Vote lottery feature. A comprehensive suite of tests was crucial for validating the protocol and refining its versions.

Vault State Machine

Vault States Diagram

Deposit & Notify Flow

Deposit and Notify Flow Diagram

Redeem Message Flow

Redeem Message Flow Diagram

Frontend Stack

For the user interface, I chose Next.js, React, and ThirdWebUI, incorporating graphical elements using libraries like Chart.js and ApexCharts.js. The data on the website, mainly sourced directly from the blockchain through QuickNode providers, includes bundle states, compositions, and asset allocations, with some data for index price comparisons sourced from the Young Platform API.

The final stage was deploying the project on Vercel for judges' review. However, I've kept broader public access limited for now, prioritizing stability and user experience, especially since the performance under multiple user access scenarios is yet to be fully tested.

Key Commands

npm run test- Run all Hardhat tests to check the XTF protocol
npm run checksize- Check the size of the contracts
npm run init- Run local testchain, build contracts, and deploy

⚡ Challenges We Ran Into

1. Mock Contract Development

One major obstacle was the absence of mock contracts for certain Chainlink components, requiring me to deepen my understanding of these elements and create custom mocks from scratch.

2. Smart Contract Size Constraints

Another significant challenge was adhering to the MAXIMUM_BYTECODE_SIZE limit set by the 'Spurious Dragon' hard fork. This limitation demanded continuous optimization and refactoring of our smart contracts. To manage the contract size effectively, I crafted a script that checked the size after each change, guiding my adjustments. Eventually, I divided the contract into three parts — a base contract, a types contract, and a third segment — to meet size constraints.

Contract Size Monitoring
Contract Size Check Output

3. Multi-Chain UX Complexity

From a backend development perspective, crafting a user interface that supported seamless network switching across multiple chains was a complex task. The standard wallet connection model, which typically limits users to a single chain, posed a significant challenge in creating a unified and flexible user experience.

4. Video Production Under Time Constraints

Lastly, producing a comprehensive video to explain the XTF protocol and demonstrate the web app within a five-minute timeframe proved to be a demanding task.

🏆 Accomplishments We're Proud Of

One of our project's major accomplishment was transforming the XTF protocol from a conceptual design to a fully operational set of smart contracts. This journey from initial sketches on paper to working code was both challenging and rewarding. It involved not only developing and testing a proof of concept using Hardhat but also swiftly building and launching a comprehensive website into a live environment, all within a matter of weeks.

"Establishing a strong foundation for the protocol was crucial. It provided the flexibility needed for continuous improvements, allowing me to effortlessly integrate new features and make adjustments as required during the shift from testing to production."

Adapting and refining the system to meet the demands of real-world applications proved to be one of the most exhilarating parts of this hackathon.

(Yes, I have spilled coffee on my notes multiple times)

The Evidence

Coffee-stained development notes
🔗
3 Chainlink Services

CCIP, Data Feeds, VRF

⛓️
Multi-Chain Protocol

Seamless cross-chain operations

Full Test Suite

Comprehensive protocol validation

Comprehensive Test Suite Results

Test Suite Results

XTF in the News

XTF News Coverage