Skip to content

Commit

Permalink
Merge pull request #141 from aurora-is-near/feat/propose-streams
Browse files Browse the repository at this point in the history
Feat/propose streams
  • Loading branch information
0x3bfc authored May 18, 2022
2 parents 44e7010 + f427bc2 commit 5b8bc9a
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/contracts/main.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"upgrade:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/upgrade.js",
"upgrade:goerli": "npx hardhat run --network goerli scripts/upgrade.js",
"proposeStream:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/proposeStream.js",
"proposeStreamPLY:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/proposeStreamPLY.js",
"proposeStreamTRI:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/proposeStreamTRI.js",
"proposeStreamBSTN:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/proposeStreamBSTN.js",
"proposeStreamUSN:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/proposeStreamUSN.js",
"proposeStream:auroraTestnet": "npx hardhat run --network auroraTestnet scripts/proposeStream.js",
"proposeStream:goerli": "npx hardhat run --network goerli scripts/proposeStream.js",
"createStream:auroraMainnet": "npx hardhat run --network auroraMainnet scripts/createStream.js",
Expand Down
2 changes: 1 addition & 1 deletion scripts/proposeStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function main() {
hre.ethers.utils.parseUnits("0", STREAM_TOKEN_DECIMALS), // 0M
]
const MAX_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0] // or something less

const [ streamManager ] = await hre.ethers.getSigners()

Expand Down
73 changes: 73 additions & 0 deletions scripts/proposeStreamBSTN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const hre = require("hardhat");

async function main() {
const {
SCHEDULE_PERIOD,
TAU_PER_STREAM,
SCHEDULE_START_TIME,
AURORA_TOKEN,
} = process.env
const STREAM_AURORA_AMOUNT = hre.ethers.utils.parseUnits("510000", 18)
const auroraAddress = AURORA_TOKEN ? AURORA_TOKEN : (await hre.ethers.getContract("Token")).address
const startTime = SCHEDULE_START_TIME ? parseInt(SCHEDULE_START_TIME) : Math.floor(Date.now()/ 1000) + 60
const STREAM_TOKEN_ADDRESS = "0x9f1f933c660a1dc856f0e0fe058435879c5ccef0"
const STREAM_TOKEN_DECIMALS = 18
const STREAM_OWNER = "0x7DB96909Da3fAbaB6c7Ee2c97c4F98221d583530"
const scheduleTimes = [
startTime,
startTime + parseInt(SCHEDULE_PERIOD),
startTime + 2 * parseInt(SCHEDULE_PERIOD),
startTime + 3 * parseInt(SCHEDULE_PERIOD),
startTime + 4 * parseInt(SCHEDULE_PERIOD)
]
const scheduleRewards = [
hre.ethers.utils.parseUnits("150000000", STREAM_TOKEN_DECIMALS), // 100%
hre.ethers.utils.parseUnits("127500000", STREAM_TOKEN_DECIMALS), // 85%
hre.ethers.utils.parseUnits("97500000", STREAM_TOKEN_DECIMALS), // 65%
hre.ethers.utils.parseUnits("52500000", STREAM_TOKEN_DECIMALS), // 35%
// Last amount should be 0 so scheduleTimes[4] marks the end of the stream schedule.
hre.ethers.utils.parseUnits("0", STREAM_TOKEN_DECIMALS), // 0M
]
const MAX_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0].div(2) // or something less

const [ streamManager ] = await hre.ethers.getSigners()

const jetStakingV1 = await hre.ethers.getContract("JetStakingV1")
const streamManagerRole = await jetStakingV1.STREAM_MANAGER_ROLE()
if(!await jetStakingV1.hasRole(streamManagerRole, streamManager.address)) {
throw new Error(`Signer '${streamManager.address}' doesn't have STREAM_MANAGER_ROLE`)
}

// ^^^^^ TODO: Edit above parameters ^^^^^
// =======================================

const auroraToken = new hre.ethers.Contract(
auroraAddress,
["function approve(address spender, uint value)"],
streamManager
)
const approvalTx = await auroraToken.approve(jetStakingV1.address, STREAM_AURORA_AMOUNT)
console.log("Approving AURORA: ", approvalTx.hash)
await approvalTx.wait()

const proposalTx = await jetStakingV1.proposeStream(
STREAM_OWNER,
STREAM_TOKEN_ADDRESS,
STREAM_AURORA_AMOUNT,
MAX_DEPOSIT_AMOUNT,
MIN_DEPOSIT_AMOUNT,
scheduleTimes,
scheduleRewards,
parseInt(TAU_PER_STREAM),
)
console.log("Proposing stream: ", proposalTx.hash)
await proposalTx.wait()
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
73 changes: 73 additions & 0 deletions scripts/proposeStreamPLY.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const hre = require("hardhat");

async function main() {
const {
SCHEDULE_PERIOD,
TAU_PER_STREAM,
SCHEDULE_START_TIME,
AURORA_TOKEN,
} = process.env
const STREAM_AURORA_AMOUNT = hre.ethers.utils.parseUnits("300000", 18)
const auroraAddress = AURORA_TOKEN ? AURORA_TOKEN : (await hre.ethers.getContract("Token")).address
const startTime = SCHEDULE_START_TIME ? parseInt(SCHEDULE_START_TIME) : Math.floor(Date.now()/ 1000) + 60
const STREAM_TOKEN_ADDRESS = "0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f"
const STREAM_TOKEN_DECIMALS = 18
const STREAM_OWNER = "0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE"
const scheduleTimes = [
startTime,
startTime + parseInt(SCHEDULE_PERIOD),
startTime + 2 * parseInt(SCHEDULE_PERIOD),
startTime + 3 * parseInt(SCHEDULE_PERIOD),
startTime + 4 * parseInt(SCHEDULE_PERIOD)
]
const scheduleRewards = [
hre.ethers.utils.parseUnits("377500000", STREAM_TOKEN_DECIMALS), // 100%
hre.ethers.utils.parseUnits("320875000", STREAM_TOKEN_DECIMALS), // 85%
hre.ethers.utils.parseUnits("245375000", STREAM_TOKEN_DECIMALS), // 65%
hre.ethers.utils.parseUnits("132125000", STREAM_TOKEN_DECIMALS), // 35%
// Last amount should be 0 so scheduleTimes[4] marks the end of the stream schedule.
hre.ethers.utils.parseUnits("0", STREAM_TOKEN_DECIMALS), // 0M or 0%
]
const MAX_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0].div(2) // or something less

const [ streamManager ] = await hre.ethers.getSigners()

const jetStakingV1 = await hre.ethers.getContract("JetStakingV1")
const streamManagerRole = await jetStakingV1.STREAM_MANAGER_ROLE()
if(!await jetStakingV1.hasRole(streamManagerRole, streamManager.address)) {
throw new Error(`Signer '${streamManager.address}' doesn't have STREAM_MANAGER_ROLE`)
}

// ^^^^^ TODO: Edit above parameters ^^^^^
// =======================================

const auroraToken = new hre.ethers.Contract(
auroraAddress,
["function approve(address spender, uint value)"],
streamManager
)
const approvalTx = await auroraToken.approve(jetStakingV1.address, STREAM_AURORA_AMOUNT)
console.log("Approving AURORA: ", approvalTx.hash)
await approvalTx.wait()

const proposalTx = await jetStakingV1.proposeStream(
STREAM_OWNER,
STREAM_TOKEN_ADDRESS,
STREAM_AURORA_AMOUNT,
MAX_DEPOSIT_AMOUNT,
MIN_DEPOSIT_AMOUNT,
scheduleTimes,
scheduleRewards,
parseInt(TAU_PER_STREAM),
)
console.log("Proposing stream: ", proposalTx.hash)
await proposalTx.wait()
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
73 changes: 73 additions & 0 deletions scripts/proposeStreamTRI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const hre = require("hardhat");

async function main() {
const {
SCHEDULE_PERIOD,
TAU_PER_STREAM,
SCHEDULE_START_TIME,
AURORA_TOKEN,
} = process.env
const STREAM_AURORA_AMOUNT = hre.ethers.utils.parseUnits("30000", 18)
const auroraAddress = AURORA_TOKEN ? AURORA_TOKEN : (await hre.ethers.getContract("Token")).address
const startTime = SCHEDULE_START_TIME ? parseInt(SCHEDULE_START_TIME) : Math.floor(Date.now()/ 1000) + 60
const STREAM_TOKEN_ADDRESS = "0xFa94348467f64D5A457F75F8bc40495D33c65aBB"
const STREAM_TOKEN_DECIMALS = 18
const STREAM_OWNER = "0x1232726DA91B25D22239C5707FE85E8F078F3532"
const scheduleTimes = [
startTime,
startTime + parseInt(SCHEDULE_PERIOD),
startTime + 2 * parseInt(SCHEDULE_PERIOD),
startTime + 3 * parseInt(SCHEDULE_PERIOD),
startTime + 4 * parseInt(SCHEDULE_PERIOD)
]
const scheduleRewards = [
hre.ethers.utils.parseUnits("1000000", STREAM_TOKEN_DECIMALS), // 100%
hre.ethers.utils.parseUnits("850000", STREAM_TOKEN_DECIMALS), // 85%
hre.ethers.utils.parseUnits("650000", STREAM_TOKEN_DECIMALS), // 65%
hre.ethers.utils.parseUnits("350000", STREAM_TOKEN_DECIMALS), // 35%
// Last amount should be 0 so scheduleTimes[4] marks the end of the stream schedule.
hre.ethers.utils.parseUnits("0", STREAM_TOKEN_DECIMALS), // 0M
]
const MAX_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0].div(2) // or something less

const [ streamManager ] = await hre.ethers.getSigners()

const jetStakingV1 = await hre.ethers.getContract("JetStakingV1")
const streamManagerRole = await jetStakingV1.STREAM_MANAGER_ROLE()
if(!await jetStakingV1.hasRole(streamManagerRole, streamManager.address)) {
throw new Error(`Signer '${streamManager.address}' doesn't have STREAM_MANAGER_ROLE`)
}

// ^^^^^ TODO: Edit above parameters ^^^^^
// =======================================

const auroraToken = new hre.ethers.Contract(
auroraAddress,
["function approve(address spender, uint value)"],
streamManager
)
const approvalTx = await auroraToken.approve(jetStakingV1.address, STREAM_AURORA_AMOUNT)
console.log("Approving AURORA: ", approvalTx.hash)
await approvalTx.wait()

const proposalTx = await jetStakingV1.proposeStream(
STREAM_OWNER,
STREAM_TOKEN_ADDRESS,
STREAM_AURORA_AMOUNT,
MAX_DEPOSIT_AMOUNT,
MIN_DEPOSIT_AMOUNT,
scheduleTimes,
scheduleRewards,
parseInt(TAU_PER_STREAM),
)
console.log("Proposing stream: ", proposalTx.hash)
await proposalTx.wait()
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
70 changes: 70 additions & 0 deletions scripts/proposeStreamUSN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const hre = require("hardhat");

async function main() {
const {
SCHEDULE_PERIOD,
TAU_PER_STREAM,
SCHEDULE_START_TIME,
AURORA_TOKEN,
} = process.env
const STREAM_AURORA_AMOUNT = hre.ethers.utils.parseUnits("0", 18) // zero arora reward for the USN stream
// const auroraAddress = AURORA_TOKEN ? AURORA_TOKEN : (await hre.ethers.getContract("Token")).address
const startTime = SCHEDULE_START_TIME ? parseInt(SCHEDULE_START_TIME) : Math.floor(Date.now()/ 1000) + 60
const STREAM_TOKEN_ADDRESS = "0x5183e1b1091804bc2602586919e6880ac1cf2896"
const STREAM_TOKEN_DECIMALS = 18
const STREAM_OWNER = "0x290FF2b6Ea23F9c8D18F63449Cc38F8dDa02CE6d"
const scheduleTimes = [
startTime,
startTime + parseInt(SCHEDULE_PERIOD)
]
const scheduleRewards = [
hre.ethers.utils.parseUnits("1800000", STREAM_TOKEN_DECIMALS), // 100%
// Last amount should be 0 so scheduleTimes[4] marks the end of the stream schedule.
hre.ethers.utils.parseUnits("0", STREAM_TOKEN_DECIMALS), // 0M
]

const MAX_DEPOSIT_AMOUNT = scheduleRewards[0]
const MIN_DEPOSIT_AMOUNT = scheduleRewards[0].div(2) // or something less

const [ streamManager ] = await hre.ethers.getSigners()

const jetStakingV1 = await hre.ethers.getContract("JetStakingV1")
const streamManagerRole = await jetStakingV1.STREAM_MANAGER_ROLE()
if(!await jetStakingV1.hasRole(streamManagerRole, streamManager.address)) {
throw new Error(`Signer '${streamManager.address}' doesn't have STREAM_MANAGER_ROLE`)
}

// ^^^^^ TODO: Edit above parameters ^^^^^
// =======================================

// FOR this stream we don't have approval for AURORA rewards

// const auroraToken = new hre.ethers.Contract(
// auroraAddress,
// ["function approve(address spender, uint value)"],
// streamManager
// )
// const approvalTx = await auroraToken.approve(jetStakingV1.address, STREAM_AURORA_AMOUNT)
// console.log("Approving AURORA: ", approvalTx.hash)
// await approvalTx.wait()

const proposalTx = await jetStakingV1.proposeStream(
STREAM_OWNER,
STREAM_TOKEN_ADDRESS,
STREAM_AURORA_AMOUNT,
MAX_DEPOSIT_AMOUNT,
MIN_DEPOSIT_AMOUNT,
scheduleTimes,
scheduleRewards,
parseInt(TAU_PER_STREAM),
)
console.log("Proposing stream: ", proposalTx.hash)
await proposalTx.wait()
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 5b8bc9a

Please sign in to comment.