Open source
The contract behind every deal
Every GonkaWeightSwap deal is settled by this escrow contract, running entirely on the Gonka network. Read it, copy it, and verify it on your own machine.
At a glance
- Name
- gonka-weight-swap
- Version
- 0.1.0-draft
- Framework
- CosmWasm 2.x (Rust)
- Files
- 6
What the contract guarantees
- Payout per epoch = verified weight × budget ÷ target weight. The rate never changes after creation.
- Total paid to the host can never exceed the budget; delivered weight is capped at the target.
- Weight is read only from Gonka's own chain modules — no oracles or external services.
- The host's node is configured with the investor's address, so the protocol credits weight and GNK rewards there; the contract never holds them.
- An epoch is settled only after the protocol has finalized its weight and rewards.
- Each epoch can be settled only once, and only after it has finished.
- Only the investor can cancel, and only before a host accepts.
- An epoch counts only if weight ≥ the minimum; smaller amounts are neither counted nor paid.
- Collateral is forfeited only if no qualifying epoch happens within the start window. After that, stopping for downtime returns it to the host.
How a deal works
- Step 1 · InvestorCreate
Instantiates the contract with the deal terms and deposits the full USDT budget into escrow.
- Step 2 · HostAccept
Locks the fixed GNK collateral, sets a USDT payout address and points its node at the investor's address. The deal starts at the next epoch.
- Step 3 · Anyone (usually the host)Settle epoch
Once an epoch's results are finalized, anyone can trigger settlement. The contract reads the weight credited to the investor's address and pays USDT at the fixed rate. The host has the incentive to call it, since that's how it gets paid.
- Step 4 · ContractFinish
Target reached, term ended or downtime limit hit: unspent USDT goes back to the investor and collateral returns to the host. Only if the host never delivers a qualifying epoch within the start window does the collateral go to the investor.
Source code
Package manifest and dependencies.
[package]
name = "gonka-weight-swap"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
cosmwasm-std = { version = "2.1", features = ["cosmwasm_2_0"] }
cosmwasm-schema = "2.1"
cw-storage-plus = "2.0"
cw-utils = "2.0"
schemars = "0.8"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
Verify it yourself
- Install Rust and the wasm target:
rustup target add wasm32-unknown-unknown - Create a folder and place each file at the path shown above.
- Run the tests:
cargo test - Build the contract:
cargo build --release --target wasm32-unknown-unknown - For a reproducible build, use the
cosmwasm/optimizerDocker image and compare checksums.
Still being finalized
- Confirm the exact CosmWasm query bindings Gonka exposes for current epoch and participant weight.
- Confirm how many epochs after an epoch ends its results are final (SETTLE_DELAY).
- One investor address should back only one active deal at a time, otherwise weight overlaps.
- Final collateral formula; whether a partial slash should apply during the start window.