-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore CSP v5 deprecated task for ZKEVM. (#101)
- Loading branch information
Showing
10 changed files
with
216,285 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
292 changes: 292 additions & 0 deletions
292
...ecated/20230711-zkevm-composable-stable-pool-v5/artifact/ComposableStablePoolFactory.json
Large diffs are not rendered by default.
Oops, something went wrong.
215,768 changes: 215,768 additions & 0 deletions
215,768
...ated/20230711-zkevm-composable-stable-pool-v5/build-info/ComposableStablePoolFactory.json
Large diffs are not rendered by default.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
tasks/deprecated/20230711-zkevm-composable-stable-pool-v5/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Task, TaskMode, TaskRunOptions } from '@src'; | ||
import { ComposableStablePoolDeployment } from './input'; | ||
|
||
import { ZERO_ADDRESS, ZERO_BYTES32 } from '@helpers/constants'; | ||
import { bn } from '@helpers/numbers'; | ||
import * as expectEvent from '@helpers/expectEvent'; | ||
import { getContractDeploymentTransactionHash, saveContractDeploymentTransactionHash } from '@src'; | ||
import { ethers } from 'hardhat'; | ||
|
||
export default async (task: Task, { force, from }: TaskRunOptions = {}): Promise<void> => { | ||
const input = task.input() as ComposableStablePoolDeployment; | ||
|
||
const args = [input.Vault, input.ProtocolFeePercentagesProvider, input.FactoryVersion, input.PoolVersion]; | ||
const factory = await task.deployAndVerify('ComposableStablePoolFactory', args, from, force); | ||
|
||
if (task.mode === TaskMode.LIVE) { | ||
// We also create a Pool using the factory and verify it, to let us compute their action IDs and so that future | ||
// Pools are automatically verified. We however don't run any of this code in CHECK mode, since we don't care about | ||
// the contracts deployed here. The action IDs will be checked to be correct via a different mechanism. | ||
|
||
// The pauseWindowDuration and bufferPeriodDuration will be filled in later, but we need to declare them here to | ||
// appease the type system. Those are constructor arguments, but automatically provided by the factory. | ||
|
||
const mockPoolArgs = { | ||
vault: input.Vault, | ||
protocolFeeProvider: input.ProtocolFeePercentagesProvider, | ||
name: 'DO NOT USE - Mock Composable Stable Pool', | ||
symbol: 'TEST', | ||
tokens: [input.WETH, input.BAL].sort(function (a, b) { | ||
return a.toLowerCase().localeCompare(b.toLowerCase()); | ||
}), | ||
rateProviders: [ZERO_ADDRESS, ZERO_ADDRESS], | ||
tokenRateCacheDurations: [0, 0], | ||
exemptFromYieldProtocolFeeFlag: false, | ||
amplificationParameter: bn(100), | ||
swapFeePercentage: bn(1e12), | ||
pauseWindowDuration: undefined, | ||
bufferPeriodDuration: undefined, | ||
owner: ZERO_ADDRESS, | ||
version: input.PoolVersion, | ||
}; | ||
|
||
// This mimics the logic inside task.deploy | ||
if (force || !task.output({ ensure: false })['MockComposableStablePool']) { | ||
const poolCreationReceipt = await ( | ||
await factory.create( | ||
mockPoolArgs.name, | ||
mockPoolArgs.symbol, | ||
mockPoolArgs.tokens, | ||
mockPoolArgs.amplificationParameter, | ||
mockPoolArgs.rateProviders, | ||
mockPoolArgs.tokenRateCacheDurations, | ||
mockPoolArgs.exemptFromYieldProtocolFeeFlag, | ||
mockPoolArgs.swapFeePercentage, | ||
mockPoolArgs.owner, | ||
ZERO_BYTES32 | ||
) | ||
).wait(); | ||
const event = expectEvent.inReceipt(poolCreationReceipt, 'PoolCreated'); | ||
const mockPoolAddress = event.args.pool; | ||
|
||
await saveContractDeploymentTransactionHash(mockPoolAddress, poolCreationReceipt.transactionHash, task.network); | ||
await task.save({ MockComposableStablePool: mockPoolAddress }); | ||
} | ||
|
||
const mockPool = await task.instanceAt('ComposableStablePool', task.output()['MockComposableStablePool']); | ||
|
||
// In order to verify the Pool's code, we need to complete its constructor arguments by computing the factory | ||
// provided arguments (pause durations). | ||
|
||
// The durations require knowing when the Pool was created, so we look for the timestamp of its creation block. | ||
const txHash = await getContractDeploymentTransactionHash(mockPool.address, task.network); | ||
const tx = await ethers.provider.getTransactionReceipt(txHash); | ||
const poolCreationBlock = await ethers.provider.getBlock(tx.blockNumber); | ||
|
||
// With those and the period end times, we can compute the durations. | ||
const { pauseWindowEndTime, bufferPeriodEndTime } = await mockPool.getPausedState(); | ||
mockPoolArgs.pauseWindowDuration = pauseWindowEndTime.sub(poolCreationBlock.timestamp); | ||
mockPoolArgs.bufferPeriodDuration = bufferPeriodEndTime | ||
.sub(poolCreationBlock.timestamp) | ||
.sub(mockPoolArgs.pauseWindowDuration); | ||
|
||
// We are now ready to verify the Pool | ||
await task.verify('ComposableStablePool', mockPool.address, [mockPoolArgs]); | ||
} | ||
}; |
26 changes: 26 additions & 0 deletions
26
tasks/deprecated/20230711-zkevm-composable-stable-pool-v5/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Task, TaskMode } from '@src'; | ||
|
||
export type ComposableStablePoolDeployment = { | ||
Vault: string; | ||
ProtocolFeePercentagesProvider: string; | ||
FactoryVersion: string; | ||
PoolVersion: string; | ||
WETH: string; | ||
BAL: string; | ||
}; | ||
|
||
const Vault = new Task('20210418-vault', TaskMode.READ_ONLY); | ||
const ProtocolFeePercentagesProvider = new Task('20220725-protocol-fee-percentages-provider', TaskMode.READ_ONLY); | ||
const WETH = new Task('00000000-tokens', TaskMode.READ_ONLY); | ||
const BAL = new Task('00000000-tokens', TaskMode.READ_ONLY); | ||
|
||
const BaseVersion = { version: 5, deployment: '20230711-composable-stable-pool-v5' }; | ||
|
||
export default { | ||
Vault, | ||
ProtocolFeePercentagesProvider, | ||
WETH, | ||
BAL, | ||
FactoryVersion: JSON.stringify({ name: 'ComposableStablePoolFactory', ...BaseVersion }), | ||
PoolVersion: JSON.stringify({ name: 'ComposableStablePool', ...BaseVersion }), | ||
}; |
4 changes: 4 additions & 0 deletions
4
tasks/deprecated/20230711-zkevm-composable-stable-pool-v5/output/zkevm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"ComposableStablePoolFactory": "0x956CCab09898C0AF2aCa5e6C229c3aD4E93d9288", | ||
"MockComposableStablePool": "0x7682e108Cd89d86303625c8478c21Ff86f401166" | ||
} |
17 changes: 17 additions & 0 deletions
17
tasks/deprecated/20230711-zkevm-composable-stable-pool-v5/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 2023-07-11 - Composable Stable Pool V5 (Polygon ZKEVM) | ||
|
||
> ⚠️ **DEPRECATED** ⚠️ | ||
> | ||
> This version has been replaced just for Polygon ZKEVM chain after the Dragon Fruit hard fork. | ||
> The new deployment can be found [here](../../20230711-composable-stable-pool-v5/), and the build info is exactly the same. The deprecated task is kept to preserve a record of the old deployment addresses and action IDs. | ||
Deployment of `ComposableStablePoolFactory`, which supersedes `20230320-composable-stable-pool-v4`. | ||
This version is resilient to abrupt changes in the value reported by the pool tokens' rate providers, and calculates | ||
protocol fees appropriately even with volatile or rapidly changing token rates. | ||
It also disables individual flags for yield-exempt tokens; now the pool is either yield exempt or non-exempt for every | ||
token. | ||
|
||
## Useful Files | ||
|
||
- [Polygon zkeVM mainnet addresses](./output/zkevm.json) | ||
- [`ComposableStablePoolFactory` artifact](./artifact/ComposableStablePoolFactory.json) |