-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (109 loc) · 3.68 KB
/
Makefile
File metadata and controls
121 lines (109 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
include .env
fmt:
pnpm fmt
cd contracts && forge fmt
start:
pnpm install && pnpm build && pnpm start
dev:
@echo "start the development server with watch..."
pnpm install
pnpm dev
build:
pnpm build
deploy:
${MAKE} -C contracts anvilDeploy
publishAGI:
@if [ -z '$(ASSET_TO_SELL)' ] || [ -z '$(AMOUNT_TO_SELL)' ] || [ -z '$(ASSET_TO_BUY)' ]; then \
echo 'Error: Missing required parameters.'; \
echo 'Usage: make publishAGI \'; \
echo ' ASSET_TO_SELL=0x... \'; \
echo ' AMOUNT_TO_SELL=100000000000000000000 \'; \
echo ' ASSET_TO_BUY=0x... \'; \
echo ' [ORDER_TYPE=0]'; \
exit 1; \
fi
@if [ -z '$(CHAIN_ID)' ]; then \
echo 'Error: CHAIN_ID environment variable is not set'; \
exit 1; \
fi
$(eval CONTRACT_ADDRESS := $(shell jq -r '.addresses.agi' contracts/deployments/agi/$(CHAIN_ID).json))
@if [ -z '$(CONTRACT_ADDRESS)' ] || [ '$(CONTRACT_ADDRESS)' = 'null' ]; then \
echo 'Error: Could not find contract address in deployment file for chain ID $(CHAIN_ID)'; \
exit 1; \
fi
@if [ -z '$(PRIVATE_KEY)' ]; then \
echo 'Error: PRIVATE_KEY environment variable is not set'; \
exit 1; \
fi
@if [ -z '$(RPC)' ]; then \
echo 'Error: RPC_URL environment variable is not set'; \
exit 1; \
fi
cast send $(CONTRACT_ADDRESS) \
'publishAGI(uint8,address,uint256,address)' \
$(if $(ORDER_TYPE),$(ORDER_TYPE),0) \
$(ASSET_TO_SELL) \
$(AMOUNT_TO_SELL) \
$(ASSET_TO_BUY) \
--rpc-url $(RPC) \
--private-key $(PRIVATE_KEY)
sellTokenA:
@if [ -z '$(CHAIN_ID)' ]; then \
echo 'Error: CHAIN_ID environment variable is not set'; \
exit 1; \
fi
$(eval TOKEN_A := $(shell jq -r '.addresses.tokenA' contracts/deployments/agi/$(CHAIN_ID).json))
$(eval TOKEN_B := $(shell jq -r '.addresses.tokenB' contracts/deployments/agi/$(CHAIN_ID).json))
@if [ -z '$(TOKEN_A)' ] || [ -z '$(TOKEN_B)' ]; then \
echo 'Error: Could not find token addresses in deployment file for chain ID $(CHAIN_ID)'; \
exit 1; \
fi
${MAKE} publishAGI \
ASSET_TO_SELL=$(TOKEN_A) \
AMOUNT_TO_SELL=100000000000000000000 \
ASSET_TO_BUY=$(TOKEN_B)
sellTokenB:
@if [ -z '$(CHAIN_ID)' ]; then \
echo 'Error: CHAIN_ID environment variable is not set'; \
exit 1; \
fi
$(eval TOKEN_A := $(shell jq -r '.addresses.tokenA' contracts/deployments/agi/$(CHAIN_ID).json))
$(eval TOKEN_B := $(shell jq -r '.addresses.tokenB' contracts/deployments/agi/$(CHAIN_ID).json))
@if [ -z '$(TOKEN_A)' ] || [ -z '$(TOKEN_B)' ]; then \
echo 'Error: Could not find token addresses in deployment file for chain ID $(CHAIN_ID)'; \
exit 1; \
fi
${MAKE} publishAGI \
ASSET_TO_SELL=$(TOKEN_B) \
AMOUNT_TO_SELL=100000000000000000000 \
ASSET_TO_BUY=$(TOKEN_A)
# BUY TOKEN C with token B
buyTokenC:
@if [ -z '$(CHAIN_ID)' ]; then \
echo 'Error: CHAIN_ID environment variable is not set'; \
exit 1; \
fi
$(eval TOKEN_B := $(shell jq -r '.addresses.tokenB' contracts/deployments/agi/$(CHAIN_ID).json))
@if [ -z '$(TOKEN_B)' ]; then \
echo 'Error: Could not find token B address in deployment file for chain ID $(CHAIN_ID)'; \
exit 1; \
fi
${MAKE} publishAGI \
ASSET_TO_SELL=$(TOKEN_B) \
AMOUNT_TO_SELL=100000000000000000000 \
ASSET_TO_BUY=0x96A98D61bCcb783160D296F107c30D0e90b2Abea
# SELL TOKEN C with token B
sellTokenC:
@if [ -z '$(CHAIN_ID)' ]; then \
echo 'Error: CHAIN_ID environment variable is not set'; \
exit 1; \
fi
$(eval TOKEN_B := $(shell jq -r '.addresses.tokenB' contracts/deployments/agi/$(CHAIN_ID).json))
@if [ -z '$(TOKEN_B)' ]; then \
echo 'Error: Could not find token B address in deployment file for chain ID $(CHAIN_ID)'; \
exit 1; \
fi
${MAKE} publishAGI \
ASSET_TO_SELL=0x96A98D61bCcb783160D296F107c30D0e90b2Abea \
AMOUNT_TO_SELL=100000000000000000000 \
ASSET_TO_BUY=$(TOKEN_B)