Git Product home page Git Product logo

locker-poc's Introduction

Locker

Locker is a consumer DeFi framework for automatically saving a small amount of tokens as users perform their normal on-chain activity. In other words, Locker is an on-chain equivalent of Acorns and other round-up savings tools.

ETH Denver 2024 presentation

Architecture

Terminology

  • Consumer dApp: dApp UI that the end user wants to interact with. This might be uniswap.com, the Metamask interface for transferring ERC20, or any other UI that talks to the blockchain.
  • Savings Contract: The on-chain contract that all the user's transactions passes through.
  • Target Contract: The on-chain component of the Consumer dApp.
  • Unlock Date: The user defined date after which savings can be withdrawn.

User flow

  1. Alice sets up a Savings Contract and defines how much she wants to put in to savings for every transaction and what the Lockup Period will be.
  2. Alice wants to do a swap on the Target Contract, 1inch, for 100 USDC to ETH
  3. Locker intercepts Alice's transaction and asks for a small amount of additional token before Alice signs the transaction.
  4. The transaction is sent to the Savings Contract which deposits the extra amount into savings.
  5. The Savings Contract forwards the swap request to the Target Contract (1inch) which processes the transaction normally.
  6. After the Unlock Date, Alice can withdraw all her savings.

Diagram

This code currently implements v1 in the diagram below. In the future, we plan on streamlining by integrating with Metamask snaps and 4337 account abstraction.

Locker design

Getting started

1. Deploy contracts

$ cd backend
$ forge build
$ HODL_DEPLOY_KEY='XXX'

# Deploy Savings Contract
$ forge create src/Factory.sol:Factory \
    --private-key $HODL_DEPLOY_KEY \
    --rpc-url https://example.com

# Deploy sample Target Contract
$ forge create src/Counter.sol:Counter \
    --private-key $HODL_DEPLOY_KEY \
    --rpc-url https://example.com

2. Run sample dApp

$ cd interface
$ yarn
$ yarn dev

Deployed Savings Contracts

Network Environment Address
Base Mainnet 0xf312F04DF2885Ec7C44cde77bAC8BB8B1FB4Aa20
Inco Testnet 0xF6c8EED3bE03a482Fe5d43c4EFC330d14dB7cfA4
Fhenix Testnet 0xF6c8EED3bE03a482Fe5d43c4EFC330d14dB7cfA4
Arbitrum Testnet 0xF6c8EED3bE03a482Fe5d43c4EFC330d14dB7cfA4
Linea Mainnet 0xF6c8EED3bE03a482Fe5d43c4EFC330d14dB7cfA4
XDC Testnet 0xF6c8EED3bE03a482Fe5d43c4EFC330d14dB7cfA4
Injective Testnet 0xa52b8D81C2A8673C704a35557E6a8B8791fC3506

Deployed Target Contracts

Network Environment Address
Base Mainnet 0x94789011AcF3c7411d1db9Abe8337f4BA7589D9f
Inco Testnet 0xf312F04DF2885Ec7C44cde77bAC8BB8B1FB4Aa20
Fhenix Testnet 0x94789011AcF3c7411d1db9Abe8337f4BA7589D9f
Arbitrum Testnet 0xf312F04DF2885Ec7C44cde77bAC8BB8B1FB4Aa20
Linea Mainnet 0xf312F04DF2885Ec7C44cde77bAC8BB8B1FB4Aa20
XDC Testnet 0x94789011AcF3c7411d1db9Abe8337f4BA7589D9f
Injective Testnet 0x144E52b74F837F5529b0c41e900BB5c61d30afb4

locker-poc's People

Contributors

0xernesto avatar marvinmarnold avatar cucupac avatar rahul0eth avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.