goderive

package module
v0.23.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 0 Imported by: 0

README

go-derive



CI Lint CodeQL OSV-Scanner gosec Semgrep Trivy Gitleaks TruffleHog

codecov Codacy Badge Codacy coverage Go Report Card

OpenSSF Best Practices OpenSSF Scorecard SLSA 3 Cosign signed SBOM Security Policy govulncheck

Go Reference Go Version Top Language

Release Commits since latest Conventional Commits release-please

Contributor Covenant Renovate enabled Dependabot enabled PRs Welcome Maintained Last commit GitHub stars

A Go SDK for the Derive exchange (formerly Lyra) — a layer-2 derivatives venue with perps, options, and spot.

Covers REST (public + private), WebSocket (public + private + subscriptions), and EIP-712 order signing with session keys.

Out of scope: on-chain operations (deposit, withdraw, session-key registration). Those require an EVM toolchain (e.g. go-ethereum) and aren't bundled here — this SDK is the JSON-RPC trading surface only. Once funds are deposited via the Derive UI or your own contract calls, every order / RFQ / quote / cancel flow runs through this SDK.

Status

v0.x — pre-1.0; the public API may still change. Track the current version via the Release badge above. Breaking changes between 0.x versions follow Conventional Commits' feat!: discipline and are listed under "BREAKING CHANGES" in CHANGELOG.md. For migration prose with before/after snippets, see MIGRATING.md.

Versioning

This project follows Semantic Versioning. Releases are computed from Conventional Commits by release-please; the type→bump mapping lives in docs/release-process.md.

Install

go get github.com/amiwrpremium/go-derive

Requires Go 1.25+.

Compatibility

Built and CI-tested against Go 1.25 and Go 1.26 on Linux, macOS and Windows. Tracks the Derive API as documented at docs.derive.xyz — see CHANGELOG.md for the API drift addressed in each release.

Quick start

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/amiwrpremium/go-derive/pkg/auth"
    "github.com/amiwrpremium/go-derive/pkg/derive"
    "github.com/amiwrpremium/go-derive/pkg/enums"
    "github.com/amiwrpremium/go-derive/pkg/types"
)

func main() {
    // NewLocalSigner takes a raw hex private key. For production setups,
    // see pkg/auth.NewSessionKeySigner — registers a hot session key
    // delegating from a long-lived owner address.
    signer, err := auth.NewLocalSigner(os.Getenv("DERIVE_PRIVATE_KEY"))
    if err != nil {
        log.Fatal(err)
    }

    c, err := derive.NewClient(
        derive.WithTestnet(), // start on testnet; switch to derive.WithMainnet() once integration is verified
        derive.WithSigner(signer),
        derive.WithSubaccount(123),
    )
    if err != nil {
        log.Fatal(err)
    }
    defer c.Close()

    ctx := context.Background()

    instruments, err := c.REST.GetInstruments(ctx, types.InstrumentsQuery{
        Currency: "BTC",
        Kind:     enums.InstrumentTypePerp,
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(len(instruments), "BTC perps")
}

See examples/ for more — and docs/getting-started.md for a step-by-step walkthrough.

Architecture

pkg/derive               top-level facade (REST + WS)
pkg/rest                 HTTP-backed JSON-RPC client
pkg/ws                   WebSocket-backed JSON-RPC + typed subscriptions
pkg/auth                 EIP-712 signing, session keys
pkg/types, pkg/enums     domain types, named-string enums
pkg/errors               sentinel errors + APIError

internal/jsonrpc         JSON-RPC 2.0 framing
internal/transport       HTTP + WS transports (shared interface)
internal/methods         RPC method definitions (shared by REST + WS)
internal/netconf         endpoints + EIP-712 domains per network
internal/codec           decimal/u256/address encoding
internal/retry           exponential backoff

The Derive API is JSON-RPC 2.0 over both HTTP and WebSocket — same method names, same params. The SDK reflects that: a single Transport interface backs both pkg/rest and pkg/ws, so each method is defined once.

Which package do I import?
  • pkg/derive — start here. The top-level facade bundles a REST client and a WS client sharing one signer and subaccount, which is what most callers want.
  • pkg/rest alone — when you only need HTTP RPCs (e.g. periodic history pulls from a non-trading process).
  • pkg/ws alone — when you only need streaming (e.g. a feed recorder that doesn't place orders).

Both pkg/rest and pkg/ws expose the full RPC method surface independently; the facade is a shortcut, not a feature gate.

See docs/architecture.md for the full design.

Documentation

The full doc set lives under docs/:

Topic
Concepts getting-started · architecture · transports · auth · subscriptions · numerics · error handling · rate limiting · reconnection
Process examples · testing · ci · release process · known tool issues
Security security index · repo policy · threat model

Continuous integration

Every push and pull request runs:

Check Tool Workflow
Format gofmt -l ci.yml
Vet go vet ci.yml
Build go build on Linux/macOS/Windows × Go 1.25/1.26 ci.yml
Tests go test -race -coverprofile ci.yml
Mod tidy go mod tidy diff check ci.yml
Vulnerabilities govulncheck ci.yml
Linters golangci-lint, staticcheck lint.yml
Extra linters markdownlint, yamllint, actionlint, editorconfig-checker, typos extra-lint.yml
Security (SAST) CodeQL, gosec, Semgrep (security-audit + golang + secrets), Codacy codeql.yml, gosec.yml, semgrep.yml, codacy.yml
Filesystem / IaC scan Trivy (filesystem + secret + config) trivy.yml
Secret scanning Gitleaks (git history) + TruffleHog (entropy, verified-only) gitleaks.yml, trufflehog.yml
Dependency review PR-time license + vulnerability gate dependency-review.yml
License compliance go-licenses allow-list (Apache-2.0, BSD, ISC, MIT, MPL-2.0, Unlicense) license-check.yml
Action SHA pinning enforces every uses: is a 40-char SHA pin-check.yml
Coverage Codecov + Codacy upload ci.yml
Releases release-please (Conventional Commits → CHANGELOG + tag) release-please.yml
Dependencies Renovate (primary), Dependabot (fallback) renovate.json, dependabot.yml
Integration live testnet smoke tests, manual dispatch only integration.yml
OpenSSF Scorecard weekly + on push, publishes public score scorecard.yml
OSV-Scanner weekly + on push/PR, transitive dep CVE scan osv-scanner.yml
SLSA + SBOM runs on every published release release.yml
Post-release re-verify cosign + slsa-verifier, weekly + on release verify-release.yml

All workflows additionally run step-security/harden-runner in audit mode for egress monitoring.

Required repository secrets
Secret Used by Required?
CODECOV_TOKEN Codecov upload in ci.yml Yes for private repos; public repos can omit
CODACY_PROJECT_TOKEN Codacy coverage upload in ci.yml Optional — coverage upload silently skipped if missing
RELEASE_PLEASE_TOKEN release-please uses this PAT to publish releases that auto-trigger release.yml Recommended — if missing, falls back to GITHUB_TOKEN, but releases won't auto-fire release.yml (artefacts need manual gh workflow run release.yml -f tag=vX.Y.Z)

GITHUB_TOKEN is provided by Actions automatically. RELEASE_PLEASE_TOKEN should be a fine-grained PAT scoped to this repo with Contents: write and Pull requests: write permissions — needed because GitHub's anti-loop protection doesn't fire release.yml on releases published by GITHUB_TOKEN.

Security

This project follows the OpenSSF best practices and publishes a public Scorecard at scorecard.dev.

What Where
Vulnerability disclosure SECURITY.md — uses GitHub private advisories
Code of conduct CODE_OF_CONDUCT.md (Contributor Covenant 2.1)
Security metadata SECURITY-INSIGHTS.yml (OpenSSF spec 1.0.0)
Required repo settings docs/security/repo-policy.md
Static analysis (SAST) CodeQL, gosec, Semgrep, staticcheck, Codacy
Filesystem / IaC scanning Trivy (filesystem + secret + config modes)
Secret scanning Gitleaks (history) + TruffleHog (verified-only)
Dependency scanning govulncheck, OSV-Scanner, Trivy filesystem, dependency-review
Dependency updates Renovate (primary) + Dependabot (fallback)
License compliance go-licenses allow-list enforced in CI
Egress audit step-security/harden-runner on every workflow (audit mode)
Action pinning enforcement pin-check workflow rejects unpinned uses: lines
Release integrity SLSA Level 3 provenance + CycloneDX & SPDX SBOMs + license inventory, all cosign-signed — release.yml
Post-release verification cosign signatures + SLSA provenance re-checked weekly + on every release — verify-release.yml
Fuzzing Go-native Fuzz* tests in pkg/types, pkg/auth, pkg/errors, internal/jsonrpc
Pinned actions every action pinned by SHA with the version as a comment

To report a vulnerability or code-of-conduct violation, use GitHub's private vulnerability reporting. The same channel handles both so reports go through one triage pipeline.

Running integration tests

Live-network tests live under test/ and are gated by the integration build tag, so the default go test ./... is unaffected.

# Public-only subset (no creds needed) against testnet.
make test-integration

# All tests except live order placement.
DERIVE_SESSION_KEY=0x... DERIVE_SUBACCOUNT=123 \
  go test -tags=integration -count=1 ./test/...

# Add live order placement (testnet only — never against mainnet).
DERIVE_RUN_LIVE_ORDERS=1 DERIVE_BASE_ASSET=0x... \
  DERIVE_SESSION_KEY=0x... DERIVE_SUBACCOUNT=123 \
  go test -tags=integration -count=1 -run='^TestPrivate_PlaceAndCancel' ./test/...

See test/README.md for the full env-var list and what each subset covers.

Project files

File Purpose
CONTRIBUTING.md how to submit changes; Conventional Commits
CODE_OF_CONDUCT.md Contributor Covenant 2.1
SECURITY.md vulnerability disclosure
SUPPORT.md where to ask which kind of question
GOVERNANCE.md how decisions get made
MAINTAINERS.md who reviews and merges
CHANGELOG.md every release, generated by release-please
MIGRATING.md hand-written before/after for every 0.x breaking change
AUTHORS contributors in chronological order
SECURITY-INSIGHTS.yml OpenSSF security metadata
.github/settings.yml declarative repo settings + label palette (Probot Settings)
.github/rulesets/ branch + tag rulesets, importable via gh api
Configs Makefile · lefthook.yml · renovate.json · .codacy.yml · .markdownlint.json · .remarkrc.yml · .typos.toml · .editorconfig

Contributing

Commits must follow Conventional Commits so release-please can derive the next version and update CHANGELOG.md. See CONTRIBUTING.md.

License

MIT.

Acknowledgements

This SDK exists thanks to:

Disclaimer

Use testnet first. Always validate any integration against the Derive testnet (derive.WithTestnet()) before pointing at mainnet. Test orders place real testnet positions but use no real funds; mainnet does the opposite.

This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement (see LICENSE for the full terms).

This is an independent, unofficial project. It is not affiliated with, endorsed by, or sponsored by Derive, Lyra Finance, the Lyra DAO, the Ethereum Foundation, or any other organisation or person. All product names, logos, and brands referenced are the property of their respective owners; their use here is for identification purposes only.

Trading derivatives carries financial risk. Nothing in this repository is financial advice. You are solely responsible for any orders submitted, keys generated or stored, and integrations built on top of this code. Use at your own risk.

Documentation

Overview

Package goderive is the root of the go-derive SDK for the Derive exchange (formerly Lyra). The user-facing API lives under pkg/. Most users want pkg/derive for the top-level facade, or pkg/rest and pkg/ws directly for fine-grained control.

Quick start:

import (
    "context"
    "github.com/amiwrpremium/go-derive/pkg/auth"
    "github.com/amiwrpremium/go-derive/pkg/derive"
)

signer, _ := auth.NewLocalSigner("0xPRIVATEKEY")
c, _ := derive.NewClient(
    derive.WithMainnet(),
    derive.WithSigner(signer),
    derive.WithSubaccount(123),
)
defer c.Close()

instruments, err := c.REST.GetInstruments(context.Background(), "BTC", "perp")

Index

Constants

View Source
const Version = "0.23.3" // x-release-please-version

Version is the SDK semantic version. It is reported in the User-Agent header of REST requests and in the WebSocket connect handshake. The literal is maintained by release-please via the x-release-please-version annotation.

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

UserAgent returns the default User-Agent string used by transports.

Types

This section is empty.

Directories

Path Synopsis
examples
auth/action_data command
Computes the EIP-712 hashStruct of an ActionData.
Computes the EIP-712 hashStruct of an ActionData.
auth/http_headers command
Builds the X-LyraWallet/Timestamp/Signature header bundle.
Builds the X-LyraWallet/Timestamp/Signature header bundle.
auth/local_signer command
Builds an auth.LocalSigner from the configured private key.
Builds an auth.LocalSigner from the configured private key.
auth/nonce command
Generates strictly-increasing nonces.
Generates strictly-increasing nonces.
auth/session_key_signer command
Builds an auth.SessionKeySigner — owner address differs from the session key address.
Builds an auth.SessionKeySigner — owner address differs from the session key address.
auth/sign_action command
Signs an EIP-712 ActionData and prints the resulting signature.
Signs an EIP-712 ActionData and prints the resulting signature.
auth/sign_auth_header command
Signs an EIP-191 timestamp for use as the X-LyraSignature header.
Signs an EIP-191 timestamp for use as the X-LyraSignature header.
auth/signature command
Demonstrates Signature.Hex serialisation.
Demonstrates Signature.Hex serialisation.
auth/trade_module_data command
Hashes the per-trade module payload that goes into ActionData.Data.
Hashes the per-trade module payload that goes into ActionData.Data.
auth/transfer_module_data command
Hashes the per-transfer module payload.
Hashes the per-transfer module payload.
derive/full command
Builds the facade with private credentials and uses both REST and WS.
Builds the facade with private credentials and uses both REST and WS.
derive/new_client command
Constructs the top-level facade with the configured network.
Constructs the top-level facade with the configured network.
derive/rest_only command
Uses only the c.REST client from the facade.
Uses only the c.REST client from the facade.
derive/ws_only command
Uses only the c.WS client from the facade — connects and fetches a ticker.
Uses only the c.WS client from the facade — connects and fetches a ticker.
rest/private/change_subaccount_label command
Sets a human-readable label on the configured subaccount.
Sets a human-readable label on the configured subaccount.
rest/private/contact_info/create command
Registers a new contact-info record on the configured signer's wallet.
Registers a new contact-info record on the configured signer's wallet.
rest/private/contact_info/delete command
Deletes one contact-info record by id.
Deletes one contact-info record by id.
rest/private/contact_info/get command
Lists every contact-info record on the configured signer's wallet.
Lists every contact-info record on the configured signer's wallet.
rest/private/contact_info/update command
Updates the value of an existing contact-info record.
Updates the value of an existing contact-info record.
rest/private/expired_and_cancelled_history command
Exports the configured subaccount's expired and cancelled orders.
Exports the configured subaccount's expired and cancelled orders.
rest/private/get_account command
Fetches wallet-level account information for the configured signer.
Fetches wallet-level account information for the configured signer.
rest/private/get_algo_orders command
Lists every active algo order on the configured subaccount.
Lists every active algo order on the configured subaccount.
rest/private/get_all_portfolios command
Lists per-subaccount portfolio snapshots for every subaccount the configured signer's wallet owns.
Lists per-subaccount portfolio snapshots for every subaccount the configured signer's wallet owns.
rest/private/get_collaterals command
Lists the subaccount's collateral positions.
Lists the subaccount's collateral positions.
rest/private/get_deposit_history command
Paginates deposit events.
Paginates deposit events.
rest/private/get_erc20_transfer_history command
Lists ERC20 transfers for the configured subaccount.
Lists ERC20 transfers for the configured subaccount.
rest/private/get_funding_history command
Fetches funding payments received / paid by the configured subaccount.
Fetches funding payments received / paid by the configured subaccount.
rest/private/get_interest_history command
Lists interest payments received / paid by the configured subaccount.
Lists interest payments received / paid by the configured subaccount.
rest/private/get_liquidation_history command
Fetches the configured subaccount's past liquidation events.
Fetches the configured subaccount's past liquidation events.
rest/private/get_liquidator_history command
Lists auction bids placed by the configured subaccount as a liquidator (paginated).
Lists auction bids placed by the configured subaccount as a liquidator (paginated).
rest/private/get_margin command
Simulates a margin calculation against the configured subaccount and reports pre/post initial- and maintenance-margin values.
Simulates a margin calculation against the configured subaccount and reports pre/post initial- and maintenance-margin values.
rest/private/get_open_orders command
Lists currently-open orders.
Lists currently-open orders.
rest/private/get_option_settlement_history command
Lists option settlements for the configured subaccount.
Lists option settlements for the configured subaccount.
rest/private/get_order command
Fetches one order by id.
Fetches one order by id.
rest/private/get_order_history command
Paginates past orders by time window.
Paginates past orders by time window.
rest/private/get_orders command
Paginates orders on the configured subaccount, optionally filtered by instrument / label / status.
Paginates orders on the configured subaccount, optionally filtered by instrument / label / status.
rest/private/get_positions command
Lists the subaccount's open positions.
Lists the subaccount's open positions.
rest/private/get_subaccount command
Fetches a single subaccount snapshot.
Fetches a single subaccount snapshot.
rest/private/get_subaccount_value_history command
Lists historical subaccount-value snapshots.
Lists historical subaccount-value snapshots.
rest/private/get_subaccounts command
Lists every subaccount the wallet owns.
Lists every subaccount the wallet owns.
rest/private/get_trade_history command
Paginates the user's filled trades.
Paginates the user's filled trades.
rest/private/get_transaction command
Fetches one transaction record by id.
Fetches one transaction record by id.
rest/private/get_trigger_orders command
Lists every untriggered trigger order on the configured subaccount.
Lists every untriggered trigger order on the configured subaccount.
rest/private/get_withdrawal_history command
Paginates withdrawal events.
Paginates withdrawal events.
rest/private/mmp/get command
Reads market-maker-protection config for the configured subaccount, optionally filtered to one currency (empty string returns every configured currency).
Reads market-maker-protection config for the configured subaccount, optionally filtered to one currency (empty string returns every configured currency).
rest/private/mmp/reset command
Unfreezes market-maker protection for one currency.
Unfreezes market-maker protection for one currency.
rest/private/mmp/set command
Configures market-maker protection for one currency.
Configures market-maker protection for one currency.
rest/private/notifications/get command
Paginates notifications for the configured subaccount.
Paginates notifications for the configured subaccount.
rest/private/notifications/update command
Marks specific notifications as seen or hidden.
Marks specific notifications as seen or hidden.
rest/private/order_debug command
Previews an order without submitting it.
Previews an order without submitting it.
rest/private/order_quote command
Pre-flights a hypothetical order through the matching engine for the configured subaccount.
Pre-flights a hypothetical order through the matching engine for the configured subaccount.
rest/private/orders/cancel command
Cancels one order by id.
Cancels one order by id.
rest/private/orders/cancel_algo_order command
Cancels one in-flight algo order by id.
Cancels one in-flight algo order by id.
rest/private/orders/cancel_all command
Cancels every open order on the subaccount.
Cancels every open order on the subaccount.
rest/private/orders/cancel_all_algo_orders command
Cancels every in-flight algo order on the configured subaccount.
Cancels every in-flight algo order on the configured subaccount.
rest/private/orders/cancel_all_trigger_orders command
Cancels every untriggered trigger order on the configured subaccount.
Cancels every untriggered trigger order on the configured subaccount.
rest/private/orders/cancel_by_instrument command
Cancels every open order on one instrument.
Cancels every open order on one instrument.
rest/private/orders/cancel_by_label command
Cancels every order carrying a given label.
Cancels every order carrying a given label.
rest/private/orders/cancel_by_nonce command
Cancels every order on the configured subaccount that carries the given nonce.
Cancels every order on the configured subaccount that carries the given nonce.
rest/private/orders/cancel_trigger_order command
Cancels one untriggered trigger order by id.
Cancels one untriggered trigger order by id.
rest/private/orders/place command
Places one limit buy 5% below mark (won't fill on a normal book).
Places one limit buy 5% below mark (won't fill on a normal book).
rest/private/orders/place_algo command
Places one TWAP algo buy 5% below mark — saved server-side and sliced over a 10-minute window into 10 child orders.
Places one TWAP algo buy 5% below mark — saved server-side and sliced over a 10-minute window into 10 child orders.
rest/private/orders/place_trigger command
Places one stop-loss trigger sell 5% below mark.
Places one stop-loss trigger sell 5% below mark.
rest/private/replace command
Replaces (cancel + place) one outstanding order in a single round trip.
Replaces (cancel + place) one outstanding order in a single round trip.
rest/private/rfq/cancel command
Cancels one outstanding RFQ.
Cancels one outstanding RFQ.
rest/private/rfq/cancel_batch_quotes command
Bulk-cancels every quote on the configured subaccount, optionally filtered by label / nonce.
Bulk-cancels every quote on the configured subaccount, optionally filtered by label / nonce.
rest/private/rfq/cancel_batch_rfqs command
Bulk-cancels every outstanding RFQ on the configured subaccount.
Bulk-cancels every outstanding RFQ on the configured subaccount.
rest/private/rfq/cancel_quote command
Cancels one outstanding quote by id.
Cancels one outstanding quote by id.
rest/private/rfq/execute_quote command
Executes (accepts) a quote received against the configured subaccount's RFQ.
Executes (accepts) a quote received against the configured subaccount's RFQ.
rest/private/rfq/get_best_quote command
Returns the best quote currently available for a hypothetical RFQ shape — the SDK's pre-flight for "what could I get if I asked for this?" without actually submitting the RFQ.
Returns the best quote currently available for a hypothetical RFQ shape — the SDK's pre-flight for "what could I get if I asked for this?" without actually submitting the RFQ.
rest/private/rfq/get_quotes command
Paginates the configured subaccount's quotes — own quotes either active or in any historical state.
Paginates the configured subaccount's quotes — own quotes either active or in any historical state.
rest/private/rfq/get_rfqs command
Paginates the configured subaccount's outstanding and historical RFQs.
Paginates the configured subaccount's outstanding and historical RFQs.
rest/private/rfq/poll command
Polls outstanding RFQs for the subaccount.
Polls outstanding RFQs for the subaccount.
rest/private/rfq/poll_quotes command
Polls quotes received against the configured subaccount's RFQs — the maker-side view of what other makers are quoting on an active RFQ.
Polls quotes received against the configured subaccount's RFQs — the maker-side view of what other makers are quoting on an active RFQ.
rest/private/rfq/replace_quote command
Replaces (cancel + send) one outstanding maker quote in a single round trip — the quote-side counterpart to private/replace for orders.
Replaces (cancel + send) one outstanding maker quote in a single round trip — the quote-side counterpart to private/replace for orders.
rest/private/rfq/send command
Sends a one-leg RFQ.
Sends a one-leg RFQ.
rest/private/rfq/send_quote command
Submits a quote in response to an existing RFQ — the maker side of the RFQ flow.
Submits a quote in response to an existing RFQ — the maker side of the RFQ flow.
rest/private/set_cancel_on_disconnect command
Arms (or disarms) the cancel-on-disconnect kill-switch for the wallet.
Arms (or disarms) the cancel-on-disconnect kill-switch for the wallet.
rest/public/all_statistics command
Aggregate (currency, instrument_type) statistics across every instrument.
Aggregate (currency, instrument_type) statistics across every instrument.
rest/public/all_user_statistics command
Per-wallet trading statistics for every wallet matching the supplied filters.
Per-wallet trading statistics for every wallet matching the supplied filters.
rest/public/get_all_instruments command
Lists every active perpetual instrument across all currencies, paginated.
Lists every active perpetual instrument across all currencies, paginated.
rest/public/get_all_points command
Program-wide points snapshot.
Program-wide points snapshot.
rest/public/get_all_referral_codes command
Lists every valid referral code for the configured signer's wallet (or omits the wallet param when no signer is configured).
Lists every valid referral code for the configured signer's wallet (or omits the wallet param when no signer is configured).
rest/public/get_asset command
Fetches one Asset record by name.
Fetches one Asset record by name.
rest/public/get_assets command
Lists Asset records matching the supplied filter.
Lists Asset records matching the supplied filter.
rest/public/get_bridge_balances command
Lists every bridge / cross-chain balance the engine tracks.
Lists every bridge / cross-chain balance the engine tracks.
rest/public/get_currencies command
Lists all quote currencies supported on the configured network.
Lists all quote currencies supported on the configured network.
rest/public/get_currency command
Fetches per-asset margin parameters and protocol-asset addresses for one underlying currency.
Fetches per-asset margin parameters and protocol-asset addresses for one underlying currency.
rest/public/get_descendant_tree command
Returns the referee tree rooted at one wallet (or invite code).
Returns the referee tree rooted at one wallet (or invite code).
rest/public/get_detailed_maker_snapshot_history command
Per-quote maker-snapshot rows for one program / epoch.
Per-quote maker-snapshot rows for one program / epoch.
rest/public/get_funding_rate_history command
Fetches historical funding-rate prints for one perpetual instrument and prints the most recent few entries.
Fetches historical funding-rate prints for one perpetual instrument and prints the most recent few entries.
rest/public/get_index_chart_data command
Fetches OHLC candles for one currency's index price feed over the last hour at one-minute resolution.
Fetches OHLC candles for one currency's index price feed over the last hour at one-minute resolution.
rest/public/get_instrument command
Fetches details for one instrument by name.
Fetches details for one instrument by name.
rest/public/get_instruments command
Lists active BTC perpetual instruments.
Lists active BTC perpetual instruments.
rest/public/get_interest_rate_history command
Fetches historical USDC borrow / supply APY prints over the last 24 hours.
Fetches historical USDC borrow / supply APY prints over the last 24 hours.
rest/public/get_invite_code command
Returns the invite code allocated to one wallet plus its remaining-uses counter.
Returns the invite code allocated to one wallet plus its remaining-uses counter.
rest/public/get_latest_signed_feeds command
Fetches the latest oracle signed-feed snapshot.
Fetches the latest oracle signed-feed snapshot.
rest/public/get_liquidation_history command
Lists the network-wide liquidation auction history (paginated).
Lists the network-wide liquidation auction history (paginated).
rest/public/get_live_incidents command
Lists ongoing platform incidents.
Lists ongoing platform incidents.
rest/public/get_maker_program_scores command
Fetches the per-wallet score breakdown for one maker incentive program at one epoch.
Fetches the per-wallet score breakdown for one maker incentive program at one epoch.
rest/public/get_maker_programs command
Lists active maker incentive programs.
Lists active maker incentive programs.
rest/public/get_margin command
Simulates a margin calculation for a hypothetical portfolio.
Simulates a margin calculation for a hypothetical portfolio.
rest/public/get_option_settlement_history command
Lists platform-wide option settlements.
Lists platform-wide option settlements.
rest/public/get_option_settlement_prices command
Fetches the per-expiry settlement prices for one currency's option market.
Fetches the per-expiry settlement prices for one currency's option market.
rest/public/get_perp_impact_twap command
Fetches the time-weighted average impact price for one currency's perpetual book over the last hour.
Fetches the time-weighted average impact price for one currency's perpetual book over the last hour.
rest/public/get_points command
One wallet's points record for one program.
One wallet's points record for one program.
rest/public/get_points_leaderboard command
One page (up to 500 entries) of the points leaderboard for one program.
One page (up to 500 entries) of the points leaderboard for one program.
rest/public/get_referral_code command
Returns the referral code currently associated with one wallet.
Returns the referral code currently associated with one wallet.
rest/public/get_referral_performance command
Fetches the headline referral performance for the configured referral code over the last 30 days.
Fetches the headline referral performance for the configured referral code over the last 30 days.
rest/public/get_spot_feed_history command
Lists historical oracle spot-feed values for one currency.
Lists historical oracle spot-feed values for one currency.
rest/public/get_spot_feed_history_candles command
Fetches OHLC candles for one currency's spot feed over the last hour at one-minute resolution.
Fetches OHLC candles for one currency's spot feed over the last hour at one-minute resolution.
rest/public/get_statistics command
Fetches rolling daily / lifetime statistics (volume, fees, trades, OI) for one instrument and prints the headline numbers.
Fetches rolling daily / lifetime statistics (volume, fees, trades, OI) for one instrument and prints the headline numbers.
rest/public/get_stdrv_snapshots command
One wallet's staked-DRV balance snapshots over a time window.
One wallet's staked-DRV balance snapshots over a time window.
rest/public/get_ticker command
Fetches a ticker (top-of-book + marks).
Fetches a ticker (top-of-book + marks).
rest/public/get_tickers command
Bulk-fetches the per-instrument ticker snapshot for every perp instrument.
Bulk-fetches the per-instrument ticker snapshot for every perp instrument.
rest/public/get_time command
Fetches Derive's server time over REST.
Fetches Derive's server time over REST.
rest/public/get_trade_history command
Paginates the public trade tape — page-sized 5, prints the latest 5 trades plus the total record count and page count Derive reports.
Paginates the public trade tape — page-sized 5, prints the latest 5 trades plus the total record count and page count Derive reports.
rest/public/get_tradingview_chart_data command
Fetches TradingView-format OHLC bars for one instrument over the last hour at one-minute resolution.
Fetches TradingView-format OHLC bars for one instrument over the last hour at one-minute resolution.
rest/public/get_tree_roots command
Lists every root wallet (top-of-tree referrer) the engine tracks.
Lists every root wallet (top-of-tree referrer) the engine tracks.
rest/public/get_vault_assets command
Lists every ERC-20 asset tracked by Derive's vault orderbook.
Lists every ERC-20 asset tracked by Derive's vault orderbook.
rest/public/get_vault_balances command
Lists one wallet's vault-token holdings across every Derive vault.
Lists one wallet's vault-token holdings across every Derive vault.
rest/public/get_vault_pools command
Lists every registered vault ERC-20 pool.
Lists every registered vault ERC-20 pool.
rest/public/get_vault_rates command
Returns the engine's current view of one basis vault's rate components.
Returns the engine's current view of one basis vault's rate components.
rest/public/get_vault_share command
Fetches per-block snapshots of one vault token's price-per-share over the last 24 hours.
Fetches per-block snapshots of one vault token's price-per-share over the last 24 hours.
rest/public/get_vault_statistics command
Lists summary statistics (TVL, total supply, last-trade subaccount value) for every Derive vault.
Lists summary statistics (TVL, total supply, last-trade subaccount value) for every Derive vault.
rest/public/margin_watch command
Calculates the mark-to-market and maintenance-margin snapshot for one subaccount.
Calculates the mark-to-market and maintenance-margin snapshot for one subaccount.
rest/public/order_quote command
Pre-flights a hypothetical order through the matching engine via public/order_quote.
Pre-flights a hypothetical order through the matching engine via public/order_quote.
rest/public/user_statistics command
One wallet's trading statistics.
One wallet's trading statistics.
rest/public/validate_invite_code command
Validates one invite code.
Validates one invite code.
ws/private/change_subaccount_label command
Sets a human-readable label on the configured subaccount over WebSocket.
Sets a human-readable label on the configured subaccount over WebSocket.
ws/private/expired_and_cancelled_history command
Exports the configured subaccount's expired and cancelled orders over WebSocket.
Exports the configured subaccount's expired and cancelled orders over WebSocket.
ws/private/get_collaterals command
Fetches collateral over WebSocket.
Fetches collateral over WebSocket.
ws/private/get_deposit_history command
Paginates deposits over WebSocket.
Paginates deposits over WebSocket.
ws/private/get_erc20_transfer_history command
Lists ERC20 transfers for the configured subaccount over WebSocket.
Lists ERC20 transfers for the configured subaccount over WebSocket.
ws/private/get_interest_history command
Lists interest payments for the configured subaccount over WebSocket.
Lists interest payments for the configured subaccount over WebSocket.
ws/private/get_margin command
Simulates a margin calculation for the configured subaccount over WebSocket.
Simulates a margin calculation for the configured subaccount over WebSocket.
ws/private/get_open_orders command
Fetches open orders over WebSocket.
Fetches open orders over WebSocket.
ws/private/get_option_settlement_history command
Lists option settlements for the configured subaccount over WebSocket.
Lists option settlements for the configured subaccount over WebSocket.
ws/private/get_order command
Fetches one order by id over WebSocket.
Fetches one order by id over WebSocket.
ws/private/get_order_history command
Paginates past orders by time window over WebSocket.
Paginates past orders by time window over WebSocket.
ws/private/get_positions command
Fetches positions over WebSocket.
Fetches positions over WebSocket.
ws/private/get_subaccount command
Fetches the configured subaccount snapshot over WebSocket.
Fetches the configured subaccount snapshot over WebSocket.
ws/private/get_subaccount_value_history command
Lists historical subaccount-value snapshots over WebSocket.
Lists historical subaccount-value snapshots over WebSocket.
ws/private/get_subaccounts command
Lists every subaccount the wallet owns over WebSocket.
Lists every subaccount the wallet owns over WebSocket.
ws/private/get_trade_history command
Paginates user trades over WebSocket.
Paginates user trades over WebSocket.
ws/private/get_transaction command
Fetches one transaction record by id over WebSocket.
Fetches one transaction record by id over WebSocket.
ws/private/get_withdrawal_history command
Paginates withdrawals over WebSocket.
Paginates withdrawals over WebSocket.
ws/private/login command
Authenticates a WebSocket session via public/login.
Authenticates a WebSocket session via public/login.
ws/private/mmp/get command
Reads MMP config over WebSocket.
Reads MMP config over WebSocket.
ws/private/mmp/reset command
Resets MMP for one currency over WebSocket.
Resets MMP for one currency over WebSocket.
ws/private/mmp/set command
Sets MMP config over WebSocket.
Sets MMP config over WebSocket.
ws/private/notifications/get command
Paginates notifications over WebSocket.
Paginates notifications over WebSocket.
ws/private/notifications/update command
Marks specific notifications as seen or hidden over WebSocket.
Marks specific notifications as seen or hidden over WebSocket.
ws/private/order_quote command
Pre-flights a hypothetical order for the configured subaccount over WebSocket.
Pre-flights a hypothetical order for the configured subaccount over WebSocket.
ws/private/orders/cancel command
Cancels one order by id over WebSocket.
Cancels one order by id over WebSocket.
ws/private/orders/cancel_all command
Cancels every open order on the subaccount over WebSocket.
Cancels every open order on the subaccount over WebSocket.
ws/private/orders/cancel_by_instrument command
Cancels orders on one instrument over WebSocket.
Cancels orders on one instrument over WebSocket.
ws/private/orders/cancel_by_label command
Cancels orders by label over WebSocket.
Cancels orders by label over WebSocket.
ws/private/orders/cancel_by_nonce command
Cancels every order on the configured subaccount that carries the given nonce, over WebSocket.
Cancels every order on the configured subaccount that carries the given nonce, over WebSocket.
ws/private/orders/place command
Places one limit order over WebSocket.
Places one limit order over WebSocket.
ws/private/rfq/cancel command
Cancels one RFQ over WebSocket.
Cancels one RFQ over WebSocket.
ws/private/rfq/cancel_batch_quotes command
Bulk-cancels every quote on the configured subaccount over WebSocket.
Bulk-cancels every quote on the configured subaccount over WebSocket.
ws/private/rfq/cancel_batch_rfqs command
Bulk-cancels every outstanding RFQ on the configured subaccount over WebSocket.
Bulk-cancels every outstanding RFQ on the configured subaccount over WebSocket.
ws/private/rfq/cancel_quote command
Cancels one outstanding quote by id over WebSocket.
Cancels one outstanding quote by id over WebSocket.
ws/private/rfq/execute_quote command
Executes (accepts) a quote against the configured subaccount's RFQ over WebSocket.
Executes (accepts) a quote against the configured subaccount's RFQ over WebSocket.
ws/private/rfq/get_best_quote command
Returns the best quote available for a hypothetical RFQ shape over WebSocket.
Returns the best quote available for a hypothetical RFQ shape over WebSocket.
ws/private/rfq/get_quotes command
Paginates the configured subaccount's quotes over WebSocket.
Paginates the configured subaccount's quotes over WebSocket.
ws/private/rfq/get_rfqs command
Paginates the configured subaccount's RFQs over WebSocket.
Paginates the configured subaccount's RFQs over WebSocket.
ws/private/rfq/poll command
Polls outstanding RFQs over WebSocket.
Polls outstanding RFQs over WebSocket.
ws/private/rfq/poll_quotes command
Polls quotes received against the configured subaccount's RFQs over WebSocket.
Polls quotes received against the configured subaccount's RFQs over WebSocket.
ws/private/rfq/send command
Sends a one-leg RFQ over WebSocket.
Sends a one-leg RFQ over WebSocket.
ws/private/rfq/send_quote command
Submits a quote in response to an existing RFQ over WebSocket — the maker side of the RFQ flow.
Submits a quote in response to an existing RFQ over WebSocket — the maker side of the RFQ flow.
ws/private/subscribe/balances command
Streams subaccount balance updates.
Streams subaccount balance updates.
ws/private/subscribe/best_quotes command
Streams the running best-quote state for every open RFQ on the configured subaccount.
Streams the running best-quote state for every open RFQ on the configured subaccount.
ws/private/subscribe/multi command
Subscribes to three private channels for one subaccount and demuxes them in a single select loop.
Subscribes to three private channels for one subaccount and demuxes them in a single select loop.
ws/private/subscribe/orders command
Streams subaccount order updates.
Streams subaccount order updates.
ws/private/subscribe/quotes command
Streams quote updates received against this subaccount's RFQs.
Streams quote updates received against this subaccount's RFQs.
ws/private/subscribe/rfqs command
Streams wallet RFQ status updates.
Streams wallet RFQ status updates.
ws/private/subscribe/trades command
Streams the subaccount's fill events.
Streams the subaccount's fill events.
ws/private/subscribe/trades_settled command
Streams the configured subaccount's fills filtered to settled-only — same payload as ws/private/subscribe/trades but filtered server-side.
Streams the configured subaccount's fills filtered to settled-only — same payload as ws/private/subscribe/trades but filtered server-side.
ws/public/connect command
Opens a WebSocket connection and reports its state.
Opens a WebSocket connection and reports its state.
ws/public/get_currencies command
Lists currencies over WebSocket.
Lists currencies over WebSocket.
ws/public/get_instrument command
Fetches one instrument over WebSocket.
Fetches one instrument over WebSocket.
ws/public/get_instruments command
Lists BTC perp instruments over WebSocket.
Lists BTC perp instruments over WebSocket.
ws/public/get_margin command
Simulates a margin calculation for a hypothetical portfolio over WebSocket.
Simulates a margin calculation for a hypothetical portfolio over WebSocket.
ws/public/get_option_settlement_history command
Lists platform-wide option settlements over WebSocket.
Lists platform-wide option settlements over WebSocket.
ws/public/get_spot_feed_history command
Lists historical oracle spot-feed values over WebSocket.
Lists historical oracle spot-feed values over WebSocket.
ws/public/get_ticker command
Fetches a ticker over WebSocket (single RPC, not a subscription).
Fetches a ticker over WebSocket (single RPC, not a subscription).
ws/public/get_time command
Fetches server time over WebSocket.
Fetches server time over WebSocket.
ws/public/get_trade_history command
Paginates the public trade tape over WebSocket.
Paginates the public trade tape over WebSocket.
ws/public/subscribe/auctions_watch command
Streams the platform-wide auctions.watch feed: every liquidation auction Derive is currently running emits per-state-transition events (one when an auction begins/updates, one when it ends).
Streams the platform-wide auctions.watch feed: every liquidation auction Derive is currently running emits per-state-transition events (one when an auction begins/updates, one when it ends).
ws/public/subscribe/margin_watch command
Streams the platform-wide margin_watch feed: every subaccount whose maintenance margin has crossed the watch threshold gets emitted as part of a per-timestamp batch.
Streams the platform-wide margin_watch feed: every subaccount whose maintenance margin has crossed the watch threshold gets emitted as part of a per-timestamp batch.
ws/public/subscribe/multi command
Subscribes to three public channels for one instrument and demultiplexes them across three goroutines — one per subscription — so a slow handler on one channel cannot starve the others.
Subscribes to three public channels for one instrument and demultiplexes them across three goroutines — one per subscription — so a slow handler on one channel cannot starve the others.
ws/public/subscribe/multi_into command
Multiplexes two trade-channel subscriptions into one shared chan using SubscribeInto.
Multiplexes two trade-channel subscriptions into one shared chan using SubscribeInto.
ws/public/subscribe/orderbook command
Streams orderbook updates for one instrument and demos every SubscribeOption: a larger buffer, DropOldest so the freshest book always wins under back-pressure, and an error handler that surfaces drops to a counter.
Streams orderbook updates for one instrument and demos every SubscribeOption: a larger buffer, DropOldest so the freshest book always wins under back-pressure, and an error handler that surfaces drops to a counter.
ws/public/subscribe/reconnect command
Demonstrates the SDK's auto-reconnect + auto-resubscribe behaviour by subscribing to a ticker_slim feed and printing the update count seen in each 10-second window for 60 seconds total.
Demonstrates the SDK's auto-reconnect + auto-resubscribe behaviour by subscribing to a ticker_slim feed and printing the update count seen in each 10-second window for 60 seconds total.
ws/public/subscribe/spot_feed command
Streams oracle spot-feed updates for one currency.
Streams oracle spot-feed updates for one currency.
ws/public/subscribe/ticker command
Streams ticker_slim updates for one instrument — the compact wire variant.
Streams ticker_slim updates for one instrument — the compact wire variant.
ws/public/subscribe/ticker_full command
Streams the full ticker channel for one instrument — instrument metadata bundled with live market data.
Streams the full ticker channel for one instrument — instrument metadata bundled with live market data.
ws/public/subscribe/trades command
Streams public trade prints.
Streams public trade prints.
ws/public/subscribe/trades_by_type command
Streams every public trade for one (instrument_type, currency) pair.
Streams every public trade for one (instrument_type, currency) pair.
ws/public/subscribe/trades_by_type_settled command
Streams public trades for one (instrument_type, currency) tuple filtered to settled fills only — same payload as ws/public/subscribe/trades_by_type but filtered server-side.
Streams public trades for one (instrument_type, currency) tuple filtered to settled fills only — same payload as ws/public/subscribe/trades_by_type but filtered server-side.
internal
codec
Package codec is a small bag of low-level encoding helpers shared between pkg/auth (action signing) and pkg/types.
Package codec is a small bag of low-level encoding helpers shared between pkg/auth (action signing) and pkg/types.
jsonrpc
Package jsonrpc implements JSON-RPC 2.0 framing.
Package jsonrpc implements JSON-RPC 2.0 framing.
methods
Package methods is the shared implementation of every JSON-RPC method Derive exposes.
Package methods is the shared implementation of every JSON-RPC method Derive exposes.
netconf
Package netconf carries the network constants — endpoint URLs, chain IDs, and EIP-712 domain separators — for each Derive environment.
Package netconf carries the network constants — endpoint URLs, chain IDs, and EIP-712 domain separators — for each Derive environment.
retry
Package retry contains backoff helpers used by the WebSocket reconnect loop.
Package retry contains backoff helpers used by the WebSocket reconnect loop.
testutil
Package testutil exposes test fixtures and mock servers used by the SDK's internal tests.
Package testutil exposes test fixtures and mock servers used by the SDK's internal tests.
transport
Package transport defines the JSON-RPC wire interface that pkg/rest and pkg/ws share, plus the HTTP and WebSocket implementations that satisfy it.
Package transport defines the JSON-RPC wire interface that pkg/rest and pkg/ws share, plus the HTTP and WebSocket implementations that satisfy it.
pkg
auth
Package auth implements the two cryptographic signing flows Derive's API requires.
Package auth implements the two cryptographic signing flows Derive's API requires.
derive
Package derive is the top-level convenience facade for the SDK.
Package derive is the top-level convenience facade for the SDK.
enums
Package enums declares the named-string enums used across the SDK.
Package enums declares the named-string enums used across the SDK.
errors
Package errors provides the SDK's error types and sentinel values.
Package errors provides the SDK's error types and sentinel values.
rest
Package rest is the HTTP-backed client for Derive's JSON-RPC API.
Package rest is the HTTP-backed client for Derive's JSON-RPC API.
types
Package types declares the domain types used in REST and WebSocket requests and responses.
Package types declares the domain types used in REST and WebSocket requests and responses.
ws
Package ws is the WebSocket-backed client for Derive's JSON-RPC API.
Package ws is the WebSocket-backed client for Derive's JSON-RPC API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL