Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

[230415 Audit][v1.3] Dev -> Master #202

Merged
merged 27 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9a4af05
Remove Forwarder (#160)
arjun-io Apr 5, 2023
4e2fa53
Chainlink Bisection Oracle for Phase Discovery (#147)
arjun-io Apr 6, 2023
df75f96
Merge branch 'master' into dev
arjun-io Apr 16, 2023
c6b0592
MultiInvokerRollup (#141)
test9955667 Apr 17, 2023
b3bfe81
Feat/charge fee (#163)
test9955667 Apr 17, 2023
2996274
Multi-Asset Vault (#162)
kbrizzle Apr 17, 2023
d579241
enable yul optimizer for coverage
arjun-io Apr 17, 2023
bdf6dfe
increase test timeout
arjun-io Apr 17, 2023
4c6b0b3
test timeout
arjun-io Apr 19, 2023
210b793
Multi-Asset Upgrades Verification Tests (#165)
arjun-io Apr 25, 2023
418ca93
Change _claimProduct param to calldata (#172)
0xfennel May 9, 2023
388fb5a
Remove negative price comment from Oracles (#173)
arjun-io May 9, 2023
ec511fd
Get rid of extraneous .only (#178)
0xfennel May 9, 2023
4f0b1f2
Revert if address is not valid product (#177)
arjun-io May 9, 2023
f75be91
Support type(uint256).max for withdrawAndUnwrap (#176)
arjun-io May 9, 2023
91631f2
Check if valid program in owner and treasury (#181)
arjun-io May 9, 2023
28a9312
fix CI
arjun-io May 10, 2023
ea7b7b8
Add more validations in BalancedVault constructor (#180)
0xfennel May 11, 2023
b5f0a5f
Reavert if round timestamp is 0 (#182)
arjun-io May 12, 2023
a79a24a
[Nit] Delete unused variables (#184)
0xfennel May 12, 2023
45de2ad
[Fix][M1] Reentrancy attack vector through incentive program rewards …
arjun-io May 15, 2023
b014fe0
fix unit test
arjun-io May 15, 2023
79f7ff6
Remove ReservoirFeedOracle (#187)
arjun-io May 16, 2023
395a330
Don't return struct when deducting program fee (#179)
arjun-io May 16, 2023
b6d8380
Upgrade Core/Vault Solidity Versions (#185)
arjun-io May 16, 2023
dba7e8a
Nose/fix rollup audit (#183)
test9955667 May 17, 2023
0a1f477
Merge branch 'master' into dev
arjun-io Jul 24, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"ethers": "^5.7.2",
"graphql": "^16.6.0",
"graphql-request": "^5.2.0",
"hardhat": "^2.12.2",
"hardhat": "^2.13.0",
"hardhat-contract-sizer": "^2.4.0",
"hardhat-dependency-compiler": "^1.1.2",
"hardhat-deploy": "^0.11.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/common/hardhat.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'hardhat-deploy'
import 'hardhat-dependency-compiler'
import { getChainId, isArbitrum, isBase, isOptimism, SupportedChain } from './testutil/network'

export const SOLIDITY_VERSION = '0.8.15'
export const SOLIDITY_VERSION = '0.8.17'
const PRIVATE_KEY_MAINNET = process.env.PRIVATE_KEY || ''
const PRIVATE_KEY_TESTNET = process.env.PRIVATE_KEY_TESTNET || ''

Expand Down Expand Up @@ -188,7 +188,7 @@ export default function defaultConfig({
parallel: MOCHA_PARALLEL,
reporter: MOCHA_REPORTER,
slow: 1000,
timeout: 180000,
timeout: 2400000,
},
contractSizer: {
alphaSort: true,
Expand Down
39 changes: 37 additions & 2 deletions packages/common/testutil/impersonate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { BigNumber, BigNumberish } from 'ethers'
import { BigNumber, BigNumberish, constants, Contract, utils } from 'ethers'
import HRE from 'hardhat'
const { ethers } = HRE

export const DSU_HOLDER = {
mainnet: '0x0B663CeaCEF01f2f88EB7451C70Aa069f19dB997',
arbitrum: '',
}
export const USDC_HOLDER = {
mainnet: '0x0A59649758aa4d66E25f08Dd01271e891fe52199',
arbitrum: '0x8b8149dd385955dc1ce77a4be7700ccd6a212e65',
}

export async function impersonate(address: string): Promise<SignerWithAddress> {
await HRE.network.provider.request({
method: 'hardhat_impersonateAccount',
Expand All @@ -14,11 +23,37 @@ export async function impersonate(address: string): Promise<SignerWithAddress> {
export async function impersonateWithBalance(address: string, balance: BigNumberish): Promise<SignerWithAddress> {
await HRE.network.provider.request({
method: 'hardhat_setBalance',
params: [address, BigNumber.from(balance).toHexString()],
// Replace is necessary because leading 0s are not allowed
params: [address, BigNumber.from(balance).toHexString().replace('0x0', '0x')],
})
await HRE.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [address],
})
return ethers.getSigner(address)
}

export async function setupTokenHolders(
dsu: Contract,
usdc: Contract,
reserve: Contract,
users: SignerWithAddress[],
network: 'mainnet' | 'arbitrum' = 'mainnet',
): Promise<{ dsuHolder: SignerWithAddress; usdcHolder: SignerWithAddress }> {
const usdcHolderAddress = USDC_HOLDER[network]
const dsuHolderAddress = DSU_HOLDER[network] || usdcHolderAddress
const usdcHolder = await impersonateWithBalance(usdcHolderAddress, utils.parseEther('10'))
const dsuHolder = await impersonateWithBalance(dsuHolderAddress, utils.parseEther('10'))

await usdc.connect(usdcHolder).approve(reserve.address, constants.MaxUint256)
await reserve.connect(usdcHolder).mint(utils.parseEther('1000000'))
await dsu.connect(usdcHolder).transfer(dsuHolder.address, utils.parseEther('1000000'))

await Promise.all(
users.map(async user => {
await dsu.connect(dsuHolder).transfer(user.address, utils.parseEther('20000'))
}),
)

return { dsuHolder, usdcHolder }
}
5 changes: 5 additions & 0 deletions packages/common/testutil/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ export function isLocalhost(networkName: string): boolean {
return false
}
}

export function isRollup(networkName: string): boolean {
if (isBase(networkName) || isArbitrum(networkName) || isOptimism(networkName)) return true
return false
}
60 changes: 60 additions & 0 deletions packages/common/testutil/oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { utils } from 'ethers'
import HRE from 'hardhat'
import { impersonateWithBalance } from './impersonate'
import { time } from './'

const { config } = HRE

const AGGREGATOR_TRANSMITTERS = {
mainnet: {
eth: '0x218b5a7861dbf368d09a84e0dbff6c6ddbf99db8',
arb: '',
},
arbitrum: {
eth: '0xa82d4edb72dd3d167d00058f2404658f4e9a010a',
arb: '0xbd620be125abf8b569b9a3cc132aad0bcf1ff0e7',
},
}

const AGGREGATOR_ADDRESSES = {
mainnet: {
eth: '0x37bc7498f4ff12c19678ee8fe19d713b87f6a9e6',
arb: '',
},
arbitrum: {
eth: '0x3607e46698d218B3a5Cae44bF381475C0a5e2ca7',
arb: '0x46de66f10343b59bacc37df9b3f67cd0ccc121a3',
},
}

const TRANSMIT_DATA = {
mainnet: {
eth: '0xc9807539000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000680000001000001000001010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004600000000000000000000000d02ee3e7b93bbe024d583e46d7fe54450000637e0307121618030b0a0f1017131b060d020e051115141a19080c041c1d09011e00000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000001f00000000000000000000000000000000000000000000000000000025c233d03400000000000000000000000000000000000000000000000000000025c309f68000000000000000000000000000000000000000000000000000000025c309f68000000000000000000000000000000000000000000000000000000025c326458000000000000000000000000000000000000000000000000000000025c3ba49a600000000000000000000000000000000000000000000000000000025c3ba49a600000000000000000000000000000000000000000000000000000025c45986cc00000000000000000000000000000000000000000000000000000025c497ef5c00000000000000000000000000000000000000000000000000000025c4f9108700000000000000000000000000000000000000000000000000000025c4f9108700000000000000000000000000000000000000000000000000000025c511383000000000000000000000000000000000000000000000000000000025c520054000000000000000000000000000000000000000000000000000000025c55d0e4000000000000000000000000000000000000000000000000000000025c57d1f3c00000000000000000000000000000000000000000000000000000025c5b73c3000000000000000000000000000000000000000000000000000000025c5b7e04000000000000000000000000000000000000000000000000000000025c5bbd01000000000000000000000000000000000000000000000000000000025c5bbd01000000000000000000000000000000000000000000000000000000025c5bbd01000000000000000000000000000000000000000000000000000000025c5c1756000000000000000000000000000000000000000000000000000000025c5ec2ee000000000000000000000000000000000000000000000000000000025c5ec2ee000000000000000000000000000000000000000000000000000000025c5fdd83000000000000000000000000000000000000000000000000000000025c5fecc8000000000000000000000000000000000000000000000000000000025c614294000000000000000000000000000000000000000000000000000000025c6236b8000000000000000000000000000000000000000000000000000000025c62b0ca000000000000000000000000000000000000000000000000000000025c634828000000000000000000000000000000000000000000000000000000025c6bd26a100000000000000000000000000000000000000000000000000000025c6bd26a100000000000000000000000000000000000000000000000000000025c7a0e3c0000000000000000000000000000000000000000000000000000000000000000be32a36813c06b85b453cecedce8105af3096411d564fd0b4ee14059db4f0b248e49f256bdf03b543f515863006b4b92c16a7f2db302c9052d8ee4801ae6e47d18b170ebe26e4c449e55b1e6ab3f6603392ce69e542f62f157c1cfec09e2b17b93856141c589f9de601d08ce30fa6ef8c7df4d58c785890d7fe0837d9545f1bf04fd257fe555d525447f87604a16f8fbcc8991272297eecdc96a76cba6151549571f101c07e62f545c49c8bb05d6a6856b1d573dcfd9e58e6a48db6367683917d356b94be544a874cbe93af7f42c1f08a89b9393a508cc41422ec9769e2876bdfc063974b6c7ae9315e295fec278f69c01fcdf3e048ba66d860582e612b00635e3860623f9102256b875aba7e4d8de31dc57d7e7121b15ecd3c07290afe2e1b6c1c27486bef3e3284ab297d67641695ea054fd2ee239eae4745e33ee3853d8da5c67acffa0be14d639de983403f1f09fa7995711873aa776686e5164f51ad0b9e000000000000000000000000000000000000000000000000000000000000000b1188261048dca9e33490656104b845619cda630c3b7a1d33642a705b66dcd2646ff859db2053ceee6d8f34d07fb196ad628372e96d1bf13d51b81294079073b26d9a910d1bafcc2c07ef4768856b1c83d49a726399c558314429367aa036f225422d25aa494ab5536dc12376ede011d45b50978ce98a972e46c7f09793075b8579190b05c91e5cac0aa3dbd12dad6b3a26550ba737f55943afb27a63ef28f2076231cb780dc73d689fcf772ef8c7d26ce4f8c01d8b6c388763fe539b1154e1b043c37beb5c62528e4b00dae076552fde6c8108d871e8ec0da70d3d5a423581ed7b102ca6bdb87a027bc6343ecce71fbf56c5f39edbe9c060ad354468943f8fa825208f17c7d83e5b064ae0aa5940f797e30cd2a4da9991fd3f936083fa15c50455ba7c245aba4860ee72fe5d1075b5be7dd3d0cf9d404a80a30744707d8009c66032ccf98302b5ae19d5824f5c7903ca6808aab80d1e9361bdff1ab8def38ae4',
arb: '',
},
arbitrum: {
eth: '0xc9807539000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000300000101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000f6d9397093865a569a3b827fbe021b4e0003a6060606010207000403050809000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000002ffb63bac00000000000000000000000000000000000000000000000000000002ffee6c7000000000000000000000000000000000000000000000000000000002ffee6c700000000000000000000000000000000000000000000000000000000300027364000000000000000000000000000000000000000000000000000000030014158d000000000000000000000000000000000000000000000000000000030014158d0000000000000000000000000000000000000000000000000000000300176e7c00000000000000000000000000000000000000000000000000000003001e40eac000000000000000000000000000000000000000000000000000000300303a2400000000000000000000000000000000000000000000000000000003004258d0000000000000000000000000000000000000000000000000000000000000000040cd9d57b3f26761b5606b3dffb11327300a64b017143239fbec97a514e615254bd20cb47ded3e708594af8b42f422e65622f09a551312a4186a3e5df8edf1c46ae2a15ac5b48fb42243b05b34366b9b1ccf1aaf3e9fe06f7e0ebf26e23ead40061f5a96d7cb636119a14f760443c0ba5b3f3cb0474c3f835da94b344af39be9f000000000000000000000000000000000000000000000000000000000000000452ccc64510100a8f36a5d8d026e995cb3c7086747405765595c7faab3fd2e1375b79c638774f4d28803fcb17462769837adc904ba76e3926422454190e6d0d9f4037f8a08da1704d4e09907ec759934729c7b6fdcb8f56943fefad0027438256322753f7b5b143d4e7d4cf800ef801fd87eca663d43b3cbcdf8a07b26c30ceca',
arb: '0xc9807539000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000300010100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000009b7760208df7ee5e7a4e980008eecbb0000275f0109020005040706010308000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000008c554b00000000000000000000000000000000000000000000000000000000008c5f0f00000000000000000000000000000000000000000000000000000000008c758000000000000000000000000000000000000000000000000000000000008c758000000000000000000000000000000000000000000000000000000000008c9b5c80000000000000000000000000000000000000000000000000000000008c9b5c80000000000000000000000000000000000000000000000000000000008c9d8f00000000000000000000000000000000000000000000000000000000008c9e8900000000000000000000000000000000000000000000000000000000008c9e8900000000000000000000000000000000000000000000000000000000008cd11a70000000000000000000000000000000000000000000000000000000000000004c706b98db35a5790f5598543b84a7773c8d535043bb22cb00e73deda0f98cee5781a23e59a2369009c06a20565e768332c7b014eab7373b1a5bd4afccb017b36cd8f51dcfc494f0cf9ee05b5e16d0d1e176aa84aefb706dfaa0b11fb2f089f07467a1d8e02711c400f333f4aced0cb0191c1c0e885c64d5e0d5fb8e872c6bde4000000000000000000000000000000000000000000000000000000000000000463a1fd7cbbee40fd0ea99d2557e4931c978355e4b9383f686af5f10e3e50c8a035062d34074c560f1111f717b428bfc04d24b2dd9e831d8869c76bcf5ea0eb64091458055f60e259b992d71d338d1089f0c6803ab5ea51c96686a1403a579ade61e5966ce7f6d05b17b32ebfe0b94beaac0e95c928dad0e244e86431ae34c1bb',
},
}

export async function pushPrice(
network: 'mainnet' | 'arbitrum' = 'mainnet',
asset: 'eth' | 'arb' = 'eth',
): Promise<void> {
if (!AGGREGATOR_TRANSMITTERS[network][asset]) {
throw 'Invalid Network/Asset pair'
}

const transmitterSigner = await impersonateWithBalance(
AGGREGATOR_TRANSMITTERS[network][asset],
utils.parseEther('10'),
)

// Push a new price version to the aggregator
await transmitterSigner.sendTransaction({
to: AGGREGATOR_ADDRESSES[network][asset],
value: 0,
data: TRANSMIT_DATA[network][asset],
})
}
2 changes: 1 addition & 1 deletion packages/perennial-examples/contracts/examples/Squeeth.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.15;
pragma solidity ^0.8.15;

import "@equilibria/perennial/contracts/interfaces/IContractPayoffProvider.sol";

Expand Down
57 changes: 0 additions & 57 deletions packages/perennial-examples/deploy/005_deploy_sfbayc.ts

This file was deleted.

Loading
Loading