Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: ETH Fidelity Bonds #2223

Closed
wants to merge 5 commits into from
Closed

multi: ETH Fidelity Bonds #2223

wants to merge 5 commits into from

Commits on Apr 7, 2023

  1. Add ETHBondV0.sol contract

    This adds a solidity contract for managing ETH fidelity bonds. In addition
    to the usual functionalities of creating and refunding bonds, it also
    allows using funds locked in existing bonds to create a new bond. If
    a bond with more funds than the existing bonds is being created, the user
    has to send additional funds, and if a bond is being created with less
    funds than the existing bonds, a "change" bond is also created with the
    remainder that maintains the earliest lockTime of the existing bonds. This
    process will only allow the user to lock funds for a longer period than
    they were previously locked for, never less.
    
    A Hardhat project is also created for this contract to allow easy testing
    of the smart contract logic. To run the tests, go to the
    `dex/networks/eth/bondcontracts/v0` folder and run the following:
    `npm install`
    `npx hardhat test`
    martonp committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    be77d13 View commit details
    Browse the repository at this point in the history
  2. client/asset/eth: Add BondUpdater interface and implement it in ETH C…

    …lient
    
    Adds a BondUpdater interface which contains a single method, `UpdateBondsTx`.
    Similar to MakeBondTx, this generates an unsigned transaction, but
    instead of creating a new bond from scratch, it uses the funds locked
    in existing bonds to create a new bond.
    
    For ETH, it is not possible to create a signed transaction that will
    be submitted later because if the nonce is used before the transaction
    is submitted, the transaction will no longer be valid. Therefore, for ETH,
    the SignedTx and UnsignedTx in the `asset.Bond` returned from `MakeBondTx`
    and `UpdateBondsTx` contain the same data. The ETH wallet backend populates
    the nonce and signs the transaction on the call to `SendTransaction`.
    martonp committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    e5a2b2e View commit details
    Browse the repository at this point in the history
  3. client/core: Support wallets that implement 'BondUpdater`

    This updates the client to support wallets that implement `BondUpdater`.
    In `rotateBonds`, if an account is set to maintain a certain tier, and it
    already has some weak or expired bonds posted in an asset that supports
    updating bonds, it will use the funds in those bonds to create a new bond
    with a sufficiently long lockTime.
    martonp committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    abdbeb6 View commit details
    Browse the repository at this point in the history
  4. server/asset/eth: Add BondUpdater interface and implement in ETH

    This adds a BondUpdater interface in the server that requires a backend
    to implement an `AllAccountBonds` method. in addition to the Bonder
    interface's methods. This method returns all the currenlty active bonds
    for an account. This new interface is implemented by the ETH backend. This
    is required for assets where it is possible to use existing unexpired
    bonds to fund new bonds, because the server needs to know if bonds that it
    was previously using the calculates a user's tier no longer exist.
    martonp committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    656891d View commit details
    Browse the repository at this point in the history
  5. server/{auth,db}: Update server to support BondUpdaters

    When a new bond is posted for an asset that implements `BondUpdater`,
    all of the currently active bonds for that asset are retrieved from
    the blockchain, and the the bonds for this asset that were stored in
    the database and the `AuthManager` are replaced by what was retreived.
    martonp committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    8823d50 View commit details
    Browse the repository at this point in the history