Skip to content

Commit e374e89

Browse files
authored
chore: add failed reason to sdks (#554)
* add failed reason to sdks * add failed reason to sdks
1 parent d35539a commit e374e89

8 files changed

Lines changed: 35 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to the searcher sdks will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [Rust: 0.13.0, Python 0.28.0, Javascript 0.29.0, api-types 0.12.0] - 2025-05-14
8+
9+
- Failed bids for swap quotes now have a reason status that exposes why the transaction failed on-chain. [554](https://github.com/pyth-network/per/pull/554)
10+
711
## [Rust: 0.12.0, Python 0.27.0, Javascript 0.28.0, api-types 0.11.0] - 2025-05-09
812

913
- Add a profile ID field to the opportunity api type. [538](https://github.com/pyth-network/per/pull/538)

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/express-relay-js",
3-
"version": "0.28.0",
3+
"version": "0.29.0",
44
"description": "Utilities for interacting with the express relay protocol",
55
"homepage": "https://github.com/pyth-network/per/tree/main/sdk/js",
66
"author": "Douro Labs",

sdk/js/src/serverTypes.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ export interface components {
262262
};
263263
/** @enum {string} */
264264
BidCreateSwapSvmTag: "swap";
265+
/** @enum {string} */
266+
BidFailedReason:
267+
| "insufficient_user_funds"
268+
| "insufficient_searcher_funds"
269+
| "insufficient_funds_sol_transfer"
270+
| "deadline_passed"
271+
| "other";
265272
BidResult: {
266273
/**
267274
* @description The unique id created to identify the bid. This id can be used to query the status of the bid.
@@ -311,6 +318,7 @@ export interface components {
311318
type: "won";
312319
}
313320
| {
321+
reason?: null | components["schemas"]["BidFailedReason"];
314322
/** @example Jb2urXPyEh4xiBgzYvwEFe4q1iMxG1DNxWGGQg94AmKgqFTwLAiTiHrYiYxwHUB4DV8u5ahNEVtMMDm3sNSRdTg */
315323
result: string;
316324
/** @enum {string} */
@@ -670,7 +678,7 @@ export interface components {
670678
/**
671679
* @description Whether the quote is cancellable by the searcher between the time the quote is requested and the time the quote is signed and submitted back.
672680
* For cancellable quotes, the quote needs to be signed and submitted back to the API. If the quote is not cancellable, the user may broadcast the transaction to the blockchain on their own instead of submitting it back to the API.
673-
* Therefore cancellable quotes allow the integrator to reduce the number of API calls to one, but at the cost of potentially worse prices. Price-optimizing integrators should use the default value of false.
681+
* Therefore, non-cancellable quotes allow the integrator to reduce the number of API calls to one, but at the cost of potentially worse prices. Price-optimizing integrators should use the default value of true.
674682
* @example true
675683
*/
676684
cancellable?: boolean;

sdk/python/express_relay/models/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,13 @@ class BidSubmissionFailedReasonVariantsSvm(Enum):
3636
DEADLINE_PASSED = "deadline_passed"
3737

3838

39+
class BidFailedReasonVariantsSvm(Enum):
40+
INSUFFICIENT_USER_FUNDS = "insufficient_user_funds"
41+
INSUFFICIENT_SEARCHER_FUNDS = "insufficient_searcher_funds"
42+
INSUFFICIENT_FUNDS_SOL_TRANSFER = "insufficient_funds_sol_transfer"
43+
DEADLINE_PASSED = "deadline_passed"
44+
OTHER = "other"
45+
46+
3947
IntString = Annotated[int, PlainSerializer(lambda x: str(x), return_type=str)]
4048
UUIDString = Annotated[UUID, PlainSerializer(lambda x: str(x), return_type=str)]

sdk/python/express_relay/models/svm.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Annotated, Any, ClassVar, Literal
55

66
from express_relay.models.base import (
7+
BidFailedReasonVariantsSvm,
78
BidStatusVariantsSvm,
89
BidSubmissionFailedReasonVariantsSvm,
910
IntString,
@@ -382,12 +383,14 @@ class BidStatusSvm(BaseModel):
382383
type: The current status of the bid.
383384
result: The result of the bid: a transaction hash if the status is not PENDING.
384385
The LOST status may have a result.
385-
reason: The reason for the bid submission failure. This is only set when the status is SUBMISSION_FAILED.
386+
reason: The reason for the bid submission failure. This is only set when the status is SUBMISSION_FAILED or FAILED.
386387
"""
387388

388389
type: BidStatusVariantsSvm
389390
result: SvmSignature | None = Field(default=None)
390-
reason: BidSubmissionFailedReasonVariantsSvm | None = Field(default=None)
391+
reason: BidSubmissionFailedReasonVariantsSvm | BidFailedReasonVariantsSvm | None = (
392+
Field(default=None)
393+
)
391394

392395
@field_validator("type", mode="before")
393396
@classmethod
@@ -407,10 +410,13 @@ def check_result(self):
407410

408411
@model_validator(mode="after")
409412
def check_failed_reason(self):
410-
if self.type == BidStatusVariantsSvm.SUBMISSION_FAILED:
413+
if (
414+
self.type == BidStatusVariantsSvm.SUBMISSION_FAILED
415+
or self.type == BidStatusVariantsSvm.FAILED
416+
):
411417
assert (
412418
self.reason is not None
413-
), "bid reason should not be empty when status is submission failed"
419+
), "bid reason should not be empty when status is submission failed or failed"
414420
return self
415421

416422

sdk/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "express-relay"
3-
version = "0.27.0"
3+
version = "0.28.0"
44
description = "Utilities for searchers and protocols to interact with the Express Relay protocol."
55
authors = ["dourolabs"]
66
license = "Apache-2.0"

sdk/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "express-relay-client"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
edition = "2021"
55
description = "Pyth Express Relay client"
66
repository = "https://github.com/pyth-network/per"

0 commit comments

Comments
 (0)