Skip to content

Commit

Permalink
push fake redemption endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ewansheldon committed Nov 20, 2024
1 parent e26ae75 commit 4ce52f4
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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();
});
Expand Down
157 changes: 157 additions & 0 deletions src/redemptions.js
Original file line number Diff line number Diff line change
@@ -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
};

0 comments on commit 4ce52f4

Please sign in to comment.