Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
delete reserves added and pairsdata returned in the pairsagainstuser …
Browse files Browse the repository at this point in the history
…endpoints
  • Loading branch information
Hammad-Mubeen committed Feb 12, 2022
1 parent 12566a9 commit 775a320
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TOKEN_SYMBOL=DRAG
TOKEN_META=origin fire,lifetime infinite
CONTRACT_NAME=UniSwapRouter

CONTRACT_HASH=88b7a94e1fa619fcc500e506c27965ff9bf91b7afb433930a6c265b347299498
CONTRACT_HASH=493fc8e66c2f1049b28fa661c65a2668c4e9e9e023447349fc9145c82304a65a
PACKAGE_HASH=3de805e07efbc2cd9c5d323ab4fe5f2f0c1c5da33aec527d73de34a1fc9d3735
INSTALL_PAYMENT_AMOUNT=300000000000
MINT_ONE_PAYMENT_AMOUNT=2000000000
Expand Down
Binary file modified JsClients/ROUTER/wasm/uniswap-v2-router.wasm
Binary file not shown.
7 changes: 7 additions & 0 deletions routes/deploypair.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,17 @@ router.route("/getpairagainstuser").post(async function (req, res, next) {
message: "This user has not added liquidity against any pair.",
});
} else {
let pairsdata=[];
for(var i=0;i<result.length;i++)
{
let pairsresult = await pairsModel.findOne({id:result[i].pair});
pairsdata.push(pairsresult);
}
return res.status(200).json({
success: true,
message: "This User has added liquidity against following pairs.",
userpairs: result,
pairsdata:pairsdata
});
}
} catch (error) {
Expand Down
25 changes: 18 additions & 7 deletions routes/listenerroutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,24 @@ router.route("/geteventsdata").post(async function (req, res, next) {
});
await pairagainstuser.create(newData);
} else {
pairagainstuserresult.reserve0 = (
BigInt(pairagainstuserresult.reserve0) - BigInt(reserve0)
).toString();
pairagainstuserresult.reserve1 = (
BigInt(pairagainstuserresult.reserve1) - BigInt(reserve1)
).toString();
await pairagainstuserresult.save();
if (
(
BigInt(pairagainstuserresult.reserve0) - BigInt(reserve0)
).toString() == "0" &&
(
BigInt(pairagainstuserresult.reserve1) - BigInt(reserve1)
).toString() == "0"
) {
await pairagainstuser.deleteOne({ _id: pairagainstuserresult._id });
} else {
pairagainstuserresult.reserve0 = (
BigInt(pairagainstuserresult.reserve0) - BigInt(reserve0)
).toString();
pairagainstuserresult.reserve1 = (
BigInt(pairagainstuserresult.reserve1) - BigInt(reserve1)
).toString();
await pairagainstuserresult.save();
}
}
}
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,3 @@
// pairagainstuserresult.reserve1 = args.amount1;
// await pairagainstuserresult.save();
// }

0 comments on commit 775a320

Please sign in to comment.