Repository navigation
Conversation
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
WalkthroughThe pull request adds Base deployment data for five tokenized-stock ERC-20 contracts and their price feeds. It also adds Base market parameters for those tokens in the Hardhat configuration. ChangesBase tokenized-stock markets
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Possibly related issues
Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4a7be18a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }, | ||
| overrides: { base: { priceFeed: "inverse" } }, | ||
| }, | ||
| AAPLc: { |
There was a problem hiding this comment.
Configure eight-decimal mocks for the new stocks
When the default Hardhat fixture includes these markets, deploy/mocks/Assets.ts:28 does not recognize any of the five new symbols and therefore creates each mock with 18 decimals. The deployed B20 stocks are 8-decimal assets (for example, the AAPLc token contract), so local deployments use raw balances and maxSupply values scaled by an extra 1e10 and never exercise production's rounding behavior. Add AAPLc, GOOGLc, NVDAc, METAc, and AMZNc to the mock-decimals mapping.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
433dc8e5-4c70-4984-86f2-5e29abfc2394
📒 Files selected for processing: 11
deployments/base/AAPLc.jsondeployments/base/AMZNc.jsondeployments/base/GOOGLc.jsondeployments/base/METAc.jsondeployments/base/NVDAc.jsondeployments/base/PriceFeedAAPLc.jsondeployments/base/PriceFeedAMZNc.jsondeployments/base/PriceFeedGOOGLc.jsondeployments/base/PriceFeedMETAc.jsondeployments/base/PriceFeedNVDAc.jsonhardhat.config.ts
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
| overrides: { base: { priceFeed: "inverse" } }, | ||
| }, | ||
| AAPLc: { | ||
| networks: ["base"], |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
echo '--- revisions ---'
git rev-parse --verify 13d99979c08697becaf7a593209d46bdd9dace00
git rev-parse --verify a4a7be18a18622ffd584c00b36f975fb7db202df
echo '--- diff name-status ---'
git diff --name-status 13d99979c08697becaf7a593209d46bdd9dace00 a4a7be18a18622ffd584c00b36f975fb7db202df
echo '--- hardhat diff/context ---'
git diff --unified=35 13d99979c08697becaf7a593209d46bdd9dace00 a4a7be18a18622ffd584c00b36f975fb7db202df -- hardhat.config.ts
echo '--- Markets.ts symbols and relevant operations ---'
rg -n -F --glob 'deploy/Markets.ts' -e 'asset.approve' -e 'deposit' -e 'getContract' -e 'getNamedAccounts' -e 'deployer' -e 'parseUnits' -e 'symbol' -e 'markets' deploy/Markets.ts || test "$?" -eq 1
echo '--- complete Markets.ts ---'
nl -ba deploy/Markets.ts
echo '--- token configuration references ---'
rg -n -F --glob '*.{ts,sol,json,md,yml,yaml}' -e 'AAPLc' -e 'GOOGLc' -e 'NVDAc' -e 'METAc' -e 'AMZNc' -e 'fund' -e 'mint' -e 'balanceOf' -e 'approve' -e 'seed' deploy scripts hardhat.config.ts package.json README.md 2>/dev/null || test "$?" -eq 1Repository: exactly/protocol
Length of output: 26351
🏁 Script executed:
set -eu
echo '--- Market deposit implementation ---'
rg -n -F --glob 'contracts/**/*.sol' -e 'function deposit' -e 'transferFrom' -e 'contract Market' -e 'abstract contract' contracts || test "$?" -eq 1
echo '--- relevant Market and token source ---'
for f in $(rg -l -F --glob 'contracts/**/*.sol' -e 'function deposit' -e 'contract Market' contracts | head -20); do
echo "--- $f"
nl -ba "$f" | sed -n '1,240p'
done
echo '--- asset deployment sources ---'
rg -n -F --glob 'deploy/*.ts' -e 'AAPLc' -e 'getContract<ERC20>' -e 'deploy(' -e 'Assets' deploy || test "$?" -eq 1
if test -f deploy/Assets.ts; then nl -ba deploy/Assets.ts; fi
if test -f deploy/mocks/Assets.ts; then nl -ba deploy/mocks/Assets.ts; fi
echo '--- Base deployment records ---'
for f in deployments/base/AAPLc.json deployments/base/GOOGLc.json deployments/base/NVDAc.json deployments/base/METAc.json deployments/base/AMZNc.json; do
echo "--- $f"
cat "$f"
done
echo '--- funding/deployment documentation ---'
rg -n -i -F --glob '*.{md,ts,json,yml,yaml}' -e 'fund' -e 'deployer.*balance' -e 'stock token' -e 'tokenized' -e 'Base' README.md docs deploy scripts hardhat.config.ts 2>/dev/null || test "$?" -eq 1Repository: exactly/protocol
Length of output: 42020
🏁 Script executed:
set -eu
echo '--- ERC4626 source candidates ---'
rg --files | rg '(^|/)(ERC4626|solmate).*(\\.sol)$|ERC4626\\.sol$' || true
echo '--- Market inheritance and deposit declarations ---'
nl -ba contracts/Market.sol | sed -n '1,80p'
rg -n -F --glob '*.sol' -e 'function deposit(uint256 assets' -e 'safeTransferFrom(msg.sender' -e 'transferFrom(msg.sender' contracts lib node_modules 2>/dev/null || true
echo '--- asset deployment source ---'
nl -ba deploy/Assets.ts | sed -n '1,180p'
echo '--- mock asset source ---'
nl -ba deploy/mocks/Assets.ts | sed -n '1,150p'
echo '--- Base accounts and network settings ---'
nl -ba hardhat.config.ts | sed -n '1,125p'
echo '--- exact asset deployment record headers ---'
for f in deployments/base/AAPLc.json deployments/base/GOOGLc.json deployments/base/NVDAc.json deployments/base/METAc.json deployments/base/AMZNc.json; do
printf '%s: ' "$f"
python3 - "$f" <<'PY'
import json, sys
with open(sys.argv[1]) as fh:
x=json.load(fh)
print({"address": x.get("address"), "abi_names": sorted({i.get("name") for i in x.get("abi", []) if i.get("name")})})
PY
doneRepository: exactly/protocol
Length of output: 16319
🏁 Script executed:
set -eu
echo '--- solmate dependency binding ---'
rg -n -F --glob 'package.json' --glob 'package-lock.json' --glob 'npm-shrinkwrap.json' --glob 'yarn.lock' --glob 'pnpm-lock.yaml' --glob 'foundry.toml' --glob 'remappings.txt' --glob 'lib/**' -e 'solmate' -e 'ERC4626' . || test "$?" -eq 1
echo '--- repository manifests ---'
for f in package.json foundry.toml remappings.txt; do
if test -f "$f"; then echo "--- $f"; nl -ba "$f" | sed -n '1,220p'; fi
done
echo '--- Market deposit declarations ---'
rg -n -F --glob 'contracts/Market*.sol' -e 'function deposit(' -e 'function mint(' -e 'function withdraw(' -e 'function redeem(' contracts || test "$?" -eq 1Repository: exactly/protocol
Length of output: 7894
🌐 Web query:
transmissions11 solmate v7 ERC4626.sol deposit safeTransferFrom implementation
💡 Result:
<source_evidence>
<source kind="open_page">
<title></title>
<location>https://raw.githubusercontent.com/transmissions11/solmate/v7/src/utils/SafeTransferLib.sol</location>
<excerpt>citeturn1view1 [wordlim: 200] Crawled: today; Content type: text/plain; Source: open({"ref_id":"https://raw.githubusercontent.com/transmissions11/solmate/v7/src/utils/SafeTransferLib.sol","lineno":null}); Total lines: 117
L0: // SPDX-License-Identifier: MIT
L1: pragma solidity >=0.8.0;
L2:
L3: import {ERC20} from "../tokens/ERC20.sol";
L4: /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
L5: /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
L6: /// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.
L7: library SafeTransferLib {
L8: /*//////////////////////////////////////////////////////////////
L9: ETH OPERATIONS
L10: //////////////////////////////////////////////////////////////*/
L11: function safeTransferETH(address to, uint256 amount) internal {
L12: bool success;
L13:
L14: assembly {
L15: // Transfer the ETH and store if it succeeded or not.
L16: success := call(gas(), to, amount, 0, 0, 0, 0)
L17: }
L18:
L19: require(success, "ETH_TRANSFER_FAILED");
L20: }
L21:
L22: /*//////////////////////////////////////////////////////////////
L23: ERC20 OPERATIONS
L24: //////////////////////////////////////////////////////////////*/
L25: function safeTransferFrom(
L26: ERC20 token,
L27: address from,
L28: address to,
L29: uint256 amount
L30: ) internal {
L31: bool success;
L32:
L33: assembly {
L34: // We'll write our calldata to this slot below, but restore it later.
L35: let memPointer := mload(0x40)
L36: // Write the abi-encoded calldata into memory, beginning with the function selector.
L37: mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
L38: mstore(4, and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
L39: mstore(36, and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
L40: mstore(68, amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
L41: success := and(
L42: // Set success to whether the call reverted, if not we check it either
L43: // returned exactly 1 (can't just be non-zero data), or had no return data.
L44: or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
L45: // We use 100 because that's the total length of our calldata (4 + 32 * 3)
L46: // Counterintuitively, this call() must be positioned after the or() in the
L47: // surrounding and() because and() evaluates its arguments from right to left.
L48: call(gas(), token, 0, 0, 100, 0, 32)
L49: )
L50: mstore(0x60, 0) // Restore the zero slot to zero.
L51: mstore(0x40, memPointer) // Restore the memPointer.
L52: }
L53:
L54: require(success, "TRANSFER_FROM_FAILED");
L55: }
L56:
L57: function safeTransfer(
L58: ERC20 token,
L59: address to,
L60: uint256 amount
L61: ) internal {
L62: bool success;
L63:
L64: assembly {
L65: // We'll write our calldata to this slot below, but restore it later.
L66: let memPointer := mload(0x40)
L67: // Write the abi-encoded calldata into memory, beginning with the function selector.
L68: mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
L69: mstore(4, and(to, 0xffffffffffffffffffffffffffffffffffffffff)…[truncated]</excerpt>
</source>
<source kind="search">
<title>solmate/src/tokens/ERC4626.sol at main · transmissions11/solmate · GitHub</title>
<location>https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 2 months ago; Copy raw file ... /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol)
transmissions11 / solmate Public
* Notifications You must be signed in to change notification settings
* Fork 706
* Star
* Code
* Issues 71
# ERC4626.sol
Copy path
[Input: Go to file]
183 lines (130 loc) · 6.37 KB
Raw
Copy raw file
Download raw file
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
import {FixedPointMathLib} from "../utils/FixedPointMathLib.sol";
/// @notice Minimal ERC4626 tokenized Vault implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol)
abstract contract ERC4626 is ERC20 {
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed caller,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
ERC20 public immutable asset;
constructor(
ERC20 _asset,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol, _asset.decimals()) {
asset = _asset;
}
/*//////////////////////////////////////////////////////////////
DEPOSIT/WITHDRAWAL LOGIC
//////////////////////////////////////////////////////////////*/
function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {
// Check for rounding error since we round down in previewDeposit.
require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES");
// Need to transfer before minting or ERC777s could reenter.
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
}
function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {
assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.
// Need to transfer before minting or ERC777s could reenter.
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
}
function withdraw(
uint256 assets,
address receiver,
address owner
) public virtual returns (uint256 shares) {
shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.
if (msg.sender != owner) {
uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
}
beforeWithdraw(assets, shares);
_burn(owner, shares);
emit Withdraw(msg.sender, receiver, owner, assets, shares);
asset.safeTransfer(receiver, assets);
</excerpt>
</source>
<source kind="search">
<title>solmate/src/tokens/ERC4626.sol at main · transmissions11/solmate · GitHub</title>
<location>https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol</location>
<excerpt>citeturn2search0 [wordlim: 200] Crawled: 2 months ago; /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol) ... ) ERC20(_name, _symbol, _asset.decimals()) { ... function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {
transmissions11 / solmate Public
* Notifications You must be signed in to change notification settings
* Fork 706
* Star
* Code
* Issues 71
# ERC4626.sol
Copy path
[Input: Go to file]
183 lines (130 loc) · 6.37 KB
Raw
Copy raw file
Download raw file
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
import {FixedPointMathLib} from "../utils/FixedPointMathLib.sol";
/// @notice Minimal ERC4626 tokenized Vault implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol)
abstract contract ERC4626 is ERC20 {
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed caller,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
ERC20 public immutable asset;
constructor(
ERC20 _asset,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol, _asset.decimals()) {
asset = _asset;
}
/*//////////////////////////////////////////////////////////////
DEPOSIT/WITHDRAWAL LOGIC
//////////////////////////////////////////////////////////////*/
function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {
// Check for rounding error since we round down in previewDeposit.
require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES");
// Need to transfer before minting or ERC777s could reenter.
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
}
function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {
assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.
// Need to transfer before minting or ERC777s could reenter.
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
}
function withdraw(
uint256 assets,
address receiver,
address owner
) public virtual returns (uint256 shares) {
shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.
if (msg.sender != owner) {
uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
}
beforeWithdraw(assets, shares);
_burn(owner, shares);
emit Withdraw(msg.sender, receiver, owner, assets, shares);
asset.safeTransfer(receiver, assets);
}
function redeem(
uint256 shares,
address receiver,
address owner
) public virtual returns (uint256 assets) {
if (msg.sender != owner) {
uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
}
// Check for rounding error since we round down in previewRedeem.
require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS");
beforeWithdraw(assets, shares);
_burn(owner, shares);
emit Withdraw(msg.sender, receiver, owner, assets,…[truncated]</excerpt>
</source>
<source kind="search">
<title>solmate/src/utils/SafeTransferLib.sol at main · transmissions11/solmate · GitHub</title>
<location>https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: 2 months ago; transmissions11 / solmate Public ... ## Files Expand file tree ... import {ERC20} from "../tokens/ERC20.sol"; ... /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) ... // returned exactly 1 (can't just be non-zero data), or had no return data and token has code.
</excerpt>
</source>
<source kind="search">
<title>GitHub - transmissions11/solmate: Modern, opinionated, and gas optimized building blocks for smart contract development. · GitHub</title>
<location>https://github.com/transmissions11/solmate</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 2 months ago; ├─ WETH — "Minimalist and modern Wrapped Ether implementation" ... ├─ ERC4626 — "Minimal ERC4626 tokenized Vault implementation" ... ├─ SafeTransferLib — "Safe ERC20/ETH transfer lib that handles missing return values" ... forge install transmissions11/solmate ... * Dappsys V2
</excerpt>
</source>
<omitted_sources count="39">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>
Citations:
- 1: https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol?utm_source=openai
- 2: https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC4626.sol?utm_source=openai
Verify deployer funding before enabling the five markets.
When live is true and a new market has zero supply, a Base deployer balance below the computed seed amount can make market.deposit fail. Deployment then stops before that market is enabled. Confirm that the deployer holds enough of each token, or add a funding step to the deployment procedure.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #827 +/- ##
=======================================
Coverage 94.82% 94.82%
=======================================
Files 32 32
Lines 2742 2742
Branches 366 366
=======================================
Hits 2600 2600
Misses 141 141
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit