Skip to content

Commit f7302d6

Browse files
feat: add startBlock to deployment manifests
1 parent 56fa8b4 commit f7302d6

11 files changed

+88
-48
lines changed

docs/sdk/lib-ethers.ethersliquityconnection.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Exposed through [ReadableEthersLiquity.connection](./lib-ethers.readableethersli
3030
| [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. |
3131
| [provider](./lib-ethers.ethersliquityconnection.provider.md) | [EthersProvider](./lib-ethers.ethersprovider.md) | Ethers <code>Provider</code> used for connecting to the network. |
3232
| [signer?](./lib-ethers.ethersliquityconnection.signer.md) | [EthersSigner](./lib-ethers.etherssigner.md) | <i>(Optional)</i> Ethers <code>Signer</code> used for sending transactions. |
33+
| [startBlock](./lib-ethers.ethersliquityconnection.startblock.md) | number | Number of block in which the first Liquity contract was deployed. |
3334
| [totalStabilityPoolLQTYReward](./lib-ethers.ethersliquityconnection.totalstabilitypoollqtyreward.md) | [Decimal](./lib-base.decimal.md) | Total amount of LQTY allocated for rewarding stability depositors. |
3435
| [version](./lib-ethers.ethersliquityconnection.version.md) | string | Version of the Liquity contracts (Git commit hash). |
3536
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@liquity/lib-ethers](./lib-ethers.md) &gt; [EthersLiquityConnection](./lib-ethers.ethersliquityconnection.md) &gt; [startBlock](./lib-ethers.ethersliquityconnection.startblock.md)
4+
5+
## EthersLiquityConnection.startBlock property
6+
7+
Number of block in which the first Liquity contract was deployed.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
readonly startBlock: number;
13+
```

packages/lib-ethers/deployments/default/goerli.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"_priceFeedIsTestnet": true,
99
"_uniTokenIsMock": false,
1010
"_isDev": false,
11+
"startBlock": 4547952,
1112
"addresses": {
1213
"activePool": "0x5948018DEeC14642E6127c5a3AC4081798bB73d8",
1314
"borrowerOperations": "0xa36bA16411AF139737E8E345Cd9422a47856bECa",

packages/lib-ethers/deployments/default/kovan.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"_priceFeedIsTestnet": false,
99
"_uniTokenIsMock": false,
1010
"_isDev": false,
11+
"startBlock": 24134777,
1112
"addresses": {
1213
"activePool": "0x2FEB8CC8eD32117D1F39168543f29c30fdf10105",
1314
"borrowerOperations": "0xA289111CC4b306E3F5F15c654D4c318B3dA51813",

packages/lib-ethers/deployments/default/mainnet.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"_priceFeedIsTestnet": false,
99
"_uniTokenIsMock": false,
1010
"_isDev": false,
11+
"startBlock": 12178551,
1112
"addresses": {
1213
"activePool": "0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F",
1314
"borrowerOperations": "0x24179CD81c9e782A4096035f7eC97fB8B783e007",

packages/lib-ethers/deployments/default/rinkeby.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"_priceFeedIsTestnet": false,
99
"_uniTokenIsMock": false,
1010
"_isDev": false,
11+
"startBlock": 8341450,
1112
"addresses": {
1213
"activePool": "0xbA49275F8F890E7296F64b3e81F1Ada656030150",
1314
"borrowerOperations": "0x91656701b33eca6425A239930FccAA842D0E2031",

packages/lib-ethers/deployments/default/ropsten.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"_priceFeedIsTestnet": true,
99
"_uniTokenIsMock": false,
1010
"_isDev": false,
11+
"startBlock": 9961294,
1112
"addresses": {
1213
"activePool": "0x8bE79B54Bff7754B57294077c2B5017AF9f57dC2",
1314
"borrowerOperations": "0xfe9049E677C5773dd72ac7E19c38c68aB0891744",

packages/lib-ethers/etc/lib-ethers.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export interface EthersLiquityConnection extends EthersLiquityConnectionOptional
233233
readonly _priceFeedIsTestnet: boolean;
234234
readonly provider: EthersProvider;
235235
readonly signer?: EthersSigner;
236+
readonly startBlock: number;
236237
readonly totalStabilityPoolLQTYReward: Decimal;
237238
readonly version: string;
238239
}

packages/lib-ethers/src/EthersLiquityConnection.ts

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export interface EthersLiquityConnection extends EthersLiquityConnectionOptional
6666
/** Date when the Liquity contracts were deployed. */
6767
readonly deploymentDate: Date;
6868

69+
/** Number of block in which the first Liquity contract was deployed. */
70+
readonly startBlock: number;
71+
6972
/** Time period (in seconds) after `deploymentDate` during which redemptions are disabled. */
7073
readonly bootstrapPeriod: number;
7174

packages/lib-ethers/src/contracts.ts

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export interface _LiquityDeploymentJSON {
224224
readonly addresses: _LiquityContractAddresses;
225225
readonly version: string;
226226
readonly deploymentDate: number;
227+
readonly startBlock: number;
227228
readonly bootstrapPeriod: number;
228229
readonly totalStabilityPoolLQTYReward: string;
229230
readonly liquidityMiningLQTYRewardRate: string;

packages/lib-ethers/utils/deploy.ts

+64-48
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const setSilent = (s: boolean): void => {
2525
silent = s;
2626
};
2727

28-
const deployContract = async (
28+
const deployContractAndGetBlockNumber = async (
2929
deployer: Signer,
3030
getContractFactory: (name: string, signer: Signer) => Promise<ContractFactory>,
3131
contractName: string,
3232
...args: unknown[]
33-
) => {
33+
): Promise<[address: string, blockNumber: number]> => {
3434
log(`Deploying ${contractName} ...`);
3535
const contract = await (await getContractFactory(contractName, deployer)).deploy(...args);
3636

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

4646
log();
4747

48-
return contract.address;
48+
return [contract.address, receipt.blockNumber];
4949
};
5050

51+
const deployContract: (
52+
...p: Parameters<typeof deployContractAndGetBlockNumber>
53+
) => Promise<string> = (...p) => deployContractAndGetBlockNumber(...p).then(([a]) => a);
54+
5155
const deployContracts = async (
5256
deployer: Signer,
5357
getContractFactory: (name: string, signer: Signer) => Promise<ContractFactory>,
5458
priceFeedIsTestnet = true,
5559
overrides?: Overrides
56-
): Promise<Omit<_LiquityContractAddresses, "uniToken">> => {
60+
): Promise<[addresses: Omit<_LiquityContractAddresses, "uniToken">, startBlock: number]> => {
61+
const [activePoolAddress, startBlock] = await deployContractAndGetBlockNumber(
62+
deployer,
63+
getContractFactory,
64+
"ActivePool",
65+
{ ...overrides }
66+
);
67+
5768
const addresses = {
58-
activePool: await deployContract(deployer, getContractFactory, "ActivePool", { ...overrides }),
69+
activePool: activePoolAddress,
5970
borrowerOperations: await deployContract(deployer, getContractFactory, "BorrowerOperations", {
6071
...overrides
6172
}),
@@ -95,40 +106,44 @@ const deployContracts = async (
95106
unipool: await deployContract(deployer, getContractFactory, "Unipool", { ...overrides })
96107
};
97108

98-
return {
99-
...addresses,
100-
lusdToken: await deployContract(
101-
deployer,
102-
getContractFactory,
103-
"LUSDToken",
104-
addresses.troveManager,
105-
addresses.stabilityPool,
106-
addresses.borrowerOperations,
107-
{ ...overrides }
108-
),
109+
return [
110+
{
111+
...addresses,
112+
lusdToken: await deployContract(
113+
deployer,
114+
getContractFactory,
115+
"LUSDToken",
116+
addresses.troveManager,
117+
addresses.stabilityPool,
118+
addresses.borrowerOperations,
119+
{ ...overrides }
120+
),
109121

110-
lqtyToken: await deployContract(
111-
deployer,
112-
getContractFactory,
113-
"LQTYToken",
114-
addresses.communityIssuance,
115-
addresses.lqtyStaking,
116-
addresses.lockupContractFactory,
117-
Wallet.createRandom().address, // _bountyAddress (TODO: parameterize this)
118-
addresses.unipool, // _lpRewardsAddress
119-
Wallet.createRandom().address, // _multisigAddress (TODO: parameterize this)
120-
{ ...overrides }
121-
),
122+
lqtyToken: await deployContract(
123+
deployer,
124+
getContractFactory,
125+
"LQTYToken",
126+
addresses.communityIssuance,
127+
addresses.lqtyStaking,
128+
addresses.lockupContractFactory,
129+
Wallet.createRandom().address, // _bountyAddress (TODO: parameterize this)
130+
addresses.unipool, // _lpRewardsAddress
131+
Wallet.createRandom().address, // _multisigAddress (TODO: parameterize this)
132+
{ ...overrides }
133+
),
122134

123-
multiTroveGetter: await deployContract(
124-
deployer,
125-
getContractFactory,
126-
"MultiTroveGetter",
127-
addresses.troveManager,
128-
addresses.sortedTroves,
129-
{ ...overrides }
130-
)
131-
};
135+
multiTroveGetter: await deployContract(
136+
deployer,
137+
getContractFactory,
138+
"MultiTroveGetter",
139+
addresses.troveManager,
140+
addresses.sortedTroves,
141+
{ ...overrides }
142+
)
143+
},
144+
145+
startBlock
146+
];
132147
};
133148

134149
export const deployTellorCaller = (
@@ -324,18 +339,19 @@ export const deployAndSetupContracts = async (
324339
_uniTokenIsMock: !wethAddress,
325340
_isDev,
326341

327-
addresses: await deployContracts(
328-
deployer,
329-
getContractFactory,
330-
_priceFeedIsTestnet,
331-
overrides
332-
).then(async addresses => ({
333-
...addresses,
342+
...(await deployContracts(deployer, getContractFactory, _priceFeedIsTestnet, overrides).then(
343+
async ([addresses, startBlock]) => ({
344+
startBlock,
345+
346+
addresses: {
347+
...addresses,
334348

335-
uniToken: await (wethAddress
336-
? createUniswapV2Pair(deployer, wethAddress, addresses.lusdToken, overrides)
337-
: deployMockUniToken(deployer, getContractFactory, overrides))
338-
}))
349+
uniToken: await (wethAddress
350+
? createUniswapV2Pair(deployer, wethAddress, addresses.lusdToken, overrides)
351+
: deployMockUniToken(deployer, getContractFactory, overrides))
352+
}
353+
})
354+
))
339355
};
340356

341357
const contracts = _connectToContracts(deployer, deployment);

0 commit comments

Comments
 (0)