Skip to content
Open
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
27 changes: 16 additions & 11 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@
# Note: Keep safe your mnemonic.
MNEMONIC_KEY="blossom spatial metal assault riot bullet truck update forward brave slide way"

# Alchemy key used to deploy smart contracts (includes archive nodes)
# Key should be the full URL
ALCHEMY_MAINNET_KEY=add-your-alchemy-key-here
ALCHEMY_RINKEBY_KEY=add-your-alchemy-key-here
ALCHEMY_ROPSTEN_KEY=add-your-alchemy-key-here
ALCHEMY_KOVAN_KEY=add-your-alchemy-key-here

# Matic key used to deploy smart contracts
# Key should be the full URL
MATIC_MAINNET_KEY=add-your-matic-vigil-key-here
MATIC_MUMBAI_KEY=add-your-matic-vigil-key-here
DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE

# Ethereum RPC URLs used to deploy smart contracts (archive nodes recommended)
# Must be the full URL, e.g. https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
RINKEBY_RPC_URL=https://eth-rinkeby.g.alchemy.com/v2/YOUR_API_KEY
ROPSTEN_RPC_URL=https://eth-ropsten.g.alchemy.com/v2/YOUR_API_KEY
KOVAN_RPC_URL=https://eth-kovan.g.alchemy.com/v2/YOUR_API_KEY

# Polygon RPC URLs used to deploy smart contracts
# Must be the full URL
MATIC_MAINNET_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY
MATIC_MUMBAI_RPC_URL=https://polygon-mumbai.g.alchemy.com/v2/YOUR_API_KEY

# Infura key used to deploy smart contracts
INFURA_KEY=add-your-infura-key-here

# Etherscan API key. This is used to verify smart contract in the Ethereum networks.
ETHERSCAN_API_KEY=add-your-etherscan-api-key-here

# Safe Global API key for proposing transactions to Gnosis Safe
SAFE_GLOBAL_API_KEY=add-your-safe-global-api-key-here

# CoinMarketCap API key used for gas reporting
CMC_KEY=add-your-coinmarketcap-key-here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ abstract contract mod_initializer_Initializable_v1 is sto_Initializable {
!initializableStorage().initialized,
"Teller: already initialized"
);
initializableStorage().initialized = true;
_;
}
}
67 changes: 67 additions & 0 deletions contracts/nft/distributor/entry/roles.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { LibDiamond } from "../../../shared/libraries/LibDiamond.sol";
import { AccessControlEvents } from "../../../contexts/access-control/data.sol";
import "../../../contexts/access-control/storage/roles.sol";

contract ent_roles_NFTDistributor_v1 is sto_AccessControl_Roles {
/**
* @notice Checks if an account has a specific role.
* @param role Encoding of the role to check.
* @param account Address to check the {role} for.
*/
function hasRole(bytes32 role, address account)
external
view
returns (bool)
{
return accessControlRolesStore().roles[role].members[account];
}

/**
* @notice Grants an account a new role.
* @param role Encoding of the role to give.
* @param account Address to give the {role} to.
*
* Requirements:
* - Sender must be diamond owner.
*/
function grantRole(bytes32 role, address account) external {
LibDiamond.enforceIsContractOwner();
_grantRole(role, account);
}

/**
* @notice Removes a role from an account.
* @param role Encoding of the role to remove.
* @param account Address to remove the {role} from.
*
* Requirements:
* - Sender must be diamond owner.
*/
function revokeRole(bytes32 role, address account) external {
LibDiamond.enforceIsContractOwner();
_revokeRole(role, account);
}

/**
* @notice Removes a role from the sender.
* @param role Encoding of the role to remove.
*/
function renounceRole(bytes32 role) external {
_revokeRole(role, msg.sender);
}

function _grantRole(bytes32 role, address account) internal {
if (accessControlRolesStore().roles[role].members[account]) return;
accessControlRolesStore().roles[role].members[account] = true;
emit AccessControlEvents.RoleGranted(role, account, msg.sender);
}

function _revokeRole(bytes32 role, address account) internal {
if (!accessControlRolesStore().roles[role].members[account]) return;
accessControlRolesStore().roles[role].members[account] = false;
emit AccessControlEvents.RoleRevoked(role, account, msg.sender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ contract NFTMainnetBridgingToPolygonFacet {
EnumerableSet.UintSet storage stakedNFTs = NFTLib.s().stakedNFTs[
msg.sender
];



// we are creating a new array so that we can overrwrite each element
// with a newTokenId.
if (EnumerableSet.contains(stakedNFTs, tokenId)) {
NFTLib.unstake(tokenId, msg.sender);
} else if (TELLER_NFT_V1.ownerOf(tokenId) == msg.sender) {
} else {

require(TELLER_NFT_V1.ownerOf(tokenId) == msg.sender);

TELLER_NFT_V1.transferFrom(msg.sender, address(this), tokenId);
}

Expand Down
8 changes: 4 additions & 4 deletions deploy/markets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import colors from 'colors'
import { ContractTransaction } from 'ethers'
import { ContractTransactionResponse } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'

Expand Down Expand Up @@ -66,11 +66,11 @@ const initializeMarkets: DeployFunction = async (hre) => {
)
const collateralTokensToAdd = new Set(
market.collateralTokens.map((sym) =>
ethers.utils.getAddress(tokenAddresses.all[sym])
ethers.getAddress(tokenAddresses.all[sym])
)
)
for (const token of existingCollateralTokens) {
const tokenAddress = ethers.utils.getAddress(token)
const tokenAddress = ethers.getAddress(token)
if (collateralTokensToAdd.has(tokenAddress))
collateralTokensToAdd.delete(tokenAddress)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ const initializeMarkets: DeployFunction = async (hre) => {

const waitAndLog = async (
msg: string,
tx: Promise<ContractTransaction>,
tx: Promise<ContractTransactionResponse>,
hre: HardhatRuntimeEnvironment
): Promise<void> => {
const receipt = await tx.then(({ wait }) => wait())
Expand Down
4 changes: 2 additions & 2 deletions deploy/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const deployNFT: DeployFunction = async (hre) => {
methodName: 'initialize',
args: [
// Initial minters
ethers.utils.defaultAbiCoder.encode(
ethers.AbiCoder.defaultAbiCoder().encode(
['address[]'],
[minterAddresses]
),
Expand All @@ -71,7 +71,7 @@ const deployNFT: DeployFunction = async (hre) => {
})

// Add the distributor as a minter if not already
const minterRole = ethers.utils.id('MINTER')
const minterRole = ethers.id('MINTER')
const distributorIsDictAdmin = await nft.hasRole(
minterRole,
nftDistributor.address
Expand Down
2 changes: 1 addition & 1 deletion deploy/platform-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createPlatformSettings: DeployFunction = async (hre) => {
const { max, min, processOnDeployment, value } = setting

if (processOnDeployment) {
const keccak = ethers.utils.id(settingName)
const keccak = ethers.id(settingName)
log(`${settingName}: `, { indent: 2, star: true, nl: false })

// Check if the platform setting has already been created
Expand Down
16 changes: 8 additions & 8 deletions deploy/price-agg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const registerPriceAggregators: DeployFunction = async (hre) => {

const definedPricer = await priceAgg.chainlinkPricer()
if (
ethers.utils.getAddress(definedPricer) !=
ethers.utils.getAddress(chainlinkPricer.address)
ethers.getAddress(definedPricer) !=
ethers.getAddress(chainlinkPricer.address)
) {
await priceAgg.setChainlinkPricer(chainlinkPricer.address)
}
Expand Down Expand Up @@ -120,12 +120,12 @@ export const deployChainlinkENS = async (
})

const tld = 'eth'
const tldLabel = hre.ethers.utils.id(tld)
const tldNode = hre.ethers.utils.namehash(tld)
const tldLabel = hre.ethers.id(tld)
const tldNode = hre.ethers.namehash(tld)

const mainDomain = 'data'
const dataLabel = hre.ethers.utils.id(mainDomain)
const dataNode = hre.ethers.utils.namehash(`${mainDomain}.${tld}`)
const dataLabel = hre.ethers.id(mainDomain)
const dataNode = hre.ethers.namehash(`${mainDomain}.${tld}`)

if (ensRegistry.deployResult.newlyDeployed) {
await ensRegistry
Expand Down Expand Up @@ -161,8 +161,8 @@ export const deployChainlinkENS = async (
for (const config of Object.values(chainlink)) {
const chainlinkAggSubdomain = `${config.baseTokenName.toLowerCase()}-${config.quoteTokenName.toLowerCase()}`
const chainlinkAggDomain = `${chainlinkAggSubdomain}.${mainDomain}.${tld}`
const chainlinkAggLabel = hre.ethers.utils.id(chainlinkAggSubdomain)
const chainlinkAggNode = hre.ethers.utils.namehash(chainlinkAggDomain)
const chainlinkAggLabel = hre.ethers.id(chainlinkAggSubdomain)
const chainlinkAggNode = hre.ethers.namehash(chainlinkAggDomain)
const address = await resolver['addr(bytes32)'](chainlinkAggNode)

hre.log(`${colors.underline(chainlinkAggSubdomain)}: ${config.address}`, {
Expand Down
22 changes: 8 additions & 14 deletions deploy/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ const deployProtocol: DeployFunction = async (hre) => {
// Try to get deployment of TellerDiamond
await contracts.get('TellerDiamond')

// If deployment exists execute upgrade function
const executeMethod = 'init2'
const upgradeExecute = {
methodName: executeMethod,
args: [wrappedNativeToken, priceAggregator.address],
}

execute = upgradeExecute
// If deployment exists, skip execute (init2 already called)
execute = undefined
} catch {
// Else execute initialize function
const executeMethod = 'init'
Expand Down Expand Up @@ -274,8 +268,8 @@ const deployLoansEscrowBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(loansEscrowLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(loansEscrowLogic.address)
) {
log(`Upgrading Loans Escrow logic: ${loansEscrowLogic.address}`, {
indent: 5,
Expand Down Expand Up @@ -328,8 +322,8 @@ const deployCollateralEscrowBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(collateralEscrowLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(collateralEscrowLogic.address)
) {
log(`Upgrading Collateral Escrow logic: ${collateralEscrowLogic.address}`, {
indent: 5,
Expand Down Expand Up @@ -382,8 +376,8 @@ const deployTTokenBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(tTokenLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(tTokenLogic.address)
) {
log(`Upgrading Teller Token logic: ${tTokenLogic.address}`, {
indent: 5,
Expand Down
Loading
Loading