Skip to content

Commit

Permalink
Done BE
Browse files Browse the repository at this point in the history
  • Loading branch information
nvq2309 committed Mar 9, 2024
1 parent 19a7bc0 commit 0b9a365
Show file tree
Hide file tree
Showing 4 changed files with 10,320 additions and 13 deletions.
31 changes: 30 additions & 1 deletion back-end/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ app.get("/api/v2/swapTokenForLP", async (req, res) => {
});

app.get("/api/v2/swapLPForLP", async (req, res) => {
const { tokenRemove, tokenAdd, removePercent, recipient } = req.query;
const { tokenRemove, tokenAdd, removePercent, sender, recipient } = req.query;
const { swapLPForLP } = require("./v2/index");
const calldata = await swapLPForLP(
tokenRemove,
tokenAdd,
sender,
removePercent,
recipient
);
Expand All @@ -131,6 +132,34 @@ app.get("/api/v2/getUserPool", async (req, res) => {
res.status(200).json({ pools });
});

app.get("/api/v2/getAllowance", async (req, res) => {
const { token, owner } = req.query;
const { getAllowance } = require("./v2/index");
const allowance = await getAllowance(token, owner);
res.status(200).json({ allowance });
});

app.get("/api/v2/approve", async (req, res) => {
const { token } = req.query;
const { approve } = require("./v2/index");
const calldata = await approve(token);
res.status(200).json({ calldata });
});

app.get("/api/v2/getSwapParams", async (req, res) => {
const { tokenA, tokenB, removePercent, tokenX, tokenY, sender } = req.query;
const { getSwapParams } = require("./v2/index");
const params = await getSwapParams(
tokenA,
tokenB,
removePercent,
tokenX,
tokenY,
sender
);
res.status(200).json({ params });
});

app.listen(9000, () => {
console.log("Server running on port 9000");
});
Loading

0 comments on commit 0b9a365

Please sign in to comment.