Skip to content

Commit

Permalink
feat(orderbook-api): order solution status (#216)
Browse files Browse the repository at this point in the history
* feat: update services types based on cowprotocol/services#2804

* feat: add getOrderCompetitionStatus method to orderbook api

* chore: bump version to 5.4.0-RC.0

* chore: update orderbook open api version

* chore: bump version to 5.4.0
  • Loading branch information
alfetopito authored Aug 2, 2024
1 parent 97d0315 commit d7e3c54
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cow-sdk",
"version": "5.3.3",
"version": "5.4.0",
"license": "(MIT OR Apache-2.0)",
"files": [
"/dist"
Expand All @@ -27,7 +27,7 @@
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml",
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/varbitrum/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/d8964a5751e8d2077c2db1502c2b429f5c6b50a4/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
"typechain:codegen": "typechain --target ethers-v5 --out-dir ./src/composable/generated './abi/*.json'"
},
"dependencies": {
Expand Down Expand Up @@ -100,4 +100,4 @@
"typescript",
"subgraph"
]
}
}
8 changes: 8 additions & 0 deletions src/order-book/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Address,
AppDataHash,
AppDataObject,
CompetitionOrderStatus,
NativePriceResponse,
Order,
OrderCancellations,
Expand Down Expand Up @@ -227,6 +228,13 @@ export class OrderBookApi {
})
}

/**
* Get the order status while open
*/
getOrderCompetitionStatus(orderUid: UID, contextOverride: PartialApiContext = {}): Promise<CompetitionOrderStatus> {
return this.fetch({ path: `/api/v1/orders/${orderUid}/status`, method: 'GET' }, contextOverride)
}

/**
* Attempt to get an order by its unique identifier, `orderUid`, from multiple environments.
*
Expand Down
2 changes: 2 additions & 0 deletions src/order-book/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export type { BigUint } from './models/BigUint';
export { BuyTokenDestination } from './models/BuyTokenDestination';
export type { CallData } from './models/CallData';
export type { CompetitionAuction } from './models/CompetitionAuction';
export { CompetitionOrderStatus } from './models/CompetitionOrderStatus';
export type { EcdsaSignature } from './models/EcdsaSignature';
export { EcdsaSigningScheme } from './models/EcdsaSigningScheme';
export type { EthflowData } from './models/EthflowData';
export type { ExecutedAmounts } from './models/ExecutedAmounts';
export type { FeePolicy } from './models/FeePolicy';
export type { InteractionData } from './models/InteractionData';
export type { NativePriceResponse } from './models/NativePriceResponse';
Expand Down
6 changes: 6 additions & 0 deletions src/order-book/generated/models/Auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* tslint:disable */
/* eslint-disable */

import type { Address } from './Address';
import type { AuctionOrder } from './AuctionOrder';
import type { AuctionPrices } from './AuctionPrices';

Expand Down Expand Up @@ -35,5 +36,10 @@ export type Auction = {
*/
orders?: Array<AuctionOrder>;
prices?: AuctionPrices;
/**
* List of addresses on whose surplus will count towards the objective value of their solution (unlike other orders that were created by the solver).
*
*/
surplusCapturingJitOrderOwners?: Array<Address>;
};

36 changes: 36 additions & 0 deletions src/order-book/generated/models/CompetitionOrderStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { ExecutedAmounts } from './ExecutedAmounts';

export type CompetitionOrderStatus = {
type: CompetitionOrderStatus.type;
/**
* A list of solvers who participated in the latest competition. The presence of executed amounts defines whether the solver provided a solution for the desired order.
*
*/
value?: Array<{
/**
* Name of the solver.
*/
solver: string;
executedAmounts?: ExecutedAmounts;
}>;
};

export namespace CompetitionOrderStatus {

export enum type {
OPEN = 'Open',
SCHEDULED = 'Scheduled',
ACTIVE = 'Active',
SOLVED = 'Solved',
EXECUTING = 'Executing',
TRADED = 'Traded',
CANCELLED = 'Cancelled',
}


}

11 changes: 11 additions & 0 deletions src/order-book/generated/models/ExecutedAmounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { BigUint } from './BigUint';

export type ExecutedAmounts = {
sell: BigUint;
buy: BigUint;
};

1 change: 1 addition & 0 deletions src/order-book/generated/models/OrderPostError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export namespace OrderPostError {
export enum errorType {
DUPLICATED_ORDER = 'DuplicatedOrder',
QUOTE_NOT_FOUND = 'QuoteNotFound',
QUOTE_NOT_VERIFIED = 'QuoteNotVerified',
INVALID_QUOTE = 'InvalidQuote',
MISSING_FROM = 'MissingFrom',
WRONG_OWNER = 'WrongOwner',
Expand Down
1 change: 1 addition & 0 deletions src/order-book/generated/models/PriceEstimationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type PriceEstimationError = {
export namespace PriceEstimationError {

export enum errorType {
QUOTE_NOT_VERIFIED = 'QuoteNotVerified',
UNSUPPORTED_TOKEN = 'UnsupportedToken',
ZERO_AMOUNT = 'ZeroAmount',
UNSUPPORTED_ORDER_TYPE = 'UnsupportedOrderType',
Expand Down
6 changes: 6 additions & 0 deletions src/order-book/generated/models/Trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import type { Address } from './Address';
import type { BigUint } from './BigUint';
import type { FeePolicy } from './FeePolicy';
import type { TokenAmount } from './TokenAmount';
import type { TransactionHash } from './TransactionHash';
import type { UID } from './UID';
Expand Down Expand Up @@ -53,5 +54,10 @@ export type Trade = {
* Transaction hash of the corresponding settlement transaction containing the trade (if available).
*/
txHash: TransactionHash | null;
/**
* The fee policies that were used to compute the fees for this trade. Listed in the order they got applied.
*
*/
feePolicies?: Array<FeePolicy>;
};

0 comments on commit d7e3c54

Please sign in to comment.