Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.6.0] - 2026-SEP-09

### Added

- Bumped `prime-sdk-go` to v0.12.0
- New financing commands: `get-conversion-fees`, `get-cross-margin-liquidation`, `list-cross-margin-liquidations`, `list-trade-finance-obligations`, `get-entity-rewards-rate`, `get-portfolio-rewards-rate`
- New futures commands: `get-equity`, `get-derivatives-currency-summary`, `get-derivative-positions`
- MCP tools for the new endpoints, plus backfill for `get_market_data`, `get_cross_margin_prime_overview`, `get_cross_margin_risk_parameters`, `update_funding_settings`
- Optional flags: `orders edit --offset/--wig-level`, `staking portfolio-unstake --validator-provider`, `staking stake/unstake --metadata-external-id`, `transactions create-withdrawal --counterparty`
- API error output now includes `trace_id` and the spec subcode/code description by default

## [0.5.1] - 2026-JUL-24

### Added
Expand Down
42 changes: 41 additions & 1 deletion COMMANDS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prime CLI Commands

A copy/paste-friendly reference for every `primectl` command in v0.5.0. Each command is shown as a runnable bash snippet that uses environment variables for the IDs you'll most often substitute.
A copy/paste-friendly reference for every `primectl` command in v0.6.0. Each command is shown as a runnable bash snippet that uses environment variables for the IDs you'll most often substitute.

> Anything marked `<...>` is a placeholder you should replace before running.

Expand Down Expand Up @@ -181,6 +181,21 @@ Most financing commands accept `--entity-id`. If omitted, the value falls back t
--automatic-loan-enabled \
--automatic-excess-return-enabled \
--excess-funds-target-amount 1000

# Conversion fees (org-level; no entity/portfolio flag)
./primectl financing get-conversion-fees

# Cross-margin liquidations
./primectl financing get-cross-margin-liquidation --entity-id "$ENTITY_ID"
./primectl financing get-cross-margin-liquidation --entity-id "$ENTITY_ID" --liquidation-id <liquidation-id>
./primectl financing list-cross-margin-liquidations --entity-id "$ENTITY_ID" --all
./primectl financing list-cross-margin-liquidations --entity-id "$ENTITY_ID" --status XM_LIQUIDATION_STATUS_LIQUIDATED --start-time 2026-01-01T00:00:00Z --end-time 2026-09-09T00:00:00Z

./primectl financing list-trade-finance-obligations --entity-id "$ENTITY_ID"

# Rewards rate (beta)
./primectl financing get-entity-rewards-rate --entity-id "$ENTITY_ID"
./primectl financing get-portfolio-rewards-rate --portfolio-id "$PORTFOLIO_ID"
```

## futures
Expand All @@ -199,6 +214,13 @@ All futures commands accept `--entity-id`. If omitted, the value falls back to t
./primectl futures schedule-sweep --entity-id "$ENTITY_ID" --amount 1000 --currency USD
./primectl futures cancel-sweep --entity-id "$ENTITY_ID"
./primectl futures set-settings --entity-id "$ENTITY_ID" --target-derivatives-excess 0.10

./primectl futures get-equity --entity-id "$ENTITY_ID"

# International derivatives (portfolio-scoped)
./primectl futures get-derivatives-currency-summary --portfolio-id "$PORTFOLIO_ID"
./primectl futures get-derivative-positions --portfolio-id "$PORTFOLIO_ID"
./primectl futures get-derivative-positions --portfolio-id "$PORTFOLIO_ID" --product-id <product-id>
```

## invoices
Expand Down Expand Up @@ -267,6 +289,13 @@ All futures commands accept `--entity-id`. If omitted, the value falls back to t
--new-base-quantity 0.02 \
--new-limit-price 2050

./primectl orders edit \
--portfolio-id "$PORTFOLIO_ID" \
--order-id <order-id> \
--new-base-quantity 0.02 \
--offset 0.01 \
--wig-level 0.5

./primectl orders create-quote \
--portfolio-id "$PORTFOLIO_ID" \
--product-id ETH-USD \
Expand Down Expand Up @@ -319,14 +348,17 @@ All futures commands accept `--entity-id`. If omitted, the value falls back to t

```bash
./primectl staking stake --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID"
./primectl staking stake --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID" --metadata-external-id my-stake-1
./primectl staking unstake --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID" --amount 1.0
./primectl staking unstake --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID" --amount 1.0 --metadata-external-id my-unstake-1
./primectl staking claim-rewards --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID"
./primectl staking get-status --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID"
./primectl staking preview-unstake --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID" --amount 1.0
./primectl staking get-unstaking-status --portfolio-id "$PORTFOLIO_ID" --wallet-id "$WALLET_ID"

./primectl staking portfolio-stake-initiate --portfolio-id "$PORTFOLIO_ID" --symbol ETH --amount 1.0
./primectl staking portfolio-unstake --portfolio-id "$PORTFOLIO_ID" --symbol ETH --amount 1.0
./primectl staking portfolio-unstake --portfolio-id "$PORTFOLIO_ID" --symbol ETH --validator-provider VALIDATOR_PROVIDER_COINBASE_CLOUD

./primectl staking query-validators \
--portfolio-id "$PORTFOLIO_ID" \
Expand Down Expand Up @@ -355,6 +387,14 @@ All futures commands accept `--entity-id`. If omitted, the value falls back to t
--destination-type DESTINATION_BLOCKCHAIN \
--blockchain-address 0xabc123...

./primectl transactions create-withdrawal \
--portfolio-id "$PORTFOLIO_ID" \
--source-wallet-id "$WALLET_ID" \
--symbol ETH \
--amount 1.0 \
--destination-type DESTINATION_COUNTERPARTY \
--counterparty <counterparty-id>

./primectl transactions create-conversion \
--portfolio-id "$PORTFOLIO_ID" \
--source-wallet-id <usd-wallet-id> \
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ Finally, to run commands for each endpoint, use the following format to test eac
./primectl orders create-preview -b 0.001 -i ETH-USD -s BUY -t MARKET
```

As of v0.5.0, the CLI covers the full surface area of [prime-sdk-go](https://github.com/coinbase/prime-sdk-go) v0.9.0, including the `advanced-transfers`, `futures`, and `positions` command groups.
As of v0.6.0, the CLI covers the full surface area of [prime-sdk-go](https://github.com/coinbase/prime-sdk-go) v0.12.0, including conversion fees, cross-margin liquidations, trade finance obligations, rewards rates, FCM equity, and international derivatives.

API failures print the Prime error `code`, `subcode`, spec description, and `trace_id` on stderr so you can share the trace with support.

## MCP Server

Expand Down Expand Up @@ -131,7 +133,7 @@ If `PRIME_CREDENTIALS` is already set in your shell environment, you can omit th

### Available tools

The MCP server exposes 98 tools across the Coinbase Prime API:
The MCP server exposes 113 tools across the Coinbase Prime API:

| Tool | Description |
|---|---|
Expand Down Expand Up @@ -178,6 +180,16 @@ The MCP server exposes 98 tools across the Coinbase Prime API:
| `list_margin_call_summaries` | List margin call summaries for an entity |
| `list_margin_conversions` | List margin conversions for a portfolio (deprecated) |
| `list_portfolio_interest_accruals` | List interest accruals for a portfolio |
| `get_market_data` | Get paginated market data for an entity |
| `get_cross_margin_prime_overview` | Get the Prime cross-margin overview for an entity |
| `get_cross_margin_risk_parameters` | Get cross-margin risk parameters for an entity |
| `update_funding_settings` | Update FCM funding settings for an entity |
| `get_conversion_fees` | Get organization stablecoin conversion fee tiers |
| `get_cross_margin_liquidation` | Get detailed cross-margin liquidation data for an entity |
| `list_cross_margin_liquidations` | List historical cross-margin liquidations for an entity |
| `list_trade_finance_obligations` | List trade finance obligations for an entity |
| `get_entity_rewards_rate` | Get current rewards rate and available tiers for an entity |
| `get_portfolio_rewards_rate` | Get current rewards rate and available tiers for a portfolio |
| **Futures (FCM)** | |
| `get_fcm_balance` | Get FCM balance summary for an entity |
| `get_fcm_positions` | Get FCM futures positions for an entity |
Expand All @@ -189,6 +201,9 @@ The MCP server exposes 98 tools across the Coinbase Prime API:
| `list_fcm_sweeps` | List futures sweeps for an entity |
| `schedule_fcm_sweep` | Schedule a futures sweep |
| `cancel_fcm_sweep` | Cancel a scheduled futures sweep |
| `get_fcm_equity` | Get FCM equity data for an entity |
| `get_derivatives_currency_summary` | Get per-currency international derivatives balances for a portfolio |
| `get_derivative_positions` | Get active derivative positions for a portfolio |
| **Invoices** | |
| `list_invoices` | List invoices for an entity |
| **Onchain Address Book** | |
Expand Down
5 changes: 4 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package cmd

import (
"fmt"
"os"

"github.com/coinbase-samples/prime-cli/cmd/activities"
"github.com/coinbase-samples/prime-cli/cmd/addressbook"
mcpcmd "github.com/coinbase-samples/prime-cli/cmd/mcp"
"github.com/coinbase-samples/prime-cli/cmd/advancedtransfers"
"github.com/coinbase-samples/prime-cli/cmd/allocations"
"github.com/coinbase-samples/prime-cli/cmd/assets"
Expand All @@ -29,6 +29,7 @@ import (
"github.com/coinbase-samples/prime-cli/cmd/financing"
"github.com/coinbase-samples/prime-cli/cmd/futures"
"github.com/coinbase-samples/prime-cli/cmd/invoices"
mcpcmd "github.com/coinbase-samples/prime-cli/cmd/mcp"
"github.com/coinbase-samples/prime-cli/cmd/onchainaddressbook"
"github.com/coinbase-samples/prime-cli/cmd/orders"
"github.com/coinbase-samples/prime-cli/cmd/paymentmethods"
Expand All @@ -50,8 +51,10 @@ var rootCmd = &cobra.Command{
}

func Execute() {
rootCmd.SilenceErrors = true
err := rootCmd.Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", utils.FormatCLIError(err))
os.Exit(1)
}
}
Expand Down
71 changes: 71 additions & 0 deletions cmd/financing/get_conversion_fees.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright 2026-present Coinbase Global, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package financing

import (
"fmt"

"github.com/coinbase-samples/prime-cli/utils"
prime "github.com/coinbase/prime-sdk-go/financing"
"github.com/spf13/cobra"
)

var getConversionFeesCmd = &cobra.Command{
Use: "get-conversion-fees",
Short: "Gets organization stablecoin conversion fee tiers",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := utils.GetClientFromEnv()
if err != nil {
return fmt.Errorf("failed to initialize client: %w", err)
}

svc := prime.NewFinancingService(client)

request := &prime.GetConversionFeesRequest{}

response, err := getConversionFees(svc, request)
if err != nil {
return err
}

if err := utils.PrintJsonDocs(cmd, response.Fees); err != nil {
return err
}

return nil
},
}

func getConversionFees(
svc prime.FinancingService,
req *prime.GetConversionFeesRequest,
) (*prime.GetConversionFeesResponse, error) {

ctx, cancel := utils.GetContextWithTimeout()
defer cancel()

response, err := svc.GetConversionFees(ctx, req)
if err != nil {
return nil, fmt.Errorf("cannot get conversion fees: %w", err)
}

return response, nil
}

func init() {
Cmd.AddCommand(getConversionFeesCmd)
}
87 changes: 87 additions & 0 deletions cmd/financing/get_cross_margin_liquidation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* Copyright 2026-present Coinbase Global, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package financing

import (
"fmt"

"github.com/coinbase-samples/prime-cli/utils"
prime "github.com/coinbase/prime-sdk-go/financing"
"github.com/spf13/cobra"
)

const liquidationIdFlag = "liquidation-id"

var getCrossMarginLiquidationCmd = &cobra.Command{
Use: "get-cross-margin-liquidation",
Short: "Gets detailed cross-margin liquidation data for an entity",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := utils.GetClientFromEnv()
if err != nil {
return fmt.Errorf("failed to initialize client: %w", err)
}

svc := prime.NewFinancingService(client)

entityId, err := utils.GetEntityId(cmd, client)
if err != nil {
return err
}

request := &prime.GetCrossMarginLiquidationRequest{
EntityId: entityId,
LiquidationId: utils.GetFlagStringValue(cmd, liquidationIdFlag),
}

response, err := getCrossMarginLiquidation(svc, request)
if err != nil {
return err
}

jsonResponse, err := utils.FormatResponseAsJson(cmd, response)
if err != nil {
return err
}

fmt.Println(jsonResponse)

return nil
},
}

func getCrossMarginLiquidation(
svc prime.FinancingService,
req *prime.GetCrossMarginLiquidationRequest,
) (*prime.GetCrossMarginLiquidationResponse, error) {

ctx, cancel := utils.GetContextWithTimeout()
defer cancel()

response, err := svc.GetCrossMarginLiquidation(ctx, req)
if err != nil {
return nil, fmt.Errorf("cannot get cross margin liquidation: %w", err)
}

return response, nil
}

func init() {
Cmd.AddCommand(getCrossMarginLiquidationCmd)

utils.AddEntityIdFlag(getCrossMarginLiquidationCmd)
getCrossMarginLiquidationCmd.Flags().String(liquidationIdFlag, "", "Optional liquidation ID")
}
Loading