Skip to content

Commit

Permalink
feat: generate specification
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Nov 2, 2023
1 parent efdbcbf commit 5671fb3
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 7 deletions.
67 changes: 66 additions & 1 deletion generator/features/__snapshots__/assetListing.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ discussions: \\"test\\"
## Specification
On AaveV3Ethereum the following steps are performed:
The table below illustrates the configured risk parameters for **PSP**
| Parameter | Value |
| ---------------------------------- | -----------------------------------------: |
| Isolation Mode | true |
| Borrowable | ENABLED |
| Collateral Enabled | true |
| Supply Cap (PSP) | 10_000 |
| Borrow Cap (PSP) | 5_000 |
| Debt Ceiling | 100_000 |
| LTV | 40_00 |
| LT | 50_00 |
| Liquidation Bonus | 5_00 |
| Liquidation Protocol Fee | 20_00 |
| Reserve Factor | 20_00 |
| Base Variable Borrow Rate | \\\\_bpsToRay(0_00) |
| Variable Slope 1 | \\\\_bpsToRay(10_00) |
| Variable Slope 2 | \\\\_bpsToRay(100_00) |
| Uoptimal | \\\\_bpsToRay(80_00) |
| Stable Borrowing | DISABLED |
| Stable Slope1 | \\\\_bpsToRay(10_00) |
| Stable Slope2 | \\\\_bpsToRay(100_00) |
| Base Stable Rate Offset | \\\\_bpsToRay(1_00) |
| Stable Rate Excess Offset | \\\\_bpsToRay() |
| Optimal Stable To Total Debt Ratio | \\\\_bpsToRay(10_00) |
| Flahloanable | ENABLED |
| Siloed Borrowing | DISABLED |
| Borrowable in Isolation | DISABLED |
| Oracle | 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8 |
## References
- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol)
Expand Down Expand Up @@ -167,7 +198,7 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
AaveV3Ethereum_Test_20231023 internal proposal;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18484119);
vm.createSelectFork(vm.rpcUrl('mainnet'), 18485230);
proposal = new AaveV3Ethereum_Test_20231023();
}
Expand Down Expand Up @@ -244,6 +275,40 @@ contract CreateProposal is EthereumScript {
exports[`feature: assetListing > should return reasonable code 1`] = `
{
"aip": {
"specification": [
"The table below illustrates the configured risk parameters for **PSP**
| Parameter | Value |
| --- | --: |
| Isolation Mode | true |
| Borrowable | ENABLED |
| Collateral Enabled | true |
| Supply Cap (PSP) | 10_000 |
| Borrow Cap (PSP) | 5_000 |
| Debt Ceiling | 100_000 |
| LTV | 40_00 |
| LT | 50_00 |
| Liquidation Bonus | 5_00 |
| Liquidation Protocol Fee | 20_00 |
| Reserve Factor | 20_00 |
| Base Variable Borrow Rate | _bpsToRay(0_00) |
| Variable Slope 1 | _bpsToRay(10_00) |
| Variable Slope 2 | _bpsToRay(100_00) |
| Uoptimal | _bpsToRay(80_00) |
| Stable Borrowing | DISABLED |
| Stable Slope1 | _bpsToRay(10_00) |
| Stable Slope2 | _bpsToRay(100_00) |
| Base Stable Rate Offset | _bpsToRay(1_00) |
| Stable Rate Excess Offset | _bpsToRay() |
| Optimal Stable To Total Debt Ratio | _bpsToRay(10_00) |
| Flahloanable | ENABLED |
| Siloed Borrowing | DISABLED |
| Borrowable in Isolation | DISABLED |
| Oracle | 0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8 |
",
],
},
"code": {
"constants": [
"address public constant PSP = 0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5;",
Expand Down
37 changes: 35 additions & 2 deletions generator/features/assetListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,39 @@ export const assetListing: FeatureModule<Listing[]> = {
}`
),
},
aip: {
specification: cfg.map((cfg) => {
let listingTemplate = `The table below illustrates the configured risk parameters for **${cfg.assetSymbol}**\n\n`;
listingTemplate += `| Parameter | Value |\n`;
listingTemplate += `| --- | --: |\n`;
listingTemplate += `| Isolation Mode | ${!!cfg.debtCeiling} |\n`;
listingTemplate += `| Borrowable | ${cfg.enabledToBorrow} |\n`;
listingTemplate += `| Collateral Enabled | ${!!cfg.liqThreshold} |\n`;
listingTemplate += `| Supply Cap (${cfg.assetSymbol}) | ${cfg.supplyCap} |\n`;
listingTemplate += `| Borrow Cap (${cfg.assetSymbol}) | ${cfg.borrowCap} |\n`;
listingTemplate += `| Debt Ceiling | ${cfg.debtCeiling} |\n`;
listingTemplate += `| LTV | ${cfg.ltv} |\n`;
listingTemplate += `| LT | ${cfg.liqThreshold} |\n`;
listingTemplate += `| Liquidation Bonus | ${cfg.liqBonus} |\n`;
listingTemplate += `| Liquidation Protocol Fee | ${cfg.liqProtocolFee} |\n`;
listingTemplate += `| Reserve Factor | ${cfg.reserveFactor} |\n`;
listingTemplate += `| Base Variable Borrow Rate | ${cfg.rateStrategyParams.baseVariableBorrowRate} |\n`;
listingTemplate += `| Variable Slope 1 | ${cfg.rateStrategyParams.variableRateSlope1} |\n`;
listingTemplate += `| Variable Slope 2 | ${cfg.rateStrategyParams.variableRateSlope2} |\n`;
listingTemplate += `| Uoptimal | ${cfg.rateStrategyParams.optimalUtilizationRate} |\n`;
listingTemplate += `| Stable Borrowing | ${cfg.stableRateModeEnabled} |\n`;
listingTemplate += `| Stable Slope1 | ${cfg.rateStrategyParams.stableRateSlope1} |\n`;
listingTemplate += `| Stable Slope2 | ${cfg.rateStrategyParams.stableRateSlope2} |\n`;
listingTemplate += `| Base Stable Rate Offset | ${cfg.rateStrategyParams.baseStableRateOffset} |\n`;
listingTemplate += `| Stable Rate Excess Offset | ${cfg.rateStrategyParams.stableRateExcessOffset} |\n`;
listingTemplate += `| Optimal Stable To Total Debt Ratio | ${cfg.rateStrategyParams.optimalStableToTotalDebtRatio} |\n`;
listingTemplate += `| Flahloanable | ${cfg.flashloanable} |\n`;
listingTemplate += `| Siloed Borrowing | ${cfg.withSiloedBorrowing} |\n`;
listingTemplate += `| Borrowable in Isolation | ${cfg.borrowableInIsolation} |\n`;
listingTemplate += `| Oracle | ${cfg.priceFeed} |\n`;
return listingTemplate;
}),
},
};
return response;
},
Expand Down Expand Up @@ -203,8 +236,8 @@ export const assetListingCustom: FeatureModule<ListingWithCustomImpl[]> = {
.map(
(cfg, ix) => `listings[${ix}] = IAaveV3ConfigEngine.ListingWithCustomImpl(
IAaveV3ConfigEngine.Listing({
asset: ${cfg.base.assetSymbol},
assetSymbol: "${cfg.base.assetSymbol}",
asset: ${cfg.base.assetSymbol},
assetSymbol: "${cfg.base.assetSymbol}",
priceFeed: ${cfg.base.priceFeed},
eModeCategory: ${cfg.base.eModeCategory},
enabledToBorrow: ${cfg.base.enabledToBorrow},
Expand Down
10 changes: 6 additions & 4 deletions generator/templates/aip.template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {generateContractName, generateFolderName} from '../common';
import {Options, PoolConfigs} from '../types';
import {Options, PoolConfigs, PoolIdentifier} from '../types';

export function generateAIP(options: Options, configs: PoolConfigs) {
return `---
Expand All @@ -14,11 +14,13 @@ discussions: ${`"${options.discussion}"` || 'TODO'}
## Specification
${Object.keys(configs).map((pool) => {
${options.pools.map((pool) => {
let template = `On ${pool} the following steps are performed:\n`;
template += configs[pool].artifacts
template += configs[pool]?.artifacts
.filter((artifact) => artifact.aip)
.map((artifact) => artifact.aip);
.map((artifact) => artifact.aip?.specification)
.join('\n\n');
return template;
})}
## References
Expand Down

0 comments on commit 5671fb3

Please sign in to comment.