diff --git a/go.md b/go.md index 7d8737141..fdfde8c20 100644 --- a/go.md +++ b/go.md @@ -33,6 +33,8 @@ flowchart LR click capabilities/integration_tests href "https://github.com/smartcontractkit/capabilities" capabilities/libs --> chainlink-common/x/config click capabilities/libs href "https://github.com/smartcontractkit/capabilities" + capabilities/pricing/pricefeed --> capabilities/libs + click capabilities/pricing/pricefeed href "https://github.com/smartcontractkit/capabilities" ccip-contract-examples/chains/evm click ccip-contract-examples/chains/evm href "https://github.com/smartcontractkit/ccip-contract-examples" ccip-owner-contracts @@ -245,6 +247,7 @@ flowchart LR capabilities/http_trigger capabilities/integration_tests capabilities/libs + capabilities/pricing/pricefeed end click capabilities-repo href "https://github.com/smartcontractkit/capabilities" diff --git a/pricing/pricefeed/README.md b/pricing/pricefeed/README.md new file mode 100644 index 000000000..f229bb692 --- /dev/null +++ b/pricing/pricefeed/README.md @@ -0,0 +1,76 @@ +# Price Feed Action + +A node-mode action that returns the current price of a cryptocurrency pair. The node operator configures the price +provider and holds its credentials, so a workflow needs no API URL, API key or response parsing of its own. + +Capability ID: `price-feed@1.0.0-alpha` + +## Use from a workflow + +Each node fetches its own price. The workflow gets consensus on the result, for example with the median: + +```go +func fetchPrice(config *Config, _ *slog.Logger, nodeRuntime *pricefeed.NodeRuntime) (decimal.Decimal, error) { + resp, err := (&pricefeed.Client{}).GetPrice(nodeRuntime, &pricefeed.GetPriceRequest{Ticker: config.Ticker}).Await() + ... +} + +price, err := pricefeed.RunInNodeMode(config, runtime, fetchPrice, cre.ConsensusMedianAggregation()).Await() +``` + +[`workflow/`](workflow) is a complete example. It runs against the real capability with an in-process stand-in for +`cre-sdk-go` (`workflow/fakesdk`), until the SDK is generated from the production protos. + +## Input: `GetPriceRequest` + +| Field | Type | Description | +|----------|--------|-------------------------------------------------------------------------------------------------| +| `ticker` | string | `BASE-QUOTE`, such as `BTC-USD`. `/` or `_` can also separate the pair. The case does not matter. | + +## Output: `GetPriceResponse` + +| Field | Type | Description | +|-------------|-----------------------------|-------------------------------------------------------------------------------------| +| `ticker` | string | The normalised pair, such as `BTC-USD`. | +| `price` | `values.v1.Decimal` | The price of one unit of the base currency in the quote currency. No precision loss. | +| `timestamp` | `google.protobuf.Timestamp` | When the provider observed the price. Coinbase gives none, so it is the receive time. | + +## Providers + +| Provider | Source | Timestamp | Credentials | +|--------------|---------------------------------------------------------------------|-------------------------------|-----------------------| +| `coinbase` | Coinbase Price API, `GET /v2/prices/{BASE-QUOTE}/spot` | When the node got the price | None | +| `dataengine` | Chainlink Data Engine REST API, `GET /api/v1/reports/latest?feedID` | Report `observationsTimestamp` | API key and secret (HMAC) | + +Data Engine reports are decoded for the v2, v3 (crypto) and v4 (RWA) schemas, which have their price at the same +position, with 18 decimals. Each ticker must be mapped to a feed ID in `pricefeed.data-engine.feeds`. The report +signatures are not verified: the report comes from the authenticated API, and on-chain consumers verify it. + +## Configuration + +Set by flag, `CL_` environment variable or config file (`pricefeed run --help` lists them all): + +| Name | Default | Description | +|---------------------------------------|------------------------------------|------------------------------------------------------------------| +| `pricefeed.provider` | `coinbase` | `coinbase` or `dataengine`. | +| `pricefeed.timeout` | `5s` | The longest a request to the provider can take. | +| `pricefeed.max-price-age` | `5m` | Prices with an older timestamp are rejected. `0` accepts any age. | +| `pricefeed.coinbase.url` | `https://api.coinbase.com` | Coinbase API base URL. | +| `pricefeed.data-engine.url` | `https://api.dataengine.chain.link` | Data Engine REST API base URL. | +| `pricefeed.data-engine.api-key` | | Data Engine API key. | +| `pricefeed.data-engine.api-secret` | | Data Engine API secret. Redacted in logs. | +| `pricefeed.data-engine.feeds.` | | The feed ID of a ticker, such as `BTC-USD=0x0003...`. | + +## Errors + +| Cause | Code | Origin | +|----------------------------------------------|--------------------|--------| +| Ticker is not `BASE-QUOTE` | `InvalidArgument` | User | +| Provider has no price for the ticker | `NotFound` | User | +| Provider timed out | `DeadlineExceeded` | System | +| Bad response: status, JSON, report, a price that is not positive, or a stale or future timestamp | `Unavailable` | System | +| Network failure (message kept private) | `Unavailable` | System | + +## Not in scope + +Historical prices (a non-goal of the PRD). diff --git a/pricing/pricefeed/go.mod b/pricing/pricefeed/go.mod new file mode 100644 index 000000000..cc2be5f4f --- /dev/null +++ b/pricing/pricefeed/go.mod @@ -0,0 +1,135 @@ +module github.com/smartcontractkit/capabilities/pricing/pricefeed + +go 1.27.3 + +require ( + github.com/samber/do/v2 v2.1.0 + github.com/shopspring/decimal v1.4.0 + github.com/smartcontractkit/capabilities/libs v0.0.0-20261112154143-07e64f263bce + github.com/smartcontractkit/chainlink-common v0.11.2-0.20261109175429-6cfabeb021f5 + github.com/smartcontractkit/chainlink-common/x/config v0.0.0-20261102161601-beffc93e226e + github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261103151748-aa8c64acc53c + github.com/stretchr/testify v1.12.1 + google.golang.org/protobuf v1.36.12 +) + +require ( + github.com/Masterminds/semver/v3 v3.4.0 // indirect + github.com/XSAM/otelsql v0.37.0 // indirect + github.com/bahlo/generic-list-go v0.2.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/buger/jsonparser v1.1.2 // indirect + github.com/cenkalti/backoff/v5 v5.0.3 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.1 // indirect + github.com/cloudevents/sdk-go/v2 v2.16.1 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect + github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 // indirect + github.com/go-logr/logr v1.4.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.26.0 // indirect + github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grafana/otel-profiling-go v0.5.1 // indirect + github.com/grafana/pyroscope-go v1.2.8 // indirect + github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect + github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect + github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect + github.com/hashicorp/go-plugin v1.8.0 // indirect + github.com/hashicorp/yamux v0.1.2 // indirect + github.com/huandu/go-clone v1.7.3 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/invopop/jsonschema v0.13.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgx/v5 v5.9.2 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/jmoiron/sqlx v1.4.0 // indirect + github.com/jonboulle/clockwork v0.5.0 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.18.7 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/mailru/easyjson v0.9.0 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect + github.com/mattn/go-isatty v0.0.21 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/oklog/run v1.2.0 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.4.3 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.23.2 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/procfs v0.20.1 // indirect + github.com/samber/go-type-to-string v1.8.0 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect + github.com/scylladb/go-reflectx v1.0.1 // indirect + github.com/smartcontractkit/chain-selectors v1.0.104 // indirect + github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261005132539-b7d63d5fd549 // indirect + github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b // indirect + github.com/smartcontractkit/chainlink-protos/metering/go v0.0.0-20260710151514-27b5a126dabe // indirect + github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260709145319-7782fb89eb16 // indirect + github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e // indirect + github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect + github.com/smartcontractkit/libocr v0.0.0-20260810200708-618b5bf7f342 // indirect + github.com/spf13/cobra v1.10.2 // indirect + github.com/spf13/pflag v1.0.10 // indirect + github.com/stellar/go-stellar-sdk v0.4.0 // indirect + github.com/stellar/go-xdr v0.0.0-20260312225820-cc2b0611aabf // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + github.com/x448/float16 v0.8.4 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/bridges/prometheus v0.68.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect + go.opentelemetry.io/otel v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.22.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.22.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.22.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0 // indirect + go.opentelemetry.io/otel/log v0.22.0 // indirect + go.opentelemetry.io/otel/metric v1.46.0 // indirect + go.opentelemetry.io/otel/sdk v1.46.0 // indirect + go.opentelemetry.io/otel/sdk/log v0.22.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.46.0 // indirect + go.opentelemetry.io/otel/trace v1.46.0 // indirect + go.opentelemetry.io/proto/otlp v1.11.0 // indirect + go.uber.org/goleak v1.3.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.28.0 // indirect + go.yaml.in/yaml/v2 v2.4.4 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect + golang.org/x/crypto v0.55.0 // indirect + golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a // indirect + golang.org/x/mod v0.38.0 // indirect + golang.org/x/net v0.58.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/text v0.41.0 // indirect + golang.org/x/time v0.15.0 // indirect + golang.org/x/tools v0.48.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect + google.golang.org/grpc v1.83.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect +) diff --git a/pricing/pricefeed/go.sum b/pricing/pricefeed/go.sum new file mode 100644 index 000000000..0a7ce547e --- /dev/null +++ b/pricing/pricefeed/go.sum @@ -0,0 +1,470 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/XSAM/otelsql v0.37.0 h1:ya5RNw028JW0eJW8Ma4AmoKxAYsJSGuNVbC7F1J457A= +github.com/XSAM/otelsql v0.37.0/go.mod h1:LHbCu49iU8p255nCn1oi04oX2UjSoRcUMiKEHo2a5qM= +github.com/apache/arrow-go/v18 v18.3.1 h1:oYZT8FqONiK74JhlH3WKVv+2NKYoyZ7C2ioD4Dj3ixk= +github.com/apache/arrow-go/v18 v18.3.1/go.mod h1:12QBya5JZT6PnBihi5NJTzbACrDGXYkrgjujz3MRQXU= +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk= +github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= +github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.1 h1:nLaJZcVAnaqch3K83AyzHfY2DmQM18/L7jvkmKSfkpI= +github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.1/go.mod h1:6Q+F2puKpJ6zWv+R02BVnizJICf7++oRT5zwpZQAsbk= +github.com/cloudevents/sdk-go/v2 v2.16.1 h1:G91iUdqvl88BZ1GYYr9vScTj5zzXSyEuqbfE63gbu9Q= +github.com/cloudevents/sdk-go/v2 v2.16.1/go.mod h1:v/kVOaWjNfbvc6tkhhlkhvLapj8Aa8kvXiH5GiOHCKI= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= +github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 h1:F8d1AJ6M9UQCavhwmO6ZsrYLfG8zVFWfEfMS2MXPkSY= +github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= +github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= +github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= +github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= +github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= +github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8= +github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls= +github.com/grafana/pyroscope-go v1.2.8 h1:UvCwIhlx9DeV7F6TW/z8q1Mi4PIm3vuUJ2ZlCEvmA4M= +github.com/grafana/pyroscope-go v1.2.8/go.mod h1:SSi59eQ1/zmKoY/BKwa5rSFsJaq+242Bcrr4wPix1g8= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9 h1:c1Us8i6eSmkW+Ez05d3co8kasnuOY813tbMN8i/a3Og= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= +github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpSQwGEnkcRpTqNOIR6bJbR0gAorgP9CSALpRcKoAA= +github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1/go.mod h1:lXGCsh6c22WGtjr+qGHj1otzZpV/1kwTMAqkwZsnWRU= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 h1:sGm2vDRFUrQJO/Veii4h4zG2vvqG6uWNkBHSTqXOZk0= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2/go.mod h1:wd1YpapPLivG6nQgbf7ZkG1hhSOXDhhn4MLTknx2aAc= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-plugin v1.8.0 h1:ie8S6RRY8RvB2usYZv+AAZ/wBvx2AU5p5QeP5j/FORs= +github.com/hashicorp/go-plugin v1.8.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8= +github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= +github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= +github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= +github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= +github.com/huandu/go-clone v1.7.3 h1:rtQODA+ABThEn6J5LBTppJfKmZy/FwfpMUWa8d01TTQ= +github.com/huandu/go-clone v1.7.3/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= +github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw= +github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jhump/protoreflect v1.18.1 h1:h4odAaLg9wyn7yHxMF7sSkJ7JfLwK1oy37/1Pi212GE= +github.com/jhump/protoreflect v1.18.1/go.mod h1:I2yar2oJEMf0k4EMryPzfV0tvGwN/SejJziYBOpETQo= +github.com/jhump/protoreflect/v2 v2.0.0-beta.2 h1:qZU+rEZUOYTz1Bnhi3xbwn+VxdXkLVeEpAeZzVXLY88= +github.com/jhump/protoreflect/v2 v2.0.0-beta.2/go.mod h1:4tnOYkB/mq7QTyS3YKtVtNrJv4Psqout8HA1U+hZtgM= +github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= +github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= +github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I= +github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw= +github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= +github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= +github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= +github.com/marcboeker/go-duckdb v1.8.5 h1:tkYp+TANippy0DaIOP5OEfBEwbUINqiFqgwMQ44jME0= +github.com/marcboeker/go-duckdb v1.8.5/go.mod h1:6mK7+WQE4P4u5AFLvVBmhFxY5fvhymFptghgJX6B+/8= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= +github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= +github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E= +github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= +github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= +github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= +github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/samber/do/v2 v2.1.0 h1:lqCHn05XvY3VqwxvZDQPSkH+jIGWSVHUrSVLEbPOopo= +github.com/samber/do/v2 v2.1.0/go.mod h1:wJBoiaZcUZyGuraOhfz15b517ZMogGs+U03DvnqvT6Q= +github.com/samber/go-type-to-string v1.8.0 h1:5z6tDTjtXxkIAoAuHAZYMYR8mkBZjVgeSH7jcSLqc8w= +github.com/samber/go-type-to-string v1.8.0/go.mod h1:jpU77vIDoIxkahknKDoEx9C8bQ1ADnh2sotZ8I4QqBU= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= +github.com/scylladb/go-reflectx v1.0.1 h1:b917wZM7189pZdlND9PbIJ6NQxfDPfBvUaQ7cjj1iZQ= +github.com/scylladb/go-reflectx v1.0.1/go.mod h1:rWnOfDIRWBGN0miMLIcoPt/Dhi2doCMZqwMCJ3KupFc= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= +github.com/smartcontractkit/capabilities/libs v0.0.0-20261112154143-07e64f263bce h1:gM5DO9ySBvz3A7agNyWJ7TtW7DRi0mgYgMA4JfJpetE= +github.com/smartcontractkit/capabilities/libs v0.0.0-20261112154143-07e64f263bce/go.mod h1:uVvhpE89qf87sqGbVBA70OVB1bPmoIeV8MBg2i+1GGA= +github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= +github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= +github.com/smartcontractkit/chainlink-common v0.11.2-0.20261109175429-6cfabeb021f5 h1:Cj961mniheL67OHGDMUhLigVtQXFv5GKisXYCP6Ad/I= +github.com/smartcontractkit/chainlink-common v0.11.2-0.20261109175429-6cfabeb021f5/go.mod h1:hdp2bQBzIDJt3UhXKnLz4OMHpsOW54Z9E9Txx4SVC8w= +github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261005132539-b7d63d5fd549 h1:J4vYRJxkBO8Yf//17wScKjYWmS45VZaFWx0zt+4ETEU= +github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261005132539-b7d63d5fd549/go.mod h1:Scyk7O80fde5rJF3Ty3fEE3xiS6j84eWbu8/2gl3pIY= +github.com/smartcontractkit/chainlink-common/x/config v0.0.0-20261102161601-beffc93e226e h1:zuim5QLXqDGW8R74eWIFpfr0XmWRPi96onpxNXUSMsY= +github.com/smartcontractkit/chainlink-common/x/config v0.0.0-20261102161601-beffc93e226e/go.mod h1:D0u/3Ne/7FR3+2TYf9uMkorU2RldtQMKWcCnBghqNaw= +github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261103151748-aa8c64acc53c h1:vt2LhimyZm6zPN46kGKlaRUmIiVbv+8VrPT7Hh4raAI= +github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261103151748-aa8c64acc53c/go.mod h1:/i8hjTPFdVWHiY+QjeSiVS2Z3GB3WAZznGgXHstC02E= +github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b h1:QuI6SmQFK/zyUlVWEf0GMkiUYBPY4lssn26nKSd/bOM= +github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b/go.mod h1:qSTSwX3cBP3FKQwQacdjArqv0g6QnukjV4XuzO6UyoY= +github.com/smartcontractkit/chainlink-protos/metering/go v0.0.0-20260710151514-27b5a126dabe h1:MDnY5wQbWTpFdDnMRicEnoMfSP5nM/KncARr4skP1ug= +github.com/smartcontractkit/chainlink-protos/metering/go v0.0.0-20260710151514-27b5a126dabe/go.mod h1:z7lx7wI3XZ4u9kmUtAVdwn1BCC9T8aieWSDcuDgPTdQ= +github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260709145319-7782fb89eb16 h1:/vkKPJoweLkRd56V4YHGRAtTG4+/JAlgklGEfvH6l4c= +github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260709145319-7782fb89eb16/go.mod h1:dkR2uYg9XYJuT1JASkPzWE51jjFkVb86P7a/yXe5/GM= +github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e h1:Hv9Mww35LrufCdM9wtS9yVi/rEWGI1UnjHbcKKU0nVY= +github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= +github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= +github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= +github.com/smartcontractkit/libocr v0.0.0-20260810200708-618b5bf7f342 h1:pEcgcjTGA83MzpqbTbyIg9AJrOs62s77SooDdJGIg9w= +github.com/smartcontractkit/libocr v0.0.0-20260810200708-618b5bf7f342/go.mod h1:5JPtsRwjugpyfsdEALC4RopfvohqK/G+3DHaR8uv+Bc= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stellar/go-stellar-sdk v0.4.0 h1:WBLeJk7EllU7WhwrTH1L5Mu2EhZor/xy5sVi/82JzNQ= +github.com/stellar/go-stellar-sdk v0.4.0/go.mod h1:tLKAQPxa2I5UvGMabBbUXcY3fmgYnfDudrMeK7CDX4w= +github.com/stellar/go-xdr v0.0.0-20260312225820-cc2b0611aabf h1:GY1RVbX3Hg7poPXEf6yojjP0hyypvgUgZmCqQU9D0xg= +github.com/stellar/go-xdr v0.0.0-20260312225820-cc2b0611aabf/go.mod h1:If+U9Z1W5xU97VrOgJandQT+2dN7/iOpkCrxBJEyF80= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xdrpp/goxdr v0.1.1 h1:E1B2c6E8eYhOVyd7yEpOyopzTPirUeF6mVOfXfGyJyc= +github.com/xdrpp/goxdr v0.1.1/go.mod h1:dXo1scL/l6s7iME1gxHWo2XCppbHEKZS7m/KyYWkNzA= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/bridges/prometheus v0.68.0 h1:w3zlHYETbDwXyWHZlyyR58ZC39XGi8rAhkBgUgJ9d5w= +go.opentelemetry.io/contrib/bridges/prometheus v0.68.0/go.mod h1:GR/mClR2nn7vE8RLwxKjoBNg+QtgdDhRzxVa93koy5o= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 h1:oECp5f+hN7nkwjU/8BxQ/q23bGPb8FIrD839owX222E= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0/go.mod h1:DqEFwLumhzMBDQv9PcWbyoDxHI/4lAk6CM4nJBH39sc= +go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= +go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc= +go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.22.0 h1:Bu39F5tzJct+f2IZbB8989fwyTps3c8e7EsUQsz+vs8= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.22.0/go.mod h1:dJUwod88EsFgYCqrDHaSPzhiY9pBUpt0d85/qSfua7k= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.22.0 h1:lYk7RmxdLK865qLwibroNGldHa1U7SWKYYvNjlK7PIo= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.22.0/go.mod h1:6GvlND0H0xdUJanOtIAn0xfwLkauh1tmsYEEVSMDdqY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0 h1:qkDYCAFiZXLcs1L4aY+tP2wguQ4kURANqHOQMA2et2s= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0/go.mod h1:tkipS4DRzmpAmvg+Gw4++O1IdDq6TVDnvnYU6cmbQVs= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0 h1:AP23h/mFgb/lc7tdck1Kfn9qxsM8TAeNPCU5C3pzaps= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0/go.mod h1:K4EqCe1b4kGk5WR690ntg9LaBfsPoV32FwthbyoptuA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 h1:OFnwLJr+pF3iHrlGSzbxyuo6/6HyBlnlN1CWEJmBVcw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0/go.mod h1:716wFneO0ov19A2beH5hjfh9AK5z/VWNAtDijp1Y0/g= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 h1:w53CDeOA/Kurp7yRsegSr6pbbr759dOvJ+yNmWM6Hxs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0/go.mod h1:BOmGMCbAtvcJiSJ+hLuhgPLdDbimnraSl8irz3iY8sY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.46.0 h1:KrC1YrQeSt46ITMWAbgQx1M1eV1/1TKzttrBzymPmss= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.46.0/go.mod h1:zDSEzoEqsOrgBeGvH66KRgxh90VonFyJqBHA0Pk3+rM= +go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.22.0 h1:kvMAiLEudKmk+CSG+iYbU8vTUGNNDaf/V09OO5lrTwI= +go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.22.0/go.mod h1:L9Dlksri+MdT1cb2gIiA1cJJYW3Y92ipvDjNxYEyaDI= +go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0 h1:PR9eAf7o0dQs3hshZNZpE9aW2dXWX/KdDf6pJilVD3U= +go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0/go.mod h1:2Z4KyNdH1uuzivdinyfGsxzNNT/Rl45pwtVwfYVI0xk= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0 h1:KdRxPiAoMptR3vfWzvjjvutTsSiwbC2uG0496rzZNfo= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0/go.mod h1:K/qSA+3G7Eovxi4K09wzrAgkWRnosS0DAOZeEpve7sM= +go.opentelemetry.io/otel/log v0.22.0 h1:5DBNnfvaJ6CVdkJ+Jle8Tzs50aSSv49TXGj9XRsEYw0= +go.opentelemetry.io/otel/log v0.22.0/go.mod h1:gzOt/R67vF2GniAqWu8Qv0SXy89f71muHcrkz76PCdc= +go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= +go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8= +go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o= +go.opentelemetry.io/otel/metric/x v0.68.0 h1:TA/cBT23D3MnxYPwHL7YFOdYGdx0A0v+s7Mzotpd1dU= +go.opentelemetry.io/otel/metric/x v0.68.0/go.mod h1:agudOmvWhwUTjgibWDzxD2PoWYnpw5Ht5jISYOD2Hd4= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI= +go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM= +go.opentelemetry.io/otel/sdk/log v0.22.0 h1:PRL+s6P63XT4E/bheEflopPUpVxuvANqZwtt89yhoGk= +go.opentelemetry.io/otel/sdk/log v0.22.0/go.mod h1:JNp0sBELrjCTcu5W3GzABVypeU6vDJjBS+X0JISuz+g= +go.opentelemetry.io/otel/sdk/log/logtest v0.22.0 h1:infPnfNrhCNgOUZRs3gWUg8vhoBUHihq02gwK05gzlg= +go.opentelemetry.io/otel/sdk/log/logtest v0.22.0/go.mod h1:gkQZA3z15Bv3KU9vigBTi8dFechSozRP7v94X4VZv+s= +go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE= +go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4= +go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c= +go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI= +go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk= +go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= +go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a h1:+3jdDGGB8NGb1Zktc737jlt3/A5f6UlwSzmvqUuufxw= +golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a/go.mod h1:d2fgXJLVs4dYDHUk5lwMIfzRzSrWCfGZb0ZqeLa/Vcw= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/telemetry v0.0.0-20260708182218-49f421fb7959 h1:RJhm5l6Fo4rmEIcndxDllNhhf/fAx8qIm4t6A7vpm2A= +golang.org/x/telemetry v0.0.0-20260708182218-49f421fb7959/go.mod h1:LV7u5Oco+Z/g6XI7PqN+EUUUGGkEcmB1uj2ceI0fOVg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= +golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20210401141331-865547bb08e2/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI= +google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/pricing/pricefeed/main.go b/pricing/pricefeed/main.go new file mode 100644 index 000000000..54c787dee --- /dev/null +++ b/pricing/pricefeed/main.go @@ -0,0 +1,12 @@ +package main + +//go:generate go run . docgen + +import ( + "github.com/smartcontractkit/capabilities/libs/capability" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/service" +) + +func main() { + capability.Run("pricefeed", service.New) +} diff --git a/pricing/pricefeed/project.json b/pricing/pricefeed/project.json new file mode 100644 index 000000000..9d61ce537 --- /dev/null +++ b/pricing/pricefeed/project.json @@ -0,0 +1,60 @@ +{ + "name": "pricing-pricefeed", + "projectType": "capability", + "implicitDependencies": ["capability"], + "tags": [], + "targets": { + "lint": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "golangci-lint run ./..." + } + }, + "test": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "go test ./... -coverpkg=./... -coverprofile=coverage.txt" + } + }, + "race": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "go test -race ./..." + } + }, + "tidy": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "go mod tidy" + } + }, + "update-libs": {}, + "build": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "commands": [ + "CGO_ENABLED='0' GOOS='linux' GOARCH='amd64' go build -o {workspaceRoot}/bin/amd64/{projectName} .", + "CGO_ENABLED='0' GOOS='linux' GOARCH='arm64' go build -o {workspaceRoot}/bin/arm64/{projectName} ." + ] + } + }, + "generate": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "commands": [ + "grep -rl \"^// Code generated by \"| xargs -r rm", + "go generate -x ./protos/...", + "go generate -x ./..." + ], + "parallel": false + } + } + } +} + diff --git a/pricing/pricefeed/protos/client.pb.go b/pricing/pricefeed/protos/client.pb.go new file mode 100644 index 000000000..da4a0c963 --- /dev/null +++ b/pricing/pricefeed/protos/client.pb.go @@ -0,0 +1,209 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.12 +// protoc v5.29.3 +// source: capabilities/pricing/pricefeed/x/v1/client.proto + +package protos + +import ( + _ "github.com/smartcontractkit/capabilities/libs/capability/feature" + _ "github.com/smartcontractkit/chainlink-protos/cre/go/tools/generator" + pb "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GetPriceRequest asks for the current price of one ticker. +type GetPriceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ticker is the pair to price, as BASE-QUOTE, such as BTC-USD. The separator can also be "/" or "_", and the case + // does not matter: the pair is normalised to upper case BASE-QUOTE. + Ticker string `protobuf:"bytes,1,opt,name=ticker,proto3" json:"ticker,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPriceRequest) Reset() { + *x = GetPriceRequest{} + mi := &file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPriceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPriceRequest) ProtoMessage() {} + +func (x *GetPriceRequest) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPriceRequest.ProtoReflect.Descriptor instead. +func (*GetPriceRequest) Descriptor() ([]byte, []int) { + return file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescGZIP(), []int{0} +} + +func (x *GetPriceRequest) GetTicker() string { + if x != nil { + return x.Ticker + } + return "" +} + +// GetPriceResponse is the current price of a ticker, as one node fetched it. Workflows reach consensus on it across +// nodes, such as with the median of price and timestamp. +type GetPriceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ticker is the normalised pair the price is for, such as BTC-USD. + Ticker string `protobuf:"bytes,1,opt,name=ticker,proto3" json:"ticker,omitempty"` + // price is the amount of the quote currency one unit of the base currency costs. It is a decimal, so no precision + // is lost. + Price *pb.Decimal `protobuf:"bytes,2,opt,name=price,proto3" json:"price,omitempty"` + // timestamp is when the provider observed the price. For a provider that does not give one, it is when the node + // received the price. + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPriceResponse) Reset() { + *x = GetPriceResponse{} + mi := &file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPriceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPriceResponse) ProtoMessage() {} + +func (x *GetPriceResponse) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPriceResponse.ProtoReflect.Descriptor instead. +func (*GetPriceResponse) Descriptor() ([]byte, []int) { + return file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescGZIP(), []int{1} +} + +func (x *GetPriceResponse) GetTicker() string { + if x != nil { + return x.Ticker + } + return "" +} + +func (x *GetPriceResponse) GetPrice() *pb.Decimal { + if x != nil { + return x.Price + } + return nil +} + +func (x *GetPriceResponse) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +var File_capabilities_pricing_pricefeed_x_v1_client_proto protoreflect.FileDescriptor + +const file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDesc = "" + + "\n" + + "0capabilities/pricing/pricefeed/x/v1/client.proto\x12#capabilities.pricing.pricefeed.x.v1\x1a capability/feature/feature.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a*tools/generator/v1alpha/cre_metadata.proto\x1a\x16values/v1/values.proto\"4\n" + + "\x0fGetPriceRequest\x12!\n" + + "\x06ticker\x18\x01 \x01(\tB\t\xa2\xbb\x18\x05priceR\x06ticker\"\xaf\x01\n" + + "\x10GetPriceResponse\x12!\n" + + "\x06ticker\x18\x01 \x01(\tB\t\xa2\xbb\x18\x05priceR\x06ticker\x123\n" + + "\x05price\x18\x02 \x01(\v2\x12.values.v1.DecimalB\t\xa2\xbb\x18\x05priceR\x05price\x12C\n" + + "\ttimestamp\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampB\t\xa2\xbb\x18\x05priceR\ttimestamp2\xad\x01\n" + + "\x06Client\x12\x82\x01\n" + + "\bGetPrice\x124.capabilities.pricing.pricefeed.x.v1.GetPriceRequest\x1a5.capabilities.pricing.pricefeed.x.v1.GetPriceResponse\"\t\xaa\xbb\x18\x05price\x1a\x1e\x82\xb5\x18\x1a\b\x02\x12\x16price-feed@1.0.0-alphaB\t\xb2\xbb\x18\x05priceb\x06proto3" + +var ( + file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescOnce sync.Once + file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescData []byte +) + +func file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescGZIP() []byte { + file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescOnce.Do(func() { + file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDesc), len(file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDesc))) + }) + return file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDescData +} + +var file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_capabilities_pricing_pricefeed_x_v1_client_proto_goTypes = []any{ + (*GetPriceRequest)(nil), // 0: capabilities.pricing.pricefeed.x.v1.GetPriceRequest + (*GetPriceResponse)(nil), // 1: capabilities.pricing.pricefeed.x.v1.GetPriceResponse + (*pb.Decimal)(nil), // 2: values.v1.Decimal + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_capabilities_pricing_pricefeed_x_v1_client_proto_depIdxs = []int32{ + 2, // 0: capabilities.pricing.pricefeed.x.v1.GetPriceResponse.price:type_name -> values.v1.Decimal + 3, // 1: capabilities.pricing.pricefeed.x.v1.GetPriceResponse.timestamp:type_name -> google.protobuf.Timestamp + 0, // 2: capabilities.pricing.pricefeed.x.v1.Client.GetPrice:input_type -> capabilities.pricing.pricefeed.x.v1.GetPriceRequest + 1, // 3: capabilities.pricing.pricefeed.x.v1.Client.GetPrice:output_type -> capabilities.pricing.pricefeed.x.v1.GetPriceResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_capabilities_pricing_pricefeed_x_v1_client_proto_init() } +func file_capabilities_pricing_pricefeed_x_v1_client_proto_init() { + if File_capabilities_pricing_pricefeed_x_v1_client_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDesc), len(file_capabilities_pricing_pricefeed_x_v1_client_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_capabilities_pricing_pricefeed_x_v1_client_proto_goTypes, + DependencyIndexes: file_capabilities_pricing_pricefeed_x_v1_client_proto_depIdxs, + MessageInfos: file_capabilities_pricing_pricefeed_x_v1_client_proto_msgTypes, + }.Build() + File_capabilities_pricing_pricefeed_x_v1_client_proto = out.File + file_capabilities_pricing_pricefeed_x_v1_client_proto_goTypes = nil + file_capabilities_pricing_pricefeed_x_v1_client_proto_depIdxs = nil +} diff --git a/pricing/pricefeed/protos/client.proto b/pricing/pricefeed/protos/client.proto new file mode 100644 index 000000000..812c958e3 --- /dev/null +++ b/pricing/pricefeed/protos/client.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package capabilities.pricing.pricefeed.x.v1; + +import "capability/feature/feature.proto"; +import "google/protobuf/timestamp.proto"; +import "tools/generator/v1alpha/cre_metadata.proto"; +import "values/v1/values.proto"; + +option (cre.feature.v1.released) = "price"; + +// GetPriceRequest asks for the current price of one ticker. +message GetPriceRequest { + // ticker is the pair to price, as BASE-QUOTE, such as BTC-USD. The separator can also be "/" or "_", and the case + // does not matter: the pair is normalised to upper case BASE-QUOTE. + string ticker = 1 [(cre.feature.v1.field) = "price"]; +} + +// GetPriceResponse is the current price of a ticker, as one node fetched it. Workflows reach consensus on it across +// nodes, such as with the median of price and timestamp. +message GetPriceResponse { + // ticker is the normalised pair the price is for, such as BTC-USD. + string ticker = 1 [(cre.feature.v1.field) = "price"]; + // price is the amount of the quote currency one unit of the base currency costs. It is a decimal, so no precision + // is lost. + values.v1.Decimal price = 2 [(cre.feature.v1.field) = "price"]; + // timestamp is when the provider observed the price. For a provider that does not give one, it is when the node + // received the price. + google.protobuf.Timestamp timestamp = 3 [(cre.feature.v1.field) = "price"]; +} + +// Client fetches current cryptocurrency prices from the provider the node operator configured, so workflows need +// no API keys of their own. +service Client { + option (tools.generator.v1alpha.capability) = { + mode: MODE_NODE + capability_id: "price-feed@1.0.0-alpha" + }; + + // GetPrice returns the current price of a ticker. + rpc GetPrice(GetPriceRequest) returns (GetPriceResponse) { + option (cre.feature.v1.method) = "price"; + } +} diff --git a/pricing/pricefeed/protos/client_server_gen.go b/pricing/pricefeed/protos/client_server_gen.go new file mode 100644 index 000000000..373918b51 --- /dev/null +++ b/pricing/pricefeed/protos/client_server_gen.go @@ -0,0 +1,113 @@ +// Code generated by github.com/smartcontractkit/capabilities/libs/capability/cmd/protoc-gen-cre, DO NOT EDIT. + +package protos + +import ( + "context" + "fmt" + "sync" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + caperrors "github.com/smartcontractkit/chainlink-common/pkg/capabilities/errors" + + "github.com/smartcontractkit/capabilities/libs/capability" + "github.com/smartcontractkit/capabilities/libs/capability/feature" + "github.com/smartcontractkit/capabilities/libs/capability/server" +) + +// Requests are read with feature.UnmarshalAny, so a capability built from its development protos serves requests +// made with its production protos too, and replies with the kind of message the request was. + +type ClientCapability interface { + GetPrice(ctx context.Context, metadata capabilities.RequestMetadata, input *GetPriceRequest) (*capabilities.ResponseAndMetadata[*GetPriceResponse], caperrors.Error) + + Start(ctx context.Context) error + Close() error + HealthReport() map[string]error + Name() string + Description() string + Ready() error +} + +func NewClientServer(capability ClientCapability) *ClientServer { + stopCh := make(chan struct{}) + return &ClientServer{ + clientCapability: clientCapability{ClientCapability: capability, stopCh: stopCh}, + stopCh: stopCh, + } +} + +// ClientServer serves a ClientCapability as a capability.Capability. +type ClientServer struct { + clientCapability + stopCh chan struct{} + stop sync.Once +} + +// Close stops answering registered triggers, then closes the capability. +func (c *ClientServer) Close() error { + c.stop.Do(func() { close(c.stopCh) }) + + return c.clientCapability.Close() +} + +type clientCapability struct { + ClientCapability + stopCh chan struct{} +} + +func (c *clientCapability) Info(ctx context.Context) (capabilities.CapabilityInfo, error) { + return capabilities.NewCapabilityInfo("price-feed@1.0.0-alpha", capabilities.CapabilityTypeCombined, c.ClientCapability.Description()) +} + +var _ capabilities.ExecutableAndTriggerCapability = (*clientCapability)(nil) + +const ClientID = "price-feed@1.0.0-alpha" + +func (c *clientCapability) Methods() []capability.Method { + return []capability.Method{ + {Name: "GetPrice", Trigger: false, Input: &GetPriceRequest{}, Output: &GetPriceResponse{}}, + } +} + +func (c *clientCapability) RegisterTrigger(ctx context.Context, request capabilities.TriggerRegistrationRequest) (<-chan capabilities.TriggerResponse, error) { + return nil, fmt.Errorf("trigger %s not found", request.Method) +} + +func (c *clientCapability) UnregisterTrigger(ctx context.Context, request capabilities.TriggerRegistrationRequest) error { + return fmt.Errorf("trigger %s not found", request.Method) +} + +func (c *clientCapability) AckEvent(ctx context.Context, triggerId string, eventId string, method string) error { + return fmt.Errorf("trigger %s not found", method) +} + +func (c *clientCapability) RegisterToWorkflow(ctx context.Context, request capabilities.RegisterToWorkflowRequest) error { + return nil +} + +func (c *clientCapability) UnregisterFromWorkflow(ctx context.Context, request capabilities.UnregisterFromWorkflowRequest) error { + return nil +} + +func (c *clientCapability) Execute(ctx context.Context, request capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { + ctx = request.Metadata.ContextWithCRE(ctx) + switch request.Method { + case "GetPrice": + input := &GetPriceRequest{} + production, err := feature.UnmarshalAny(request.Payload, input) + if err != nil { + return capabilities.CapabilityResponse{}, fmt.Errorf("failed to read the request: %w", err) + } + output, caperr := c.ClientCapability.GetPrice(ctx, request.Metadata, input) + if caperr != nil { + return capabilities.CapabilityResponse{}, caperr + } + if output == nil || output.Response == nil { + return capabilities.CapabilityResponse{}, fmt.Errorf("GetPrice returned neither a response nor an error") + } + return server.Respond(output.Response, production, output.ResponseMetadata, output.OCRAttestation) + default: + return capabilities.CapabilityResponse{}, fmt.Errorf("method %s not found", request.Method) + } +} diff --git a/pricing/pricefeed/protos/generate.go b/pricing/pricefeed/protos/generate.go new file mode 100644 index 000000000..62b0d2a31 --- /dev/null +++ b/pricing/pricefeed/protos/generate.go @@ -0,0 +1,2 @@ +//go:generate go run github.com/smartcontractkit/capabilities/libs/capability/cmd/protoc +package protos diff --git a/pricing/pricefeed/protos/production/capabilities/pricing/pricefeed/v1/client.proto b/pricing/pricefeed/protos/production/capabilities/pricing/pricefeed/v1/client.proto new file mode 100644 index 000000000..c664c8de2 --- /dev/null +++ b/pricing/pricefeed/protos/production/capabilities/pricing/pricefeed/v1/client.proto @@ -0,0 +1,42 @@ +// Code generated by protoc-gen-cre. DO NOT EDIT. + +syntax = "proto3"; + +package capabilities.pricing.pricefeed.v1; + +import "google/protobuf/timestamp.proto"; + +import "tools/generator/v1alpha/cre_metadata.proto"; + +import "values/v1/values.proto"; + +// GetPriceRequest asks for the current price of one ticker. +message GetPriceRequest { + // ticker is the pair to price, as BASE-QUOTE, such as BTC-USD. The separator can also be "/" or "_", and the case + // does not matter: the pair is normalised to upper case BASE-QUOTE. + string ticker = 1; +} + +// GetPriceResponse is the current price of a ticker, as one node fetched it. Workflows reach consensus on it across +// nodes, such as with the median of price and timestamp. +message GetPriceResponse { + // ticker is the normalised pair the price is for, such as BTC-USD. + string ticker = 1; + + // price is the amount of the quote currency one unit of the base currency costs. It is a decimal, so no precision + // is lost. + values.v1.Decimal price = 2; + + // timestamp is when the provider observed the price. For a provider that does not give one, it is when the node + // received the price. + google.protobuf.Timestamp timestamp = 3; +} + +// Client fetches current cryptocurrency prices from the provider the node operator configured, so workflows need +// no API keys of their own. +service Client { + option (tools.generator.v1alpha.capability) = { mode: MODE_NODE, capability_id: "price-feed@1.0.0-alpha" }; + + // GetPrice returns the current price of a ticker. + rpc GetPrice ( GetPriceRequest ) returns ( GetPriceResponse ); +} diff --git a/pricing/pricefeed/protos/protostest/client_instances_gen.go b/pricing/pricefeed/protos/protostest/client_instances_gen.go new file mode 100644 index 000000000..14efe017d --- /dev/null +++ b/pricing/pricefeed/protos/protostest/client_instances_gen.go @@ -0,0 +1,21 @@ +// Code generated by github.com/smartcontractkit/capabilities/libs/capability/cmd/protoc-gen-cre, DO NOT EDIT. + +package protostest + +import ( + "context" + + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + + "github.com/smartcontractkit/capabilities/libs/capability/instances" +) + +// ClientInstances calls each method on every instance at once, checking that they agree. A node capability +// has one. +type ClientInstances []*protos.ClientServer + +func (s ClientInstances) GetPrice(ctx context.Context, metadata capabilities.RequestMetadata, input *protos.GetPriceRequest) (*capabilities.ResponseAndMetadata[*protos.GetPriceResponse], error) { + return instances.TypedExecute[*protos.GetPriceResponse](ctx, s, "GetPrice", metadata, input) +} diff --git a/pricing/pricefeed/provider/coinbase.go b/pricing/pricefeed/provider/coinbase.go new file mode 100644 index 000000000..c143a74d7 --- /dev/null +++ b/pricing/pricefeed/provider/coinbase.go @@ -0,0 +1,126 @@ +package provider + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + "time" + + "github.com/shopspring/decimal" +) + +// CoinbaseURL is the Coinbase API's production URL. +const CoinbaseURL = "https://api.coinbase.com" + +// Coinbase fetches spot prices from the Coinbase Price API, which needs no API key: +// https://docs.cdp.coinbase.com/coinbase-app/track-apis/prices +type Coinbase struct { + baseURL *url.URL + client *http.Client + now func() time.Time +} + +// NewCoinbase returns a Coinbase provider for the API at baseURL, such as CoinbaseURL. +func NewCoinbase(baseURL string, client *http.Client) (*Coinbase, error) { + u, err := parseBaseURL(baseURL) + if err != nil { + return nil, err + } + + return &Coinbase{baseURL: u, client: client, now: time.Now}, nil +} + +func (c *Coinbase) Name() string { return "coinbase" } + +type coinbaseResponse struct { + Data *struct { + Amount string `json:"amount"` + Base string `json:"base"` + Currency string `json:"currency"` + } `json:"data"` + Errors []struct { + ID string `json:"id"` + Message string `json:"message"` + } `json:"errors"` + // Message is how some errors, such as an unknown pair, are given instead of Errors. + Message string `json:"message"` +} + +// Price returns the spot price of ticker. The Price API does not say when it observed the price, so its timestamp +// is when the response was received. +func (c *Coinbase) Price(ctx context.Context, ticker Ticker) (Quote, error) { + u := c.baseURL.JoinPath("v2", "prices", ticker.String(), "spot") + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) + if err != nil { + return Quote{}, err + } + + req.Header.Set("Accept", "application/json") + status, body, err := get(c.client, req) + if err != nil { + return Quote{}, err + } + + received := c.now() + var resp coinbaseResponse + if err = json.Unmarshal(body, &resp); err != nil { + return Quote{}, fmt.Errorf("%w: status %d, invalid JSON: %w", ErrBadResponse, status, err) + } + + switch { + case status == http.StatusBadRequest || status == http.StatusNotFound: + // Coinbase answers an unknown currency with 400 or 404, and an error saying which. + return Quote{}, fmt.Errorf("%w %s: coinbase: %s", ErrUnsupportedTicker, ticker, coinbaseErrors(resp)) + case status != http.StatusOK: + return Quote{}, fmt.Errorf("%w: status %d: %s", ErrBadResponse, status, coinbaseErrors(resp)) + case resp.Data == nil: + return Quote{}, fmt.Errorf("%w: no data", ErrBadResponse) + case !strings.EqualFold(resp.Data.Base, ticker.Base) || !strings.EqualFold(resp.Data.Currency, ticker.Quote): + return Quote{}, fmt.Errorf("%w: price is for %s-%s, not %s", ErrBadResponse, resp.Data.Base, resp.Data.Currency, ticker) + } + + price, err := decimal.NewFromString(resp.Data.Amount) + if err != nil { + return Quote{}, fmt.Errorf("%w: invalid amount %q: %w", ErrBadResponse, resp.Data.Amount, err) + } + + if err = validPrice(price); err != nil { + return Quote{}, err + } + + return Quote{Price: price, Timestamp: received.UTC()}, nil +} + +func coinbaseErrors(resp coinbaseResponse) string { + if len(resp.Errors) == 0 { + if resp.Message != "" { + return resp.Message + } + + return "no error message" + } + + msgs := make([]string, len(resp.Errors)) + for i, e := range resp.Errors { + msgs[i] = e.ID + ": " + e.Message + } + + return strings.Join(msgs, "; ") +} + +// parseBaseURL parses the base URL of a provider's API, which must be absolute and http or https. +func parseBaseURL(s string) (*url.URL, error) { + u, err := url.Parse(s) + if err != nil { + return nil, fmt.Errorf("invalid URL %q: %w", s, err) + } + + if (u.Scheme != "https" && u.Scheme != "http") || u.Host == "" { + return nil, fmt.Errorf("invalid URL %q: must be an absolute http or https URL", s) + } + + return u, nil +} diff --git a/pricing/pricefeed/provider/coinbase_test.go b/pricing/pricefeed/provider/coinbase_test.go new file mode 100644 index 000000000..a1a457573 --- /dev/null +++ b/pricing/pricefeed/provider/coinbase_test.go @@ -0,0 +1,90 @@ +package provider + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var btcUSD = Ticker{Base: "BTC", Quote: "USD"} + +func newCoinbase(t *testing.T, status int, body string) *Coinbase { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodGet, r.Method) + assert.Equal(t, "/v2/prices/BTC-USD/spot", r.URL.Path) + w.WriteHeader(status) + _, _ = w.Write([]byte(body)) + })) + t.Cleanup(srv.Close) + + c, err := NewCoinbase(srv.URL, srv.Client()) + require.NoError(t, err) + return c +} + +func TestCoinbasePrice(t *testing.T) { + c := newCoinbase(t, http.StatusOK, `{"data":{"amount":"89012.345678901234","base":"BTC","currency":"USD"}}`) + now := time.Date(2026, 11, 12, 10, 0, 0, 0, time.UTC) + c.now = func() time.Time { return now } + + q, err := c.Price(t.Context(), btcUSD) + require.NoError(t, err) + assert.True(t, decimal.RequireFromString("89012.345678901234").Equal(q.Price), q.Price.String()) + assert.Equal(t, now, q.Timestamp) + assert.Equal(t, "coinbase", c.Name()) +} + +func TestCoinbaseErrors(t *testing.T) { + for name, tc := range map[string]struct { + status int + body string + err error + msg string + }{ + "unknown currency": {http.StatusBadRequest, `{"errors":[{"id":"invalid_request","message":"Invalid base currency"}]}`, ErrUnsupportedTicker, "Invalid base currency"}, + "not found": {http.StatusNotFound, `{"errors":[{"id":"not_found","message":"Not found"}]}`, ErrUnsupportedTicker, "not_found"}, + "unknown pair": {http.StatusNotFound, `{"error":"rpc error: code = NotFound desc = not found","code":5,"message":"rpc error: code = NotFound desc = not found"}`, ErrUnsupportedTicker, "NotFound"}, + "server error": {http.StatusInternalServerError, `{"errors":[{"id":"internal","message":"boom"}]}`, ErrBadResponse, "status 500"}, + "rate limited": {http.StatusTooManyRequests, `{}`, ErrBadResponse, "no error message"}, + "not JSON": {http.StatusOK, ``, ErrBadResponse, "invalid JSON"}, + "no data": {http.StatusOK, `{}`, ErrBadResponse, "no data"}, + "wrong pair": {http.StatusOK, `{"data":{"amount":"1","base":"ETH","currency":"USD"}}`, ErrBadResponse, "not BTC-USD"}, + "not a number": {http.StatusOK, `{"data":{"amount":"lots","base":"BTC","currency":"USD"}}`, ErrBadResponse, "invalid amount"}, + "empty amount": {http.StatusOK, `{"data":{"amount":"","base":"BTC","currency":"USD"}}`, ErrBadResponse, "invalid amount"}, + "zero": {http.StatusOK, `{"data":{"amount":"0","base":"BTC","currency":"USD"}}`, ErrBadResponse, "not positive"}, + "negative": {http.StatusOK, `{"data":{"amount":"-1.5","base":"BTC","currency":"USD"}}`, ErrBadResponse, "not positive"}, + "too large": {http.StatusOK, `{"data":{"amount":"1","pad":"` + strings.Repeat("x", maxBodySize) + `"}}`, ErrBadResponse, "larger than"}, + } { + t.Run(name, func(t *testing.T) { + _, err := newCoinbase(t, tc.status, tc.body).Price(t.Context(), btcUSD) + require.ErrorIs(t, err, tc.err) + assert.ErrorContains(t, err, tc.msg) + }) + } +} + +func TestCoinbaseUnreachable(t *testing.T) { + srv := httptest.NewServer(http.NotFoundHandler()) + srv.Close() + c, err := NewCoinbase(srv.URL, srv.Client()) + require.NoError(t, err) + + _, err = c.Price(t.Context(), btcUSD) + require.Error(t, err) + assert.NotErrorIs(t, err, ErrBadResponse) + assert.NotErrorIs(t, err, ErrUnsupportedTicker) +} + +func TestNewCoinbaseInvalidURL(t *testing.T) { + for _, u := range []string{"", "api.coinbase.com", "ftp://api.coinbase.com", "://"} { + _, err := NewCoinbase(u, http.DefaultClient) + assert.Error(t, err, u) + } +} diff --git a/pricing/pricefeed/provider/dataengine.go b/pricing/pricefeed/provider/dataengine.go new file mode 100644 index 000000000..03c3cd791 --- /dev/null +++ b/pricing/pricefeed/provider/dataengine.go @@ -0,0 +1,285 @@ +package provider + +import ( + "bytes" + "context" + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "fmt" + "math/big" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/shopspring/decimal" +) + +// DataEngineURL is the Chainlink Data Engine (Data Streams) REST API's mainnet URL. +const DataEngineURL = "https://api.dataengine.chain.link" + +// dataEngineDecimals is how many decimals the prices of the report schemas DataEngine decodes have. +const dataEngineDecimals = 18 + +// DataEngine fetches the latest reports of Chainlink Data Engine (Data Streams) feeds over its REST API: +// https://docs.chain.link/data-streams/reference/data-streams-api/interface-api +type DataEngine struct { + baseURL *url.URL + client *http.Client + apiKey string + apiSecret []byte + // feedIDs are the hex IDs of the feeds, by the ticker they price. + feedIDs map[Ticker]string + now func() time.Time +} + +// NewDataEngine returns a DataEngine provider for the API at baseURL, such as DataEngineURL. It authenticates with +// apiKey and apiSecret, and prices the tickers of feedIDs, the hex IDs of feeds by their ticker, such as BTC-USD. +func NewDataEngine(baseURL, apiKey, apiSecret string, feedIDs map[string]string, client *http.Client) (*DataEngine, error) { + u, err := parseBaseURL(baseURL) + if err != nil { + return nil, err + } + + if apiKey == "" || apiSecret == "" { + return nil, fmt.Errorf("data engine needs an API key and secret") + } + + ids := make(map[Ticker]string, len(feedIDs)) + for t, id := range feedIDs { + ticker, err := ParseTicker(t) + if err != nil { + return nil, fmt.Errorf("feed of %q: %w", t, err) + } + + raw, err := decodeHex(id) + if err != nil || len(raw) != 32 { + return nil, fmt.Errorf("feed of %s: invalid feed ID %q: must be 32 bytes of hex", ticker, id) + } + + if _, ok := ids[ticker]; ok { + return nil, fmt.Errorf("feed of %s is configured more than once", ticker) + } + + ids[ticker] = "0x" + hex.EncodeToString(raw) + } + + return &DataEngine{ + baseURL: u, + client: client, + apiKey: apiKey, + apiSecret: []byte(apiSecret), + feedIDs: ids, + now: time.Now, + }, nil +} + +func (d *DataEngine) Name() string { return "dataengine" } + +type dataEngineResponse struct { + Report *struct { + FeedID string `json:"feedID"` + ObservationsTimestamp int64 `json:"observationsTimestamp"` + FullReport string `json:"fullReport"` + } `json:"report"` +} + +// Price returns the benchmark price of the latest report of ticker's feed, and the time it was observed. +func (d *DataEngine) Price(ctx context.Context, ticker Ticker) (Quote, error) { + feedID, ok := d.feedIDs[ticker] + if !ok { + return Quote{}, fmt.Errorf("%w %s: no data engine feed is configured for it", ErrUnsupportedTicker, ticker) + } + + u := d.baseURL.JoinPath("api", "v1", "reports", "latest") + u.RawQuery = url.Values{"feedID": {feedID}}.Encode() + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) + if err != nil { + return Quote{}, err + } + + d.sign(req) + status, body, err := get(d.client, req) + if err != nil { + return Quote{}, err + } + + if status != http.StatusOK { + return Quote{}, fmt.Errorf("%w: status %d: %s", ErrBadResponse, status, truncate(body)) + } + + var resp dataEngineResponse + if err = json.Unmarshal(body, &resp); err != nil { + return Quote{}, fmt.Errorf("%w: invalid JSON: %w", ErrBadResponse, err) + } + + if resp.Report == nil { + return Quote{}, fmt.Errorf("%w: no report", ErrBadResponse) + } + + if !strings.EqualFold(resp.Report.FeedID, feedID) { + return Quote{}, fmt.Errorf("%w: report is for feed %s, not %s", ErrBadResponse, resp.Report.FeedID, feedID) + } + + fullReport, err := decodeHex(resp.Report.FullReport) + if err != nil { + return Quote{}, fmt.Errorf("%w: invalid full report: %w", ErrBadResponse, err) + } + + r, err := decodeReport(fullReport) + if err != nil { + return Quote{}, fmt.Errorf("%w: %w", ErrBadResponse, err) + } + + if "0x"+hex.EncodeToString(r.feedID[:]) != feedID { + return Quote{}, fmt.Errorf("%w: signed report is for feed 0x%x, not %s", ErrBadResponse, r.feedID, feedID) + } + + price := decimal.NewFromBigInt(r.price, -dataEngineDecimals) + if err = validPrice(price); err != nil { + return Quote{}, err + } + + return Quote{Price: price, Timestamp: time.Unix(int64(r.observationsTimestamp), 0).UTC()}, nil +} + +// sign adds the HMAC headers the Data Engine API authenticates requests with. The string signed is the method, the +// path and query, the SHA-256 of the body (empty for a GET), the API key and the timestamp in milliseconds. +func (d *DataEngine) sign(req *http.Request) { + ts := strconv.FormatInt(d.now().UnixMilli(), 10) + bodyHash := sha256.Sum256(nil) + msg := strings.Join([]string{req.Method, req.URL.RequestURI(), hex.EncodeToString(bodyHash[:]), d.apiKey, ts}, " ") + + mac := hmac.New(sha256.New, d.apiSecret) + mac.Write([]byte(msg)) + + req.Header.Set("Authorization", d.apiKey) + req.Header.Set("X-Authorization-Timestamp", ts) + req.Header.Set("X-Authorization-Signature-SHA256", hex.EncodeToString(mac.Sum(nil))) + req.Header.Set("Accept", "application/json") +} + +// report is what DataEngine uses of a decoded report. +type report struct { + feedID [32]byte + observationsTimestamp uint32 + price *big.Int +} + +const word = 32 + +// Report schemas DataEngine decodes, which are the first two bytes of a feed ID. Each starts with feedId, +// validFromTimestamp, observationsTimestamp, nativeFee, linkFee and expiresAt, and has its price after them: +// benchmarkPrice for v2 and v3 (crypto), price for v4 (real world assets). +var priceSchemas = map[uint16]bool{2: true, 3: true, 4: true} + +const ( + observationsTimestampWord = 2 + priceWord = 6 +) + +// decodeReport decodes the report blob of fullReport, which is the ABI encoding of +// (bytes32[3] reportContext, bytes reportBlob, bytes32[] rawRs, bytes32[] rawSs, bytes32 rawVs). +// It does not verify the signatures: the report is from the authenticated API, and verifying is done on chain. +func decodeReport(fullReport []byte) (report, error) { + var r report + blob, err := abiBytes(fullReport, 3) + if err != nil { + return r, fmt.Errorf("invalid full report: %w", err) + } + + if len(blob) < (priceWord+1)*word { + return r, fmt.Errorf("report blob is %d bytes, too short for a price", len(blob)) + } + + copy(r.feedID[:], blob[:word]) + schema := uint16(r.feedID[0])<<8 | uint16(r.feedID[1]) + if !priceSchemas[schema] { + return r, fmt.Errorf("report schema v%d is not supported", schema) + } + + ts, err := abiUint32(blob[observationsTimestampWord*word : (observationsTimestampWord+1)*word]) + if err != nil { + return r, fmt.Errorf("invalid observationsTimestamp: %w", err) + } + + r.observationsTimestamp = ts + r.price = abiInt(blob[priceWord*word : (priceWord+1)*word]) + return r, nil +} + +// abiBytes returns the dynamic bytes argument at index i of the ABI encoded data. +func abiBytes(data []byte, i int) ([]byte, error) { + if len(data) < (i+1)*word { + return nil, fmt.Errorf("%d bytes is too short", len(data)) + } + + offset, err := abiOffset(data[i*word : (i+1)*word]) + if err != nil { + return nil, err + } + + if offset > uint64(len(data)-word) { //nolint:gosec // len(data) >= word, checked above. + return nil, fmt.Errorf("offset %d is out of range", offset) + } + + length, err := abiOffset(data[offset : offset+word]) + if err != nil { + return nil, err + } + + start := offset + word + if length > uint64(len(data))-start { + return nil, fmt.Errorf("length %d is out of range", length) + } + + return data[start : start+length], nil +} + +// abiOffset decodes a uint256 that is an offset or a length, so must fit in an int. +func abiOffset(w []byte) (uint64, error) { + v := new(big.Int).SetBytes(w) + if !v.IsUint64() || v.Uint64() > 1<<32 { + return 0, fmt.Errorf("offset or length %s is out of range", v) + } + + return v.Uint64(), nil +} + +// abiUint32 decodes a uint32 word. +func abiUint32(w []byte) (uint32, error) { + v := new(big.Int).SetBytes(w) + if !v.IsUint64() || v.Uint64() > 1<<32-1 { + return 0, fmt.Errorf("%s does not fit in a uint32", v) + } + + return uint32(v.Uint64()), nil //nolint:gosec // Checked to fit above. +} + +// abiInt decodes a signed, two's complement int word, such as an int192, which ABI encoding sign extends to a word. +func abiInt(w []byte) *big.Int { + v := new(big.Int).SetBytes(w) + if w[0]&0x80 != 0 { + v.Sub(v, new(big.Int).Lsh(big.NewInt(1), word*8)) + } + + return v +} + +func decodeHex(s string) ([]byte, error) { + return hex.DecodeString(strings.TrimPrefix(strings.TrimPrefix(s, "0x"), "0X")) +} + +// truncate returns the start of a response body, for errors. +func truncate(body []byte) string { + const maxLen = 256 + body = bytes.TrimSpace(body) + if len(body) > maxLen { + return string(body[:maxLen]) + "..." + } + + return string(body) +} diff --git a/pricing/pricefeed/provider/dataengine_test.go b/pricing/pricefeed/provider/dataengine_test.go new file mode 100644 index 000000000..a3f19d4f0 --- /dev/null +++ b/pricing/pricefeed/provider/dataengine_test.go @@ -0,0 +1,224 @@ +package provider + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "math/big" + "net/http" + "net/http/httptest" + "strconv" + "strings" + "testing" + "time" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const ( + testAPIKey = "test-key" + testAPISecret = "test-secret" + // v3 (crypto) feed IDs start with 0x0003. + btcFeedID = "0x00039d9e45394f473ab1f050a1b963e6b05351e52d71e507509ada0c95ed75b8" + ethFeedID = "0x000362205e10b3a147d02792eccee483dca6c7b44ecce7012cb8c6e0b68b3ae9" +) + +var observed = time.Date(2026, 11, 12, 10, 0, 0, 0, time.UTC) + +// u256 encodes v as an ABI word, two's complement when negative. +func u256(v *big.Int) []byte { + if v.Sign() < 0 { + v = new(big.Int).Add(v, new(big.Int).Lsh(big.NewInt(1), 256)) + } + + return v.FillBytes(make([]byte, word)) +} + +// reportBlob encodes a v2/v3/v4 report blob: feedId, validFromTimestamp, observationsTimestamp, nativeFee, linkFee, +// expiresAt, price, then extra. +func reportBlob(feedID string, ts uint32, price *big.Int, extra int) []byte { + id, _ := decodeHex(feedID) + blob := append([]byte{}, id...) + for _, v := range []*big.Int{big.NewInt(int64(ts)), big.NewInt(int64(ts)), big.NewInt(1), big.NewInt(2), big.NewInt(int64(ts) + 86400), price} { + blob = append(blob, u256(v)...) + } + + for range extra { + blob = append(blob, u256(price)...) + } + + return blob +} + +// fullReport ABI encodes (bytes32[3] reportContext, bytes reportBlob, bytes32[] rawRs, bytes32[] rawSs, bytes32 rawVs) +// with one signature. +func fullReport(blob []byte) []byte { + head := 7 * word + padded := (len(blob) + word - 1) / word * word + blobOffset := head + rsOffset := blobOffset + word + padded + ssOffset := rsOffset + 2*word + + var out []byte + for range 3 { + out = append(out, make([]byte, word)...) + } + + for _, o := range []int{blobOffset, rsOffset, ssOffset} { + out = append(out, u256(big.NewInt(int64(o)))...) + } + + out = append(out, make([]byte, word)...) // rawVs + out = append(out, u256(big.NewInt(int64(len(blob))))...) + out = append(out, blob...) + out = append(out, make([]byte, padded-len(blob))...) + for range 2 { // rs and ss, one signature each + out = append(out, u256(big.NewInt(1))...) + out = append(out, make([]byte, word)...) + } + + return out +} + +func reportResponse(feedID string, full []byte) string { + b, _ := json.Marshal(map[string]any{"report": map[string]any{ + "feedID": feedID, + "validFromTimestamp": observed.Unix(), + "observationsTimestamp": observed.Unix(), + "fullReport": "0x" + hex.EncodeToString(full), + }}) + return string(b) +} + +func e18(s string) *big.Int { + return decimal.RequireFromString(s).Shift(dataEngineDecimals).BigInt() +} + +func newDataEngine(t *testing.T, handler http.HandlerFunc) *DataEngine { + t.Helper() + srv := httptest.NewServer(handler) + t.Cleanup(srv.Close) + + d, err := NewDataEngine(srv.URL, testAPIKey, testAPISecret, map[string]string{"BTC-USD": btcFeedID, "eth/usd": ethFeedID}, srv.Client()) + require.NoError(t, err) + return d +} + +func respond(status int, body string) http.HandlerFunc { + return func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(status) + _, _ = w.Write([]byte(body)) + } +} + +func TestDataEnginePrice(t *testing.T) { + now := time.Now() + d := newDataEngine(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodGet, r.Method) + assert.Equal(t, "/api/v1/reports/latest", r.URL.Path) + assert.Equal(t, btcFeedID, r.URL.Query().Get("feedID")) + + // The request is signed as the Data Engine API documents. + assert.Equal(t, testAPIKey, r.Header.Get("Authorization")) + ts := r.Header.Get("X-Authorization-Timestamp") + assert.Equal(t, strconv.FormatInt(now.UnixMilli(), 10), ts) + emptyHash := sha256.Sum256(nil) + mac := hmac.New(sha256.New, []byte(testAPISecret)) + mac.Write([]byte("GET " + r.URL.RequestURI() + " " + hex.EncodeToString(emptyHash[:]) + " " + testAPIKey + " " + ts)) + assert.Equal(t, hex.EncodeToString(mac.Sum(nil)), r.Header.Get("X-Authorization-Signature-SHA256")) + + _, _ = w.Write([]byte(reportResponse(btcFeedID, fullReport(reportBlob(btcFeedID, uint32(observed.Unix()), e18("89012.345678901234567891"), 2))))) //nolint:gosec // A test timestamp. + }) + d.now = func() time.Time { return now } + + q, err := d.Price(t.Context(), btcUSD) + require.NoError(t, err) + assert.True(t, decimal.RequireFromString("89012.345678901234567891").Equal(q.Price), q.Price.String()) + assert.Equal(t, observed, q.Timestamp) + assert.Equal(t, "dataengine", d.Name()) +} + +func TestDataEngineSchemas(t *testing.T) { + for schema, extra := range map[string]int{"0002": 0, "0003": 2, "0004": 1} { + t.Run("v"+schema, func(t *testing.T) { + feedID := "0x" + schema + strings.Repeat("ab", 30) + srv := httptest.NewServer(respond(http.StatusOK, reportResponse(feedID, fullReport(reportBlob(feedID, uint32(observed.Unix()), e18("1.5"), extra))))) //nolint:gosec // A test timestamp. + t.Cleanup(srv.Close) + d, err := NewDataEngine(srv.URL, testAPIKey, testAPISecret, map[string]string{"XAU-USD": feedID}, srv.Client()) + require.NoError(t, err) + + q, err := d.Price(t.Context(), Ticker{Base: "XAU", Quote: "USD"}) + require.NoError(t, err) + assert.Equal(t, "1.5", q.Price.String()) + }) + } +} + +func TestDataEngineErrors(t *testing.T) { + ts := uint32(observed.Unix()) //nolint:gosec // A test timestamp. + v8FeedID := "0x0008" + strings.Repeat("ab", 30) + full := fullReport(reportBlob(btcFeedID, ts, e18("1"), 2)) + for name, tc := range map[string]struct { + handler http.HandlerFunc + msg string + }{ + "unauthorized": {respond(http.StatusUnauthorized, `{"error":"bad signature"}`), "status 401"}, + "server error": {respond(http.StatusInternalServerError, `oops`), "status 500"}, + "not JSON": {respond(http.StatusOK, ``), "invalid JSON"}, + "no report": {respond(http.StatusOK, `{}`), "no report"}, + "other feed": {respond(http.StatusOK, reportResponse(ethFeedID, full)), "not " + btcFeedID}, + "signed other feed": {respond(http.StatusOK, reportResponse(btcFeedID, fullReport(reportBlob(ethFeedID, ts, e18("1"), 2)))), "signed report is for feed"}, + "not hex": {respond(http.StatusOK, strings.Replace(reportResponse(btcFeedID, full), `"fullReport":"0x00`, `"fullReport":"0xzz`, 1)), "invalid full report"}, + "truncated": {respond(http.StatusOK, reportResponse(btcFeedID, full[:5*word])), "out of range"}, + "bad offset": {respond(http.StatusOK, reportResponse(btcFeedID, append(append(append([]byte{}, full[:3*word]...), u256(big.NewInt(1<<20))...), full[4*word:]...))), "out of range"}, + "short blob": {respond(http.StatusOK, reportResponse(btcFeedID, fullReport(reportBlob(btcFeedID, ts, e18("1"), 0)[:4*word]))), "too short for a price"}, + "unknown schema": {respond(http.StatusOK, reportResponse(btcFeedID, fullReport(reportBlob(v8FeedID, ts, e18("1"), 2)))), "schema v8"}, + "zero price": {respond(http.StatusOK, reportResponse(btcFeedID, fullReport(reportBlob(btcFeedID, ts, big.NewInt(0), 2)))), "not positive"}, + "negative price": {respond(http.StatusOK, reportResponse(btcFeedID, fullReport(reportBlob(btcFeedID, ts, e18("-2"), 2)))), "-2 is not positive"}, + } { + t.Run(name, func(t *testing.T) { + _, err := newDataEngine(t, tc.handler).Price(t.Context(), btcUSD) + require.ErrorIs(t, err, ErrBadResponse) + assert.ErrorContains(t, err, tc.msg) + }) + } +} + +func TestDataEngineUnsupportedTicker(t *testing.T) { + d := newDataEngine(t, func(http.ResponseWriter, *http.Request) { + t.Error("the API must not be called for a ticker without a feed") + }) + + _, err := d.Price(t.Context(), Ticker{Base: "DOGE", Quote: "USD"}) + require.ErrorIs(t, err, ErrUnsupportedTicker) +} + +func TestNewDataEngineInvalidConfig(t *testing.T) { + feeds := map[string]string{"BTC-USD": btcFeedID} + for name, tc := range map[string]struct { + url, key, secret string + feeds map[string]string + }{ + "invalid URL": {"nope", testAPIKey, testAPISecret, feeds}, + "no key": {DataEngineURL, "", testAPISecret, feeds}, + "no secret": {DataEngineURL, testAPIKey, "", feeds}, + "invalid ticker": {DataEngineURL, testAPIKey, testAPISecret, map[string]string{"BTCUSD": btcFeedID}}, + "invalid feed ID": {DataEngineURL, testAPIKey, testAPISecret, map[string]string{"BTC-USD": "0x1234"}}, + "not hex": {DataEngineURL, testAPIKey, testAPISecret, map[string]string{"BTC-USD": "0xzz"}}, + "duplicate": {DataEngineURL, testAPIKey, testAPISecret, map[string]string{"BTC-USD": btcFeedID, "btc/usd": btcFeedID}}, + } { + t.Run(name, func(t *testing.T) { + _, err := NewDataEngine(tc.url, tc.key, tc.secret, tc.feeds, http.DefaultClient) + assert.Error(t, err) + }) + } +} + +func TestAbiInt(t *testing.T) { + for _, v := range []int64{0, 1, -1, 1 << 40, -(1 << 40)} { + assert.Equal(t, v, abiInt(u256(big.NewInt(v))).Int64()) + } +} diff --git a/pricing/pricefeed/provider/provider.go b/pricing/pricefeed/provider/provider.go new file mode 100644 index 000000000..bced0d916 --- /dev/null +++ b/pricing/pricefeed/provider/provider.go @@ -0,0 +1,98 @@ +// Package provider fetches current prices from the price providers the price feed capability supports. +package provider + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "regexp" + "strings" + "time" + + "github.com/shopspring/decimal" +) + +// Provider fetches the current price of a ticker. +type Provider interface { + // Name is the provider's name, for logs and errors. + Name() string + // Price returns the current price of ticker. Its errors wrap ErrUnsupportedTicker when the provider has no price + // for ticker, and ErrBadResponse when the provider answered with something that is not a valid price. + Price(ctx context.Context, ticker Ticker) (Quote, error) +} + +// Quote is a price and when it was observed. +type Quote struct { + Price decimal.Decimal + Timestamp time.Time +} + +var ( + // ErrInvalidTicker is returned for a ticker that is not a BASE-QUOTE pair. It is the caller's fault. + ErrInvalidTicker = errors.New("invalid ticker") + // ErrUnsupportedTicker is returned for a well formed ticker the provider has no price for. It is the caller's + // fault. + ErrUnsupportedTicker = errors.New("unsupported ticker") + // ErrBadResponse is returned when the provider answers with something that is not a valid, current price. It is + // not the caller's fault. + ErrBadResponse = errors.New("bad response from price provider") +) + +// Ticker is a normalised BASE-QUOTE pair, such as BTC-USD. +type Ticker struct { + Base string + Quote string +} + +func (t Ticker) String() string { return t.Base + "-" + t.Quote } + +var tickerPattern = regexp.MustCompile(`^([A-Z0-9]{1,16})[-/_]([A-Z0-9]{1,16})$`) + +// ParseTicker parses a BASE-QUOTE pair, such as BTC-USD, btc/usd or ETH_USDC. Surrounding space is ignored. +func ParseTicker(s string) (Ticker, error) { + m := tickerPattern.FindStringSubmatch(strings.ToUpper(strings.TrimSpace(s))) + if m == nil { + return Ticker{}, fmt.Errorf("%w %q: must be BASE-QUOTE, such as BTC-USD", ErrInvalidTicker, s) + } + + if m[1] == m[2] { + return Ticker{}, fmt.Errorf("%w %q: base and quote are the same", ErrInvalidTicker, s) + } + + return Ticker{Base: m[1], Quote: m[2]}, nil +} + +// maxBodySize is the most a provider's response body is read, so a misbehaving provider cannot exhaust memory. +const maxBodySize = 1 << 20 + +// get sends req and returns the status code and body of the response. +func get(client *http.Client, req *http.Request) (int, []byte, error) { + resp, err := client.Do(req) + if err != nil { + return 0, nil, err + } + + defer resp.Body.Close() + + body, err := io.ReadAll(io.LimitReader(resp.Body, maxBodySize+1)) + if err != nil { + return resp.StatusCode, nil, fmt.Errorf("%w: failed to read body: %w", ErrBadResponse, err) + } + + if len(body) > maxBodySize { + return resp.StatusCode, nil, fmt.Errorf("%w: body is larger than %d bytes", ErrBadResponse, maxBodySize) + } + + return resp.StatusCode, body, nil +} + +// validPrice returns an error unless price is a usable price: more than zero. +func validPrice(price decimal.Decimal) error { + if !price.IsPositive() { + return fmt.Errorf("%w: price %s is not positive", ErrBadResponse, price) + } + + return nil +} diff --git a/pricing/pricefeed/provider/provider_test.go b/pricing/pricefeed/provider/provider_test.go new file mode 100644 index 000000000..1c8b2a2d6 --- /dev/null +++ b/pricing/pricefeed/provider/provider_test.go @@ -0,0 +1,48 @@ +package provider + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestParseTicker(t *testing.T) { + for in, want := range map[string]Ticker{ + "BTC-USD": {Base: "BTC", Quote: "USD"}, + "btc-usd": {Base: "BTC", Quote: "USD"}, + "Eth/Usd": {Base: "ETH", Quote: "USD"}, + "LINK_USDC": {Base: "LINK", Quote: "USDC"}, + " SOL-EUR ": {Base: "SOL", Quote: "EUR"}, + "1INCH-USD": {Base: "1INCH", Quote: "USD"}, + } { + t.Run(in, func(t *testing.T) { + got, err := ParseTicker(in) + require.NoError(t, err) + assert.Equal(t, want, got) + }) + } + + for _, in := range []string{ + "", + "BTC", + "BTCUSD", + "BTC-", + "-USD", + "BTC-USD-EUR", + "BTC USD", + "BTC-USD?x=1", + "../BTC-USD", + "BTC-BTC", + "ABCDEFGHIJKLMNOPQ-USD", + } { + t.Run("invalid "+in, func(t *testing.T) { + _, err := ParseTicker(in) + require.ErrorIs(t, err, ErrInvalidTicker) + }) + } +} + +func TestTickerString(t *testing.T) { + assert.Equal(t, "BTC-USD", Ticker{Base: "BTC", Quote: "USD"}.String()) +} diff --git a/pricing/pricefeed/service/capability.go b/pricing/pricefeed/service/capability.go new file mode 100644 index 000000000..0a4c17162 --- /dev/null +++ b/pricing/pricefeed/service/capability.go @@ -0,0 +1,226 @@ +package service + +import ( + "context" + "errors" + "fmt" + "net" + "net/http" + "time" + + "github.com/samber/do/v2" + + "github.com/smartcontractkit/capabilities/libs/capability" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/provider" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + caperrors "github.com/smartcontractkit/chainlink-common/pkg/capabilities/errors" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb" + "google.golang.org/protobuf/types/known/timestamppb" +) + +// ConfigNamespace is the namespace the price feed capability's Config is set under. +const ConfigNamespace = "pricefeed" + +// Providers the node operator can configure. +const ( + ProviderCoinbase = "coinbase" + ProviderDataEngine = "dataengine" +) + +// Config is how the node operator configures the price feed capability. The operator, not the workflow, holds the +// provider's credentials, so workflows need no API keys of their own. +type Config struct { + // Provider is the price provider prices are fetched from: coinbase or dataengine. + Provider string `validate:"oneof=coinbase dataengine"` + + // Timeout is the longest a request to the provider can take. + Timeout time.Duration `validate:"gt=0"` + + // MaxPriceAge is the oldest a price can be, by its timestamp, to be returned. Zero accepts any age. + MaxPriceAge time.Duration `validate:"gte=0"` + + // Coinbase configures the coinbase provider. + Coinbase CoinbaseConfig + + // DataEngine configures the dataengine provider. + DataEngine DataEngineConfig +} + +// CoinbaseConfig configures the Coinbase Price API provider, which needs no API key. +type CoinbaseConfig struct { + // URL is the base URL of the Coinbase API. + URL string +} + +// DataEngineConfig configures the Chainlink Data Engine (Data Streams) provider. +type DataEngineConfig struct { + // URL is the base URL of the Data Engine REST API. + URL string + + // APIKey is the Data Engine API key. + APIKey string + + // APISecret is the Data Engine API secret the requests are signed with. + APISecret commonconfig.SecretString + + // Feeds are the hex IDs of the Data Engine feeds, by the ticker they price, such as BTC-USD. A ticker without a + // feed is not supported. + Feeds map[string]string +} + +// DefaultConfig returns the config a node runs with when it sets nothing: Coinbase, which needs no credentials. +func DefaultConfig() Config { + return Config{ + Provider: ProviderCoinbase, + Timeout: 5 * time.Second, + MaxPriceAge: 5 * time.Minute, + Coinbase: CoinbaseConfig{URL: provider.CoinbaseURL}, + DataEngine: DataEngineConfig{URL: provider.DataEngineURL}, + } +} + +// init provides Config however the capability is run, so whoever embeds it gets its defaults without providing it. +func init() { + cfg := DefaultConfig() + capability.Injectors.MustProvideConfig(ConfigNamespace, &cfg) +} + +var _ capability.Capability = (*protos.ClientServer)(nil) + +// New builds the price feed capability from what the run provides, for capability.Run. +func New(i do.Injector) (*protos.ClientServer, error) { + lggr, err := do.Invoke[logger.Logger](i) + if err != nil { + return nil, err + } + + cfg, err := do.Invoke[*Config](i) + if err != nil { + return nil, err + } + + p, err := NewProvider(*cfg) + if err != nil { + return nil, err + } + + return protos.NewClientServer(newService(lggr, *cfg, p)), nil +} + +// NewProvider returns the provider cfg configures. +func NewProvider(cfg Config) (provider.Provider, error) { + client := &http.Client{Timeout: cfg.Timeout} + switch cfg.Provider { + case ProviderCoinbase: + return provider.NewCoinbase(cfg.Coinbase.URL, client) + case ProviderDataEngine: + de := cfg.DataEngine + return provider.NewDataEngine(de.URL, de.APIKey, string(de.APISecret), de.Feeds, client) + default: + return nil, fmt.Errorf("unknown price provider %q", cfg.Provider) + } +} + +// service implements the price feed capability. +type service struct { + services.Service + lggr logger.SugaredLogger + cfg Config + provider provider.Provider + now func() time.Time +} + +var _ protos.ClientCapability = (*service)(nil) + +func newService(lggr logger.Logger, cfg Config, p provider.Provider) *service { + s := &service{cfg: cfg, provider: p, now: time.Now} + s.Service = services.Config{Name: "PriceFeed"}.NewService(lggr) + s.lggr = logger.Sugared(logger.Named(lggr, "PriceFeed")) + return s +} + +func (s *service) Description() string { + return "Fetches current cryptocurrency prices from a provider the node operator configures" +} + +// GetPrice validates the ticker, fetches its price from the provider and validates it. +func (s *service) GetPrice(ctx context.Context, metadata capabilities.RequestMetadata, input *protos.GetPriceRequest) (*capabilities.ResponseAndMetadata[*protos.GetPriceResponse], caperrors.Error) { + lggr := logger.With(s.lggr, "workflowID", metadata.WorkflowID, "workflowExecutionID", metadata.WorkflowExecutionID, + "provider", s.provider.Name()) + + ticker, err := provider.ParseTicker(input.GetTicker()) + if err != nil { + return nil, caperrors.NewPublicUserError(err, caperrors.InvalidArgument) + } + + lggr = logger.With(lggr, "ticker", ticker.String()) + ctx, cancel := context.WithTimeout(ctx, s.cfg.Timeout) + defer cancel() + + quote, err := s.provider.Price(ctx, ticker) + if err != nil { + lggr.Warnw("Failed to fetch price", "err", err) + return nil, toCapError(fmt.Errorf("failed to fetch the price of %s from %s: %w", ticker, s.provider.Name(), err)) + } + + if err = s.checkAge(quote); err != nil { + lggr.Warnw("Price is stale", "err", err) + return nil, caperrors.NewPublicSystemError(fmt.Errorf("price of %s from %s: %w", ticker, s.provider.Name(), err), + caperrors.Unavailable) + } + + lggr.Debugw("Fetched price", "price", quote.Price.String(), "timestamp", quote.Timestamp) + return &capabilities.ResponseAndMetadata[*protos.GetPriceResponse]{Response: &protos.GetPriceResponse{ + Ticker: ticker.String(), + Price: pb.NewDecimalValue(quote.Price).GetDecimalValue(), + Timestamp: timestamppb.New(quote.Timestamp), + }}, nil +} + +// clockSkew is how far in the future a price's timestamp can be, for clocks that differ a little. +const clockSkew = 30 * time.Second + +func (s *service) checkAge(quote provider.Quote) error { + now := s.now() + if quote.Timestamp.After(now.Add(clockSkew)) { + return fmt.Errorf("%w: timestamp %s is in the future", provider.ErrBadResponse, quote.Timestamp) + } + + if s.cfg.MaxPriceAge > 0 { + if age := now.Sub(quote.Timestamp); age > s.cfg.MaxPriceAge { + return fmt.Errorf("price is %s old, older than the maximum of %s", age.Round(time.Second), s.cfg.MaxPriceAge) + } + } + + return nil +} + +// toCapError tells the workflow's errors, which are its fault, apart from the provider's. +func toCapError(err error) caperrors.Error { + switch { + case errors.Is(err, provider.ErrInvalidTicker): + return caperrors.NewPublicUserError(err, caperrors.InvalidArgument) + case errors.Is(err, provider.ErrUnsupportedTicker): + return caperrors.NewPublicUserError(err, caperrors.NotFound) + case errors.Is(err, context.DeadlineExceeded), isTimeout(err): + return caperrors.NewPublicSystemError(err, caperrors.DeadlineExceeded) + case errors.Is(err, context.Canceled): + return caperrors.NewPublicSystemError(err, caperrors.Canceled) + case errors.Is(err, provider.ErrBadResponse): + return caperrors.NewPublicSystemError(err, caperrors.Unavailable) + default: + // Such as a failed connection, whose message can say more about the node's network than is public. + return caperrors.NewPrivateSystemError(err, caperrors.Unavailable) + } +} + +// isTimeout tells whether err is a network timeout, such as the HTTP client's. +func isTimeout(err error) bool { + var netErr net.Error + return errors.As(err, &netErr) && netErr.Timeout() +} diff --git a/pricing/pricefeed/service/capability_test.go b/pricing/pricefeed/service/capability_test.go new file mode 100644 index 000000000..d10b6e488 --- /dev/null +++ b/pricing/pricefeed/service/capability_test.go @@ -0,0 +1,251 @@ +package service + +import ( + "context" + "errors" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/samber/do/v2" + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/capabilities/libs/capability" + "github.com/smartcontractkit/capabilities/libs/capability/capabilitytest" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos/protostest" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/provider" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + caperrors "github.com/smartcontractkit/chainlink-common/pkg/capabilities/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-protos/cre/go/values" + "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb" +) + +var metadata = capabilities.RequestMetadata{WorkflowID: "workflow-id"} + +// instances is how many instances the tests run: a node runs its capability alone. +const instances = 1 + +func start(t *testing.T, cfg Config, n int) protostest.ClientInstances { + t.Helper() + + return capabilitytest.Start(t, New, n, capability.WithProvider(func(i *capability.Injector) error { + return i.ProvideValue(&cfg) + })) +} + +// coinbase serves the Coinbase Price API, pricing BTC-USD at price and nothing else. +func coinbase(t *testing.T, price string) Config { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/v2/prices/BTC-USD/spot" { + w.WriteHeader(http.StatusBadRequest) + _, _ = w.Write([]byte(`{"errors":[{"id":"invalid_request","message":"Invalid currency"}]}`)) + return + } + + _, _ = w.Write([]byte(`{"data":{"amount":"` + price + `","base":"BTC","currency":"USD"}}`)) + })) + t.Cleanup(srv.Close) + + cfg := DefaultConfig() + cfg.Coinbase.URL = srv.URL + return cfg +} + +func TestNew(t *testing.T) { + c := start(t, coinbase(t, "1"), 1)[0] + + info, err := c.Info(t.Context()) + require.NoError(t, err) + assert.Equal(t, protos.ClientID, info.ID) + assert.Equal(t, "price-feed@1.0.0-alpha", info.ID) + assert.NotEmpty(t, info.Description) + assert.NoError(t, c.Ready()) +} + +func TestNewInvalidConfig(t *testing.T) { + for name, cfg := range map[string]func(*Config){ + "unknown provider": func(c *Config) { c.Provider = "nope" }, + "invalid coinbase URL": func(c *Config) { c.Coinbase.URL = "nope" }, + "data engine no secret": func(c *Config) { c.Provider = ProviderDataEngine; c.DataEngine.APIKey = "key" }, + "data engine bad feeds": func(c *Config) { c.Provider = ProviderDataEngine; c.DataEngine.Feeds = map[string]string{"x": "y"} }, + "data engine no API key": func(c *Config) { c.Provider = ProviderDataEngine; c.DataEngine.APISecret = "secret" }, + } { + t.Run(name, func(t *testing.T) { + c := DefaultConfig() + cfg(&c) + _, err := NewProvider(c) + assert.Error(t, err) + }) + } +} + +func TestNewProviders(t *testing.T) { + c := DefaultConfig() + p, err := NewProvider(c) + require.NoError(t, err) + assert.Equal(t, ProviderCoinbase, p.Name()) + + c.Provider = ProviderDataEngine + c.DataEngine.APIKey = "key" + c.DataEngine.APISecret = "secret" + c.DataEngine.Feeds = map[string]string{"BTC-USD": "0x00039d9e45394f473ab1f050a1b963e6b05351e52d71e507509ada0c95ed75b8"} + p, err = NewProvider(c) + require.NoError(t, err) + assert.Equal(t, ProviderDataEngine, p.Name()) +} + +func TestLifecycle(t *testing.T) { + s := newService(logger.Test(t), DefaultConfig(), nil) + require.Error(t, s.Ready()) + require.Error(t, s.HealthReport()[s.Name()]) + + require.NoError(t, s.Start(t.Context())) + require.NoError(t, s.Ready()) + require.NoError(t, s.HealthReport()[s.Name()]) + + require.NoError(t, s.Close()) + require.Error(t, s.Ready()) + require.Error(t, s.HealthReport()[s.Name()]) +} + +func TestNewWithoutDependencies(t *testing.T) { + _, err := New(do.New()) + assert.Error(t, err) +} + +func TestGetPrice(t *testing.T) { + c := start(t, coinbase(t, "89012.345678901234567891"), instances) + before := time.Now() + + resp, err := c.GetPrice(t.Context(), metadata, &protos.GetPriceRequest{Ticker: "btc/usd"}) + require.NoError(t, err) + assert.Equal(t, "BTC-USD", resp.Response.Ticker) + + price, err := values.FromProto(&pb.Value{Value: &pb.Value_DecimalValue{DecimalValue: resp.Response.Price}}) + require.NoError(t, err) + got, err := price.Unwrap() + require.NoError(t, err) + assert.True(t, decimal.RequireFromString("89012.345678901234567891").Equal(got.(decimal.Decimal)), got) + + ts := resp.Response.Timestamp.AsTime() + assert.False(t, ts.Before(before.Truncate(time.Second)), ts) + assert.False(t, ts.After(time.Now()), ts) +} + +func TestGetPriceErrors(t *testing.T) { + c := start(t, coinbase(t, "-1"), instances) + for name, tc := range map[string]struct { + ticker string + code caperrors.ErrorCode + origin caperrors.Origin + }{ + "invalid ticker": {"BTCUSD", caperrors.InvalidArgument, caperrors.OriginUser}, + "empty ticker": {"", caperrors.InvalidArgument, caperrors.OriginUser}, + "unsupported ticker": {"FOO-BAR", caperrors.NotFound, caperrors.OriginUser}, + "bad price": {"BTC-USD", caperrors.Unavailable, caperrors.OriginSystem}, + } { + t.Run(name, func(t *testing.T) { + _, err := c.GetPrice(t.Context(), metadata, &protos.GetPriceRequest{Ticker: tc.ticker}) + var capErr caperrors.Error + require.ErrorAs(t, err, &capErr) + assert.Equal(t, tc.code, capErr.Code(), capErr) + assert.Equal(t, tc.origin, capErr.Origin(), capErr) + }) + } +} + +// fakeProvider returns quote or err. +type fakeProvider struct { + quote provider.Quote + err error +} + +func (f fakeProvider) Name() string { return "fake" } + +func (f fakeProvider) Price(ctx context.Context, _ provider.Ticker) (provider.Quote, error) { + if f.err != nil { + return provider.Quote{}, f.err + } + + return f.quote, ctx.Err() +} + +func TestGetPriceAge(t *testing.T) { + now := time.Date(2026, 11, 12, 10, 0, 0, 0, time.UTC) + cfg := DefaultConfig() + cfg.MaxPriceAge = time.Minute + for name, tc := range map[string]struct { + age time.Duration + max time.Duration + code caperrors.ErrorCode + }{ + "fresh": {age: 30 * time.Second, max: time.Minute}, + "stale": {age: 2 * time.Minute, max: time.Minute, code: caperrors.Unavailable}, + "any age": {age: 24 * time.Hour}, + "small skew": {age: -10 * time.Second, max: time.Minute}, + "in the future": {age: -time.Hour, max: time.Minute, code: caperrors.Unavailable}, + } { + t.Run(name, func(t *testing.T) { + cfg.MaxPriceAge = tc.max + s := newService(logger.Test(t), cfg, fakeProvider{quote: provider.Quote{Price: decimal.NewFromInt(1), Timestamp: now.Add(-tc.age)}}) + s.now = func() time.Time { return now } + + resp, err := s.GetPrice(t.Context(), metadata, &protos.GetPriceRequest{Ticker: "BTC-USD"}) + if tc.code == 0 { + require.NoError(t, err) + assert.Equal(t, now.Add(-tc.age), resp.Response.Timestamp.AsTime()) + return + } + + require.Error(t, err) + assert.Equal(t, tc.code, err.Code(), err) + }) + } +} + +func TestToCapError(t *testing.T) { + for name, tc := range map[string]struct { + err error + code caperrors.ErrorCode + origin caperrors.Origin + visibility caperrors.Visibility + }{ + "invalid": {provider.ErrInvalidTicker, caperrors.InvalidArgument, caperrors.OriginUser, caperrors.VisibilityPublic}, + "unsupported": {provider.ErrUnsupportedTicker, caperrors.NotFound, caperrors.OriginUser, caperrors.VisibilityPublic}, + "timeout": {context.DeadlineExceeded, caperrors.DeadlineExceeded, caperrors.OriginSystem, caperrors.VisibilityPublic}, + "canceled": {context.Canceled, caperrors.Canceled, caperrors.OriginSystem, caperrors.VisibilityPublic}, + "bad": {provider.ErrBadResponse, caperrors.Unavailable, caperrors.OriginSystem, caperrors.VisibilityPublic}, + "network": {errors.New("dial tcp 10.0.0.1:443: connection refused"), caperrors.Unavailable, caperrors.OriginSystem, caperrors.VisibilityPrivate}, + } { + t.Run(name, func(t *testing.T) { + err := toCapError(tc.err) + assert.Equal(t, tc.code, err.Code()) + assert.Equal(t, tc.origin, err.Origin()) + assert.Equal(t, tc.visibility, err.Visibility()) + }) + } +} + +func TestGetPriceTimeout(t *testing.T) { + block := make(chan struct{}) + srv := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { <-block })) + t.Cleanup(srv.Close) + t.Cleanup(func() { close(block) }) + + cfg := DefaultConfig() + cfg.Coinbase.URL = srv.URL + cfg.Timeout = 50 * time.Millisecond + p, err := NewProvider(cfg) + require.NoError(t, err) + + _, capErr := newService(logger.Test(t), cfg, p).GetPrice(t.Context(), metadata, &protos.GetPriceRequest{Ticker: "BTC-USD"}) + require.Error(t, capErr) + assert.Equal(t, caperrors.DeadlineExceeded, capErr.Code(), capErr) +} diff --git a/pricing/pricefeed/service/doccomments_gen.go b/pricing/pricefeed/service/doccomments_gen.go new file mode 100644 index 000000000..1970a7e53 --- /dev/null +++ b/pricing/pricefeed/service/doccomments_gen.go @@ -0,0 +1,30 @@ +// Code generated by github.com/smartcontractkit/capabilities/pricing/pricefeed docgen, DO NOT EDIT. + +package service + +import "github.com/smartcontractkit/chainlink-common/x/config/commentparsing" + +func (CoinbaseConfig) DocComments() map[string]commentparsing.FieldDoc { + return map[string]commentparsing.FieldDoc{ + "URL": {Comment: "URL is the base URL of the Coinbase API."}, + } +} + +func (Config) DocComments() map[string]commentparsing.FieldDoc { + return map[string]commentparsing.FieldDoc{ + "Coinbase": {Comment: "Coinbase configures the coinbase provider."}, + "DataEngine": {Comment: "DataEngine configures the dataengine provider."}, + "MaxPriceAge": {Comment: "MaxPriceAge is the oldest a price can be, by its timestamp, to be returned. Zero accepts any age."}, + "Provider": {Comment: "Provider is the price provider prices are fetched from: coinbase or dataengine."}, + "Timeout": {Comment: "Timeout is the longest a request to the provider can take."}, + } +} + +func (DataEngineConfig) DocComments() map[string]commentparsing.FieldDoc { + return map[string]commentparsing.FieldDoc{ + "APIKey": {Comment: "APIKey is the Data Engine API key."}, + "APISecret": {Comment: "APISecret is the Data Engine API secret the requests are signed with."}, + "Feeds": {Comment: "Feeds are the hex IDs of the Data Engine feeds, by the ticker they price, such as BTC-USD. A ticker without a\nfeed is not supported."}, + "URL": {Comment: "URL is the base URL of the Data Engine REST API."}, + } +} diff --git a/pricing/pricefeed/workflow/fakesdk/cre/cre.go b/pricing/pricefeed/workflow/fakesdk/cre/cre.go new file mode 100644 index 000000000..a9a60f832 --- /dev/null +++ b/pricing/pricefeed/workflow/fakesdk/cre/cre.go @@ -0,0 +1,104 @@ +// Package cre is a minimal in-process stand-in for github.com/smartcontractkit/cre-sdk-go/cre. It mirrors the SDK API +// the example workflow uses, so that workflow code can run natively against the real capability in tests. +package cre + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "log/slog" + "slices" + + "github.com/shopspring/decimal" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" +) + +type Runtime interface { + Logger() *slog.Logger + Context() context.Context + Metadata() capabilities.RequestMetadata + NumNodes() int + Capability(id string) any +} + +// TestRuntime runs DON-mode callbacks once and node-mode callbacks once per node, sequentially. +type TestRuntime struct { + Ctx context.Context //nolint:containedctx // The runtime is the context the workflow runs in. + Lggr *slog.Logger + RequestMeta capabilities.RequestMetadata + Nodes int + CapabilityMap map[string]any +} + +var _ Runtime = (*TestRuntime)(nil) + +func (r *TestRuntime) Logger() *slog.Logger { return r.Lggr } +func (r *TestRuntime) Context() context.Context { return r.Ctx } +func (r *TestRuntime) Metadata() capabilities.RequestMetadata { return r.RequestMeta } +func (r *TestRuntime) NumNodes() int { return r.Nodes } +func (r *TestRuntime) Capability(id string) any { return r.CapabilityMap[id] } + +type Promise[T any] interface { + Await() (T, error) +} + +type promise[T any] func() (T, error) + +func (p promise[T]) Await() (T, error) { return p() } + +func NewPromise[T any](await func() (T, error)) Promise[T] { return promise[T](await) } + +type Trigger[T any] interface { + ID() string +} + +type ExecutionHandler[C any] interface { + TriggerID() string + Execute(config C, runtime Runtime, payload any) (any, error) +} + +type handler[C, T, O any] struct { + trigger Trigger[T] + callback func(C, Runtime, T) (O, error) +} + +func (h handler[C, T, O]) TriggerID() string { return h.trigger.ID() } + +func (h handler[C, T, O]) Execute(config C, runtime Runtime, payload any) (any, error) { + p, ok := payload.(T) + if !ok { + return nil, fmt.Errorf("unexpected trigger payload type %T", payload) + } + + return h.callback(config, runtime, p) +} + +func Handler[C, T, O any](trigger Trigger[T], callback func(C, Runtime, T) (O, error)) ExecutionHandler[C] { + return handler[C, T, O]{trigger: trigger, callback: callback} +} + +type Workflow[C any] []ExecutionHandler[C] + +func ParseJSON[C any](b []byte) (*C, error) { + c := new(C) + return c, json.Unmarshal(b, c) +} + +type ConsensusAggregation[T any] struct { + Aggregate func(observations []T) (T, error) +} + +// ConsensusMedianAggregation returns the upper median of decimal observations. +func ConsensusMedianAggregation() ConsensusAggregation[decimal.Decimal] { + return ConsensusAggregation[decimal.Decimal]{Aggregate: func(observations []decimal.Decimal) (decimal.Decimal, error) { + if len(observations) == 0 { + return decimal.Decimal{}, errors.New("no observations") + } + + sorted := slices.Clone(observations) + slices.SortFunc(sorted, decimal.Decimal.Cmp) + return sorted[len(sorted)/2], nil + }} +} diff --git a/pricing/pricefeed/workflow/fakesdk/cron/cron.go b/pricing/pricefeed/workflow/fakesdk/cron/cron.go new file mode 100644 index 000000000..25ae3a7b4 --- /dev/null +++ b/pricing/pricefeed/workflow/fakesdk/cron/cron.go @@ -0,0 +1,26 @@ +// Package cron is a minimal stand-in for github.com/smartcontractkit/cre-sdk-go/capabilities/scheduler/cron. +package cron + +import ( + "time" + + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cre" +) + +type Config struct { + Schedule string +} + +type Payload struct { + ScheduledExecutionTime time.Time +} + +type trigger struct { + config *Config +} + +func (trigger) ID() string { return "cron-trigger@1.0.0" } + +func Trigger(config *Config) cre.Trigger[*Payload] { + return trigger{config: config} +} diff --git a/pricing/pricefeed/workflow/fakesdk/pricefeed/pricefeed.go b/pricing/pricefeed/workflow/fakesdk/pricefeed/pricefeed.go new file mode 100644 index 000000000..67c152025 --- /dev/null +++ b/pricing/pricefeed/workflow/fakesdk/pricefeed/pricefeed.go @@ -0,0 +1,73 @@ +// Package pricefeed is a minimal stand-in for the SDK client cre-sdk-go would generate from the price feed +// capability's production protos. It calls a real price feed capability in-process. +package pricefeed + +import ( + "context" + "fmt" + "log/slog" + + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cre" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" +) + +const CapabilityID = protos.ClientID + +type ( + GetPriceRequest = protos.GetPriceRequest + GetPriceResponse = protos.GetPriceResponse +) + +// Capability is what the runtime gives for CapabilityID: the capability, or a client of it. +type Capability interface { + GetPrice(ctx context.Context, metadata capabilities.RequestMetadata, input *GetPriceRequest) (*capabilities.ResponseAndMetadata[*GetPriceResponse], error) +} + +type Client struct{} + +// NodeRuntime is what a node-mode callback calls the capability with. +type NodeRuntime struct { + runtime cre.Runtime +} + +// GetPrice returns the current price of the ticker the request names, as this node fetched it. +func (c *Client) GetPrice(runtime *NodeRuntime, req *GetPriceRequest) cre.Promise[*GetPriceResponse] { + return cre.NewPromise(func() (*GetPriceResponse, error) { + capability, ok := runtime.runtime.Capability(CapabilityID).(Capability) + if !ok { + return nil, fmt.Errorf("capability %s not registered", CapabilityID) + } + + out, err := capability.GetPrice(runtime.runtime.Context(), runtime.runtime.Metadata(), req) + if err != nil { + return nil, err + } + + return out.Response, nil + }) +} + +// RunInNodeMode runs fn on every node and aggregates the results. +func RunInNodeMode[C, T any]( + config C, + runtime cre.Runtime, + fn func(C, *slog.Logger, *NodeRuntime) (T, error), + aggregation cre.ConsensusAggregation[T], +) cre.Promise[T] { + return cre.NewPromise(func() (T, error) { + observations := make([]T, 0, runtime.NumNodes()) + for i := range runtime.NumNodes() { + obs, err := fn(config, runtime.Logger().With("node", i), &NodeRuntime{runtime: runtime}) + if err != nil { + var zero T + return zero, fmt.Errorf("node %d: %w", i, err) + } + + observations = append(observations, obs) + } + + return aggregation.Aggregate(observations) + }) +} diff --git a/pricing/pricefeed/workflow/workflow.go b/pricing/pricefeed/workflow/workflow.go new file mode 100644 index 000000000..2dc9a62b7 --- /dev/null +++ b/pricing/pricefeed/workflow/workflow.go @@ -0,0 +1,70 @@ +// Package workflow is an example workflow that uses the price feed capability, the "Desired" flow of the PRD: it asks +// for a ticker's price with no API URL, API key or response parsing of its own. It is built against fakesdk instead of +// cre-sdk-go, so it runs natively instead of as WASM. +package workflow + +import ( + "fmt" + "log/slog" + + "github.com/shopspring/decimal" + + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cre" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cron" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/pricefeed" + + "github.com/smartcontractkit/chainlink-protos/cre/go/values" + "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb" +) + +type Config struct { + Schedule string `json:"schedule"` + Ticker string `json:"ticker"` +} + +type Result struct { + Ticker string + Price decimal.Decimal +} + +func InitWorkflow(config *Config, _ *slog.Logger) (cre.Workflow[*Config], error) { + return cre.Workflow[*Config]{ + cre.Handler(cron.Trigger(&cron.Config{Schedule: config.Schedule}), onCronTrigger), + }, nil +} + +// fetchPrice runs on each node: it is all a workflow needs to get a price. +func fetchPrice(config *Config, _ *slog.Logger, nodeRuntime *pricefeed.NodeRuntime) (decimal.Decimal, error) { + priceFeed := &pricefeed.Client{} + resp, err := priceFeed.GetPrice(nodeRuntime, &pricefeed.GetPriceRequest{Ticker: config.Ticker}).Await() + if err != nil { + return decimal.Decimal{}, err + } + + return toDecimal(resp.Price) +} + +func onCronTrigger(config *Config, runtime cre.Runtime, _ *cron.Payload) (*Result, error) { + // Each node fetches its own price, so the DON agrees on their median. + price, err := pricefeed.RunInNodeMode(config, runtime, fetchPrice, cre.ConsensusMedianAggregation()).Await() + if err != nil { + return nil, err + } + + runtime.Logger().Info("Fetched price", "ticker", config.Ticker, "price", price) + return &Result{Ticker: config.Ticker, Price: price}, nil +} + +func toDecimal(d *pb.Decimal) (decimal.Decimal, error) { + v, err := values.FromProto(&pb.Value{Value: &pb.Value_DecimalValue{DecimalValue: d}}) + if err != nil { + return decimal.Decimal{}, err + } + + var price decimal.Decimal + if err = v.UnwrapTo(&price); err != nil { + return decimal.Decimal{}, fmt.Errorf("price is not a decimal: %w", err) + } + + return price, nil +} diff --git a/pricing/pricefeed/workflow/workflow_test.go b/pricing/pricefeed/workflow/workflow_test.go new file mode 100644 index 000000000..4b7121d5f --- /dev/null +++ b/pricing/pricefeed/workflow/workflow_test.go @@ -0,0 +1,88 @@ +package workflow + +import ( + "io" + "log/slog" + "net/http" + "net/http/httptest" + "sync/atomic" + "testing" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/capabilities/libs/capability" + "github.com/smartcontractkit/capabilities/libs/capability/capabilitytest" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/protos/protostest" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/service" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cre" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/cron" + "github.com/smartcontractkit/capabilities/pricing/pricefeed/workflow/fakesdk/pricefeed" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" +) + +// run runs the workflow on len(bodies) nodes, each fetching its price from a Coinbase that answers with the next of bodies. +func run(t *testing.T, ticker string, bodies ...string) (*Result, int32, error) { + t.Helper() + var calls atomic.Int32 + api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = io.WriteString(w, bodies[int(calls.Add(1)-1)%len(bodies)]) + })) + t.Cleanup(api.Close) + + cfg := service.DefaultConfig() + cfg.Coinbase.URL = api.URL + priceFeed := protostest.ClientInstances(capabilitytest.Start(t, service.New, 1, capability.WithProvider(func(i *capability.Injector) error { + return i.ProvideValue(&cfg) + }))) + + config, err := cre.ParseJSON[Config]([]byte(`{"schedule":"0 */1 * * * *","ticker":"` + ticker + `"}`)) + require.NoError(t, err) + + lggr := slog.New(slog.NewTextHandler(t.Output(), nil)) + wf, err := InitWorkflow(config, lggr) + require.NoError(t, err) + require.Len(t, wf, 1) + + runtime := &cre.TestRuntime{ + Ctx: t.Context(), + Lggr: lggr, + RequestMeta: capabilities.RequestMetadata{WorkflowID: "workflow-id", WorkflowExecutionID: "execution-id"}, + Nodes: len(bodies), + CapabilityMap: map[string]any{pricefeed.CapabilityID: priceFeed}, + } + + out, err := wf[0].Execute(config, runtime, &cron.Payload{}) + if err != nil { + return nil, calls.Load(), err + } + + return out.(*Result), calls.Load(), nil +} + +func coinbasePrice(amount string) string { + return `{"data":{"amount":"` + amount + `","base":"BTC","currency":"USD"}}` +} + +func TestPriceFeedWorkflow(t *testing.T) { + // Each node sees a slightly different price; the workflow agrees on their median. + out, calls, err := run(t, "btc-usd", + coinbasePrice("89000.10"), coinbasePrice("89000.30"), coinbasePrice("89000.20"), coinbasePrice("89000.40")) + require.NoError(t, err) + assert.Equal(t, int32(4), calls) + assert.True(t, decimal.RequireFromString("89000.30").Equal(out.Price), out.Price) +} + +func TestPriceFeedWorkflowBadTicker(t *testing.T) { + _, calls, err := run(t, "not a ticker", coinbasePrice("1")) + require.ErrorContains(t, err, "invalid ticker") + assert.Zero(t, calls, "an invalid ticker must not reach the provider") +} + +func TestPriceFeedWorkflowBadResponse(t *testing.T) { + _, _, err := run(t, "BTC-USD", coinbasePrice("1"), `{"data":{"amount":"NaN","base":"BTC","currency":"USD"}}`) + require.ErrorContains(t, err, "node 1") + require.ErrorContains(t, err, "invalid amount") +}