Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cowprotocol/cow-sdk into fe…
Browse files Browse the repository at this point in the history
…at/swap-for-people
  • Loading branch information
shoom3301 committed Sep 2, 2024
2 parents 5639517 + b898ea3 commit 92c7d14
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 2 deletions.
4 changes: 2 additions & 2 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.1",
"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/v2.272.1/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
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
3 changes: 3 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 All @@ -42,6 +44,7 @@ export { PriceEstimationError } from './models/PriceEstimationError';
export type { PriceImprovement } from './models/PriceImprovement';
export { PriceQuality } from './models/PriceQuality';
export type { ProtocolAppData } from './models/ProtocolAppData';
export type { Quote } from './models/Quote';
export { SellTokenSource } from './models/SellTokenSource';
export type { Signature } from './models/Signature';
export { SigningScheme } from './models/SigningScheme';
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>;
};

10 changes: 10 additions & 0 deletions src/order-book/generated/models/AuctionOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { FeePolicy } from './FeePolicy';
import type { InteractionData } from './InteractionData';
import type { OrderClass } from './OrderClass';
import type { OrderKind } from './OrderKind';
import type { Quote } from './Quote';
import type { SellTokenSource } from './SellTokenSource';
import type { Signature } from './Signature';
import type { TokenAmount } from './TokenAmount';
Expand Down Expand Up @@ -36,6 +37,10 @@ export type AuctionOrder = {
* see `OrderParameters::buyAmount`
*/
buyAmount: TokenAmount;
/**
* Creation time of the order. Denominated in epoch seconds.
*/
created: string;
/**
* see `OrderParameters::validTo`
*/
Expand Down Expand Up @@ -84,5 +89,10 @@ export type AuctionOrder = {
*
*/
protocolFees: Array<FeePolicy>;
/**
* A winning quote.
*
*/
quote?: Quote;
};

37 changes: 37 additions & 0 deletions src/order-book/generated/models/CompetitionOrderStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* 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, sorted by score in ascending order, where the last element is the winner.
* 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/PriceImprovement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
/* tslint:disable */
/* eslint-disable */

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

/**
* The protocol fee is taken as a percent of the order price improvement which is a difference between the executed price and the best quote.
*/
export type PriceImprovement = {
factor: number;
maxVolumeFactor: number;
/**
* The best quote received.
*/
quote: Quote;
};

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

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

/**
* A calculated order quote.
*
*/
export type Quote = {
/**
* The amount of the sell token.
*/
sellAmount?: TokenAmount;
/**
* The amount of the buy token.
*/
buyAmount?: TokenAmount;
/**
* The amount that needs to be paid, denominated in the sell token.
*/
fee?: TokenAmount;
};

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 92c7d14

Please sign in to comment.