Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for refund option on sendPrivateTransaction #48

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: "./tsconfig.json",
project: './tsconfig.json',
tsconfigRootDir: __dirname,
emcaVersion: 2018,
sourceType: 'module',
Expand All @@ -11,11 +11,24 @@ module.exports = {
root: true,
rules: {
'@typescript-eslint/no-explicit-any': 'off',
"tsdoc/syntax": "warn",
"require-jsdoc": "warn",
"jsdoc/check-tag-names": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/empty-tags": "off"
}
};
'@typescript-eslint/member-delimiter-style': [
'warn',
{
multiline: {
delimiter: 'comma',
requireLast: true,
},
singleline: {
delimiter: 'comma',
requireLast: false,
},
},
],
'tsdoc/syntax': 'warn',
'require-jsdoc': 'warn',
'jsdoc/check-tag-names': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/empty-tags': 'off',
},
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
.idea/
*.log
.env
.vscode
15 changes: 12 additions & 3 deletions src/api/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type IEventHistoryEntry = {
logs?: Array<LogParams>,
gasUsed: string,
mevGasPrice: string,
}
},
}

/**
Expand Down Expand Up @@ -85,7 +85,16 @@ export interface TransactionOptions {
hints?: HintPreferences,
/** Maximum block number for the transaction to be included in. */
maxBlockNumber?: number,
/** Builders that are allowed to receive this tx. See [flashbots docs](https://github.com/flashbots/dowg/blob/main/builder-registrations.json) for supported builders. */
builders?: string[],
/** Specifies how refund should be paid if tx is used by another searcher. */
refund?: Array<{
/** The address that receives this portion of the refund. */
address: string,
/** Percentage of refund to be paid to `address`. Set this to `100` unless splitting refunds between multiple recipients. */
percent: number,
}>,

}

/**
Expand Down Expand Up @@ -128,12 +137,12 @@ export interface BundleParams {
privacy?: {
/** Data fields from bundle transactions to be shared with searchers on MEV-Share. */
hints?: HintPreferences,
/** Builders that are allowed to receive this bundle. See [mev-share spec](https://github.com/flashbots/mev-share/blob/main/builders/registration.json) for supported builders. */
/** Builders that are allowed to receive this bundle. See [flashbots docs](https://github.com/flashbots/dowg/blob/main/builder-registrations.json) for supported builders. */
builders?: Array<string>,
},
metadata?: {
originId?: string,
}
},
}

/** Response received from MEV-Share API */
Expand Down
3 changes: 3 additions & 0 deletions src/api/mungers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export function mungePrivateTxParams(signedTx: string, options?: TransactionOpti
hints: extractSpecifiedHints(options.hints),
},
builders: options?.builders,
validity: options?.refund && {
refund: options.refund
}
},
}]
}
Expand Down