@zoralabs/coins 0.7.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +106 -84
- package/CHANGELOG.md +68 -0
- package/abis/BadImpl.json +15 -0
- package/abis/BalanceDeltaLibrary.json +15 -0
- package/abis/BaseCoin.json +1350 -0
- package/abis/BaseCoinDeployHook.json +78 -0
- package/abis/BaseHook.json +897 -0
- package/abis/BaseTest.json +60 -91
- package/abis/BeforeSwapDeltaLibrary.json +15 -0
- package/abis/BuySupplyWithSwapRouterHook.json +126 -0
- package/abis/Coin.json +214 -150
- package/abis/CoinConstants.json +65 -0
- package/abis/CoinDopplerMultiCurve.json +38 -0
- package/abis/CoinRewardsV4.json +54 -0
- package/abis/CoinTest.json +66 -111
- package/abis/CoinUniV4Test.json +1053 -0
- package/abis/CoinV4.json +1687 -0
- package/abis/CurrencyLibrary.json +25 -0
- package/abis/DeployHooks.json +9 -0
- package/abis/DeployScript.json +47 -0
- package/abis/DeployedCoinVersionLookup.json +21 -0
- package/abis/DeployedCoinVersionLookupTest.json +716 -0
- package/abis/DifferentNamespaceVersionLookup.json +39 -0
- package/abis/DopplerUniswapV3Test.json +62 -184
- package/abis/ERC20.json +310 -0
- package/abis/FactoryTest.json +98 -98
- package/abis/FakeHookNoInterface.json +21 -0
- package/abis/FeeEstimatorHook.json +1528 -0
- package/abis/Hooks.json +28 -0
- package/abis/HooksDeployment.json +23 -0
- package/abis/HooksTest.json +698 -0
- package/abis/IAllowanceTransfer.json +486 -0
- package/abis/ICoin.json +62 -69
- package/abis/ICoinDeployHook.json +31 -0
- package/abis/ICoinV3.json +879 -0
- package/abis/ICoinV4.json +915 -0
- package/abis/IContractMetadata.json +28 -0
- package/abis/IDeployedCoinVersionLookup.json +21 -0
- package/abis/IEIP712.json +15 -0
- package/abis/IEIP712_v4.json +15 -0
- package/abis/IERC20Minimal.json +172 -0
- package/abis/IERC6909Claims.json +288 -0
- package/abis/IERC721.json +36 -36
- package/abis/IERC721Permit_v4.json +88 -0
- package/abis/IExtsload.json +64 -0
- package/abis/IExttload.json +40 -0
- package/abis/IHasAfterCoinDeploy.json +31 -0
- package/abis/IHasContractName.json +15 -0
- package/abis/IHasPoolKey.json +42 -0
- package/abis/IHasRewardsRecipients.json +54 -0
- package/abis/IHasSwapPath.json +60 -0
- package/abis/IHooks.json +789 -0
- package/abis/IImmutableState.json +15 -0
- package/abis/IMsgSender.json +15 -0
- package/abis/IMulticall_v4.json +21 -0
- package/abis/INotifier.json +187 -0
- package/abis/IPermit2.json +865 -0
- package/abis/IPermit2Forwarder.json +138 -0
- package/abis/IPoolConfigEncoding.json +46 -0
- package/abis/IPoolInitializer_v4.json +53 -0
- package/abis/IPoolManager.json +1286 -0
- package/abis/IPositionManager.json +712 -0
- package/abis/IProtocolFees.json +174 -0
- package/abis/ISignatureTransfer.json +394 -0
- package/abis/ISubscriber.json +89 -0
- package/abis/ISwapPathRouter.json +92 -0
- package/abis/ISwapRouter.json +82 -0
- package/abis/IUniversalRouter.json +61 -0
- package/abis/IUnlockCallback.json +21 -0
- package/abis/IUnorderedNonce.json +44 -0
- package/abis/IV4Quoter.json +310 -0
- package/abis/IV4Router.json +47 -0
- package/abis/IZoraFactory.json +328 -4
- package/abis/IZoraV4CoinHook.json +427 -0
- package/abis/ImmutableState.json +36 -0
- package/abis/LPFeeLibrary.json +65 -0
- package/abis/MockERC20.json +21 -0
- package/abis/MultiOwnableTest.json +60 -91
- package/abis/{CoinConfigurationVersions.json → Position.json} +1 -1
- package/abis/PrintUpgradeCommand.json +9 -0
- package/abis/ProxyShim.json +24 -0
- package/abis/Simulate.json +0 -91
- package/abis/StateLibrary.json +80 -0
- package/abis/TestDeployedCoinVersionLookupImplementation.json +39 -0
- package/abis/TestV4Swap.json +9 -0
- package/abis/{CoinSetup.json → UniV3BuySell.json} +5 -0
- package/abis/UniV3Errors.json +32 -0
- package/abis/UpgradeCoinImpl.json +47 -0
- package/abis/UpgradeFactoryImpl.json +9 -0
- package/abis/UpgradesTest.json +671 -0
- package/abis/Vm.json +1482 -111
- package/abis/VmSafe.json +856 -32
- package/abis/ZoraFactoryImpl.json +450 -1
- package/abis/ZoraV4CoinHook.json +1439 -0
- package/addresses/8453.json +8 -3
- package/addresses/84532.json +8 -3
- package/dist/index.cjs +1998 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1989 -178
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +2852 -688
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/wagmiGenerated.ts +1992 -173
- package/package.json +7 -2
- package/remappings.txt +6 -1
- package/script/CoinsDeployerBase.sol +105 -10
- package/script/DeployDevFactory.s.sol +21 -0
- package/script/DeployHooks.s.sol +22 -0
- package/script/PrintUpgradeCommand.s.sol +13 -0
- package/script/Simulate.s.sol +4 -12
- package/script/TestBackingCoinSwap.s.sol +146 -0
- package/script/TestV4Swap.s.sol +136 -0
- package/script/UpgradeCoinImpl.sol +2 -2
- package/script/UpgradeFactoryImpl.s.sol +23 -0
- package/src/BaseCoin.sol +176 -0
- package/src/Coin.sol +93 -515
- package/src/CoinV4.sol +121 -0
- package/src/ZoraFactoryImpl.sol +257 -57
- package/src/hooks/ZoraV4CoinHook.sol +195 -0
- package/src/hooks/deployment/BaseCoinDeployHook.sol +62 -0
- package/src/hooks/deployment/BuySupplyWithSwapRouterHook.sol +80 -0
- package/src/interfaces/ICoin.sol +35 -39
- package/src/interfaces/ICoinDeployHook.sol +8 -0
- package/src/interfaces/ICoinV3.sol +71 -0
- package/src/interfaces/ICoinV4.sol +69 -0
- package/src/interfaces/IDeployedCoinVersionLookup.sol +11 -0
- package/src/interfaces/IMsgSender.sol +9 -0
- package/src/interfaces/IPoolConfigEncoding.sol +14 -0
- package/src/interfaces/ISwapPathRouter.sol +14 -0
- package/src/interfaces/ISwapRouter.sol +1 -35
- package/src/interfaces/IZoraFactory.sol +97 -7
- package/src/interfaces/IZoraV4CoinHook.sol +116 -0
- package/src/libs/CoinCommon.sol +15 -0
- package/src/libs/CoinConfigurationVersions.sol +116 -1
- package/src/{utils → libs}/CoinConstants.sol +11 -6
- package/src/libs/CoinDopplerMultiCurve.sol +134 -0
- package/src/libs/CoinDopplerUniV3.sol +19 -171
- package/src/libs/CoinRewards.sol +195 -0
- package/src/libs/CoinRewardsV4.sol +180 -0
- package/src/libs/CoinSetup.sol +40 -20
- package/src/libs/CoinSetupV3.sol +50 -0
- package/src/libs/DopplerMath.sol +156 -0
- package/src/libs/HooksDeployment.sol +84 -0
- package/src/libs/MarketConstants.sol +4 -0
- package/src/libs/PoolStateReader.sol +22 -0
- package/src/libs/UniV3BuySell.sol +231 -0
- package/src/libs/UniV3Errors.sol +11 -0
- package/src/libs/UniV4SwapHelper.sol +65 -0
- package/src/libs/UniV4SwapToCurrency.sol +109 -0
- package/src/libs/V4Liquidity.sol +129 -0
- package/src/types/PoolConfiguration.sol +15 -0
- package/src/utils/DeployedCoinVersionLookup.sol +52 -0
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/Coin.t.sol +94 -101
- package/test/CoinDopplerUniV3.t.sol +35 -184
- package/test/CoinUniV4.t.sol +752 -0
- package/test/DeploymentHooks.t.sol +270 -0
- package/test/Factory.t.sol +84 -50
- package/test/MultiOwnable.t.sol +6 -3
- package/test/Upgrades.t.sol +68 -0
- package/test/mocks/MockERC20.sol +12 -0
- package/test/utils/BaseTest.sol +124 -59
- package/test/utils/DeployedCoinVersionLookup.t.sol +127 -0
- package/test/utils/FeeEstimatorHook.sol +84 -0
- package/test/utils/ProxyShim.sol +17 -0
- package/wagmi.config.ts +10 -9
- package/src/libs/CoinLegacy.sol +0 -48
package/src/BaseCoin.sol
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
+
import {ICoin, IHasRewardsRecipients} from "./interfaces/ICoin.sol";
|
|
7
|
+
import {ICoinComments} from "./interfaces/ICoinComments.sol";
|
|
8
|
+
import {IERC7572} from "./interfaces/IERC7572.sol";
|
|
9
|
+
import {IAirlock} from "./interfaces/IAirlock.sol";
|
|
10
|
+
|
|
11
|
+
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
|
|
12
|
+
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
|
|
13
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
14
|
+
import {ContractVersionBase} from "./version/ContractVersionBase.sol";
|
|
15
|
+
import {MultiOwnable} from "./utils/MultiOwnable.sol";
|
|
16
|
+
import {CoinConstants} from "./libs/CoinConstants.sol";
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
$$$$$$\ $$$$$$\ $$$$$$\ $$\ $$\
|
|
20
|
+
$$ __$$\ $$ __$$\ \_$$ _|$$$\ $$ |
|
|
21
|
+
$$ / \__|$$ / $$ | $$ | $$$$\ $$ |
|
|
22
|
+
$$ | $$ | $$ | $$ | $$ $$\$$ |
|
|
23
|
+
$$ | $$ | $$ | $$ | $$ \$$$$ |
|
|
24
|
+
$$ | $$\ $$ | $$ | $$ | $$ |\$$$ |
|
|
25
|
+
\$$$$$$ | $$$$$$ |$$$$$$\ $$ | \$$ |
|
|
26
|
+
\______/ \______/ \______|\__| \__|
|
|
27
|
+
*/
|
|
28
|
+
abstract contract BaseCoin is ICoin, ContractVersionBase, ERC20PermitUpgradeable, MultiOwnable, ReentrancyGuardUpgradeable {
|
|
29
|
+
using SafeERC20 for IERC20;
|
|
30
|
+
|
|
31
|
+
/// @notice The address of the protocol rewards contract
|
|
32
|
+
address public immutable protocolRewards;
|
|
33
|
+
/// @notice The address of the protocol reward recipient
|
|
34
|
+
address public immutable protocolRewardRecipient;
|
|
35
|
+
/// @notice The address of the Airlock contract, ownership is used for a protocol fee split.
|
|
36
|
+
address public immutable airlock;
|
|
37
|
+
|
|
38
|
+
/// @notice The metadata URI
|
|
39
|
+
string public tokenURI;
|
|
40
|
+
/// @notice The address of the coin creator
|
|
41
|
+
address public payoutRecipient;
|
|
42
|
+
/// @notice The address of the platform referrer
|
|
43
|
+
address public platformReferrer;
|
|
44
|
+
/// @notice The address of the currency
|
|
45
|
+
address public currency;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @notice The constructor for the static Coin contract deployment shared across all Coins.
|
|
49
|
+
* @param _protocolRewardRecipient The address of the protocol reward recipient
|
|
50
|
+
* @param _protocolRewards The address of the protocol rewards contract
|
|
51
|
+
* @param _airlock The address of the Airlock contract
|
|
52
|
+
*/
|
|
53
|
+
constructor(address _protocolRewardRecipient, address _protocolRewards, address _airlock) initializer {
|
|
54
|
+
if (_protocolRewardRecipient == address(0)) {
|
|
55
|
+
revert AddressZero();
|
|
56
|
+
}
|
|
57
|
+
if (_protocolRewards == address(0)) {
|
|
58
|
+
revert AddressZero();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (_airlock == address(0)) {
|
|
62
|
+
revert AddressZero();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protocolRewardRecipient = _protocolRewardRecipient;
|
|
66
|
+
protocolRewards = _protocolRewards;
|
|
67
|
+
airlock = _airlock;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// @notice Initializes a new coin
|
|
71
|
+
/// @param payoutRecipient_ The address of the coin creator
|
|
72
|
+
/// @param tokenURI_ The metadata URI
|
|
73
|
+
/// @param name_ The coin name
|
|
74
|
+
/// @param symbol_ The coin symbol
|
|
75
|
+
/// @param platformReferrer_ The address of the platform referrer
|
|
76
|
+
function _initialize(
|
|
77
|
+
address payoutRecipient_,
|
|
78
|
+
address[] memory owners_,
|
|
79
|
+
string memory tokenURI_,
|
|
80
|
+
string memory name_,
|
|
81
|
+
string memory symbol_,
|
|
82
|
+
address platformReferrer_
|
|
83
|
+
) internal {
|
|
84
|
+
// Validate the creation parameters
|
|
85
|
+
if (payoutRecipient_ == address(0)) {
|
|
86
|
+
revert AddressZero();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Set base contract state
|
|
90
|
+
__ERC20_init(name_, symbol_);
|
|
91
|
+
__ERC20Permit_init(name_);
|
|
92
|
+
__MultiOwnable_init(owners_);
|
|
93
|
+
__ReentrancyGuard_init();
|
|
94
|
+
|
|
95
|
+
// Set mutable state
|
|
96
|
+
_setPayoutRecipient(payoutRecipient_);
|
|
97
|
+
_setContractURI(tokenURI_);
|
|
98
|
+
|
|
99
|
+
// Store the referrer or use the protocol reward recipient if not set
|
|
100
|
+
platformReferrer = platformReferrer_ == address(0) ? protocolRewardRecipient : platformReferrer_;
|
|
101
|
+
|
|
102
|
+
// Mint the total supply to the coin contract
|
|
103
|
+
_mint(address(this), CoinConstants.MAX_TOTAL_SUPPLY);
|
|
104
|
+
|
|
105
|
+
// Distribute the creator launch reward to the payout recipient
|
|
106
|
+
_transfer(address(this), payoutRecipient, CoinConstants.CREATOR_LAUNCH_REWARD);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// @notice Enables a user to burn their tokens
|
|
110
|
+
/// @param amount The amount of tokens to burn
|
|
111
|
+
function burn(uint256 amount) external {
|
|
112
|
+
// This burn function sets the from as msg.sender, so having an unauthed call is safe.
|
|
113
|
+
_burn(msg.sender, amount);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// @notice Set the creator's payout address
|
|
117
|
+
/// @param newPayoutRecipient The new recipient address
|
|
118
|
+
function setPayoutRecipient(address newPayoutRecipient) external onlyOwner {
|
|
119
|
+
_setPayoutRecipient(newPayoutRecipient);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// @notice Set the contract URI
|
|
123
|
+
/// @param newURI The new URI
|
|
124
|
+
function setContractURI(string memory newURI) external onlyOwner {
|
|
125
|
+
_setContractURI(newURI);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// @notice The contract metadata
|
|
129
|
+
function contractURI() external view returns (string memory) {
|
|
130
|
+
return tokenURI;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// @notice ERC165 interface support
|
|
134
|
+
/// @param interfaceId The interface ID to check
|
|
135
|
+
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
|
|
136
|
+
return
|
|
137
|
+
interfaceId == type(ICoin).interfaceId ||
|
|
138
|
+
interfaceId == type(ICoinComments).interfaceId ||
|
|
139
|
+
interfaceId == type(IERC7572).interfaceId ||
|
|
140
|
+
interfaceId == type(IERC165).interfaceId ||
|
|
141
|
+
interfaceId == type(IHasRewardsRecipients).interfaceId;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// @dev Overrides ERC20's _update function to emit a superset `CoinTransfer` event
|
|
145
|
+
function _update(address from, address to, uint256 value) internal virtual override {
|
|
146
|
+
super._update(from, to, value);
|
|
147
|
+
|
|
148
|
+
emit CoinTransfer(from, to, value, balanceOf(from), balanceOf(to));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// @dev Used to set the payout recipient on coin creation and updates
|
|
152
|
+
/// @param newPayoutRecipient The new recipient address
|
|
153
|
+
function _setPayoutRecipient(address newPayoutRecipient) internal {
|
|
154
|
+
if (newPayoutRecipient == address(0)) {
|
|
155
|
+
revert AddressZero();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
emit CoinPayoutRecipientUpdated(msg.sender, payoutRecipient, newPayoutRecipient);
|
|
159
|
+
|
|
160
|
+
payoutRecipient = newPayoutRecipient;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// @dev Used to set the contract URI on coin creation and updates
|
|
164
|
+
/// @param newURI The new URI
|
|
165
|
+
function _setContractURI(string memory newURI) internal {
|
|
166
|
+
emit ContractMetadataUpdated(msg.sender, newURI, name());
|
|
167
|
+
emit ContractURIUpdated();
|
|
168
|
+
|
|
169
|
+
tokenURI = newURI;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/// @notice Returns the address of the Doppler protocol fee recipient
|
|
173
|
+
function dopplerFeeRecipient() public view returns (address) {
|
|
174
|
+
return IAirlock(airlock).owner();
|
|
175
|
+
}
|
|
176
|
+
}
|