Skip to content

Commit

Permalink
Merge pull request #1307 from DefiDebauchery/add-single-vault-endpoint
Browse files Browse the repository at this point in the history
Expose single vault endpoint
  • Loading branch information
seguido authored Nov 28, 2023
2 parents 9868537 + 81bf236 commit 600568d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/api/vaults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
getSingleChainVaults,
getMultichainGovVaults,
getSingleChainGovVaults,
getVaultByID,
} = require('../stats/getMultichainVaults');
const { getVaultFees } = require('./getVaultFees');

Expand Down Expand Up @@ -54,6 +55,17 @@ async function singleChainVaults(ctx) {
}
}

async function singleVault(ctx) {
try {
const vault = getVaultByID(ctx.params.vaultId);
ctx.status = vault ? 200 : 404;
ctx.body = vault ?? {};
} catch (err) {
console.error(err);
ctx.status = 500;
}
}

async function singleGovChainVaults(ctx) {
try {
const chainVaults = getSingleChainGovVaults(ctx.params.chainId);
Expand Down Expand Up @@ -81,6 +93,7 @@ module.exports = {
multichainGovVaults,
singleChainVaults,
singleGovChainVaults,
singleVault,
vaultFees,
vaultsLastHarvest,
};
1 change: 1 addition & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ router.get('/vaults', multichainVaults.multichainVaults);
router.get('/vaults/zap-support', vaultZapSupport);
router.get('/vaults/zap-support/debug', vaultZapSupportDebug);
router.get('/vaults/last-harvest', multichainVaults.vaultsLastHarvest);
router.get('/vaults/id/:vaultId', multichainVaults.singleVault);
router.get('/vaults/:chainId', multichainVaults.singleChainVaults);
router.get('/gov-vaults', multichainVaults.multichainGovVaults);
router.get('/gov-vaults/:chainId', multichainVaults.singleGovChainVaults);
Expand Down

0 comments on commit 600568d

Please sign in to comment.