[Draft][OBRA] Safing intelligently - Build Credio Module to extend Safe’s automated decision making with AI/Machine Learning
1. Abstract:
Untangled Vault is built on Safe and Tokenized Vault standards (ERC 4626). It is designed for non-custodial asset management use cases where LP’s ownership in assets in the Safe is represented by a vault share.
Credio is a risk oracle protocol linking machine learning model outputs directly to smart contracts in an automated, decentralized privacy preserving manner.
Untangled Finance has developed both Vault (including some of the tools such as Untangled Vault CLI and Credio. Our team has also built machine learning models to predict debt default and stablecoin depegging probabilities.
We propose to build a Credio Safe Module to extend Safe’s automated decision making, transforming it into a dynamic, intelligent system where it can adapt and learn and be more responsive and intuitive for users. We request a budget of USDC 49,500 to cover the following:
- Build a module to integrate Credio to Safe
- Simulate an end-to-end proof of concept where Safe makes automated decisions with the power of a machine learning model
- Build/curate a bot to actualise the decisions
- Publish a whitepaper on the result and future work
The immediate use cases we are working on are automated risk management, portfolio rebalancing to treasury management. Automated, real-time decisions are also more efficient in highly volatile crypto market conditions.
- Real-time risk management: given price trajectories, certain positions in lending protocol become underwater, creating opportunities for a bot to trigger Safe transactions to adjust risk parameters in real-time
- Restaking slashing risk prediction and protection: a model to predict slashing risks in a re-staking protocol which triggers an automated portfolio rebalancing (stakes with different validators)
Credio could also facilitate modeling competitions involving a global community of data scientists. By integrating Credio, Safe’s decision making is not only automated but can further be decentralized.
We are excited to work with Safe community on this initiative. At Untangled Finance we have used Safe/Gnosis at both work and personal level (Some of our members have Gnosis debit card). We have met with some contributors in the Greenfield event in May but generally not been in touch with many of you in the community. We would welcome any DM or forum questions to elaborate on our proposal.
2. Aligned strategy
This proposal is straddling between Strategies 3, 4 and 5. It is most aligned with
[Strategy 3] Increase awareness of Safe Ecosystem
3. Funding request
USDC 49.5k
5. If applicable, upfront funding
N/A
6. Relation to budget
71% of Total Budget, 100% Remaining Budget of Strategy 3
7. Metrics and KPIs
-
Credio Safe module: This module will focus on validating zero-knowledge proof associated with a model inference before passing on the bot’s proposed actions to the Safe for execution.
-
Open-sourced bot: build or curate a simple bot to automate safe transactions involving a lending protocol or a restaking protocol
-
End-to-end simulation: Using our simulation engine (agent-based) we will simulate how a model’s outputs drive a bot and the Safe module to automatically execute Safe transactions
-
Whitepaper: Publish a whitepaper with technical details on the simulation and suggestions for future work
8. Initiative description
Workflow
Example: A lending protocol’s real-time risk parameter updates or liquidation triggers
-
Model building: A model predicting positions in a lending protocols are eligible for liquidation under different price trajectories
-
Model selection: As mentioned above, a model can be built by a centralised team or through a modeling competition involving a decentralized community of data scientists. Credio can facilitate both of these scenario
-
Deployment: Once the model is selected it will be deployed to production together with a verification file using ezkl library
-
Oracle Data Update: A real-time data pipeline is fed to the model which in turn drives the model outputs (inferences). The outputs are updated to a custom oracle adapter contract
-
Bot Action:
- The bot (e.g., liquidator-js) monitors the Oracle adapter contracts and identifies a position at risk
- Prepares a transaction to withdraw funds or liquidate the position.
- Credio Safe Module Validation:
- The bot submits the transaction to the Credio Safe Module.
- The module verifies the transaction against Oracle data (e.g., risk score > threshold) and zero-knowledge proof
- Safe Execution:
- The module forwards the validated transaction to the Safe wallet.
- The Safe wallet executes the transaction, ensuring role and permission policies are followed.
9. Current status:
We have built the Untangled Vault with the following components (some common features with both Gnosis Guild and Lagoon proposals)
-
Vault core: Safe and ERC 4626 → minimal smart contract risk
-
Modules
-
Asynchronous withdrawal following ERC7540
-
Cross-chain deposit: Vault able to attract deposit from multichain
-
KYC’ed for RWA use cases
-
Valuation: Position tracking, TVL and NAV calculation
-
-
CLI tool for user-friendly role and permission generation
Credio core
- A contract that feeds machine learning model inferences to directly to smart contracts in an automated, privacy-preserving manner
Status: Done Credio Core
Oracle adapter
- Publishes machine learning inferences (e.g., risk scores, portfolio weights) on-chain.
- Acts as the single source of truth for bots and the module.
Status: Oracle adapter contract has been built but needs to be adapted for this simulation.
Bots:
- Handle monitoring, decision-making, and transaction preparation off-chain.
- Interact with the Credio Safe Module to propose and execute transactions.
Status: Bots have not been built but we could use pre-built libraries like liquidator-js for tasks such as liquidation, trading, and rebalancing.
Credio Safe Module
-
A lightweight module that enforces basic rules and validates transaction proposals from bots.
-
Relies on Credio Oracle Adapter data to verify transaction legitimacy.
-
Executes transactions on the Safe wallet.
Status: To be built
CLI tool:
- User-friendly way to set role and permission using Safe protocol kit and Zodiac role module sdk
Status: Built Untangled Vault CLI
Simulation engine
A pyEVM environment that can replicate real blockchain state in order to simulate Safe execution which is triggered by machine learning model via Credio
Status: under development
9. Risks
Functionality risk - not meeting use case requirements. In order to mitigate against this risk we will run the initiative as a simulation under a real EVM environment. This allows us full control of parameter settings to ensure the end-to-end flow works and address use case requirements
Smart contract risk - security vulnerability with any smart contract system. We mitigate this risk by architecting Vault Core to be just Safe + ERC4626 and remove all custom codes to extensible modules. Our architecture is modular and therefore very similar to Safe (Core + modules). The Vault is subject to audit before deployment.
Incorrect operation: In addition to simulation, we will also provide recommendations for bounds for automated decision making initially leaving certain decisions to be made by multisigs. The CLI is to ensure that role and permissions are to be set easily and correctly.
10. Timeline and milestones
Component | Status | Timeline | Key milestones |
---|---|---|---|
Vault incorporating Safe | Done | ||
Model building and selection | Need to build model for this simulation | 4 weeks | Model output dashboard |
Credio Core | Done | ||
Oracle adapter contract | Need to build adapter for this use case | 1 week | Deployed contract |
Bot | Build/Curate bots | 1 week | Open sourced code |
Credio safe module | Build module | 4 weeks | Open source code |
CLI | Done | 1 week | Role and permission contract |
Simulation environment | Being built | 4 weeks | Simulation results |
Whitepaper | 1 week | Published report |
Total: 12-16 weeks for a team of part time and full time members (2-3 FTEs) for 2-3 months
11. Initiative lead
Both Vault and Credio products of Untangled Finance, a credit investment infrastructure builder and manager based in London. Untangled Finance is backed by Fasanara Capital https://www.fasanara.com, an institutional asset manager managing $4.5bn in private credits originated by 140 fintechs in over 60 countries.
Untangled also developed Pool which is a tokenized private credits funding platform that was launched earlier this year on Celo blockchain.
Untangled Finance will deploy vault strategies focusing on bridging institutional investors to DeFi yields and DeFi investors to RWAs. We look to list our vault strategies on Safe Marketplace when it is completed.
12. Team
Manrui Tang, Cofounder (Linkedin). TradFi expert but built in blockchain space since 2017. Ex Big 4. Degrees from Imperial College and LSE London. Responsible for partnership and bizdev
Quan Le: Cofounder (Linkedin) TradFi expert but built in blockchain space since 2017. Ex Big 4. Degrees in applied finance and investment. Responsible for architecture and product.
Tan Phan: (Linkedin) Core developer of modules; ensure the whole system works. CS graduate from Hanoi University of Science and Technology
Duong: Linkedin Core developer of Credio contract and simulation engine. Applied math graduate from Hanoi University of Science and Technology
Tuan: Core developer of pyEVM environment. Applied math graduate from Hanoi University of Science and Technology
In Feb 2024, Minh (developer of Untangled Pool, auditor of Untangled Vault) and Duong won an Ethereum Vietnam buidlathon and received the prize from Vitalik Buterin
In June 2023, Tan, Duong won Chainlink hackathon for privacy-preserving voting in a DAO
13. Additional support/resources
-
Integrate Credio Safe Module into Zodiac Suite.
-
Integrate Untangled Vault (with Credio) to Safe App and Safe Marketplace: Untangled Finance will deploy vault strategies focusing on bridging institutional investors to DeFi yields and DeFi investors to RWAs. We look to list our vault strategies on Safe Marketplace when it is completed.
14. Implementation dependencies
N/A