Skip to content

Commit 817e4ea

Browse files
committed
bid pools
1 parent 555390d commit 817e4ea

20 files changed

Lines changed: 3766 additions & 7 deletions

.solcover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
skipFiles: ["test", "mixin/HookInstrumentERC721.sol", "lib/HookStrings.sol"]
2+
skipFiles: ["test", "mixin/HookInstrumentERC721.sol", "lib/HookStrings.sol", "lib/lyra", "lib/synthetix"]
33
};

docs/generated/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[default]
1+
[profile.default]
22
src = 'src'
33
out = 'out'
44
libs = ['lib']

integration/helpers/index.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@ export interface Entitlement {
1313
expiry: string;
1414
}
1515

16+
export enum OrderDirection {
17+
BUY = 0,
18+
SELL = 1,
19+
}
20+
21+
export enum OptionType {
22+
CALL = 0,
23+
PUT = 1,
24+
}
25+
26+
export interface VolOrderNFTProperties {
27+
propertyValidator: string;
28+
propertyData: string;
29+
}
30+
31+
export interface VolOrder {
32+
direction: OrderDirection;
33+
maker: string;
34+
orderExpiry: string;
35+
nonce: string;
36+
size: string;
37+
optionType: OptionType;
38+
maxStrikePriceMultiple: string;
39+
minOptionDuration: string;
40+
maxOptionDuration: string;
41+
maxPriceSignalAge: string;
42+
nftProperties: VolOrderNFTProperties[];
43+
optionMarketAddress: string;
44+
impliedVolBips: string;
45+
skewDecimal: string;
46+
riskFreeRateBips: string;
47+
}
48+
1649
const signTypedData = async (
1750
domain: TypedDataDomain,
1851
types: Record<string, TypedDataField[]>,
@@ -33,6 +66,47 @@ const signTypedData = async (
3366
return signature;
3467
};
3568

69+
export function genVolOrderTypedData(
70+
order: VolOrder,
71+
verifyingContract: string
72+
) {
73+
return {
74+
// All properties on a domain are optional
75+
domain: {
76+
name: "Hook",
77+
version: "1.0.0",
78+
chainId: 1337, // pulled from hardhat.config.ts
79+
verifyingContract, // Hook Protocol
80+
},
81+
// The named list of all type definitions
82+
types: {
83+
Property: [
84+
{ name: "propertyValidator", type: "address" },
85+
{ name: "propertyData", type: "bytes" },
86+
],
87+
Order: [
88+
{ name: "direction", type: "uint8" },
89+
{ name: "maker", type: "address" },
90+
{ name: "orderExpiry", type: "uint256" },
91+
{ name: "nonce", type: "uint256" },
92+
{ name: "size", type: "uint8" },
93+
{ name: "optionType", type: "uint8" },
94+
{ name: "maxStrikePriceMultiple", type: "uint256" },
95+
{ name: "minOptionDuration", type: "uint64" },
96+
{ name: "maxOptionDuration", type: "uint64" },
97+
{ name: "maxPriceSignalAge", type: "uint64" },
98+
{ name: "nftProperties", type: "Property[]" },
99+
{ name: "optionMarketAddress", type: "address" },
100+
{ name: "impliedVolBips", type: "uint64" },
101+
{ name: "skewDecimal", type: "uint64" },
102+
{ name: "riskFreeRateBips", type: "uint64" },
103+
],
104+
},
105+
// The data to sign
106+
value: order,
107+
};
108+
}
109+
36110
function genEntitlementTypedData(
37111
entitlement: Entitlement,
38112
verifyingContract: string
@@ -91,3 +165,19 @@ export async function signEntitlement(
91165

92166
return signature;
93167
}
168+
169+
export async function signVolOrder(
170+
order: VolOrder,
171+
signer: SignerWithAddress,
172+
hookProtocol: string // Hook Protocol
173+
) {
174+
const { domain, types, value } = genVolOrderTypedData(order, hookProtocol);
175+
const signature = await signTypedData(
176+
domain,
177+
types,
178+
value,
179+
signer,
180+
order.maker
181+
);
182+
return signature;
183+
}

0 commit comments

Comments
 (0)