Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Incede committed Nov 11, 2024
1 parent dd52049 commit 59a6142
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lens-ai-poc",
"name": "lisk-contracts",
"version": "0.0.1",
"description": "Smart Oracle that pushes prices online every hour or when the price difference with the last price is greater or equal than 2%",
"description": "Smart Oracle that pushes prices online if deviation is above 0.5% or last update is more than 6 hours ago",
"scripts": {
"clean": "rm -rf node_modules .tmp",
"format": "prettier --write 'web3-functions/**/*.{js,json,md,ts}'",
Expand Down
11 changes: 5 additions & 6 deletions web3-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {

const oracle = new Contract(oracleAddress, ORACLE_ABI, provider);

let dataFeedIds = new Map<string, DataFeed>();
const dataFeedIds = new Map<string, DataFeed>();
for (const id of dataFeedIdsString) {
dataFeedIds.set(id, {
symbol: id,
Expand Down Expand Up @@ -111,13 +111,12 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
debugLog(getDashLine());
printSignedDataPackage(dataPackageIndex, signedDataPackage);

let dataFeed = dataFeedIds.get(
const dataFeed = dataFeedIds.get(
signedDataPackage.dataPackage.dataPoints[0].dataFeedId
);

if (
dataFeed != undefined &&
dataFeed.symbol === signedDataPackage.dataPackage.dataPoints[0].dataFeedId
dataFeed != undefined
) {
if (dataFeed.livePrice.eq(zero)) {
dataFeed.livePrice = BigNumber.from(
Expand Down Expand Up @@ -153,7 +152,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
console.log(getDashLine());

// Check price deviation and create an array for price feeds which needs to be updated
let priceFeedIdsToUpdate: string[] = [];
const priceFeedIdsToUpdate: string[] = [];
console.log("Price deviations and time elapsed since last update:");
console.log(getDashLine());
for (const dataFeed of dataFeedIds.values()) {
Expand Down Expand Up @@ -189,7 +188,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
if (priceFeedIdsToUpdate.length === 0) {
return {
canExec: false,
message: `No update: price deviation too small or time elapsed since last update is less than 6 hours`,
message: `No update: price deviation less than ${MIN_DEVIATION.toFixed(2)}% or time elapsed since last update is less than ${MIN_TIME_ELAPSED} hours`,
};
}

Expand Down

0 comments on commit 59a6142

Please sign in to comment.