Skip to content

Commit

Permalink
Simplify deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Jun 7, 2023
1 parent 39df201 commit c4b552c
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 210 deletions.
151 changes: 124 additions & 27 deletions contracts/ethereum/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ modifier onlyOracle()

_Validate the caller is the manager oracle_

### onlyOracleOrRegistry

```solidity
modifier onlyOracleOrRegistry()
```

_Validate the caller is the oracle or registry_

### onlyOracleOrUpkeep

```solidity
Expand Down Expand Up @@ -320,13 +328,13 @@ Activate a given count of the next pending pools
function requestForcedExitReports(uint256 count) external
```

Request reports for a given count of pools forced to exit
Request reports a given count of forced exits

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| count | uint256 | The number of pools forced to exit |
| count | uint256 | The number of forced exits |

### requestCompletedExitReports

Expand All @@ -342,6 +350,20 @@ Request reports for a given count of completed exits
| ---- | ---- | ----------- |
| count | uint256 | The number of completed exits |

### requestReshares

```solidity
function requestReshares(uint64 operatorId) external
```

Request reshares for an operator

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| operatorId | uint64 | The operator ID |

### reportForcedExits

```solidity
Expand Down Expand Up @@ -910,24 +932,6 @@ function getStatus() external view returns (enum ICasimirPool.PoolStatus)

## CasimirRegistry

### requiredCollateral

```solidity
uint256 requiredCollateral
```

### minimumCollateralDeposit

```solidity
uint256 minimumCollateralDeposit
```

### totalCollateral

```solidity
uint256 totalCollateral
```

### onlyOwnerOrPool

```solidity
Expand Down Expand Up @@ -1016,13 +1020,27 @@ Remove a pool from an operator
| poolId | uint32 | The pool ID |
| blameAmount | uint256 | The amount to recover from collateral |

### requestDeregistration

```solidity
function requestDeregistration(uint64 operatorId) external
```

Request deregistration for an operator

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| operatorId | uint64 | The operator ID |

### getOperatorCollateral

```solidity
function getOperatorCollateral(uint64 operatorId) external view returns (int256)
function getOperatorCollateral(uint64 operatorId) external view returns (int256 collateral)
```

Get the collateral for an operator
Get the collateral of an operator

#### Parameters

Expand All @@ -1034,7 +1052,41 @@ Get the collateral for an operator

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | int256 | The collateral |
| collateral | int256 | The collateral |

### getOperatorEligibility

```solidity
function getOperatorEligibility(uint64 operatorId) external view returns (bool eligibility)
```

Get the eligibility of an operator

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| operatorId | uint64 | The operator ID |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| eligibility | bool | The eligibility |

### getOperatorIds

```solidity
function getOperatorIds() external view returns (uint64[])
```

Get the operator IDs

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | uint64[] | operatorIds The operator IDs |

## CasimirUpkeep

Expand Down Expand Up @@ -1247,7 +1299,7 @@ Fulfill the request for testing
### constructor

```solidity
constructor(address managerAddress) public
constructor(address managerAddress, address registryAddress) public
```

### getCompoundablePoolIds
Expand All @@ -1273,6 +1325,27 @@ _Should be called off-chain_
| ---- | ---- | ----------- |
| poolIds | uint32[5] | The next five compoundable pool IDs |

### getEligibleOperatorIds

```solidity
function getEligibleOperatorIds(uint256 startIndex, uint256 endIndex) external view returns (uint64[] activeOperatorIds)
```

Get the active operator IDs

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| startIndex | uint256 | The start index |
| endIndex | uint256 | The end index |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| activeOperatorIds | uint64[] | The active operator IDs |

### getSweptBalance

```solidity
Expand Down Expand Up @@ -1359,10 +1432,10 @@ event DepositInitiated(uint32 poolId)
event DepositActivated(uint32 poolId)
```

### ReshareRequested
### ResharesRequested

```solidity
event ReshareRequested(uint32 poolId)
event ResharesRequested(uint64 operatorId)
```

### ReshareCompleted
Expand Down Expand Up @@ -1533,6 +1606,18 @@ function requestForcedExitReports(uint256 count) external
function requestCompletedExitReports(uint256 count) external
```

### requestReshares

```solidity
function requestReshares(uint64 operatorId) external
```

### reportForcedExits

```solidity
function reportForcedExits(uint32[] poolIds) external
```

### reportCompletedExit

```solidity
Expand Down Expand Up @@ -1818,10 +1903,10 @@ event DeregistrationCompleted(uint64 operatorId)
```solidity
struct Operator {
bool active;
bool resharing;
int256 collateral;
uint256 poolCount;
mapping(uint32 => bool) pools;
bool deregistering;
}
```

Expand Down Expand Up @@ -1861,6 +1946,18 @@ function removeOperatorPool(uint64 operatorId, uint32 poolId, uint256 blameAmoun
function getOperatorCollateral(uint64 operatorId) external view returns (int256)
```

### getOperatorEligibility

```solidity
function getOperatorEligibility(uint64 operatorId) external view returns (bool eligibility)
```

### getOperatorIds

```solidity
function getOperatorIds() external view returns (uint64[])
```

## ICasimirUpkeep

### RequestType
Expand Down
21 changes: 0 additions & 21 deletions contracts/ethereum/helpers/deploy.ts

This file was deleted.

2 changes: 2 additions & 0 deletions contracts/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"scripts": {
"node": "npx hardhat node",
"dev": "npx hardhat run scripts/dev.ts",
"deploy": "npx hardhat run scripts/deploy.ts",
"deploy:multisig": "npx hardhat run scripts/multisig.ts",
"docgen": "npx hardhat docgen",
"test": "npx esno scripts/test.ts --clean \"$npm_config_clean\"",
"clean": "npx hardhat clean",
Expand Down
69 changes: 28 additions & 41 deletions contracts/ethereum/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,36 @@
import { deployContract } from '@casimir/ethereum/helpers/deploy'
import { ContractConfig, DeploymentConfig } from '@casimir/types'
import { ethers } from 'hardhat'

void async function () {
const config: DeploymentConfig = {
CasimirManager: {
address: '',
args: {
oracleAddress: process.env.ORACLE_ADDRESS,
beaconDepositAddress: process.env.BEACON_DEPOSIT_ADDRESS,
linkFunctionsAddress: process.env.LINK_FUNCTIONS_ADDRESS,
linkRegistrarAddress: process.env.LINK_REGISTRAR_ADDRESS,
linkRegistryAddress: process.env.LINK_REGISTRY_ADDRESS,
linkTokenAddress: process.env.LINK_TOKEN_ADDRESS,
ssvNetworkAddress: process.env.SSV_NETWORK_ADDRESS,
ssvNetworkViewsAddress: process.env.SSV_NETWORK_VIEWS_ADDRESS,
ssvTokenAddress: process.env.SSV_TOKEN_ADDRESS,
swapFactoryAddress: process.env.SWAP_FACTORY_ADDRESS,
swapRouterAddress: process.env.SWAP_ROUTER_ADDRESS,
wethTokenAddress: process.env.WETH_TOKEN_ADDRESS
},
options: {},
proxy: false
},
CasimirViews: {
address: '',
args: {
managerAddress: ''
},
options: {},
proxy: false
}
const managerArgs = {
oracleAddress: process.env.ORACLE_ADDRESS,
beaconDepositAddress: process.env.BEACON_DEPOSIT_ADDRESS,
linkFunctionsAddress: process.env.LINK_FUNCTIONS_ADDRESS,
linkRegistrarAddress: process.env.LINK_REGISTRAR_ADDRESS,
linkRegistryAddress: process.env.LINK_REGISTRY_ADDRESS,
linkTokenAddress: process.env.LINK_TOKEN_ADDRESS,
ssvNetworkAddress: process.env.SSV_NETWORK_ADDRESS,
ssvNetworkViewsAddress: process.env.SSV_NETWORK_VIEWS_ADDRESS,
ssvTokenAddress: process.env.SSV_TOKEN_ADDRESS,
swapFactoryAddress: process.env.SWAP_FACTORY_ADDRESS,
swapRouterAddress: process.env.SWAP_ROUTER_ADDRESS,
wethTokenAddress: process.env.WETH_TOKEN_ADDRESS
}
const managerFactory = await ethers.getContractFactory('CasimirManager')
const manager = await managerFactory.deploy(...Object.values(managerArgs))
await manager.deployed()
console.log(`CasimirManager contract deployed to ${manager.address}`)

for (const name in config) {
if (name === 'CasimirViews') {
(config[name as keyof typeof config] as ContractConfig).args.managerAddress = config.CasimirManager.address
}
const registryAddress = await manager.getRegistryAddress()
console.log(`CasimirRegistry contract deployed to ${registryAddress}`)

const { args, options, proxy } = config[name as keyof typeof config] as ContractConfig
const upkeepAddress = await manager.getUpkeepAddress()
console.log(`CasimirUpkeep contract deployed to ${upkeepAddress}`)

const contract = await deployContract(name, proxy, args, options)
const { address } = contract

console.log(`${name} contract deployed to ${address}`)

;(config[name as keyof DeploymentConfig] as ContractConfig).address = address
const viewsArgs = {
managerAddress: manager.address,
registryAddress
}
const viewsFactory = await ethers.getContractFactory('CasimirViews')
const views = await viewsFactory.deploy(...Object.values(viewsArgs))
console.log(`CasimirViews contract deployed to ${views.address}`)
}()
Loading

0 comments on commit c4b552c

Please sign in to comment.