-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add orderLabel, updateOrderResultFromLogs, getDefaultLimitOrderGasreq. * chore: format * feat: Refactor update order test and fix variable declaration. * feat: Add set expiration result from logs params to limit order exports. * feat: Add remove order functionality with deprovision flag. * feat: Add logs result on update and remove unnecessary code. * feat(market-actions): Add functions to wait for order results. * feat: Remove changeset * chore: changeset * refactor: Update return type of waitForMarketOrderResult to exclude 'request' field. --------- Co-authored-by: maxencerb <[email protected]>
- Loading branch information
Showing
7 changed files
with
306 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@mangrovedao/mgv": patch | ||
--- | ||
|
||
Add wait for result on orders |
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,114 @@ | ||
import type { | ||
Client, | ||
TransactionReceipt, | ||
WaitForTransactionReceiptParameters, | ||
} from 'viem' | ||
import { waitForTransactionReceipt } from 'viem/actions' | ||
import { | ||
type LimitOrderResult, | ||
type LimitOrderResultFromLogsParams, | ||
type RemoveOrderResult, | ||
type RemoveOrderResultFromLogsParams, | ||
type SetExpirationResultFromLogsParams, | ||
type UpdateOrderResult, | ||
type UpdateOrderResultFromLogsParams, | ||
limitOrderResultFromLogs, | ||
removeOrderResultFromLogs, | ||
setExpirationResultFromLogs, | ||
updateOrderResultFromLogs, | ||
} from '../../lib/limit-order.js' | ||
import type { | ||
MangroveActionsDefaultParams, | ||
MarketParams, | ||
} from '../../types/index.js' | ||
import { getAction } from '../../utils/getAction.js' | ||
|
||
export type WaitForLimitOrderResultParams = | ||
WaitForTransactionReceiptParameters & | ||
Omit<LimitOrderResultFromLogsParams, 'logs'> | ||
|
||
export type ResultWithReceipt<T> = { receipt: TransactionReceipt; result: T } | ||
|
||
export async function waitForLimitOrderResult( | ||
client: Client, | ||
actionParams: MangroveActionsDefaultParams, | ||
market: MarketParams, | ||
params: WaitForLimitOrderResultParams, | ||
): Promise<ResultWithReceipt<LimitOrderResult>> { | ||
const receipt = await getAction( | ||
client, | ||
waitForTransactionReceipt, | ||
'waitForTransactionReceipt', | ||
)(params) | ||
const result = limitOrderResultFromLogs(actionParams, market, { | ||
...params, | ||
logs: receipt.logs, | ||
}) | ||
return { receipt, result } | ||
} | ||
|
||
export type WaitForLimitOrderUpdateResultParams = | ||
WaitForTransactionReceiptParameters & | ||
Omit<UpdateOrderResultFromLogsParams, 'logs'> | ||
|
||
export async function waitForLimitOrderUpdateResult( | ||
client: Client, | ||
actionParams: MangroveActionsDefaultParams, | ||
market: MarketParams, | ||
params: WaitForLimitOrderUpdateResultParams, | ||
): Promise<ResultWithReceipt<UpdateOrderResult>> { | ||
const receipt = await getAction( | ||
client, | ||
waitForTransactionReceipt, | ||
'waitForTransactionReceipt', | ||
)(params) | ||
const result = updateOrderResultFromLogs(actionParams, market, { | ||
...params, | ||
logs: receipt.logs, | ||
}) | ||
return { receipt, result } | ||
} | ||
|
||
export type WaitForSetExpirationResultParams = | ||
WaitForTransactionReceiptParameters & | ||
Omit<SetExpirationResultFromLogsParams, 'logs'> | ||
|
||
export async function waitForSetExpirationResult( | ||
client: Client, | ||
actionParams: MangroveActionsDefaultParams, | ||
market: MarketParams, | ||
params: WaitForSetExpirationResultParams, | ||
): Promise<ResultWithReceipt<bigint | undefined>> { | ||
const receipt = await getAction( | ||
client, | ||
waitForTransactionReceipt, | ||
'waitForTransactionReceipt', | ||
)(params) | ||
const result = setExpirationResultFromLogs(actionParams, market, { | ||
...params, | ||
logs: receipt.logs, | ||
}) | ||
return { receipt, result } | ||
} | ||
|
||
export type WaitForRemoveLimitOrderResult = | ||
WaitForTransactionReceiptParameters & | ||
Omit<RemoveOrderResultFromLogsParams, 'logs'> | ||
|
||
export async function waitForRemoveLimitOrderResult( | ||
client: Client, | ||
actionParams: MangroveActionsDefaultParams, | ||
market: MarketParams, | ||
params: WaitForRemoveLimitOrderResult, | ||
): Promise<ResultWithReceipt<RemoveOrderResult>> { | ||
const receipt = await getAction( | ||
client, | ||
waitForTransactionReceipt, | ||
'waitForTransactionReceipt', | ||
)(params) | ||
const result = removeOrderResultFromLogs(actionParams, market, { | ||
...params, | ||
logs: receipt.logs, | ||
}) | ||
return { receipt, result } | ||
} |
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.