Reject Job and Refund
Integrating Job Rejection and Refund Logic in Trading Use Cases
Example: Open Position
case JobName.OPEN_POSITION: {
const openPositionPayload = job.requirement as V2DemoOpenPositionPayload;
if (REJECT_AND_REFUND) { // to cater cases where a reject and refund is needed (ie: internal server error)
const reason = `Internal server error handling $${openPositionPayload.symbol} trades`
console.log(`Rejecting and refunding job ${job.id} with reason: ${reason}`);
await job.rejectPayable(
`${reason}. Returned ${openPositionPayload.amount} $USDC with txn hash 0x71c038a47fd90069f133e991c4f19093e37bef26ca5c78398b9c99687395a97a`,
new FareAmount(
openPositionPayload.amount,
config.baseFare
)
)
console.log(`Job ${job.id} rejected and refunded.`);
return;
}Example: Swap Token
Last updated