Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Mar 14, 2024
1 parent 24a3765 commit 1ad5937
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions script/optimized-deployer-meta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"constant_product_hash": "0x6b37069ad34cca2a7a7d3a8ed052f775eda0bec3d704c9ac5b6f9402c44b4765",
"factory_hash": "0xd8a0495564d5556148a54de0b0074f4171da381bb172a684a90378592e37e0f8",
"oracle_caller_hash": "0x401f8cdddb19e47b49df421d81efc922b706e72f2f7d84af19c3b7ad5cf2b2e1",
"stable_hash": "0x7172144b5b8e564ba70205fa2337a9eab5e081b953d7ca079491221904a402d5"
"constant_product_hash": "0xa0719fd65c4db1b8f15ac06274344fb7c121fa84bcfc2f854a2c7fd3b0a8de13",
"factory_hash": "0xf8f34d4275709774705694daa526ffbb6c91f1c875c3af2049cc1690d9326ffc",
"oracle_caller_hash": "0x2a0f1f77423fb968788cf68a9638c9ed5eb16ab66a050dfde6bf18dfe8bdb2c3",
"stable_hash": "0xff427f388472489d39aaeee6d9f34588d56ca65960369a26e8aa59e36e494078"
}
8 changes: 4 additions & 4 deletions src/ReservoirDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ contract ReservoirDeployer {
uint256 public step = 0;

// Bytecode hashes.
bytes32 public constant FACTORY_HASH = bytes32(0xd8a0495564d5556148a54de0b0074f4171da381bb172a684a90378592e37e0f8);
bytes32 public constant FACTORY_HASH = bytes32(0xf8f34d4275709774705694daa526ffbb6c91f1c875c3af2049cc1690d9326ffc);
bytes32 public constant CONSTANT_PRODUCT_HASH =
bytes32(0x6b37069ad34cca2a7a7d3a8ed052f775eda0bec3d704c9ac5b6f9402c44b4765);
bytes32 public constant STABLE_HASH = bytes32(0x7172144b5b8e564ba70205fa2337a9eab5e081b953d7ca079491221904a402d5);
bytes32(0xa0719fd65c4db1b8f15ac06274344fb7c121fa84bcfc2f854a2c7fd3b0a8de13);
bytes32 public constant STABLE_HASH = bytes32(0xff427f388472489d39aaeee6d9f34588d56ca65960369a26e8aa59e36e494078);
bytes32 public constant ORACLE_CALLER_HASH =
bytes32(0x401f8cdddb19e47b49df421d81efc922b706e72f2f7d84af19c3b7ad5cf2b2e1);
bytes32(0x2a0f1f77423fb968788cf68a9638c9ed5eb16ab66a050dfde6bf18dfe8bdb2c3);

// Deployment addresses.
GenericFactory public factory;
Expand Down
16 changes: 7 additions & 9 deletions src/ReservoirPair.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ abstract contract ReservoirPair is IAssetManagedPair, ReservoirERC20 {
_writeSlot0Timestamp(sSlot0, aBlockTimestampLast, false);
}

// update reserves with new balances
// on the first call per block, update price oracle using previous reserves
/// @notice update reserves with new balances
/// @notice on the first call per block, accumulate price oracle using previous instant prices and write the new instant prices
/// @dev we write an oracle sample even at the time of pair creation. Also we do not update instant prices for
/// subsequent mint/burn/swaps in the same block. the team has assessed that this is a small risk given the very
/// fast block times on L2s and has decided to make the tradeoff to minimize complexity
function _updateAndUnlock(
Slot0 storage sSlot0,
uint256 aBalance0,
Expand All @@ -156,13 +159,8 @@ abstract contract ReservoirPair is IAssetManagedPair, ReservoirERC20 {
lTimeElapsed = lBlockTimestamp - aBlockTimestampLast;

// both balance should never be zero, but necessary to check so we don't pass 0 values into arithmetic operations
// on the first activity of every block, accumulate using previous instant prices and write the current instant prices
// we create a new sample even at the time of pair creation
// this implies that we do not update instant prices for subsequent mint/burn/swaps in the same block
// but the team has assessed that this is a small risk given the very fast block times on L2s
// and has decided to make the tradeoff to minimize complexity
if (lTimeElapsed * aBalance0 * aBalance1 > 0 ) {

// shortcut to calculate lTimeElapsed > 0 && aBalance0 > 0 && aBalance1 > 0
if (lTimeElapsed * aBalance0 * aBalance1 > 0) {
Observation storage lPrevious = _observations[sSlot0.index];
(uint256 lInstantRawPrice, int256 lLogInstantRawPrice) = _calcSpotAndLogPrice(aBalance0, aBalance1);

Expand Down

0 comments on commit 1ad5937

Please sign in to comment.