alexander pfp

alexander

@attar

238 Following
145 Followers


alexander pfp
alexander
@attar
happens every cycle! best time to build
0 reply
0 recast
2 reactions

alexander pfp
alexander
@attar
@hellwolf looks cool! can you explain a little on how you use that? do you just call to observe periodically over a period you want to calculate the twap at the end of?
1 reply
0 recast
0 reaction

alexander pfp
alexander
@attar
Nice I’ll have a look!
0 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
lol
0 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
7/ Learned a lot over the last day. These docs, in particular, helped me implement and deploy a fix: https://docs.uniswap.org/sdk/v3/guides/advanced/price-oracle#:~:text=Observations%20are%20only%20stored%20when,to%20the%20value%20we%20desire.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
8/ Looking Ahead I'd love to build something similar with Uniswap V4, but currently, these tokens are more frequently deployed in V3 pools, so that's why I'm using V3 at the moment!
0 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
6/ Key Takeaway When relying on Uniswap V3's TWAP for extended periods, ensure the pool's observation buffer is sufficiently large to prevent data overwriting during finalization.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
5/ Resolution Steps Immediate Action: Manually compensated winners by sending direct transactions with the correct prize amounts.​ Future Measures: Increase Observation Capacity: Before initiating a game, we'll use increaseObservationCardinalityNext to expand the pool's observation buffer, ensuring it can store the full TWAP period's data. ​ https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool Implement Fallback Mechanism: Introduce an admin fallback function to finalize games using a shorter TWAP if necessary, accompanied by a script to determine the maximum available observation window.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
4/ Impact on the Game With essential data overwritten, the contract couldn't finalize the 24-hour TWAP. Participants who paid to join were unable to claim potential winnings.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
3/ Why This Wasn't Immediately Apparent No Visible Shrinking: The buffer size remains constant, but older data is silently overwritten by newer observations.​ Initial Success: Our contract's validation logic checked the pool's history during game creation. Early calls to observe(86400) succeeded because the buffer contained 24 hours of data. However, as more trades occurred, older observations were overwritten, leading to the error upon finalization.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
1/ Post-Mortem: Uniswap V3 'OLD' Error During Game Finalization Our game contract, referencing a Uniswap V3 pool for 24-hour TWAP calculations, failed at finalization due to an 'OLD' error.​
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
2/ Cause of the Error Uniswap V3 pools store price observations in a fixed-size ring buffer. If the buffer isn't large enough for the entire TWAP period, older observations get overwritten. Attempting to retrieve a 24-hour TWAP without the necessary data triggers the 'OLD' error.
1 reply
0 recast
1 reaction

alexander pfp
alexander
@attar
We encountered a critical issue during the finalization of our game contracts: Uniswap V3's "OLD" error disrupted our 24-hour TWAP calculations. Here's a concise breakdown:
2 replies
0 recast
2 reactions

alexander pfp
alexander
@attar
I'm glad we're alpha testing because we've already mitigated a flaw in the prediction market contract I'm building. https://warpcast.com/attar/0xb61066f4
2 replies
0 recast
3 reactions

alexander pfp
alexander
@attar
Rsvped!
0 reply
0 recast
0 reaction

alexander pfp
alexander
@attar
Let me know if you have comments, questions, or other feedback. Keep in mind this is still in alpha testing and hasn't been fully audited yet.
0 reply
0 recast
2 reactions

alexander pfp
alexander
@attar
The PriceLibrary specifically does some fancy math. This article in particular was a big help while i was implementing it! https://blog.uniswap.org/uniswap-v3-math-primer#how-do-i-calculate-the-current-exchange-rate
1 reply
0 recast
2 reactions

alexander pfp
alexander
@attar
I created a couple libraries for this along with the core contract, with some cool functionality that utilizes Uniswap's built in TWAP logic. If you're interested in diving into it Main contract - https://basescan.org/address/0x27c742b7879cd2f1c084c92a0b688af3a4f5d17a Pricing lib - https://basescan.org/address/0x05e18070386cc56be9a59f86f16da052fbbce8f5
1 reply
0 recast
2 reactions

alexander pfp
alexander
@attar
I had a lot of fun writing the smart contract for this. It uses Uniswap pools as pricing feeds on tokens. Users select the token they think will perform the best over 24 hours. It's limited in scope at the moment, but very expandable.
1 reply
0 recast
3 reactions

alexander pfp
alexander
@attar
I've been working on a @farcaster miniapp recently and we're currently alpha testing it here @warpcast with a small group. It's a kind of prediction market game with prizes at stake! We'd love to have more participants! Join us: https://warpcast.com/lostmidas/0x3936b41d
3 replies
1 recast
5 reactions