Giter Club home page Giter Club logo

bitsave_zeta's Introduction

Documentation

Bitsave solves it's problems with zeta chain using

  1. Interoperability of zetachain
    • Cross chain saving features (1 contract, several chains supported)
    • Safety with savings - cross chain swap. Converts savings to stable coin with the cross chain swap.
  2. Security With the minimal surface for attacks, savings are kept protected since they mostly are staying at a spot

Constants

  • bitsaveAddress => 0x6e299956270c355aAe829c2aaB435b2e81E5B5f6
  • paymentTokenAddress => 0x91d18e54DAf4F677cB28167158d6dd21F6aB3921
  • parsedJoiningFee => parseUnits("100")

Project interface

All interaction with the contract passes through the onCrossChainCall method. After gaining the Contract object using whatever tool e.g. ethersjs, You can name the Contract object as Bitsave, format example with ethersjs.

new ethers.Contract(
    bitsaveAddress,
    BitsaveABI,
    signer // from the user's wallet
)

You also create the Payment Token Contract object, can name as PaymentToken. You also create the User Child Contract object, can name as UserChildContract.

All ABIs have been provided already, sources include

  1. BitsaveABI => hardhat_contract/artifacts/contracts/Bitsave.sol/Bitsave.json
  2. UserChildContractABI => hardhat_contract/artifacts/contracts/userContract.bitsave.sol/UserContract.json
  3. PaymentContractABI => hardhat_contract/artifacts/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/IZRC20.json

Each integration proceeds as follows:

  • Join Bitsave

  1. Approve joining fee:
    PaymentToken.approve(bitsaveAddress, parsedJoiningFee)
  2. Call onCrossChainCall on Bitsave Bitsave.onCrossChainCall(...arguments)
  3. Pass the following arguments
    • paymentTokenAddress
    • parsedJoiningFee
    • joinParameters(): (This function has been provided already) encodeParams("JON", 0, 0, 0, false) // this is data returned from it
  4. You can always retrieve the user's child address from userChildContractAddress = Bitsave.getUserChildContractAddress()
  5. From this child address, the userChildContract can be created using same approach for the Bitsave Object
  • Create Savings

  1. Approve saving amount Implementation in 'Join Bitsave'
  2. Call onCrossChain on Bitsave
  3. Pass the following arguments
    • paymentTokenAddress
    • parsed form of savingsAmount eg: parseUnits(savingsAmount.toString())
    • getSavingsParams(...arguments): (function provided already)
    • arguments are:
      1. nameOfSaving,
      2. endTime: timestamp / 1000 // remove decimal,
      3. startTime: type of endTime
      4. penaltyPercentage: penaltyPercentage eg 1 or 2...
      5. isSavingInSafeMode: boolean
  4. You can always retrieve a particular savings data from UserChildContract.getSavings(nameOfSaving)
  • Increment Savings

  1. Approve saving amount Implementation in 'Join Bitsave'
  2. Call onCrossChain on Bitsave
  3. Pass the following arguments
    • paymentTokenAddress
    • parsed form of savingsAmount eg: parseUnits(savingsAmount.toString())
    • getSavingsParams(...arguments): (function provided already)
    • arguments are:
      1. nameOfSaving,
  • Withdraw Savings

  1. Call onCrossChainCall on Bitsave
  2. Pass the following arguments
    • paymentTokenAddress
    • 0
    • getWithdrawParams(...arguments): (function provided already)
    • arguments are:
      1. nameOfSaving
  • Get all user's savings

    UserChildContract.getSavingsNames()

Project Development:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js

bitsave_zeta's People

Contributors

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