[Discussion][OBRA] Safing intelligently - Build Credio Module to extend Safe’s automated decision making with AI

[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

:drum:[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

  1. Model building: A model predicting positions in a lending protocols are eligible for liquidation under different price trajectories

  2. 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

  3. Deployment: Once the model is selected it will be deployed to production together with a verification file using ezkl library

  4. 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

  5. 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.
  1. 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
  1. 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

2 Likes

Hey @muntangled, thank you for the interesting proposal! I’m not sure if the initiative proposed fits into Strategy 3 at all. If you look at the metrics for Strategy 3, you’ll understand my confusion:

Secondly, since the tool primarily facilitates treasury-related decision-making, it seems more appropriate for this proposal to go through something like the Treasury Management Steering Committee, allowing the DAO to first identify its treasury diversification priorities, enabling it to fund supporting initiatives more effectively.

Thanks @amanwithwings for your comment.

  1. Our first read of the Strategies, [Strategy 2] Foster module ecosystem or [Strategy 4] Research decentralization of Safe tech stack or Wildcard seem relevant. We, however, chose Strategy 3 because:
  • There is available budget
  • One of the recent initiatives Lagoon on DeFi Kit Enhancement passed with strategy 3. This initiative shares some common features with Lagoon or Gnosis Guild
  • the proposed initiative is meant to increase the use of Safe with AI/machine learning models so could help increase awareness.
  1. Your suggestion re Treasury Management Steering Committee - perhaps we should have made it clearer in our proposal:
  • the proposed Credio Safe Module is a generic module focusing validating proposed actions from bots against zero knowledge proof - It does not contain any business logics such as treasury management

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.
  • Untangled Finance, as an user of the initiative, might be focusing on automated risk management and portfolio rebalancing but other users could use it for something completely different such as optimising DEX trade routes or any use cases that can be automated by ML/AI models

  • The Treasury Committee you referred to, may deal with Safe DAO treasury whereas the use case we are working on (as user of the initiative) is not specific to any DAOs

Hope the above is helpful and look forward to further comments.

1 Like

This example of combining AI with Safe is a little underperforming.

@Elizabeth thanks for your comments - performance (over/under) is up to the machine learning model - the Credio Safe Module here is a conduit/oracle between models and Safe. Increasingly ML models are being used to automate execution such as real-time risk management in Aave’s recent vote of approval of protocol parameter adjustment

@amanwithwings please let us know if this proposal could move to Phase 1: Draft - and the timing for the next cycle?

Hey @muntangled, now that SEP 49 has passed, OBRA in its current form has been sunsetted. Please wait for the next iteration to go live before applying through it. Thank you!

1 Like