Skip to content

Commit

Permalink
Added vault contract and moved michelson output to own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
glottologist committed Oct 13, 2023
1 parent 2284c2b commit ecb47a7
Show file tree
Hide file tree
Showing 30 changed files with 1,430 additions and 97 deletions.
58 changes: 34 additions & 24 deletions batcher/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LIGO_DOCKER := docker run --rm -v $(PWD):$(PWD) -w $(PWD) ligolang/ligo:$(LIGO_

TEST_DIRECTORY:=test
STORAGE_DIRECTORY:=storage
MICHELSON_DIRECTORY:=michelson
TOKENS_DIRECTORY:=$(BATCHER_TEST_DIRECTORY)/tokens
FA12_DIRECTORY:=$(TOKENS_DIRECTORY)/fa12
FA12_STORAGE_DIRECTORY:=$(FA12_DIRECTORY)/storage
Expand All @@ -24,6 +25,11 @@ define compile_storage
$(LIGO_DOCKER) compile expression cameligo -p $(TEZOS_PROTOCOL) --michelson-format text --werror --init-file $(1) 'f()' > $(2)
endef

define build_vault
$(call compile_contract,vault.mligo, $(MICHELSON_DIRECTORY)/'$(1)-vault-$(2).tz')
$(call compile_storage,$(STORAGE_DIRECTORY)/$(1)_vault_storage_$(2).mligo, $(MICHELSON_DIRECTORY)/$(1)-vault-storage-$(2).tz)
endef

define measure_contract
$(LIGO_DOCKER) info measure-contract -p $(TEZOS_PROTOCOL) $(1)
endef
Expand All @@ -45,48 +51,52 @@ clean:
$(call clean_ghostnet_files)
build-mainnet:
$(call clean_mainnet_files)
$(call compile_contract,batcher.mligo, batcher-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/initial_storage_mainnet.mligo, batcher-storage-mainnet.tz)
$(call compile_contract,batcher.mligo, $(MICHELSON_DIRECTORY)/batcher-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/initial_storage_mainnet.mligo, $(MICHELSON_DIRECTORY)/batcher-storage-mainnet.tz)
build-ghostnet:
$(call clean_ghostnet_files)
$(call compile_contract,batcher.mligo, batcher-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/initial_storage_ghostnet.mligo, batcher-storage-ghostnet.tz)
$(call compile_contract,batcher.mligo, $(MICHELSON_DIRECTORY)/batcher-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/initial_storage_ghostnet.mligo, $(MICHELSON_DIRECTORY)/batcher-storage-ghostnet.tz)
build-mm-mainnet:
$(call compile_contract,marketmaker.mligo, marketmaker-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/marketmaker_storage_mainnet.mligo, marketmaker-storage-mainnet.tz)
$(call compile_contract,marketmaker.mligo, $(MICHELSON_DIRECTORY)/marketmaker-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/marketmaker_storage_mainnet.mligo, $(MICHELSON_DIRECTORY)/marketmaker-storage-mainnet.tz)
build-mm-ghostnet:
$(call compile_contract,marketmaker.mligo, marketmaker-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/marketmaker_storage_ghostnet.mligo, marketmaker-storage-ghostnet.tz)
$(call compile_contract,marketmaker.mligo, $(MICHELSON_DIRECTORY)/marketmaker-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/marketmaker_storage_ghostnet.mligo, $(MICHELSON_DIRECTORY)/marketmaker-storage-ghostnet.tz)
build-tm-mainnet:
$(call compile_contract,tokenmanager.mligo, tokenmanager-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/tokenmanager_storage_mainnet.mligo, tokenmanager-storage-mainnet.tz)
$(call compile_contract,tokenmanager.mligo, $(MICHELSON_DIRECTORY)/tokenmanager-mainnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/tokenmanager_storage_mainnet.mligo, $(MICHELSON_DIRECTORY)/tokenmanager-storage-mainnet.tz)
build-tm-ghostnet:
$(call compile_contract,tokenmanager.mligo, tokenmanager-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/tokenmanager_storage_ghostnet.mligo, tokenmanager-storage-ghostnet.tz)
$(call compile_contract,tokenmanager.mligo, $(MICHELSON_DIRECTORY)/tokenmanager-ghostnet.tz)
$(call compile_storage,$(STORAGE_DIRECTORY)/tokenmanager_storage_ghostnet.mligo, $(MICHELSON_DIRECTORY)/tokenmanager-storage-ghostnet.tz)
build-tzbtc-vault-mainnet:
$(call build_vault,tzbtc,mainnet)
build-tzbtc-vault-ghostnet:
$(call build_vault,tzbtc,ghostnet)
build-tzBTC:
$(call clean_files)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, tzBTC_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/tzBTC_storage.mligo, tzBTC_token_storage.tz)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/tzBTC_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/tzBTC_storage.mligo, $(MICHELSON_DIRECTORY)/tzBTC_token_storage.tz)
build-USDT:
$(call clean_files)
$(call compile_contract,$(FA2_DIRECTORY)/main.mligo, USDT_token.tz)
$(call compile_storage,$(FA2_STORAGE_DIRECTORY)/USDT_storage.mligo, USDT_token_storage.tz)
$(call compile_contract,$(FA2_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/USDT_token.tz)
$(call compile_storage,$(FA2_STORAGE_DIRECTORY)/USDT_storage.mligo, $(MICHELSON_DIRECTORY)/USDT_token_storage.tz)
build-CTEZ:
$(call clean_files)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, CTEZ_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/CTEZ_storage.mligo, CTEZ_token_storage.tz)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/CTEZ_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/CTEZ_storage.mligo, $(MICHELSON_DIRECTORY)/CTEZ_token_storage.tz)
build-KUSD:
$(call clean_files)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, KUSD_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/KUSD_storage.mligo, KUSD_token_storage.tz)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/KUSD_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/KUSD_storage.mligo, $(MICHELSON_DIRECTORY)/KUSD_token_storage.tz)
build-EURL:
$(call clean_files)
$(call compile_contract, $(FA2_DIRECTORY)/main.mligo, EURL_token.tz)
$(call compile_storage, $(FA2_STORAGE_DIRECTORY)/EURL_storage.mligo, EURL_token_storage.tz)
$(call compile_contract, $(FA2_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/EURL_token.tz)
$(call compile_storage, $(FA2_STORAGE_DIRECTORY)/EURL_storage.mligo, $(MICHELSON_DIRECTORY)/EURL_token_storage.tz)
build-fa12-tzBTC:
$(call clean_files)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, tzBTC_fa12_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/tzBTC_storage.mligo, tzBTC_fa12_token_storage.tz)
$(call compile_contract,$(FA12_DIRECTORY)/main.mligo, $(MICHELSON_DIRECTORY)/tzBTC_fa12_token.tz)
$(call compile_storage,$(FA12_STORAGE_DIRECTORY)/tzBTC_storage.mligo, $(MICHELSON_DIRECTORY)/tzBTC_fa12_token_storage.tz)
test-mm:
$(call test_ligo,$(TEST_DIRECTORY)/test-market-maker.mligo)
test-batcher:
Expand Down
1 change: 1 addition & 0 deletions batcher/errors.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@
[@inline] let unable_to_get_oracle_price = 159n
[@inline] let contract_does_not_exist = 160n
[@inline] let unable_to_call_on_chain_view = 161n
[@inline] let unable_to_get_tokens_from_token_manager = 162n
57 changes: 1 addition & 56 deletions batcher/marketmaker.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module Storage = struct
}
end


module MarketVaultUtils = struct

[@inline]
Expand Down Expand Up @@ -530,63 +531,7 @@ let deposit

end

type result = operation list * Storage.t

[@inline]
let no_op (s : Storage.t) : result = (([] : operation list), s)

type entrypoint =
| RemoveLiquidity of string
| AddLiquidity of token_amount
| Claim of string
| Tick
| Change_admin_address of address
| Change_batcher_address of address

(* Add Liquidity into a market vault *)
[@inline]
let add_liquidity
(token_amount: token_amount)
(storage: Storage.t) : result =
let () = Utils.reject_if_tez_supplied () in
let holder = Tezos.get_sender () in
MarketVaultUtils.add_liquidity_to_market_maker holder token_amount storage

(* Add Liquidity into a market vault *)
[@inline]
let claim
(token_name: string)
(storage: Storage.t) : result =
let () = Utils.reject_if_tez_supplied () in
let holder = Tezos.get_sender () in
MarketVaultUtils.claim_rewards holder token_name storage

(* Remove Liquidity into a market vault *)
[@inline]
let remove_liquidity
(token_name: string)
(storage: Storage.t) : result =
let () = Utils.reject_if_tez_supplied () in
let holder = Tezos.get_sender () in
MarketVaultUtils.remove_liquidity_from_market_maker holder token_name storage

[@inline]
let change_admin_address
(new_admin_address: address)
(storage: Storage.t) : result =
let () = Utils.is_administrator storage.administrator in
let () = Utils.reject_if_tez_supplied () in
let storage = { storage with administrator = new_admin_address; } in
no_op storage

[@inline]
let change_batcher_address
(new_batcher_address: address)
(storage: Storage.t) : result =
let () = Utils.is_administrator storage.administrator in
let () = Utils.reject_if_tez_supplied () in
let storage = { storage with batcher = new_batcher_address; } in
no_op storage

[@inline]
let get_batches
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ecb47a7

Please sign in to comment.