-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsetPricesWETH.ts
More file actions
193 lines (185 loc) · 5.63 KB
/
Copy pathsetPricesWETH.ts
File metadata and controls
193 lines (185 loc) · 5.63 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import { ethers } from "ethers";
import { types } from "hardhat/config";
import { action } from "../lib/action";
import { setPrices } from "../armPrices";
import { setPricesForBases } from "../../utils/priceActionUtils";
import { mainnet } from "../../utils/addresses";
const multiAssetARMAbi = require("../../../abis/MultiAssetARM.json");
const LIDO_BASES = new Set(["STETH", "WSTETH"]);
const SUPPORTED_BASES = new Set(["STETH", "WSTETH", "EETH", "WEETH"]);
const lidoDefaults = {
maxBuyPrice: 0.9999,
minBuyPrice: 0.998,
maxSellPrice: 1,
minSellPrice: 0.9999,
tolerance: 0.1,
inch: true,
kyber: false,
};
const etherFiDefaults = {
maxBuyPrice: 0.9998,
minBuyPrice: 0.99,
maxSellPrice: 1,
minSellPrice: 0.99996,
tolerance: 0.09,
inch: false,
kyber: true,
};
action({
name: "setPricesWETH",
description: "Set prices for WETH ARM",
chains: [1],
params: (t) =>
t
.addOptionalParam(
"bases",
"Comma-separated list of base assets to set prices for.",
"STETH,WSTETH,EETH,WEETH",
types.string,
)
.addOptionalParam(
"buyPrice",
"Exact buy price; when set, sellPrice must also be set (WETH per base asset).",
undefined,
types.float,
)
.addOptionalParam(
"sellPrice",
"Exact sell price; when set, buyPrice must also be set (WETH per base asset).",
undefined,
types.float,
)
.addOptionalParam(
"buyAmount",
"WETH remaining at the buy price, as an integer in native token units.",
undefined,
types.string,
)
.addOptionalParam(
"sellAmount",
"Base asset remaining at the sell price, as an integer in native token units.",
undefined,
types.string,
)
.addOptionalParam(
"maxBuyPrice",
"Override the profile upper bound for the buy-side price.",
undefined,
types.float,
)
.addOptionalParam(
"minBuyPrice",
"Override the profile lower bound for the buy-side price.",
undefined,
types.float,
)
.addOptionalParam(
"maxSellPrice",
"Override the profile upper bound for the sell-side price.",
undefined,
types.float,
)
.addOptionalParam(
"minSellPrice",
"Override the profile lower bound for the sell-side price.",
undefined,
types.float,
)
.addOptionalParam(
"amount",
"Override the DEX swap amount used to fetch reference price quotes.",
undefined,
types.float,
)
.addOptionalParam(
"inch",
"Override whether 1Inch is the aggregator price source.",
undefined,
types.boolean,
)
.addOptionalParam(
"kyber",
"Override whether Kyber is the aggregator price source.",
undefined,
types.boolean,
)
.addOptionalParam(
"offset",
"Price offset applied to aggregator quotes.",
0.2,
types.float,
)
.addOptionalParam(
"dynamicOffset",
"Use a dynamic offset that scales from zero at cross price to the DEX spread at the full-spread price.",
false,
types.boolean,
)
.addOptionalParam(
"dynamicOffsetFullSpreadPrice",
"DEX sell price where dynamic offset reaches 100% of the DEX spread.",
0.999,
types.float,
)
.addOptionalParam(
"tolerance",
"Override the profile tolerance used when comparing target and current prices.",
undefined,
types.float,
)
.addOptionalParam(
"fee",
"Swap fee in basis points used when computing target prices.",
2,
types.float,
),
run: async ({ signer, log, args }) => {
const arm = new ethers.Contract(mainnet.wethARM, multiAssetARMAbi, signer);
const bases = String(args.bases)
.split(",")
.map((base) => base.trim().toUpperCase())
.filter(Boolean);
const unsupported = bases.filter((base) => !SUPPORTED_BASES.has(base));
if (unsupported.length > 0) {
throw new Error(
`Unsupported WETH ARM base asset${unsupported.length === 1 ? "" : "s"}: ${unsupported.join(", ")}`,
);
}
if (bases.length === 0) {
throw new Error("At least one WETH ARM base asset is required");
}
const aggregatorOverridden =
args.inch !== undefined || args.kyber !== undefined;
log.info("Setting prices for WETH ARM");
for (const base of bases) {
const defaults = LIDO_BASES.has(base) ? lidoDefaults : etherFiDefaults;
await setPricesForBases({
setPrices,
bases: [base],
options: {
signer,
arm,
armName: "WETH",
buyPrice: args.buyPrice,
sellPrice: args.sellPrice,
buyAmount: args.buyAmount,
sellAmount: args.sellAmount,
maxSellPrice: args.maxSellPrice ?? defaults.maxSellPrice,
minSellPrice: args.minSellPrice ?? defaults.minSellPrice,
maxBuyPrice: args.maxBuyPrice ?? defaults.maxBuyPrice,
minBuyPrice: args.minBuyPrice ?? defaults.minBuyPrice,
kyber: aggregatorOverridden ? Boolean(args.kyber) : defaults.kyber,
inch: aggregatorOverridden ? Boolean(args.inch) : defaults.inch,
amount: args.amount,
tolerance: args.tolerance ?? defaults.tolerance,
fee: args.fee,
offset: args.offset,
dynamicOffset: args.dynamicOffset,
dynamicOffsetFullSpreadPrice: args.dynamicOffsetFullSpreadPrice,
priceOffset: true,
blockTag: "latest",
},
});
}
},
});