Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions scripts/deployment/deployApiConsumer.js

This file was deleted.

7 changes: 4 additions & 3 deletions scripts/deployment/deployRandomNumberConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ async function deployRandomNumberConsumer(chainId) {
if (chainId == 31337) {
const BASE_FEE = "100000000000000000"
const GAS_PRICE_LINK = "1000000000" // 0.000000001 LINK per gas
const WEI_PER_UNIT_LINK = "4000000000000000"

const VRFCoordinatorV2MockFactory = await ethers.getContractFactory("VRFCoordinatorV2Mock")
VRFCoordinatorV2Mock = await VRFCoordinatorV2MockFactory.deploy(BASE_FEE, GAS_PRICE_LINK)
const VRFCoordinatorV2MockFactory = await ethers.getContractFactory("VRFCoordinatorV2_5Mock")
VRFCoordinatorV2Mock = await VRFCoordinatorV2MockFactory.deploy(BASE_FEE, GAS_PRICE_LINK, WEI_PER_UNIT_LINK)
vrfCoordinatorAddress = VRFCoordinatorV2Mock.address

const fundAmount = networkConfig[chainId]["fundAmount"] || "1000000000000000000"
Expand All @@ -30,7 +31,7 @@ async function deployRandomNumberConsumer(chainId) {

const keyHash = networkConfig[chainId]["keyHash"]

const randomNumberConsumerV2Factory = await ethers.getContractFactory("RandomNumberConsumerV2")
const randomNumberConsumerV2Factory = await ethers.getContractFactory("RandomNumberConsumerV2Plus")
const randomNumberConsumerV2 = await randomNumberConsumerV2Factory.deploy(
subscriptionId,
vrfCoordinatorAddress,
Expand Down
50 changes: 35 additions & 15 deletions scripts/deployment/deployRandomNumberDirectFundingConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ async function deployRandomNumberDirectFundingConsumer(chainId) {
// - 10 words requested
// - Refund issued to consumer
const wrapperGasOverhead = BigNumber.from(60_000)
const coordinatorGasOverhead = BigNumber.from(52_000)
const wrapperPremiumPercentage = 10
const coordinatorGasOverheadNative = BigNumber.from(52_000)
const coordinatorGasOverheadLink = BigNumber.from(52_000)
const coordinatorGasOverheadPerWord = BigNumber.from(325)
const coordinatorNativePremiumPercentage = 10
const coordinatorLinkPremiumPercentage = 10
const maxNumWords = 10
const stalenessSeconds = 86400 // 24 hours
const fallbackWeiPerUnitLink = pointZeroZeroThreeLink
const fulfillmentFlatFeeNativePPM = 500000 // 0.5 USD flat fee
const fulfillmentFlatFeeLinkDiscountPPM = 100000 // 0.1 USD discount for LINK payment
const weiPerUnitLink = pointZeroZeroThreeLink

let wrapper, wrapperAddress, linkAddress
Expand All @@ -30,11 +37,12 @@ async function deployRandomNumberDirectFundingConsumer(chainId) {
* @dev Read more at https://docs.chain.link/docs/chainlink-vrf/
*/

const coordinatorFactory = await ethers.getContractFactory("VRFCoordinatorV2Mock")
const coordinator = await coordinatorFactory.deploy(
pointOneLink,
1e9 // 0.000000001 LINK per gas
)
const BASE_FEE = "100000000000000000"
const GAS_PRICE_LINK = "1000000000" // 0.000000001 LINK per gas
const WEI_PER_UNIT_LINK = "4000000000000000"

const coordinatorFactory = await ethers.getContractFactory("VRFCoordinatorV2_5Mock")
const coordinator = await coordinatorFactory.deploy(BASE_FEE, GAS_PRICE_LINK, WEI_PER_UNIT_LINK)

const linkEthFeedFactory = await ethers.getContractFactory("MockV3Aggregator")
const linkEthFeed = await linkEthFeedFactory.deploy(18, weiPerUnitLink) // 1 LINK = 0.003 ETH
Expand All @@ -43,29 +51,41 @@ async function deployRandomNumberDirectFundingConsumer(chainId) {
const link = await linkFactory.deploy()
linkAddress = link.address

const wrapperFactory = await ethers.getContractFactory("VRFV2Wrapper")
wrapper = await wrapperFactory.deploy(linkAddress, linkEthFeed.address, coordinator.address)
// Create subscription first
const createSubTx = await coordinator.createSubscription()
const createSubReceipt = await createSubTx.wait()
const subId = createSubReceipt.events[0].args.subId

const wrapperFactory = await ethers.getContractFactory("VRFV2PlusWrapper")
wrapper = await wrapperFactory.deploy(linkAddress, linkEthFeed.address, coordinator.address, subId)
wrapperAddress = wrapper.address

// configure wrapper
const keyHash = networkConfig[chainId]["keyHash"]
await wrapper.setConfig(
wrapperGasOverhead,
coordinatorGasOverhead,
wrapperPremiumPercentage,
coordinatorGasOverheadNative,
coordinatorGasOverheadLink,
coordinatorGasOverheadPerWord,
coordinatorNativePremiumPercentage,
coordinatorLinkPremiumPercentage,
keyHash,
maxNumWords
maxNumWords,
stalenessSeconds,
fallbackWeiPerUnitLink,
fulfillmentFlatFeeNativePPM,
fulfillmentFlatFeeLinkDiscountPPM
)

// fund subscription. The Wrapper's subscription id is 1
await coordinator.fundSubscription(1, oneHundredLink)
// fund subscription. The Wrapper's subscription id is the created subId
await coordinator.fundSubscription(subId, oneHundredLink)
} else {
wrapperAddress = networkConfig[chainId]["vrfWrapper"]
linkAddress = networkConfig[chainId]["linkToken"]
}

const randomNumberConsumerV2Factory = await ethers.getContractFactory(
"RandomNumberDirectFundingConsumerV2"
"RandomNumberDirectFundingConsumerV2Plus"
)
const randomNumberConsumerV2 = await randomNumberConsumerV2Factory.deploy(
linkAddress,
Expand Down
2 changes: 0 additions & 2 deletions scripts/deployment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// global scope, and execute the script.
const { network, run } = require("hardhat")

const { deployApiConsumer } = require("./deployApiConsumer")
const { deployAutomationCounter } = require("./deployAutomationCounter")
const { deployPriceConsumerV3 } = require("./deployPriceConsumerV3")
const { deployRandomNumberConsumer } = require("./deployRandomNumberConsumer")
Expand All @@ -17,7 +16,6 @@ const {
async function main() {
await run("compile")
const chainId = network.config.chainId
await deployApiConsumer(chainId)
await deployAutomationCounter(chainId)
await deployPriceConsumerV3(chainId)
await deployRandomNumberConsumer(chainId)
Expand Down
Loading