Skip to content

Commit a670e85

Browse files
committed
Add burn condition
1 parent eb5ced9 commit a670e85

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

on-chain/validators/synth-dolar.ak

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use types/u32
1010
pub type Action {
1111
Mint
1212
Burn
13+
Liquidate
1314
}
1415

1516
validator synth_dolar(pyth_policy_id: PolicyId, ada_usd_feed_id: Int) {
@@ -24,16 +25,34 @@ validator synth_dolar(pyth_policy_id: PolicyId, ada_usd_feed_id: Int) {
2425
let Transaction { mint, .. } = _self
2526
let minted_amount = get_minted_amount(mint, _policy_id)
2627

27-
let is_deposit_not_zero: Bool = ada_deposited >= 1
28+
when _redeemer is {
29+
Mint -> {
30+
let is_deposit_not_zero: Bool = ada_deposited >= 1
2831

29-
let expected_minted_amount =
30-
todo @"compute_expected_synth_amount(ada_deposited, raw_price, exponent) — pending lib from partner"
32+
let expected_minted_amount =
33+
todo @"compute_expected_synth_amount(ada_deposited, raw_price, exponent) — pending lib from partner"
3134

32-
let is_deposit_correct: Bool = minted_amount == expected_minted_amount
35+
let is_deposit_correct: Bool = minted_amount == expected_minted_amount
3336

34-
and {
35-
is_deposit_correct,
36-
is_deposit_not_zero
37+
and {
38+
is_deposit_not_zero,
39+
is_deposit_correct,
40+
}
41+
}
42+
43+
Burn -> {
44+
let is_withdrawal_not_zero: Bool = ada_deposited <= -1
45+
46+
let expected_burned_amount =
47+
todo @"compute_expected_synth_amount(-ada_deposited, raw_price, exponent) — pending lib from partner"
48+
49+
let is_burn_correct: Bool = minted_amount == -expected_burned_amount
50+
51+
and {
52+
is_withdrawal_not_zero,
53+
is_burn_correct,
54+
}
55+
}
3756
}
3857
}
3958

0 commit comments

Comments
 (0)