GithubHelp home page GithubHelp logo

brolloks / cardano-dex-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from teddy-swap/cardano-dex-backend

0.0 0.0 0.0 3.71 MB

TeddySwap Official Badger ๐Ÿฆก

Haskell 74.97% Nix 14.72% Dockerfile 1.69% Dhall 8.62%

cardano-dex-backend's Introduction

TeddySwap Badger

Running the ๐Ÿงธ TeddySwap Badger ๐Ÿฏ ๐Ÿฆก

This section describes how to run a TeddySwap Badger (transaction batcher) in the Cardano Preview Testnet.

Prerequisites

Badger Wallet

First, you will need a cardano-cli generated private key text envelope. If you already have one please skip this step.

You can also generate a private key text envelope derived from a BIP39 mnemonic seed using cardano-addresses but it will not be convered in this document. Please see https://github.com/input-output-hk/cardano-addresses for more information.

cardano-cli address key-gen \
--verification-key-file payment.vkey \
--signing-key-file payment.skey

Generate a Cardano wallet address:

cardano-cli address build \
--payment-verification-key-file payment.vkey \
--out-file payment.addr \
--testnet-magic 2

Please make sure your wallet address contains some amount of ADA in it to process transactions, 100 ADA should do!

Next is to move everything into one directory, for example:

badger-volume
โ”œโ”€โ”€ payment.addr
โ”œโ”€โ”€ payment.skey
โ””โ”€โ”€ payment.vkey

Once that is set, run the wallet secret/cypher generator via docker

docker run -v ${PATH_TO_BADGER_VOLUME}:/testWallet spectrumlabs/spectrum-wallet-helper:0.0.1.0 /testWallet/secret.json /testWallet/payment.skey YOUR_PASSWORD

Where $(pwd) points to the directory of your badger-volume or the directory that contains the cardano-cli keys.

If succesful you should see a new file has been created secret.json.

Your badger-volume directory should now look like this:

badger-volume/
โ”œโ”€โ”€ payment.addr
โ”œโ”€โ”€ payment.skey
โ”œโ”€โ”€ payment.vkey
โ””โ”€โ”€ secret.json

Now we are ready to run the Badger ๐Ÿฆก, Let's go!

Running the Badger

We create a Badger config file named config.dhall inside the badger-volume directory:

Testnet Config

let FeePolicy = < Strict | Balance >
let CollateralPolicy = < Ignore | Cover >
let Network = < Mainnet | Preview >

let LogLevel = < Info | Error | Warn | Debug >
let format = "$time - $loggername - $prio - $msg" : Text
let fileHandlers = \(path : Text) -> \(level : LogLevel) -> {_1 = path, _2 = level, _3 = format}
let levelOverride = \(component : Text) -> \(level : LogLevel) -> {_1 = component, _2 = level}
in
{ mainnetMode = False
, nodeSocketConfig =
    { nodeSocketPath = "/ipc/node.socket"
    , maxInFlight    = 256
    }
, eventSourceConfig =
    { startAt =
        { slot = 32045163
        , hash = "825568a8f7272fa8662c5a1fee156fe5dfb932ae8a47c8526b737399c9b3e836"
        }
    }
, networkConfig =
    { cardanoNetworkId = 2
    }
, ledgerStoreConfig =
    { storePath       = "/data/amm-executor"
    , createIfMissing = True
    }
, nodeConfigPath = "/config/cardano/preview/config.json"
, pstoreConfig =
    { storePath       = "/data/psStore"
    , createIfMissing = True
    }
, backlogConfig =
    { orderLifetime        = 4500
    , orderExecTime        = 1500
    , suspendedPropability = 0
    }
, backlogStoreConfig =
    { storePath       = "/data/backlogStore"
    , createIfMissing = True
    }
, utxoStoreConfig =
    { utxoStorePath   = "/data/utxoStore"
    , createIfMissing = True
    }
, txsInsRefs =
    { swapRef = "81bdfd89f3c8ff1a23dbe70af2db399ad0ed028b36a41974662a2cf8cda3c7c3#0"
    , depositRef = "77186dc10826227acd5e4a48e636bd3b11d5f39cc051d794540a7125903e157c#0"
    , redeemRef = "2266866d4d85cd582a34d27638a6eeb885cc4fb96fee230c86720e1f3f9eb0a0#0"
    , poolV1Ref = "64747d26baba95016a42c078360a431bb74d603f3f2582eb1b77d5dcfd53f128#0"
    , poolV2Ref = "64747d26baba95016a42c078360a431bb74d603f3f2582eb1b77d5dcfd53f128#0"
    }
, scriptsConfig =
    { swapScriptPath    = "/scripts/swap.uplc"
    , depositScriptPath = "/scripts/deposit.uplc"
    , redeemScriptPath  = "/scripts/redeem.uplc"
    , poolV1ScriptPath  = "/scripts/pool.uplc"
    , poolV2ScriptPath  = "/scripts/pool.uplc"
    }
, explorerConfig =
    { explorerUri = "https://80-faithful-argument-jp00vi.us1.demeter.run"
    , network = Network.Preview
    }
, txAssemblyConfig =
    { feePolicy         = FeePolicy.Strict
    , collateralPolicy  = CollateralPolicy.Cover
    , deafultChangeAddr = "<your cardano wallet address>"
    }
, secrets =
    { secretFile = "/keys/secret.json"
    , keyPass    = "<your key password>"
    }
, loggingConfig =
    { rootLogLevel   = LogLevel.Debug
    , fileHandlers   = [fileHandlers "/dev/stdout" LogLevel.Debug]
    , levelOverrides = [] : List { _1 : Text, _2 : LogLevel }
    }
, unsafeEval =
    { unsafeTxFee = +320000
    , exUnits = 165000000
    , exMem = 530000
    }
}

Mainnet Config

let FeePolicy = < Strict | Balance >
let CollateralPolicy = < Ignore | Cover >
let Network = < Mainnet | Preview >

let LogLevel = < Info | Error | Warn | Debug >
let format = "$time - $loggername - $prio - $msg" : Text
let fileHandlers = \(path : Text) -> \(level : LogLevel) -> {_1 = path, _2 = level, _3 = format}
let levelOverride = \(component : Text) -> \(level : LogLevel) -> {_1 = component, _2 = level}
in
{ mainnetMode = True
, nodeSocketConfig =
    { nodeSocketPath = "/ipc/node.socket"
    , maxInFlight    = 256
    }
, eventSourceConfig =
    { startAt =
        { slot = 109076993
        , hash = "328bac757d1b100c68e0fd8f346a1bd53ee415b94271b8b7353866a22063f7bf"
        }
    }
, networkConfig =
    { cardanoNetworkId = 2
    }
, ledgerStoreConfig =
    { storePath       = "/data/amm-executor"
    , createIfMissing = True
    }
, nodeConfigPath = "/config/cardano/preview/config.json"
, pstoreConfig =
    { storePath       = "/data/psStore"
    , createIfMissing = True
    }
, backlogConfig =
    { orderLifetime        = 4500
    , orderExecTime        = 1500
    , suspendedPropability = 0
    }
, backlogStoreConfig =
    { storePath       = "/data/backlogStore"
    , createIfMissing = True
    }
, utxoStoreConfig =
    { utxoStorePath   = "/data/utxoStore"
    , createIfMissing = True
    }
, txsInsRefs =
    { swapRef = "fb6906c2bc39777086036f9c46c297e9d8a41ede154b398d85245a2549b4bf04#0"
    , depositRef = "570f810fe5f8cef730587fb832bb70d8783bad711064d70fc1a378cbefdd7c94#0"
    , redeemRef = "e33584ade2b47fb0ab697b63585fb4be935852131643981ba95acde09fe31f41#0"
    , poolV1Ref = "cdafc4e33524e767c4d0ffde094d56fa42105dcfc9b62857974f86fd0e443c32#0"
    , poolV2Ref = "cdafc4e33524e767c4d0ffde094d56fa42105dcfc9b62857974f86fd0e443c32#0"
    }
, scriptsConfig =
    { swapScriptPath    = "/scripts/swap.uplc"
    , depositScriptPath = "/scripts/deposit.uplc"
    , redeemScriptPath  = "/scripts/redeem.uplc"
    , poolV1ScriptPath  = "/scripts/pool.uplc"
    , poolV2ScriptPath  = "/scripts/pool.uplc"
    }
, explorerConfig =
    { explorerUri = "https://explorer.teddyswap.org"
    , network = Network.Mainnet
    }
, txAssemblyConfig =
    { feePolicy         = FeePolicy.Strict
    , collateralPolicy  = CollateralPolicy.Cover
    , deafultChangeAddr = "<your cardano wallet address>"
    }
, secrets =
    { secretFile = "/keys/secret.json"
    , keyPass    = "<your key password>"
    }
, loggingConfig =
    { rootLogLevel   = LogLevel.Debug
    , fileHandlers   = [fileHandlers "/dev/stdout" LogLevel.Debug]
    , levelOverrides = [] : List { _1 : Text, _2 : LogLevel }
    }
, unsafeEval =
    { unsafeTxFee = +320000
    , exUnits = 165000000
    , exMem = 530000
    }
}

Change <your cardano wallet address> to your newly generated cardano wallet address:

, txAssemblyConfig =
    { feePolicy         = FeePolicy.Balance
    , collateralPolicy  = CollateralPolicy.Cover
    , deafultChangeAddr = "<your cardano wallet address>"
    }

Make sure you updated keyPass to your secret.json keypass.

, secrets =
    { secretFile = "/keys/secret.json"
    , keyPass    = "<your key password>"
    }

Your badger-volume directory should now look like this:

badger-volume/
โ”œโ”€โ”€ config.dhall
โ”œโ”€โ”€ payment.addr
โ”œโ”€โ”€ payment.skey
โ”œโ”€โ”€ payment.vkey
โ””โ”€โ”€ secret.json

Now we can start the badger with the following code:

Make sure your cardano-node is running, connected to Preview testnet and fully-synced!

Replace /absolute/path/to/cardano.socket to the path of your cardano-node socket file

docker run -d --restart --name teddyswap-dex-backend \
  -v $(pwd)/config.dhall:/config/batcher.dhall \
  -v /absolute/path/to/cardano.socket:/ipc/cardano.socket \
  -v $(pwd)/keys/secret.json:/keys/secret.json \
  -e CONFIG_PATH=/config/batcher.dhall \
  --restart on-failure \
  clarkteddyswap/teddy-badger:6c8a8c7b589c2817dae53a08dc4d3413f4d24ff4

Where $(pwd) points to the directory of your badger-volume.

if succesful, You can then check the logs using the container id:

docker logs -f --tail 10 teddyswap-dex-backend

Congratulations ๐ŸŽŠ, your TeddySwap Badger ๐Ÿฆก should now be running and will pick up order transactions soon, rewards will be sent to your defined cardano wallet address!

Running with docker-compose

Please see DOCKER_COMPOSE.md

cardano-dex-backend's People

Contributors

bromel777 avatar gusevtimofey avatar mercurial avatar oskin1 avatar yasha-black 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.