-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Conditional Order factory (#151)
* Add factory * Set rc.3 * Improvements from Leandro Co-authored-by: Leandro <[email protected]> --------- Co-authored-by: Leandro <[email protected]>
- Loading branch information
1 parent
e77585b
commit 34fbd9a
Showing
13 changed files
with
91 additions
and
22 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
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,24 @@ | ||
import { type ConditionalOrder } from './ConditionalOrder' | ||
import { ConditionalOrderParams } from './types' | ||
|
||
export type FromParams<D, S> = (params: ConditionalOrderParams) => ConditionalOrder<D, S> | ||
export type ConditionalOrderRegistry = Record<string, FromParams<unknown, unknown>> | ||
|
||
export class ConditionalOrderFactory { | ||
public knownOrderTypes | ||
|
||
constructor(registry: ConditionalOrderRegistry) { | ||
this.knownOrderTypes = registry | ||
} | ||
|
||
public fromParams(params: ConditionalOrderParams): ConditionalOrder<unknown, unknown> | undefined { | ||
const { handler } = params | ||
|
||
const factory = this.knownOrderTypes[handler] | ||
if (!factory) { | ||
return undefined | ||
} | ||
|
||
return factory(params) | ||
} | ||
} |
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
File renamed without changes.
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,8 @@ | ||
import { ConditionalOrderRegistry } from '../ConditionalOrderFactory' | ||
import { TWAP_ADDRESS, Twap } from './Twap' | ||
export * from './Twap' | ||
|
||
export const DEFAULT_CONDITIONAL_ORDER_REGSTRY: ConditionalOrderRegistry = { | ||
// Registry of all known order types | ||
[TWAP_ADDRESS]: (params) => Twap.fromParams(params), | ||
} |
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 was deleted.
Oops, something went wrong.
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