diff --git a/audit/chainsecurity/SBC-deposit-contracts-1.2.0-rc0-security-assessment-report.pdf b/audit/chainsecurity/SBC-deposit-contracts-1.2.0-rc0-security-assessment-report.pdf new file mode 100644 index 0000000..779102a Binary files /dev/null and b/audit/chainsecurity/SBC-deposit-contracts-1.2.0-rc0-security-assessment-report.pdf differ diff --git a/migrations/1_deploy.js b/migrations/1_deploy.js index 803f96c..f33fc6f 100644 --- a/migrations/1_deploy.js +++ b/migrations/1_deploy.js @@ -3,6 +3,7 @@ require('dotenv').config() const SBCDepositContractProxy = artifacts.require('SBCDepositContractProxy') const SBCToken = artifacts.require('SBCToken') const SBCTokenProxy = artifacts.require('SBCTokenProxy') +const SBCWrapper = artifacts.require('SBCWrapper') const SBCWrapperProxy = artifacts.require('SBCWrapperProxy') module.exports = async function (deployer, network, accounts) { @@ -22,13 +23,19 @@ module.exports = async function (deployer, network, accounts) { const depositContractProxy = await SBCDepositContractProxy.deployed() // deploy token wrapper - await deployer.deploy(SBCWrapperProxy, admin, token.address, depositContractProxy.address) - const wrapper = await SBCWrapperProxy.deployed() + await deployer.deploy(SBCWrapperProxy, accounts[0], token.address, depositContractProxy.address) + const wrapperProxy = await SBCWrapperProxy.deployed() + const wrapper = await SBCWrapper.at(wrapperProxy.address) // set token minter to deployed wrapper await token.setMinter(wrapper.address) if (accounts[0].toLowerCase() !== admin.toLowerCase()) { await tokenProxy.setAdmin(admin) } + + await wrapper.enableToken(process.env.STAKE_TOKEN_ADDRESS, web3.utils.toWei('32')) + if (accounts[0].toLowerCase() !== admin.toLowerCase()) { + await wrapperProxy.setAdmin(admin) + } } } diff --git a/package.json b/package.json index ef7d6f4..33dd589 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deposit-contract", - "version": "1.0.0", + "version": "1.2.0", "description": "Gnosis Chain official deposit contract", "main": "index.js", "repository": "https://github.com/gnosischain/deposit-contract", diff --git a/scripts/.env.example b/scripts/.env.example index 604812c..e8b9279 100644 --- a/scripts/.env.example +++ b/scripts/.env.example @@ -11,9 +11,15 @@ N=256 # index of the first deposit to read from file OFFSET=0 -# address of the wrapped GBC token -TOKEN_ADDRESS=0x722fc4DAABFEaff81b97894fC623f91814a1BF68 +# address of the wrapped mGNO token, leave this option only if you want to deposit wrapped mGNO tokens +META_TOKEN_ADDRESS=0x722fc4DAABFEaff81b97894fC623f91814a1BF68 +# specify these options only if you want to deposit unwrapped GNO tokens +# address of the GNO token +# TOKEN_ADDRESS=0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb +# address of the GBC wrapper contract +# WRAPPER_ADDRESS=0x647507A70Ff598F386CB96ae5046486389368C66 + # address of the GBC deposit contract DEPOSIT_CONTRACT_ADDRESS=0x0B98057eA310F4d31F2a452B414647007d1645d9 # block where the deposit contract was deployed at -START_BLOCK_NUMBER=19469077 \ No newline at end of file +START_BLOCK_NUMBER=19469077 diff --git a/scripts/deposit.js b/scripts/deposit.js index db916e0..3742510 100644 --- a/scripts/deposit.js +++ b/scripts/deposit.js @@ -10,10 +10,12 @@ const { BATCH_SIZE, N, OFFSET, - TOKEN_ADDRESS, - DEPOSIT_CONTRACT_ADDRESS, START_BLOCK_NUMBER, SKIP_PREVIOUS_DEPOSITS_CHECK, + WRAPPER_ADDRESS, + TOKEN_ADDRESS, + META_TOKEN_ADDRESS, + DEPOSIT_CONTRACT_ADDRESS, } = process.env const web3 = new Web3(RPC_URL) @@ -25,8 +27,18 @@ const batchSize = parseInt(BATCH_SIZE, 10) const offset = parseInt(OFFSET, 10) const n = parseInt(N, 10) async function main() { - const token = new web3.eth.Contract(abi, TOKEN_ADDRESS) + const useMetaTokenDeposit = !!META_TOKEN_ADDRESS && !WRAPPER_ADDRESS && !TOKEN_ADDRESS + const useWrapAndDeposit = !META_TOKEN_ADDRESS && !!WRAPPER_ADDRESS && !!TOKEN_ADDRESS + if (useMetaTokenDeposit === useWrapAndDeposit) { + console.log('Specify either a single META_TOKEN_ADDRESS variable for depositing mGNO directly, ' + + 'or specify both WRAPPER_ADDRESS and TOKEN_ADDRESS variables for depositing GNO without manual mGNO conversion.') + return + } + const depositContract = new web3.eth.Contract(depositABI, DEPOSIT_CONTRACT_ADDRESS) + const receiver = useWrapAndDeposit ? WRAPPER_ADDRESS : DEPOSIT_CONTRACT_ADDRESS + const tokenAddress = useWrapAndDeposit ? TOKEN_ADDRESS : META_TOKEN_ADDRESS + const token = new web3.eth.Contract(abi, tokenAddress) const deposits = depositData.slice(offset, offset + n) if (batchSize > 1) { @@ -45,7 +57,7 @@ async function main() { return } - const depositAmountBN = web3.utils.toBN(32).mul(web3.utils.toBN('1000000000000000000')) + const depositAmountBN = web3.utils.toBN(useWrapAndDeposit ? 1 : 32).mul(web3.utils.toBN('1000000000000000000')) const totalDepositAmountBN = depositAmountBN.muln(deposits.length) const tokenBalance = await token.methods.balanceOf(address).call() @@ -88,7 +100,7 @@ async function main() { if (count === batchSize || i === deposits.length - 1) { const amount = depositAmountBN.muln(count) - const call = token.methods.transferAndCall(DEPOSIT_CONTRACT_ADDRESS, amount, data) + const call = token.methods.transferAndCall(receiver, amount, data) let gas try { gas = await call.estimateGas({ from: address })