-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
349fbcd
commit 905e096
Showing
9 changed files
with
7,642 additions
and
19 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
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
134 changes: 134 additions & 0 deletions
134
protocol/scripts/deploys/localhost/templegold/01-localhost.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,134 @@ | ||
import '@nomiclabs/hardhat-ethers'; | ||
import { ethers } from 'hardhat'; | ||
import { TempleGold__factory, TempleGoldAdmin__factory, | ||
TempleGoldStaking__factory, TempleTeleporter__factory, | ||
DaiGoldAuction__factory, FakeERC20__factory } from '../../../../typechain'; | ||
import { | ||
deployAndMine, | ||
ensureExpectedEnvvars, | ||
toAtto, | ||
} from '../../helpers'; | ||
import { getDeployedContracts } from '../../mainnet/v2/contract-addresses'; | ||
import { getDeployedTempleGoldContracts } from '../../arbitrumOne/contract-addresses'; | ||
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; | ||
import { ContractAddresses } from '@balancer-labs/sdk'; | ||
|
||
async function main() { | ||
ensureExpectedEnvvars(); | ||
const [owner, rescuer] = await ethers.getSigners(); | ||
|
||
await _deployTempleToken(owner); | ||
await _deployTempleGold(owner); | ||
await _deployTempleGoldAdmin(owner, rescuer); | ||
|
||
await _deployTempleGoldStaking(owner, rescuer); | ||
await _deployTempleTeleporter(owner); | ||
|
||
await _deployDaiGoldAuction(owner, rescuer); | ||
} | ||
|
||
async function _deployTempleToken(owner: SignerWithAddress) { | ||
const factory = new FakeERC20__factory(owner); | ||
await deployAndMine( | ||
'TEMPLE_TOKEN', | ||
factory, | ||
factory.deploy, | ||
"Temple", | ||
"TEMPLE", | ||
await owner.getAddress(), | ||
toAtto(1000) | ||
); | ||
} | ||
|
||
async function _deployTempleGold(owner: SignerWithAddress) { | ||
const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
const ARBITRUM_ONE_CHAIN_ID = 42161; | ||
const ARBITRUM_ONE_LZ_EID = 30110; | ||
const _initArgs = { | ||
// Changed in transfer ownership to TempleAdmin | ||
executor: await owner.getAddress(), // executor is also used as delegate in LayerZero Endpoint. | ||
layerZeroEndpoint: TEMPLEGOLD_ADDRESSES.EXTERNAL.LAYER_ZERO.ENDPOINT, // local endpoint address | ||
mintChainId: ARBITRUM_ONE_CHAIN_ID, | ||
mintChainLzEid: ARBITRUM_ONE_LZ_EID, | ||
name: "TEMPLE GOLD", | ||
symbol: "TGLD" | ||
}; | ||
const factory = new TempleGold__factory(owner); | ||
await deployAndMine( | ||
'TEMPLE_GOLD', | ||
factory, | ||
factory.deploy, | ||
_initArgs | ||
); | ||
} | ||
|
||
async function _deployTempleGoldAdmin(owner: SignerWithAddress, rescuer: SignerWithAddress) { | ||
const factory = new TempleGoldAdmin__factory(owner); | ||
const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
await deployAndMine( | ||
'TEMPLE_GOLD_ADMIN', | ||
factory, | ||
factory.deploy, | ||
await rescuer.getAddress(), | ||
await owner.getAddress(), | ||
TEMPLEGOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD | ||
); | ||
} | ||
|
||
async function _deployTempleGoldStaking(owner: SignerWithAddress, rescuer: SignerWithAddress) { | ||
const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
const CORE_ADDRESSES = getDeployedContracts(); | ||
|
||
|
||
const factory = new TempleGoldStaking__factory(owner); | ||
await deployAndMine( | ||
'TEMPLE_GOLD_STAKING', | ||
factory, | ||
factory.deploy, | ||
await rescuer.getAddress(), | ||
await owner.getAddress(), | ||
CORE_ADDRESSES.CORE.TEMPLE_TOKEN, | ||
TEMPLEGOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD | ||
); | ||
} | ||
|
||
async function _deployTempleTeleporter(owner: SignerWithAddress) { | ||
const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
const CORE_ADDRESSES = getDeployedContracts(); | ||
|
||
const factory = new TempleTeleporter__factory(owner); | ||
await deployAndMine( | ||
'TEMPLE_TELEPORTER', | ||
factory, | ||
factory.deploy, | ||
await owner.getAddress(), | ||
CORE_ADDRESSES.CORE.TEMPLE_TOKEN, | ||
TEMPLEGOLD_ADDRESSES.EXTERNAL.LAYER_ZERO.ENDPOINT | ||
); | ||
} | ||
|
||
async function _deployDaiGoldAuction(owner: SignerWithAddress, rescuer: SignerWithAddress): Promise<void> { | ||
const TEMPLEGOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
const arbDaiToken = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"; | ||
const factory = new DaiGoldAuction__factory(owner); | ||
await deployAndMine( | ||
'DAI_GOLD_AUCTION', | ||
factory, | ||
factory.deploy, | ||
TEMPLEGOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD, | ||
arbDaiToken, | ||
await owner.getAddress(), // treasury | ||
await rescuer.getAddress(), | ||
await owner.getAddress(), | ||
TEMPLEGOLD_ADDRESSES.TEMPLE_GOLD.AUCTION_AUTOMATION_EOA | ||
); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
81 changes: 81 additions & 0 deletions
81
protocol/scripts/deploys/localhost/templegold/999-localhost.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,81 @@ | ||
import { ethers, network } from 'hardhat'; | ||
import { | ||
ensureExpectedEnvvars, | ||
mine, | ||
} from '../../helpers'; | ||
import { connectToContracts, getDeployedTempleGoldContracts } from '../../arbitrumOne/contract-addresses'; | ||
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; | ||
import { TempleGold__factory, TempleGoldStaking__factory, DaiGoldAuction__factory } from '../../../../typechain'; | ||
|
||
|
||
async function main() { | ||
ensureExpectedEnvvars(); | ||
const [owner] = await ethers.getSigners(); | ||
const TEMPLE_GOLD_ADDRESSES = getDeployedTempleGoldContracts(); | ||
const TEMPLE_GOLD_INSTANCES = connectToContracts(owner); | ||
// signer 0 | ||
const teamGnosis = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'; | ||
console.log(`OWNER ${await TEMPLE_GOLD_INSTANCES.TEMPLE_GOLD.TEMPLE_GOLD.owner()}`); | ||
console.log(`OWNER ${await TEMPLE_GOLD_INSTANCES.TEMPLE_GOLD.TEMPLE_GOLD_STAKING.executor()}`); | ||
const distributionParams = { | ||
staking: ethers.utils.parseEther("20"), | ||
daiGoldAuction: ethers.utils.parseEther("70"), | ||
gnosis: ethers.utils.parseEther("10") | ||
} | ||
const vestingFactor = { | ||
value: 35, | ||
weekMultiplier: 3600 * 24 * 7 // 1 week | ||
} | ||
///// TEMPLE GOLD | ||
const templeGold = TempleGold__factory.connect(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD, owner); | ||
const staking = TempleGoldStaking__factory.connect(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD_STAKING, owner); | ||
const daiGoldAuction = DaiGoldAuction__factory.connect(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.DAI_GOLD_AUCTION, owner); | ||
console.log(`TempleGOld: ${await daiGoldAuction.templeGold()}`); | ||
// // Set and whitelist contracts | ||
await mine(templeGold.setTeamGnosis(teamGnosis)); | ||
await mine(templeGold.setDaiGoldAuction(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.DAI_GOLD_AUCTION)); | ||
await mine(templeGold.setStaking(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD_STAKING)); | ||
await mine(templeGold.setVestingFactor(vestingFactor)); | ||
await mine(templeGold.setDistributionParams(distributionParams)); | ||
// // authorize contracts | ||
await mine(templeGold.authorizeContract(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.DAI_GOLD_AUCTION, true)); | ||
await mine(templeGold.authorizeContract(TEMPLE_GOLD_ADDRESSES.TEMPLE_GOLD.TEMPLE_GOLD_STAKING, true)); | ||
await mine(templeGold.authorizeContract(teamGnosis, true)); | ||
|
||
// ///// Staking | ||
const duration = 24 * 3600 * 7; | ||
const unstakeCooldown = duration * 2; // 2 weeks | ||
const rewardsDistributionCooldown = 3600; // 1 hour | ||
// reward duration | ||
await mine(staking.setRewardDuration(duration)); | ||
// distribution starter | ||
await mine(staking.setDistributionStarter(teamGnosis)); | ||
// rewards distribution cool down | ||
await mine(staking.setRewardDistributionCoolDown(rewardsDistributionCooldown)); | ||
// unstake cool down | ||
await mine(staking.setUnstakeCooldown(unstakeCooldown)); | ||
|
||
////// DAI GOLD AUCTION | ||
const auctionsTimeDiff = 60; | ||
const auctionConfig = { | ||
/// Time diff between two auctions. Usually 2 weeks | ||
auctionsTimeDiff: auctionsTimeDiff, | ||
/// Cooldown after auction start is triggered, to allow deposits | ||
auctionStartCooldown: 60, | ||
/// Minimum Gold distributed to enable auction start | ||
auctionMinimumDistributedGold: ethers.utils.parseEther("0.01"), | ||
}; | ||
// auction starter | ||
await mine(daiGoldAuction.setAuctionStarter(teamGnosis)); | ||
// auction config | ||
await mine(daiGoldAuction.setAuctionConfig(auctionConfig)); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
5 changes: 5 additions & 0 deletions
5
protocol/scripts/deploys/localhost/templegold/deploy-anvil.sh
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,5 @@ | ||
#!/bin/bash | ||
|
||
anvil --fork-url $ARBITRUM_ONE_RPC_URL | ||
|
||
npx hardhat --network localhost run scripts/deploys/localhost/templegold/01-localhost.ts |
Oops, something went wrong.