From 64d1165c745364629b08da6ce2a549aa7b23809b Mon Sep 17 00:00:00 2001 From: bayge Date: Mon, 30 Sep 2024 22:39:43 +0930 Subject: [PATCH] Update addresses, allow failing in conversion with position info --- pkg/README.md | 16 ++++++++-------- pkg/seawater/src/error.rs | 4 ++++ pkg/seawater/src/lib.rs | 12 +++--------- pkg/seawater/src/pool.rs | 18 ++++++++++++++++-- web/src/config/contracts.ts | 2 +- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/pkg/README.md b/pkg/README.md index 0f46bd60..c88dfc01 100644 --- a/pkg/README.md +++ b/pkg/README.md @@ -23,15 +23,15 @@ Longtail is Arbitrum's cheapest and most rewarding AMM. | Deployment name | Deployment address | |--------------------------------|--------------------------------------------| -| Longtail AMM | 0x4622e516abFd1BBF34E0e884570eA0FC7EeF10cc | -| Longtail NFT manager | 0x92b85ecA5f8A4744AaF7d403C4C69e9a0F586591 | +| Longtail AMM | 0x3d37c3f4a7c773243f9FC31a891911D39d5A75fE | +| Longtail NFT manager | 0x0000000000000000000000000000000000000000 | | Permit2 router | 0x2246431582087b930F2CE561c34deb8E7e5c44bE | -| Swaps implementation | 0xb48dd3f6f25453c284d505c33bebf9b220aa7a8f | -| Swaps permit2 implementation | 0x73f0a38ff769a28999196978613945b51d1dd05b | -| Quotes implementation | 0x67af82f586d64888ce0149a511c47b9a9ab8c141 | -| Positions implementation | 0x377a50c9539b0a6005d52a90a9dba331be21b374 | -| Update position implementation | 0x68d82f448a7e40f624b8c75547faac1ef470321b | -| Admin implementation | 0x4f2464fe772c4dfa472784723956247021855122 | +| Swaps implementation | 0xf45d0f868e93d68c6698c88b2c0a06feb0f5effc | +| Swaps permit2 implementation | 0x486ee4cb319b19652c97bf4bf81046a5fbd62bf4 | +| Quotes implementation | 0xa75a2c5e441c3b97d49ceb2d3b1fb4c4ec5f8284 | +| Positions implementation | 0xd82a006d4af64db35ea83963e815cd8f1ba41fdc | +| Update position implementation | 0xbf20f2a6f01fc23b4dc45eacb584e85a04d62130 | +| Admin implementation | 0x092fbb759ab57261e2ad6d283a25ee3c235620e8 | ##### Leo contract deployments diff --git a/pkg/seawater/src/error.rs b/pkg/seawater/src/error.rs index 0b57e667..5e78714e 100644 --- a/pkg/seawater/src/error.rs +++ b/pkg/seawater/src/error.rs @@ -261,6 +261,10 @@ pub enum Error { // 48 (0x30) #[error("Pool is already initialised!")] PoolIsInitialised, + + // 49 (0x31) + #[error("Position conversion fail")] + PositionConvFail, } impl From for Vec { diff --git a/pkg/seawater/src/lib.rs b/pkg/seawater/src/lib.rs index 3ff28734..647eaef3 100644 --- a/pkg/seawater/src/lib.rs +++ b/pkg/seawater/src/lib.rs @@ -788,7 +788,7 @@ impl Pools { /// Refreshes and updates liquidity in a position, transferring tokens from the user with a restriction on the amount taken. /// See [Self::adjust_position_internal]. #[allow(non_snake_case)] - pub fn incr_pos_D_3521721( + pub fn swag_3_a_4394_a_6( &mut self, pool: Address, id: U256, @@ -861,7 +861,7 @@ impl Pools { Ok(()) } - /// Creates a new pool. Only usable by the seawater admin. + /// Creates a new pool. /// /// # Arguments /// * `pool` - The address of the non-fluid token to construct the pool around. @@ -871,7 +871,7 @@ impl Pools { /// * `max_liquidity_per_tick` - The maximum amount of liquidity allowed in a single tick. /// /// # Errors - /// Requires the caller to be the seawater admin. Requires the pool to not exist. + /// Requires the pool to not exist. #[allow(non_snake_case)] pub fn create_pool_D650_E2_D0( &mut self, @@ -881,12 +881,6 @@ impl Pools { tick_spacing: u8, max_liquidity_per_tick: u128, ) -> Result<(), Revert> { - assert_eq_or!( - msg::sender(), - self.seawater_admin.get(), - Error::SeawaterAdminOnly - ); - self.pools .setter(pool) .init(price, fee, tick_spacing, max_liquidity_per_tick)?; diff --git a/pkg/seawater/src/pool.rs b/pkg/seawater/src/pool.rs index 1bf385ba..6f379835 100644 --- a/pkg/seawater/src/pool.rs +++ b/pkg/seawater/src/pool.rs @@ -209,8 +209,22 @@ impl StoragePool { let position = self.positions.positions.get(id); let sqrt_ratio_x_96 = self.sqrt_price.get(); - let sqrt_ratio_a_x_96 = tick_math::get_sqrt_ratio_at_tick(position.lower.get().as_i32())?; - let sqrt_ratio_b_x_96 = tick_math::get_sqrt_ratio_at_tick(position.upper.get().as_i32())?; + + let sqrt_ratio_a_x_96 = tick_math::get_sqrt_ratio_at_tick( + position + .lower + .get() + .try_into() + .map_err(|_| Error::PositionConvFail)?, + )?; + + let sqrt_ratio_b_x_96 = tick_math::get_sqrt_ratio_at_tick( + position + .upper + .get() + .try_into() + .map_err(|_| Error::PositionConvFail)?, + )?; let mut delta = sqrt_price_math::get_liquidity_for_amounts( sqrt_ratio_x_96, // cur_tick diff --git a/web/src/config/contracts.ts b/web/src/config/contracts.ts index 26809555..b322c2c1 100644 --- a/web/src/config/contracts.ts +++ b/web/src/config/contracts.ts @@ -29,7 +29,7 @@ const chainContracts: { }, }, 98985: { - amm: { address: "0x4622e516abFd1BBF34E0e884570eA0FC7EeF10cc" }, + amm: { address: "0x3d37c3f4a7c773243f9FC31a891911D39d5A75fE" }, leo: { address: "0x0000000000000000000000000000000000000000" }, }, 421614: {