Skip to content

Commit

Permalink
Merge pull request #20 from penumbra-zone/clamp_reserves
Browse files Browse the repository at this point in the history
Clamp reserves posted in positions to 80-bits
  • Loading branch information
zbuc authored Jul 26, 2023
2 parents 1aac7b5 + 90049d9 commit 753131b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/trader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ where
// assets. so we should really have _half the total available reserves divided
// amongst the positions involving that asset_
let reserves = Reserves {
r1: reserves_1 / 2u32.into(),
r2: reserves_2 / 2u32.into(),
// We need to clamp the reserves to 80 bits, which is the max the node
// software can handle.
r1: (reserves_1 / 2u32.into()).clamp(0u32.into(), (u128::pow(2, 80) - 1).into()),
r2: (reserves_2 / 2u32.into()).clamp(0u32.into(), (u128::pow(2, 80) - 1).into()),
};

if reserves.r1 == 0u32.into() && reserves.r2 == 0u32.into() {
Expand Down

0 comments on commit 753131b

Please sign in to comment.