Skip to content

Commit

Permalink
Merge branch 'main' into test_all_liquidity
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChqrles authored Oct 7, 2024
2 parents e307d2e + 4d57db4 commit 3f6b15e
Show file tree
Hide file tree
Showing 3 changed files with 354 additions and 37 deletions.
4 changes: 2 additions & 2 deletions contracts/src/contracts/ramps/revolut/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub struct Proof {
pub foo: felt252
}

#[derive(Drop, Copy, Hash, Serde, starknet::Store)]
#[derive(Drop, Copy, Hash, Serde, starknet::Store, Debug, PartialEq)]
pub struct LiquidityKey {
pub owner: ContractAddress,
pub offchain_id: OffchainId,
}

#[derive(Drop, Copy, Serde, starknet::Store)]
#[derive(Drop, Copy, Serde, starknet::Store, Debug, PartialEq)]
pub struct LiquidityShareRequest {
pub requestor: ContractAddress,
pub liquidity_key: LiquidityKey,
Expand Down
12 changes: 9 additions & 3 deletions contracts/src/contracts/ramps/revolut/revolut.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub mod RevolutRamp {
//

#[generate_trait]
impl InternalImpl of InternalTrait {
pub impl InternalImpl of InternalTrait {
fn _get_available_liquidity(self: @ContractState, liquidity_key: LiquidityKey) -> u256 {
let mut amount = self.liquidity.read(liquidity_key);
let current_timestamp = get_block_timestamp();
Expand All @@ -362,8 +362,14 @@ pub mod RevolutRamp {
}

fn _get_next_timestamp_key(self: @ContractState, after: u64) -> u64 {
// minus 1 in order to return `after` if it's already a valid key timestamp.
after - 1 + LOCK_DURATION_STEP - ((after - 1) % LOCK_DURATION_STEP)
if after.is_zero() {
0
} else {
// minus 1 in order to return `after` if it's already a valid key timestamp.
let increment_step = (after - 1) / LOCK_DURATION_STEP + 1;
// returns a multiple of LOCK_DURATION_STEP
LOCK_DURATION_STEP * increment_step
}
}
}
}
Loading

0 comments on commit 3f6b15e

Please sign in to comment.