Skip to content

Commit 277c374

Browse files
committed
deriving Serialize for Position
1 parent f35480c commit 277c374

File tree

1 file changed

+2
-28
lines changed
  • noir-projects/noir-contracts/contracts/lending_contract/src

1 file changed

+2
-28
lines changed
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
11
use dep::aztec::protocol_types::traits::{Deserialize, Serialize};
2+
use std::meta::derive;
23

4+
#[derive(Serialize, Deserialize)]
35
pub struct Position {
46
collateral: U128,
57
static_debt: U128,
68
debt: U128,
79
}
8-
9-
global POSITION_SERIALIZED_LEN: u32 = 6;
10-
11-
impl Serialize<POSITION_SERIALIZED_LEN> for Position {
12-
fn serialize(position: Position) -> [Field; POSITION_SERIALIZED_LEN] {
13-
let serialized_collateral = position.collateral.serialize();
14-
let serialized_static_debt = position.static_debt.serialize();
15-
let serialized_debt = position.debt.serialize();
16-
[
17-
serialized_collateral[0],
18-
serialized_collateral[1],
19-
serialized_static_debt[0],
20-
serialized_static_debt[1],
21-
serialized_debt[0],
22-
serialized_debt[1],
23-
]
24-
}
25-
}
26-
27-
impl Deserialize<POSITION_SERIALIZED_LEN> for Position {
28-
fn deserialize(fields: [Field; POSITION_SERIALIZED_LEN]) -> Position {
29-
Position {
30-
collateral: U128::deserialize([fields[0], fields[1]]),
31-
static_debt: U128::deserialize([fields[2], fields[3]]),
32-
debt: U128::deserialize([fields[4], fields[5]]),
33-
}
34-
}
35-
}

0 commit comments

Comments
 (0)