-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the new order request; Add the mutable type
- Loading branch information
1 parent
872dadb
commit ae84315
Showing
22 changed files
with
279 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import type { NewOrderRequest } from '../../exchange/index'; | ||
import type { SwapPreview } from './swapPreview'; | ||
|
||
export type NewSwapRequest = NewOrderRequest & { | ||
readonly accountAddress: string; | ||
}; | ||
export interface NewSwapRequest { | ||
swapPreview: SwapPreview; | ||
refundAddress?: string; | ||
isInitiator?: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type BigNumber from 'bignumber.js'; | ||
|
||
import type { Currency, Side } from '../../common/index'; | ||
import type { OrderType } from '../../exchange/index'; | ||
|
||
export interface SwapPreview { | ||
readonly type: OrderType; | ||
readonly from: SwapPreviewData; | ||
readonly to: SwapPreviewData; | ||
readonly symbol: string; | ||
readonly side: Side; | ||
readonly fees: { | ||
success: readonly SwapPreviewFee[]; | ||
refund: readonly SwapPreviewFee[]; | ||
} | ||
readonly errors: readonly SwapPreviewError[]; | ||
readonly warnings: readonly SwapPreviewWarning[]; | ||
} | ||
|
||
interface SwapPreviewData { | ||
readonly address: string; | ||
readonly currencyId: Currency['id']; | ||
readonly actual: SwapPreviewCurrencyData; | ||
readonly available: SwapPreviewCurrencyData; | ||
readonly max?: SwapPreviewCurrencyData; | ||
} | ||
|
||
interface SwapPreviewCurrencyData { | ||
readonly amount: BigNumber; | ||
readonly price: BigNumber; | ||
} | ||
|
||
interface SwapPreviewError<TErrorData = unknown> { | ||
readonly id: string | ||
readonly data: TErrorData; | ||
} | ||
|
||
interface SwapPreviewWarning<TWarningData = unknown> { | ||
readonly id: string | ||
readonly data: TWarningData; | ||
} | ||
|
||
interface SwapPreviewFee { | ||
readonly name: string; | ||
readonly currencyId: Currency['id']; | ||
readonly estimated: BigNumber; | ||
readonly max: BigNumber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type BigNumber from 'bignumber.js'; | ||
|
||
import type { Side } from '../../common/index'; | ||
import type { CurrencyDirection, OrderType } from '../../exchange/index'; | ||
|
||
interface SwapPreviewParametersBase { | ||
type: OrderType; | ||
amount: BigNumber; | ||
useWatchTower?: boolean; | ||
} | ||
|
||
export type SwapPreviewParameters = SwapPreviewParametersBase & ( | ||
| { | ||
from: CurrencyDirection['from']; | ||
to: CurrencyDirection['to']; | ||
isFromAmount?: boolean; | ||
symbol?: never; | ||
side?: never; | ||
isQuoteCurrencyAmount?: never; | ||
} | ||
| { | ||
from?: never; | ||
to?: never; | ||
isFromAmount?: never; | ||
symbol: string; | ||
side: Side; | ||
isQuoteCurrencyAmount?: boolean; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
export type Mutable<T> = T extends ReadonlyMap<infer K, infer V> | ||
? Map<K, V> | ||
: T extends ReadonlySet<infer V> | ||
? Set<V> | ||
: T extends (...args: any) => any | ||
? T | ||
: T extends new (...args: any) => any | ||
? T | ||
: unknown extends T | ||
? T | ||
: { | ||
-readonly [K in keyof T]: T[K] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.