diff --git a/.github/workflows/dispatch-draft-release.yml b/.github/workflows/dispatch-draft-release.yml deleted file mode 100644 index de180c9..0000000 --- a/.github/workflows/dispatch-draft-release.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Draft release - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: true - -on: - workflow_dispatch: - -jobs: - draft-release: - uses: bgd-labs/github-workflows/.github/workflows/draft-release.yml@main diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..58f6c25 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,34 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please +jobs: + test-node: + uses: bgd-labs/github-workflows/.github/workflows/test-node.yml@main + + release-please: + runs-on: ubuntu-latest + outputs: + releaseCreated: ${{ steps.release.outputs.release_created }} + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + package-name: aave-cli + pull-request-header: 'I have created a release' + + release-node: + uses: bgd-labs/github-workflows/.github/workflows/release-node.yml@main + if: ${{ needs.release-please.outputs.releaseCreated }} + needs: + - test-node + - release-please + secrets: + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml deleted file mode 100644 index f2c09ad..0000000 --- a/.github/workflows/test-release.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Test & release - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -on: - push: - branches: - - main - -jobs: - test-node: - uses: bgd-labs/github-workflows/.github/workflows/test-node.yml@main - release: - uses: bgd-labs/github-workflows/.github/workflows/release.yml@main - needs: test-node - release-node: - uses: bgd-labs/github-workflows/.github/workflows/release-node.yml@main - needs: test-node - secrets: - NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index b7208a4..2d0af29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.26](https://github.com/bgd-labs/report-engine/compare/v0.0.25...v0.0.26) (2023-10-03) + + +### Features + +* expose tenderly setCode ([e45aff4](https://github.com/bgd-labs/report-engine/commit/e45aff413ef831434b38e330d1bbe451fa84509e)) + + +### Bug Fixes + +* work around concat bug ([6bfb027](https://github.com/bgd-labs/report-engine/commit/6bfb0275b59a19cbe944b2976ae5c3e7167e96b5)) + ### [0.0.25](https://github.com/bgd-labs/report-engine/compare/v0.0.24...v0.0.25) (2023-09-25) diff --git a/package.json b/package.json index e12ed6d..24e3fda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bgd-labs/aave-cli", - "version": "0.0.25", + "version": "0.0.26", "description": "A cli to perform various aave governance related tasks", "private": false, "scripts": { diff --git a/src/reports/__snapshots__/reserve.spec.ts.snap b/src/reports/__snapshots__/reserve.spec.ts.snap index f32da78..307400a 100644 --- a/src/reports/__snapshots__/reserve.spec.ts.snap +++ b/src/reports/__snapshots__/reserve.spec.ts.snap @@ -46,3 +46,41 @@ exports[`reserve > renderReserve > should properly render new reserve 1`] = ` | interestRateStrategy | [0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f](https://etherscan.io/address/0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f) | " `; + +exports[`reserve > renderReserve > should properly render new reserve with local chain id 1`] = ` +"#### WBTC (0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f) + +| description | value | +| --- | --- | +| decimals | 8 | +| isActive | true | +| isFrozen | false | +| supplyCap | 2,100 WBTC | +| borrowCap | 1,115 WBTC | +| debtCeiling | 1,000 $ | +| isSiloed | false | +| isFlashloanable | false | +| eModeCategory | 0 | +| oracle | 0x6ce185860a4963106506C203335A2910413708e9 | +| oracleDecimals | 8 | +| oracleDescription | BTC / USD | +| oracleName | BTC / USD | +| oracleLatestAnswer | 22519.04551524 | +| usageAsCollateralEnabled | true | +| ltv | 70 % | +| liquidationThreshold | 75.55 % | +| liquidationBonus | 10 % | +| liquidationProtocolFee | 10 % | +| reserveFactor | 20 % | +| aToken | 0x078f358208685046a11C85e8ad32895DED33A249 | +| aTokenImpl | 0xa5ba6E5EC19a1Bf23C857991c857dB62b2Aa187B | +| variableDebtToken | 0x92b42c66840C7AD907b4BF74879FF3eF7c529473 | +| variableDebtTokenImpl | 0x81387c40EB75acB02757C1Ae55D5936E78c9dEd3 | +| stableDebtToken | 0x633b207Dd676331c413D4C013a6294B0FE47cD0e | +| stableDebtTokenImpl | 0x52A1CeB68Ee6b7B5D13E0376A1E0E4423A8cE26e | +| borrowingEnabled | true | +| stableBorrowRateEnabled | false | +| isBorrowableInIsolation | false | +| interestRateStrategy | 0x9b34E3e183c9b0d1a08fF57a8fb59c821616295f | +" +`; diff --git a/src/reports/reserve.spec.ts b/src/reports/reserve.spec.ts index 6132fa6..bd32e52 100644 --- a/src/reports/reserve.spec.ts +++ b/src/reports/reserve.spec.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; import { diff } from './diff'; -import { AaveV3Reserve } from './snapshot-types'; +import { AaveV3Reserve, CHAIN_ID } from './snapshot-types'; import { renderReserve, renderReserveDiff, renderReserveValue } from './reserve'; const WBTC_MOCK = { @@ -49,12 +49,22 @@ describe('reserve', () => { it('lt', () => { expect(renderReserveValue('liquidationThreshold', WBTC_MOCK, 1)).toBe('75.55 %'); }); + it('address with block explorer', () => { + expect(renderReserveValue('aToken', WBTC_MOCK, 1)).toBe(`[${WBTC_MOCK.aToken}](https://etherscan.io/address/${WBTC_MOCK.aToken})`); + }); + it('address without block explorer', () => { + expect(renderReserveValue('aToken', WBTC_MOCK, 31337 as CHAIN_ID)).toBe(WBTC_MOCK.aToken); + }); }); describe('renderReserve', () => { it('should properly render new reserve', () => { const out = renderReserve(WBTC_MOCK, 1); expect(out).toMatchSnapshot(); }); + it('should properly render new reserve with local chain id', () => { + const out = renderReserve(WBTC_MOCK, 31337 as CHAIN_ID); + expect(out).toMatchSnapshot(); + }); it('should properly render altered reserve', () => { const input: AaveV3Reserve = { ...WBTC_MOCK, borrowCap: 100 }; const out = diff(WBTC_MOCK, { ...input }); diff --git a/src/reports/reserve.ts b/src/reports/reserve.ts index 0b7f032..e111773 100644 --- a/src/reports/reserve.ts +++ b/src/reports/reserve.ts @@ -1,26 +1,19 @@ import { formatUnits } from 'viem'; import { AaveV3Reserve, CHAIN_ID } from './snapshot-types'; -export const getBlockExplorerLink: { - [key in CHAIN_ID]: (address: string) => string; -} = { - [CHAIN_ID.MAINNET]: (address) => - `[${address}](https://etherscan.io/address/${address})`, - [CHAIN_ID.OPTIMISM]: (address) => - `[${address}](https://optimistic.etherscan.io/address/${address})`, - [CHAIN_ID.POLYGON]: (address) => - `[${address}](https://polygonscan.com/address/${address})`, - [CHAIN_ID.FANTOM]: (address) => - `[${address}](https://ftmscan.com/address/${address})`, - [CHAIN_ID.ARBITRUM]: (address) => - `[${address}](https://arbiscan.io/address/${address})`, - [CHAIN_ID.AVALANCHE]: (address) => - `[${address}](https://snowtrace.io/address/${address})`, - [CHAIN_ID.METIS]: (address) => - `[${address}](https://andromeda-explorer.metis.io/address/${address})`, - [CHAIN_ID.BASE]: (address) => - `[${address}](https://basescan.org/address/${address})`, -}; +export const getBlockExplorerLink = (chain: number, address: string): string => { + switch (chain) { + case CHAIN_ID.MAINNET: return `[${address}](https://etherscan.io/address/${address})`; + case CHAIN_ID.OPTIMISM: return `[${address}](https://optimistic.etherscan.io/address/${address})`; + case CHAIN_ID.POLYGON: return `[${address}](https://polygonscan.com/address/${address})`; + case CHAIN_ID.FANTOM: return `[${address}](https://ftmscan.com/address/${address})`; + case CHAIN_ID.ARBITRUM: return `[${address}](https://arbiscan.io/address/${address})`; + case CHAIN_ID.AVALANCHE: return `[${address}](https://snowtrace.io/address/${address})`; + case CHAIN_ID.METIS: return `[${address}](https://andromeda-explorer.metis.io/address/${address})`; + case CHAIN_ID.BASE: return `[${address}](https://basescan.org/address/${address})`; + default: return address; + }; +} export function renderReserveValue( key: T, @@ -47,18 +40,18 @@ export function renderReserveValue( ? '0 %' : `${((reserve[key] as number) - 10000) / 100} %`; if (key === 'interestRateStrategy') - return getBlockExplorerLink[chainId](reserve[key] as string); + return getBlockExplorerLink(chainId, reserve[key] as string); if (key === 'oracleLatestAnswer' && reserve.oracleDecimals) return formatUnits(BigInt(reserve[key]), reserve.oracleDecimals); if (typeof reserve[key] === 'number') return reserve[key].toLocaleString('en-US'); if (typeof reserve[key] === 'string' && /0x.+/.test(reserve[key] as string)) - return getBlockExplorerLink[chainId](reserve[key] as string); + return getBlockExplorerLink(chainId, reserve[key] as string); return reserve[key]; } function renderReserveHeadline(reserve: AaveV3Reserve, chainId: CHAIN_ID) { - return `#### ${reserve.symbol} (${getBlockExplorerLink[chainId]( + return `#### ${reserve.symbol} (${getBlockExplorerLink(chainId, reserve.underlying )})\n\n`; } diff --git a/src/utils/storageSlots.ts b/src/utils/storageSlots.ts index 1a00e10..acdf890 100644 --- a/src/utils/storageSlots.ts +++ b/src/utils/storageSlots.ts @@ -61,7 +61,10 @@ export function getDynamicArraySlot(baseSlot: bigint, arrayIndex: number, itemSi export function getBytesValue(value: string | Hex) { const bytesString = toBytes(value); if (bytesString.length > 31) throw new Error('Error: strings > 31 bytes are not implemented'); - return concat([toHex(pad(bytesString, { size: 31, dir: 'right' })), toHex(bytesString.length * 2, { size: 1 })]); + return pad( + concat([toHex(pad(bytesString, { size: 31, dir: 'right' })), toHex(bytesString.length * 2, { size: 1 })]), + { size: 32 } + ); } /**