From 4ce52f4e0ca093a0e078529fe5e14e1f7894cac3 Mon Sep 17 00:00:00 2001 From: Ewan Sheldon Date: Wed, 20 Nov 2024 18:03:38 +0100 Subject: [PATCH] push fake redemption endpoint --- app.js | 3 + src/redemptions.js | 157 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 src/redemptions.js diff --git a/app.js b/app.js index a2d8d6a..aec2631 100644 --- a/app.js +++ b/app.js @@ -6,6 +6,7 @@ const { getYieldData } = require('./src/yield.js'); const { estimateSwap, estimateSwapUrl } = require('./src/swap.js'); const { getTransactions, vaultTransactionsAddress } = require('./src/transactions.js'); const { getLiquidationPoolData, liquidationPoolsAddress } = require('./src/liquidationPools.js'); +const { getRedemptionData } = require('./src/redemptions.js'); const port = process.env.PORT || 3000; const server = http.createServer(async (req, res) => { @@ -29,6 +30,8 @@ const server = http.createServer(async (req, res) => { res.end(JSON.stringify(await getTransactions(req.url))); } else if (liquidationPoolsAddress(req.url)) { res.end(JSON.stringify(await getLiquidationPoolData(req.url))); + } else if (req.url === '/redemption') { + res.end(JSON.stringify(await getRedemptionData())) } res.end(); }); diff --git a/src/redemptions.js b/src/redemptions.js new file mode 100644 index 0000000..8448be1 --- /dev/null +++ b/src/redemptions.js @@ -0,0 +1,157 @@ +const { ethers } = require("ethers"); +const managerABI = [ + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "vaultData", + "inputs": [ + { + "name": "_tokenID", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct SmartVaultManagerV6.SmartVaultData", + "components": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralRate", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "mintFeeRate", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "burnFeeRate", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "status", + "type": "tuple", + "internalType": "struct ISmartVault.Status", + "components": [ + { + "name": "vaultAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "minted", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxMintable", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalCollateralValue", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateral", + "type": "tuple[]", + "internalType": "struct ISmartVault.Asset[]", + "components": [ + { + "name": "token", + "type": "tuple", + "internalType": "struct ITokenManager.Token", + "components": [ + { + "name": "symbol", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "addr", + "type": "address", + "internalType": "address" + }, + { + "name": "dec", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "clAddr", + "type": "address", + "internalType": "address" + }, + { + "name": "clDec", + "type": "uint8", + "internalType": "uint8" + } + ] + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "collateralValue", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "liquidated", + "type": "bool", + "internalType": "bool" + }, + { + "name": "version", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "vaultType", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ] + } + ], + "stateMutability": "view" + } +]; + +const getRedemptionData = async _ => { + return ethers.utils.defaultAbiCoder.encode(['uint256','address'],['29','0x82aF49447D8a07e3bd95BD0d56f35241523fBab1']); +}; + +module.exports = { + getRedemptionData +}; +