Skip to content

Commit

Permalink
feat: add startBlock to deployment manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed May 4, 2021
1 parent 56fa8b4 commit f7302d6
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 48 deletions.
1 change: 1 addition & 0 deletions docs/sdk/lib-ethers.ethersliquityconnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Exposed through [ReadableEthersLiquity.connection](./lib-ethers.readableethersli
| [liquidityMiningLQTYRewardRate](./lib-ethers.ethersliquityconnection.liquiditymininglqtyrewardrate.md) | [Decimal](./lib-base.decimal.md) | Amount of LQTY collectively rewarded to stakers of the liquidity mining pool per second. |
| [provider](./lib-ethers.ethersliquityconnection.provider.md) | [EthersProvider](./lib-ethers.ethersprovider.md) | Ethers <code>Provider</code> used for connecting to the network. |
| [signer?](./lib-ethers.ethersliquityconnection.signer.md) | [EthersSigner](./lib-ethers.etherssigner.md) | <i>(Optional)</i> Ethers <code>Signer</code> used for sending transactions. |
| [startBlock](./lib-ethers.ethersliquityconnection.startblock.md) | number | Number of block in which the first Liquity contract was deployed. |
| [totalStabilityPoolLQTYReward](./lib-ethers.ethersliquityconnection.totalstabilitypoollqtyreward.md) | [Decimal](./lib-base.decimal.md) | Total amount of LQTY allocated for rewarding stability depositors. |
| [version](./lib-ethers.ethersliquityconnection.version.md) | string | Version of the Liquity contracts (Git commit hash). |
13 changes: 13 additions & 0 deletions docs/sdk/lib-ethers.ethersliquityconnection.startblock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [EthersLiquityConnection](./lib-ethers.ethersliquityconnection.md) &gt; [startBlock](./lib-ethers.ethersliquityconnection.startblock.md)

## EthersLiquityConnection.startBlock property

Number of block in which the first Liquity contract was deployed.

<b>Signature:</b>

```typescript
readonly startBlock: number;
```
1 change: 1 addition & 0 deletions packages/lib-ethers/deployments/default/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_priceFeedIsTestnet": true,
"_uniTokenIsMock": false,
"_isDev": false,
"startBlock": 4547952,
"addresses": {
"activePool": "0x5948018DEeC14642E6127c5a3AC4081798bB73d8",
"borrowerOperations": "0xa36bA16411AF139737E8E345Cd9422a47856bECa",
Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/deployments/default/kovan.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_priceFeedIsTestnet": false,
"_uniTokenIsMock": false,
"_isDev": false,
"startBlock": 24134777,
"addresses": {
"activePool": "0x2FEB8CC8eD32117D1F39168543f29c30fdf10105",
"borrowerOperations": "0xA289111CC4b306E3F5F15c654D4c318B3dA51813",
Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/deployments/default/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_priceFeedIsTestnet": false,
"_uniTokenIsMock": false,
"_isDev": false,
"startBlock": 12178551,
"addresses": {
"activePool": "0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F",
"borrowerOperations": "0x24179CD81c9e782A4096035f7eC97fB8B783e007",
Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/deployments/default/rinkeby.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_priceFeedIsTestnet": false,
"_uniTokenIsMock": false,
"_isDev": false,
"startBlock": 8341450,
"addresses": {
"activePool": "0xbA49275F8F890E7296F64b3e81F1Ada656030150",
"borrowerOperations": "0x91656701b33eca6425A239930FccAA842D0E2031",
Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/deployments/default/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_priceFeedIsTestnet": true,
"_uniTokenIsMock": false,
"_isDev": false,
"startBlock": 9961294,
"addresses": {
"activePool": "0x8bE79B54Bff7754B57294077c2B5017AF9f57dC2",
"borrowerOperations": "0xfe9049E677C5773dd72ac7E19c38c68aB0891744",
Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/etc/lib-ethers.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export interface EthersLiquityConnection extends EthersLiquityConnectionOptional
readonly _priceFeedIsTestnet: boolean;
readonly provider: EthersProvider;
readonly signer?: EthersSigner;
readonly startBlock: number;
readonly totalStabilityPoolLQTYReward: Decimal;
readonly version: string;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/lib-ethers/src/EthersLiquityConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export interface EthersLiquityConnection extends EthersLiquityConnectionOptional
/** Date when the Liquity contracts were deployed. */
readonly deploymentDate: Date;

/** Number of block in which the first Liquity contract was deployed. */
readonly startBlock: number;

/** Time period (in seconds) after `deploymentDate` during which redemptions are disabled. */
readonly bootstrapPeriod: number;

Expand Down
1 change: 1 addition & 0 deletions packages/lib-ethers/src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export interface _LiquityDeploymentJSON {
readonly addresses: _LiquityContractAddresses;
readonly version: string;
readonly deploymentDate: number;
readonly startBlock: number;
readonly bootstrapPeriod: number;
readonly totalStabilityPoolLQTYReward: string;
readonly liquidityMiningLQTYRewardRate: string;
Expand Down
112 changes: 64 additions & 48 deletions packages/lib-ethers/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export const setSilent = (s: boolean): void => {
silent = s;
};

const deployContract = async (
const deployContractAndGetBlockNumber = async (
deployer: Signer,
getContractFactory: (name: string, signer: Signer) => Promise<ContractFactory>,
contractName: string,
...args: unknown[]
) => {
): Promise<[address: string, blockNumber: number]> => {
log(`Deploying ${contractName} ...`);
const contract = await (await getContractFactory(contractName, deployer)).deploy(...args);

Expand All @@ -45,17 +45,28 @@ const deployContract = async (

log();

return contract.address;
return [contract.address, receipt.blockNumber];
};

const deployContract: (
...p: Parameters<typeof deployContractAndGetBlockNumber>
) => Promise<string> = (...p) => deployContractAndGetBlockNumber(...p).then(([a]) => a);

const deployContracts = async (
deployer: Signer,
getContractFactory: (name: string, signer: Signer) => Promise<ContractFactory>,
priceFeedIsTestnet = true,
overrides?: Overrides
): Promise<Omit<_LiquityContractAddresses, "uniToken">> => {
): Promise<[addresses: Omit<_LiquityContractAddresses, "uniToken">, startBlock: number]> => {
const [activePoolAddress, startBlock] = await deployContractAndGetBlockNumber(
deployer,
getContractFactory,
"ActivePool",
{ ...overrides }
);

const addresses = {
activePool: await deployContract(deployer, getContractFactory, "ActivePool", { ...overrides }),
activePool: activePoolAddress,
borrowerOperations: await deployContract(deployer, getContractFactory, "BorrowerOperations", {
...overrides
}),
Expand Down Expand Up @@ -95,40 +106,44 @@ const deployContracts = async (
unipool: await deployContract(deployer, getContractFactory, "Unipool", { ...overrides })
};

return {
...addresses,
lusdToken: await deployContract(
deployer,
getContractFactory,
"LUSDToken",
addresses.troveManager,
addresses.stabilityPool,
addresses.borrowerOperations,
{ ...overrides }
),
return [
{
...addresses,
lusdToken: await deployContract(
deployer,
getContractFactory,
"LUSDToken",
addresses.troveManager,
addresses.stabilityPool,
addresses.borrowerOperations,
{ ...overrides }
),

lqtyToken: await deployContract(
deployer,
getContractFactory,
"LQTYToken",
addresses.communityIssuance,
addresses.lqtyStaking,
addresses.lockupContractFactory,
Wallet.createRandom().address, // _bountyAddress (TODO: parameterize this)
addresses.unipool, // _lpRewardsAddress
Wallet.createRandom().address, // _multisigAddress (TODO: parameterize this)
{ ...overrides }
),
lqtyToken: await deployContract(
deployer,
getContractFactory,
"LQTYToken",
addresses.communityIssuance,
addresses.lqtyStaking,
addresses.lockupContractFactory,
Wallet.createRandom().address, // _bountyAddress (TODO: parameterize this)
addresses.unipool, // _lpRewardsAddress
Wallet.createRandom().address, // _multisigAddress (TODO: parameterize this)
{ ...overrides }
),

multiTroveGetter: await deployContract(
deployer,
getContractFactory,
"MultiTroveGetter",
addresses.troveManager,
addresses.sortedTroves,
{ ...overrides }
)
};
multiTroveGetter: await deployContract(
deployer,
getContractFactory,
"MultiTroveGetter",
addresses.troveManager,
addresses.sortedTroves,
{ ...overrides }
)
},

startBlock
];
};

export const deployTellorCaller = (
Expand Down Expand Up @@ -324,18 +339,19 @@ export const deployAndSetupContracts = async (
_uniTokenIsMock: !wethAddress,
_isDev,

addresses: await deployContracts(
deployer,
getContractFactory,
_priceFeedIsTestnet,
overrides
).then(async addresses => ({
...addresses,
...(await deployContracts(deployer, getContractFactory, _priceFeedIsTestnet, overrides).then(
async ([addresses, startBlock]) => ({
startBlock,

addresses: {
...addresses,

uniToken: await (wethAddress
? createUniswapV2Pair(deployer, wethAddress, addresses.lusdToken, overrides)
: deployMockUniToken(deployer, getContractFactory, overrides))
}))
uniToken: await (wethAddress
? createUniswapV2Pair(deployer, wethAddress, addresses.lusdToken, overrides)
: deployMockUniToken(deployer, getContractFactory, overrides))
}
})
))
};

const contracts = _connectToContracts(deployer, deployment);
Expand Down

0 comments on commit f7302d6

Please sign in to comment.