Sitelet https://github.com/roycoprotocol/royco-iam/commit/06edfbe4625b357d66016e8ea8b3fbeff979cfe4
Skip to content

Commit 06edfbe

Browse files
authored
Merge pull request #132 from roycoprotocol/feat/event-changes
2 parents 7dd8e0e + bab003f commit 06edfbe

11 files changed

Lines changed: 88 additions & 57 deletions

‎src/RecipeMarketHub.sol‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ contract RecipeMarketHub is RecipeMarketHubBase {
144144
offerHashToRemainingQuantity[offerHash] = quantity;
145145

146146
/// @dev APOffer events are stored in events and do not exist onchain outside of the offerHashToRemainingQuantity mapping
147-
emit APOfferCreated(numAPOffers, targetMarketHash, fundingVault, quantity, incentivesRequested, incentiveAmountsRequested, expiry);
147+
emit APOfferCreated(numAPOffers, targetMarketHash, msg.sender, fundingVault, quantity, incentivesRequested, incentiveAmountsRequested, expiry);
148148

149149
// Increment the number of AP offers created
150150
numAPOffers++;
@@ -269,7 +269,16 @@ contract RecipeMarketHub is RecipeMarketHubBase {
269269

270270
// Emit IP offer creation event
271271
emit IPOfferCreated(
272-
numIPOffers, offerHash, targetMarketHash, quantity, incentivesOffered, incentiveAmountsOffered, protocolFeesToBePaid, frontendFeesToBePaid, expiry
272+
numIPOffers,
273+
offerHash,
274+
targetMarketHash,
275+
msg.sender,
276+
quantity,
277+
incentivesOffered,
278+
incentiveAmountsOffered,
279+
protocolFeesToBePaid,
280+
frontendFeesToBePaid,
281+
expiry
273282
);
274283

275284
// Increment the number of IP offers created
@@ -368,11 +377,10 @@ contract RecipeMarketHub is RecipeMarketHubBase {
368377
uint256[] memory protocolFeesPaid = new uint256[](numIncentives);
369378
uint256[] memory frontendFeesPaid = new uint256[](numIncentives);
370379

371-
// Calculate the percentage of the offer the AP is filling
372-
uint256 fillPercentage = fillAmount.divWadDown(offer.quantity);
373-
374380
// Perform incentive accounting on a per incentive basis
375381
for (uint256 i = 0; i < numIncentives; ++i) {
382+
// Calculate the percentage of the offer the AP is filling
383+
uint256 fillPercentage = fillAmount.divWadDown(offer.quantity);
376384
// Incentive address
377385
address incentive = offer.incentivesOffered[i];
378386

@@ -410,7 +418,7 @@ contract RecipeMarketHub is RecipeMarketHubBase {
410418
// Execute deposit recipe
411419
wallet.executeWeiroll(market.depositRecipe.weirollCommands, market.depositRecipe.weirollState);
412420

413-
emit IPOfferFilled(offerHash, fillAmount, address(wallet), incentiveAmountsPaid, protocolFeesPaid, frontendFeesPaid);
421+
emit IPOfferFilled(offerHash, msg.sender, fillAmount, address(wallet), incentiveAmountsPaid, protocolFeesPaid, frontendFeesPaid);
414422
}
415423

416424
/// @dev Fill multiple AP offers
@@ -535,7 +543,7 @@ contract RecipeMarketHub is RecipeMarketHubBase {
535543
// Execute deposit recipe
536544
wallet.executeWeiroll(market.depositRecipe.weirollCommands, market.depositRecipe.weirollState);
537545

538-
emit APOfferFilled(offer.offerID, fillAmount, address(wallet), incentiveAmountsPaid, protocolFeesPaid, frontendFeesPaid);
546+
emit APOfferFilled(offer.offerID, msg.sender, fillAmount, address(wallet), incentiveAmountsPaid, protocolFeesPaid, frontendFeesPaid);
539547
}
540548

541549
/// @notice Cancel an AP offer, setting the remaining quantity available to fill to 0

‎src/VaultMarketHub.sol‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
3737

3838
/// @notice The minimum time a campaign must run for before someone can be allocated into it
3939
uint256 public constant MIN_CAMPAIGN_DURATION = 1 weeks;
40-
40+
4141
/// @notice whether offer fills are paused
4242
bool public offersPaused;
43-
43+
4444
/// @dev The minimum quantity of tokens for an offer
4545
uint256 internal constant MINIMUM_QUANTITY = 1e6;
4646

@@ -49,6 +49,7 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
4949

5050
/// @param offerID Set to numOffers - 1 on offer creation (zero-indexed)
5151
/// @param marketID The ID of the market to place the offer in
52+
/// @param ap The address that created this AP offer
5253
/// @param fundingVault The address of the vault where the input tokens will be withdrawn from
5354
/// @param quantity The total amount of the base asset to be withdrawn from the funding vault
5455
/// @param incentivesRequested The incentives requested by the AP in offer to fill the offer
@@ -57,6 +58,7 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
5758
event APOfferCreated(
5859
uint256 indexed offerID,
5960
address indexed marketID,
61+
address indexed ap,
6062
address fundingVault,
6163
uint256 quantity,
6264
address[] incentivesRequested,
@@ -154,7 +156,7 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
154156
}
155157

156158
// Emit the offer creation event, used for matching offers
157-
emit APOfferCreated(numOffers, targetVault, fundingVault, quantity, incentivesRequested, incentivesRatesRequested, expiry);
159+
emit APOfferCreated(numOffers, targetVault, msg.sender, fundingVault, quantity, incentivesRequested, incentivesRatesRequested, expiry);
158160
// Set the quantity of the offer
159161
APOffer memory offer = APOffer(numOffers, targetVault, msg.sender, fundingVault, expiry, incentivesRequested, incentivesRatesRequested);
160162
offerHashToRemainingQuantity[getOfferHash(offer)] = quantity;
@@ -211,7 +213,7 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
211213
} else {
212214
// Get pre-withdraw token balance of VaultMarketHub
213215
uint256 preWithdrawTokenBalance = targetAsset.balanceOf(address(this));
214-
216+
215217
// Withdraw from the funding vault to the VaultMarketHub
216218
ERC4626(offer.fundingVault).withdraw(fillAmount, address(this), offer.ap);
217219

@@ -225,7 +227,7 @@ contract VaultMarketHub is Ownable2Step, ReentrancyGuardTransient {
225227
}
226228

227229
for (uint256 i; i < offer.incentivesRatesRequested.length; ++i) {
228-
(, uint32 end, ) = WrappedVault(offer.targetVault).rewardToInterval(offer.incentivesRequested[i]);
230+
(, uint32 end,) = WrappedVault(offer.targetVault).rewardToInterval(offer.incentivesRequested[i]);
229231
if (end < MIN_CAMPAIGN_DURATION + block.timestamp) {
230232
revert OfferConditionsNotMet();
231233
}

‎src/base/RecipeMarketHubBase.sol‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
2323
address public immutable POINTS_FACTORY;
2424

2525
/// @notice The minimum percent you can fill an AP offer with, to prevent griefing attacks
26-
uint256 public constant MIN_FILL_PERCENT = 0.10e18; // == 10%
26+
uint256 public constant MIN_FILL_PERCENT = 0.1e18; // == 10%
2727

2828
/// @dev The minimum quantity of tokens for an offer
2929
uint256 internal constant MINIMUM_QUANTITY = 1e6;
@@ -148,6 +148,7 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
148148

149149
/// @param offerID Set to numAPOffers (zero-indexed) - ordered separately for AP and IP offers
150150
/// @param marketHash The hash of the weiroll market which the AP offer is for
151+
/// @param ap The address of the AP that created this offer.
151152
/// @param fundingVault The address of the vault where the input tokens will be withdrawn from
152153
/// @param quantity The total amount of input tokens to be deposited
153154
/// @param incentiveAddresses The requested rewards
@@ -156,6 +157,7 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
156157
event APOfferCreated(
157158
uint256 indexed offerID,
158159
bytes32 indexed marketHash,
160+
address indexed ap,
159161
address fundingVault,
160162
uint256 quantity,
161163
address[] incentiveAddresses,
@@ -166,16 +168,18 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
166168
/// @param offerID Set to numIPOffers (zero-indexed) - ordered separately for AP and IP offers
167169
/// @param offerHash Set to the hash of the offer (used to identify IP offers)
168170
/// @param marketHash The hash of the weiroll market which the IP offer is for
171+
/// @param ip The address of the IP that created this offer.
169172
/// @param quantity The total amount of input tokens to be deposited
170173
/// @param incentivesOffered The offered rewards
171174
/// @param incentiveAmounts The offered rewards per input token
172175
/// @param protocolFeeAmounts The offered rewards protocol fee per input token
173176
/// @param frontendFeeAmounts The offered rewards frontend fee per input token
174177
/// @param expiry The timestamp after which the offer is considered expired
175178
event IPOfferCreated(
176-
uint256 indexed offerID,
179+
uint256 offerID,
177180
bytes32 indexed offerHash,
178181
bytes32 indexed marketHash,
182+
address indexed ip,
179183
uint256 quantity,
180184
address[] incentivesOffered,
181185
uint256[] incentiveAmounts,
@@ -185,13 +189,15 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
185189
);
186190

187191
/// @param offerHash Hash of the offer (used to identify IP offers)
192+
/// @param ap The address of the AP that filled this offer.
188193
/// @param fillAmount The amount of the offer that was filled in the market input token
189194
/// @param weirollWallet The address of the weiroll wallet containing the AP's funds, created on fill, used to execute the recipes
190195
/// @param incentiveAmounts The amount of incentives allocated to the AP on fill (claimable as per the market's reward type)
191196
/// @param protocolFeeAmounts The protocol fee per incentive on fill (claimable as per the market's reward type)
192197
/// @param frontendFeeAmounts The rewards frontend fee per incentive on fill (claimable as per the market's reward type)
193198
event IPOfferFilled(
194199
bytes32 indexed offerHash,
200+
address indexed ap,
195201
uint256 fillAmount,
196202
address weirollWallet,
197203
uint256[] incentiveAmounts,
@@ -200,13 +206,15 @@ abstract contract RecipeMarketHubBase is Owned, ReentrancyGuardTransient {
200206
);
201207

202208
/// @param offerID The ID of the AP offer filled
209+
/// @param ip The address of the IP that filled this offer.
203210
/// @param fillAmount The amount of the offer that was filled in the market input token
204211
/// @param weirollWallet The address of the weiroll wallet containing the AP's funds, created on fill, used to execute the recipes
205212
/// @param incentiveAmounts The amount of incentives allocated to the AP on fill (claimable as per the market's reward type)
206213
/// @param protocolFeeAmounts The amount taken as the protocol fee per incentive on fill (claimable as per the market's reward type)
207214
/// @param frontendFeeAmounts The amount taken as the frontend fee per incentive on fill (claimable as per the market's reward type)
208215
event APOfferFilled(
209216
uint256 indexed offerID,
217+
address indexed ip,
210218
uint256 fillAmount,
211219
address weirollWallet,
212220
uint256[] incentiveAmounts,

‎test/concrete/RecipeMarketHub/Test_APOfferCreation.t.sol‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ contract Test_APOfferCreation_RecipeMarketHub is RecipeMarketHubTestBase {
2828
emit RecipeMarketHubBase.APOfferCreated(
2929
0, // Expected offer ID (starts at 0)
3030
marketHash, // Market ID
31+
ALICE_ADDRESS,
3132
address(0), // No funding vault
3233
quantity,
3334
tokensRequested, // Tokens requested

0 commit comments

Comments
 (0)