Code Monkey home page Code Monkey logo

libsushi's Introduction

npm typedoc - v0.1.0

OpenMEV Library for SushiSwap's SushiGuard

Potential statuses

  • PENDING - The transaction was received and is currently being submitted to miners
  • INCLUDED - The transaction was included on-chain
  • FAILED - The transaction was submitted for 25 blocks and failed to be included on-chain
  • CANCELLED - The transaction was cancelled by the user and not included on-chain
  • UNKNOWN - The transaction was not received

Typescript Library

// @see {@link https://github.com/manifoldfinance/libsushi/blob/master/src/SushiGuard/index.ts}
/**
 * @package OpenMevTxState
 * @version 2022.04
 * @see {@link docs.openmev.org}
 * @notice This is a flashbots-api compatible interface ( ~v0.6 )
 *
 * - UNCHECKED -> Tx status has not been checked and there's no information about it.
 * - PROCESSING -> Tx checks are in place until a resolution happens: OK, INDETERMINATE, ERROR.
 * - OK -> Relay received the Tx && all downstream miners accepted without complains && tx mined successfully
 * - INDETERMINATE -> Relay received correctly the Tx && at least one miner accepted the TX && TX potentially mineable
 * - ERROR -> Relay hasn't received the TX || none of the miners accepted the Tx || Tx was not mined successfully
 *
 */

export enum PrivateTxState {
  UNCHECKED = 'UNCHECKED',
  PROCESSING = 'PROCESSING',
  OK = 'OK',
  INDETERMINATE = 'INDETERMINATE',
  ERROR = 'ERROR',
}

export type RelayResponses = Record<string, RelayResponse>;

export interface RelayResponse {
  response: JsonRpcResponse<any>;
  error?: string;
}

export interface PrivateTxStatus {
  transactionHash: string;
  receivedAt: string;
  relayedAt?: string;
  minedAt?: string;
  relayFailure?: boolean;
  relayResponses?: RelayResponses;
}

libsushi's People

Contributors

sambacha avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

libsushi's Issues

Feature: add Transaction Replacement support

When using tx.wait() on a transaction made from the sendTransaction() method of a Signer (including non-constant methods on Contract), if the transaction is repriced or cancelled, a TRANSACTION_REPLACED error is thrown along with some extra details of what happened, allowing for appropriate “next steps” to be taken.

Error {
  code: "TRANSACTION_REPLACED",
  // The reason why the transaction was replaced
  // - "repriced" is generally nothing of concern, the 
  //   only difference in the transaction is the gasPrice
  // - "cancelled" means the `to` has been set to the `from`,
  //   the data has been set to `0x` and value set to 0
  // - "replaced" means that the transaction is unrelated to
  //   the original transaction
  reason: "repriced" | "cancelled" | "replaced",
  // This is a short-hand property as the effects of either a
  // "cancelled" or "replaced" tx are effectively cancelled
  cancelled: (reason === "cancelled" || reason === "replaced"),
  // The TransactionResponse which replaced the original
  replacement: [ the replacement transaction response ]
  // The TransactionReceipt of the replacement transaction
  receipt: [ the receipt for the replacement transaction ],
}

This should be supported 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.