Skip to content

Commit

Permalink
fetching gas estimation values for bsc from api.owlracle.info
Browse files Browse the repository at this point in the history
  • Loading branch information
Zikriya committed Oct 30, 2023
1 parent 6ae89fa commit 7358a04
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions app/lib/crons/getGasEstimationJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,26 @@ async function getGasEstimation(network: any) {

async function updateGas(network: any, gasEstimation: any) {
let speed = getSpeed(gasEstimation);
let body: any = {};
if (network && speed) {
let body = {
dynamicValues: {
maxFeePerGas: speed?.maxFeePerGas ? speed?.maxFeePerGas : null,
maxPriorityFeePerGas: speed?.maxPriorityFeePerGas
? speed?.maxPriorityFeePerGas
: null,
},
};
if (network.chainId == 56) {
body = {
dynamicValues: {
maxFeePerGas: speed?.gasPrice ? speed?.gasPrice : null,
maxPriorityFeePerGas: speed?.gasPrice ? speed?.gasPrice : null,
},
};
} else {
body = {
dynamicValues: {
maxFeePerGas: speed?.maxFeePerGas ? speed?.maxFeePerGas : null,
maxPriorityFeePerGas: speed?.maxPriorityFeePerGas
? speed?.maxPriorityFeePerGas
: null,
},
};
}

await db.GasFees.findOneAndUpdate({ chainId: network.chainId }, body, {
new: true,
});
Expand Down

0 comments on commit 7358a04

Please sign in to comment.