Skip to content
Draft
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
25 changes: 24 additions & 1 deletion bot/StateRelayerBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,48 @@ export async function handler(props: StateRelayerHandlerProps): Promise<DFCData
const dataMasterNode = transformDataMasternode(statsData);

const nonce = await signer.getNonce();
const feeData = await signer.provider?.getFeeData();
const baseFeePerGas = (await signer.provider?.getBlock('latest'))?.baseFeePerGas || 10_000_000_000n;
let maxFeePerGas: bigint;
let maxPriorityFeePerGas: bigint;
if (feeData?.maxPriorityFeePerGas) {
maxFeePerGas =
feeData.maxFeePerGas ||
baseFeePerGas +
(feeData.maxPriorityFeePerGas >= 10_000_000_000n ? feeData.maxPriorityFeePerGas : 10_000_000_000n);
maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
} else {
maxFeePerGas = baseFeePerGas + 10_000_000_000n;
maxPriorityFeePerGas = 2_000_000_000n;
}
// Call SC Function to update Data
// Update Dex information
const dexInfoTx = await stateRelayerContract.updateDEXInfo(
inputForDexUpdate.dex,
inputForDexUpdate.dexInfo,
inputForDexUpdate.totalValueLocked,
inputForDexUpdate.total24HVolume,
{ nonce: nonce, gasLimit: props.gasUpdateDEX },
{
nonce: nonce,
gasLimit: props.gasUpdateDEX,
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
},
);

// Update Master Node information
const masterDataTx = await stateRelayerContract.updateMasterNodeInformation(dataMasterNode, {
nonce: nonce + 1,
gasLimit: props.gasUpdateMaster,
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
});
// Update Vault general information
const vaultTx = await stateRelayerContract.updateVaultGeneralInformation(dataVault, {
nonce: nonce + 2,
gasLimit: props.gasUpdateVault,
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
});

console.log('Hash of dex update transaction', dexInfoTx.hash);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waveshq/state-relayer-bot",
"version": "0.0.0-beta.5",
"version": "0.0.0-beta.6",
"private": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"extends": "@birthdayresearch/sticky-typescript",
"compilerOptions": {
"lib": [
"es2020", "esnext"
],
"rootDir": "./"
}
}