Skip to content

Commit

Permalink
Update addresses, allow failing in conversion with position info
Browse files Browse the repository at this point in the history
  • Loading branch information
af-afk committed Sep 30, 2024
1 parent 1b5bafe commit 64d1165
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
16 changes: 8 additions & 8 deletions pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions pkg/seawater/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ pub enum Error {
// 48 (0x30)
#[error("Pool is already initialised!")]
PoolIsInitialised,

// 49 (0x31)
#[error("Position conversion fail")]
PositionConvFail,
}

impl From<Error> for Vec<u8> {
Expand Down
12 changes: 3 additions & 9 deletions pkg/seawater/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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)?;
Expand Down
18 changes: 16 additions & 2 deletions pkg/seawater/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion web/src/config/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const chainContracts: {
},
},
98985: {
amm: { address: "0x4622e516abFd1BBF34E0e884570eA0FC7EeF10cc" },
amm: { address: "0x3d37c3f4a7c773243f9FC31a891911D39d5A75fE" },
leo: { address: "0x0000000000000000000000000000000000000000" },
},
421614: {
Expand Down

0 comments on commit 64d1165

Please sign in to comment.