Skip to content

Commit

Permalink
Current mainnet contract (#395)
Browse files Browse the repository at this point in the history
* Added enforcement of correct side when depositing tokens (#390)

* Added enforcement of correct side when depositing tokens

* Built contract

* Enforce side (#391)

* Added enforcement of correct side when depositing tokens

* Built contract

* :/:Dockerfile.tick.ghostnet

* Enforce side (#392)

* Added enforcement of correct side when depositing tokens

* Built contract

* :/:Dockerfile.tick.ghostnet

* Added correct tokens for ghostnet contract

* Switched UI to new ghostnet contract

* Enforce side (#394)

* Added enforcement of correct side when depositing tokens

* Built contract

* :/:Dockerfile.tick.ghostnet

* Added correct tokens for ghostnet contract

* Switched UI to new ghostnet contract

* Changed enforce side code to parse side first before checking

* Updated contract storage for mainnet

---------

Co-authored-by: Jason Ridgway-Taylor (~misfur-mondut) <[email protected]>
  • Loading branch information
quentin-burg and glottologist authored Sep 1, 2023
1 parent 9f2ad10 commit ed3aa21
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 31 deletions.
54 changes: 32 additions & 22 deletions batcher/batcher-ghostnet.tz
Original file line number Diff line number Diff line change
Expand Up @@ -1049,34 +1049,44 @@
IF { DROP 5 ; PUSH nat 125 ; FAILWITH }
{ DUP 4 ;
CAR ;
PUSH nat 0 ;
DUP 6 ;
DUP 5 ;
GET 5 ;
PUSH nat 0 ;
DUP 2 ;
COMPARE ;
EQ ;
IF { SWAP ;
CAR ;
CAR ;
CAR ;
CAR ;
IF { DROP ; UNIT ; LEFT unit }
{ PUSH nat 1 ;
SWAP ;
CAR ;
CAR ;
CAR ;
COMPARE ;
EQ ;
IF {} { PUSH nat 138 ; FAILWITH } }
{ SWAP ;
CAR ;
CDR ;
CAR ;
SWAP ;
CAR ;
CAR ;
CAR ;
COMPARE ;
EQ ;
IF {} { PUSH nat 138 ; FAILWITH } } ;
IF { UNIT ; RIGHT unit } { PUSH nat 106 ; FAILWITH } } ;
IF_LEFT
{ DROP ;
SWAP ;
CAR ;
CAR ;
CAR ;
CAR ;
SWAP ;
CAR ;
CAR ;
CAR ;
COMPARE ;
EQ ;
IF {} { PUSH nat 138 ; FAILWITH } }
{ DROP ;
SWAP ;
CAR ;
CDR ;
CAR ;
SWAP ;
CAR ;
CAR ;
CAR ;
COMPARE ;
EQ ;
IF {} { PUSH nat 138 ; FAILWITH } } ;
DUP 4 ;
CAR ;
CAR ;
Expand Down
24 changes: 20 additions & 4 deletions batcher/batcher-storage-ghostnet.tz
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@
(Pair (Pair {} 1)
{}
{ Elt "tzBTC/EURL"
(Pair (Pair "tzBTC" "EURL") "KT1DG2g5DPYWqyHKGpRL579YkYZwJxibwaAZ" "BTC-EUR" 6 False) ;
(Pair (Pair (Pair (Pair "tzBTC" (Some "KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS") 8 (Some "FA1.2 token")) 1)
"EURL"
(Some "KT1RcHjqDWWycYQGrz4KBYoGZSMmMuVpkmuS")
6
(Some "FA2 token"))
"KT1DG2g5DPYWqyHKGpRL579YkYZwJxibwaAZ"
"BTC-EUR"
6
False) ;
Elt "tzBTC/USDT"
(Pair (Pair "tzBTC" "USDT") "KT1DG2g5DPYWqyHKGpRL579YkYZwJxibwaAZ" "BTC-USDT" 6 False) })
{ Elt "EURL" (Pair 0 "EURL" (Some "KT1UhjCszVyY5dkNUXFGAwdNcVgVe2ZeuPv5") 6 (Some "FA2 token")) ;
Elt "USDT" (Pair 0 "USDT" (Some "KT1H9hKtcqcMHuCoaisu8Qy7wutoUPFELcLm") 6 (Some "FA2 token")) ;
(Pair (Pair (Pair (Pair "tzBTC" (Some "KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS") 8 (Some "FA1.2 token")) 1)
"USDT"
(Some "KT1WNrZ7pEbpmYBGPib1e7UVCeC6GA6TkJYR")
6
(Some "FA2 token"))
"KT1DG2g5DPYWqyHKGpRL579YkYZwJxibwaAZ"
"BTC-USDT"
6
False) })
{ Elt "EURL" (Pair "EURL" (Some "KT1RcHjqDWWycYQGrz4KBYoGZSMmMuVpkmuS") 6 (Some "FA2 token")) ;
Elt "USDT" (Pair "USDT" (Some "KT1WNrZ7pEbpmYBGPib1e7UVCeC6GA6TkJYR") 6 (Some "FA2 token")) ;
Elt "tzBTC"
(Pair 0 "tzBTC" (Some "KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS") 8 (Some "FA1.2 token")) })

6 changes: 4 additions & 2 deletions batcher/batcher.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,11 @@ let enforce_correct_side
(order:external_swap_order)
(valid_swap:valid_swap) : unit =
let swap = order.swap in
if order.side = 0n then
let side = Utils.nat_to_side order.side in
match side with
| Buy ->
if swap.from.token.name = valid_swap.swap.from.token.name then () else failwith incorrect_side_specified
else
| Sell ->
if swap.from.token.name = valid_swap.swap.to.name then () else failwith incorrect_side_specified


Expand Down
19 changes: 16 additions & 3 deletions batcher/storage/initial_storage_mainnet.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ let f(_:unit) : Batcher.Storage.t = {
valid_swaps = Map.literal [
("tzBTC/USDT", {
swap = {
from = "tzBTC";
to = "USDT";
from = {
amount = 1n;
token = {
name = "tzBTC";
address = Some(("KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" : address));
decimals = 8n;
standard = Some "FA1.2 token"
}
};
to = {
name = "USDT";
address = Some(("KT1XnTn74bUtxHfDtBmm2bGZAQfhPbvKWR8o" : address));
decimals = 6n;
standard = Some "FA2 token";
}
};
oracle_address = ("KT1EhS7KVk6cAaYjUpg4jM1VjPGLJTrT9vqG": address);
oracle_asset_name = "BTC-USDT";
Expand Down Expand Up @@ -58,7 +71,7 @@ let f(_:unit) : Batcher.Storage.t = {
user_batch_ordertypes = (Big_map.empty: Batcher.user_batch_ordertypes);
fee_in_mutez = 10_000mutez;
fee_recipient = ("tz1burnburnburnburnburnburnburjAYjjX" : address);
administrator = ("tz1aSL2gjFnfh96Xf1Zp4T36LxbzKuzyvVJ4" : address);
administrator = ("tz1ftWawLjmm6poX3R73Xc1UaFRoucCSpnhf" : address);
limit_on_tokens_or_pairs = 10n;
deposit_time_window_in_seconds = 600n;
scale_factor_for_oracle_staleness = 1n
Expand Down

0 comments on commit ed3aa21

Please sign in to comment.