timelock-sdk 0.0.254 → 0.0.255
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis.cjs +1 -1
- package/dist/abis.d.cts +98 -0
- package/dist/abis.d.ts +98 -0
- package/dist/abis.js +1 -1
- package/dist/client.cjs +123 -59
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +20 -37
- package/dist/client.d.ts +20 -37
- package/dist/client.js +123 -59
- package/dist/client.js.map +1 -1
- package/dist/{factory-CzYOPurN.cjs → factory-AGrigZB6.cjs} +119 -1
- package/dist/{factory-CzYOPurN.cjs.map → factory-AGrigZB6.cjs.map} +1 -1
- package/dist/{factory-I_Evaj33.js → factory-DRw6YTAD.js} +119 -1
- package/dist/{factory-I_Evaj33.js.map → factory-DRw6YTAD.js.map} +1 -1
- package/dist/{graphql-OwLorEip.js → graphql-BKnux7da.js} +2 -2
- package/dist/graphql-BKnux7da.js.map +1 -0
- package/dist/{graphql-B4hXFsA2.cjs → graphql-kf13KPwy.cjs} +2 -2
- package/dist/graphql-kf13KPwy.cjs.map +1 -0
- package/dist/{index-CNYDmu55.d.ts → index-B4WXvCJZ.d.ts} +5 -5
- package/dist/{index-C_d6dHDk.d.cts → index-vgZSYuwB.d.cts} +5 -5
- package/dist/package.cjs +1 -1
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/package.json +4 -4
- package/dist/graphql-B4hXFsA2.cjs.map +0 -1
- package/dist/graphql-OwLorEip.js.map +0 -1
package/dist/abis.cjs
CHANGED
package/dist/abis.d.cts
CHANGED
|
@@ -101,6 +101,104 @@ declare const factoryAbi: readonly [{
|
|
|
101
101
|
readonly internalType: "contract FeeStrategy";
|
|
102
102
|
}];
|
|
103
103
|
readonly stateMutability: "view";
|
|
104
|
+
}, {
|
|
105
|
+
readonly type: "function";
|
|
106
|
+
readonly name: "getFeeStrategy";
|
|
107
|
+
readonly inputs: readonly [{
|
|
108
|
+
readonly name: "_openingFeeRate";
|
|
109
|
+
readonly type: "uint32";
|
|
110
|
+
readonly internalType: "uint32";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "_baseFeeRate";
|
|
113
|
+
readonly type: "uint32";
|
|
114
|
+
readonly internalType: "uint32";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "_minOpeningFee";
|
|
117
|
+
readonly type: "uint128";
|
|
118
|
+
readonly internalType: "uint128";
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "_minBaseFee";
|
|
121
|
+
readonly type: "uint128";
|
|
122
|
+
readonly internalType: "uint128";
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "_feeRecipient";
|
|
125
|
+
readonly type: "address";
|
|
126
|
+
readonly internalType: "address";
|
|
127
|
+
}];
|
|
128
|
+
readonly outputs: readonly [{
|
|
129
|
+
readonly name: "strategy";
|
|
130
|
+
readonly type: "address";
|
|
131
|
+
readonly internalType: "contract FeeStrategy";
|
|
132
|
+
}, {
|
|
133
|
+
readonly name: "paramsHash";
|
|
134
|
+
readonly type: "bytes32";
|
|
135
|
+
readonly internalType: "bytes32";
|
|
136
|
+
}];
|
|
137
|
+
readonly stateMutability: "view";
|
|
138
|
+
}, {
|
|
139
|
+
readonly type: "function";
|
|
140
|
+
readonly name: "getOptionPricing";
|
|
141
|
+
readonly inputs: readonly [{
|
|
142
|
+
readonly name: "_logicContract";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
readonly internalType: "contract StatelessOptionPricing";
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "_iv";
|
|
147
|
+
readonly type: "uint32";
|
|
148
|
+
readonly internalType: "uint32";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "_riskFreeRate";
|
|
151
|
+
readonly type: "uint32";
|
|
152
|
+
readonly internalType: "uint32";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "_minPremiumDailyRate";
|
|
155
|
+
readonly type: "uint32";
|
|
156
|
+
readonly internalType: "uint32";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "_minPremiumAmount";
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
readonly internalType: "uint256";
|
|
161
|
+
}];
|
|
162
|
+
readonly outputs: readonly [{
|
|
163
|
+
readonly name: "pricing";
|
|
164
|
+
readonly type: "address";
|
|
165
|
+
readonly internalType: "contract OptionPricing";
|
|
166
|
+
}, {
|
|
167
|
+
readonly name: "paramsHash";
|
|
168
|
+
readonly type: "bytes32";
|
|
169
|
+
readonly internalType: "bytes32";
|
|
170
|
+
}];
|
|
171
|
+
readonly stateMutability: "view";
|
|
172
|
+
}, {
|
|
173
|
+
readonly type: "function";
|
|
174
|
+
readonly name: "getStaticPerpsPricing";
|
|
175
|
+
readonly inputs: readonly [{
|
|
176
|
+
readonly name: "_openingRate";
|
|
177
|
+
readonly type: "uint32";
|
|
178
|
+
readonly internalType: "uint32";
|
|
179
|
+
}, {
|
|
180
|
+
readonly name: "_dailyFundingRate";
|
|
181
|
+
readonly type: "uint32";
|
|
182
|
+
readonly internalType: "uint32";
|
|
183
|
+
}, {
|
|
184
|
+
readonly name: "_minOpeningAmount";
|
|
185
|
+
readonly type: "uint128";
|
|
186
|
+
readonly internalType: "uint128";
|
|
187
|
+
}, {
|
|
188
|
+
readonly name: "_minFundingAmount";
|
|
189
|
+
readonly type: "uint128";
|
|
190
|
+
readonly internalType: "uint128";
|
|
191
|
+
}];
|
|
192
|
+
readonly outputs: readonly [{
|
|
193
|
+
readonly name: "pricing";
|
|
194
|
+
readonly type: "address";
|
|
195
|
+
readonly internalType: "contract StaticPerpsPricing";
|
|
196
|
+
}, {
|
|
197
|
+
readonly name: "paramsHash";
|
|
198
|
+
readonly type: "bytes32";
|
|
199
|
+
readonly internalType: "bytes32";
|
|
200
|
+
}];
|
|
201
|
+
readonly stateMutability: "view";
|
|
104
202
|
}, {
|
|
105
203
|
readonly type: "function";
|
|
106
204
|
readonly name: "optionPricings";
|
package/dist/abis.d.ts
CHANGED
|
@@ -101,6 +101,104 @@ declare const factoryAbi: readonly [{
|
|
|
101
101
|
readonly internalType: "contract FeeStrategy";
|
|
102
102
|
}];
|
|
103
103
|
readonly stateMutability: "view";
|
|
104
|
+
}, {
|
|
105
|
+
readonly type: "function";
|
|
106
|
+
readonly name: "getFeeStrategy";
|
|
107
|
+
readonly inputs: readonly [{
|
|
108
|
+
readonly name: "_openingFeeRate";
|
|
109
|
+
readonly type: "uint32";
|
|
110
|
+
readonly internalType: "uint32";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "_baseFeeRate";
|
|
113
|
+
readonly type: "uint32";
|
|
114
|
+
readonly internalType: "uint32";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "_minOpeningFee";
|
|
117
|
+
readonly type: "uint128";
|
|
118
|
+
readonly internalType: "uint128";
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "_minBaseFee";
|
|
121
|
+
readonly type: "uint128";
|
|
122
|
+
readonly internalType: "uint128";
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "_feeRecipient";
|
|
125
|
+
readonly type: "address";
|
|
126
|
+
readonly internalType: "address";
|
|
127
|
+
}];
|
|
128
|
+
readonly outputs: readonly [{
|
|
129
|
+
readonly name: "strategy";
|
|
130
|
+
readonly type: "address";
|
|
131
|
+
readonly internalType: "contract FeeStrategy";
|
|
132
|
+
}, {
|
|
133
|
+
readonly name: "paramsHash";
|
|
134
|
+
readonly type: "bytes32";
|
|
135
|
+
readonly internalType: "bytes32";
|
|
136
|
+
}];
|
|
137
|
+
readonly stateMutability: "view";
|
|
138
|
+
}, {
|
|
139
|
+
readonly type: "function";
|
|
140
|
+
readonly name: "getOptionPricing";
|
|
141
|
+
readonly inputs: readonly [{
|
|
142
|
+
readonly name: "_logicContract";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
readonly internalType: "contract StatelessOptionPricing";
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "_iv";
|
|
147
|
+
readonly type: "uint32";
|
|
148
|
+
readonly internalType: "uint32";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "_riskFreeRate";
|
|
151
|
+
readonly type: "uint32";
|
|
152
|
+
readonly internalType: "uint32";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "_minPremiumDailyRate";
|
|
155
|
+
readonly type: "uint32";
|
|
156
|
+
readonly internalType: "uint32";
|
|
157
|
+
}, {
|
|
158
|
+
readonly name: "_minPremiumAmount";
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
readonly internalType: "uint256";
|
|
161
|
+
}];
|
|
162
|
+
readonly outputs: readonly [{
|
|
163
|
+
readonly name: "pricing";
|
|
164
|
+
readonly type: "address";
|
|
165
|
+
readonly internalType: "contract OptionPricing";
|
|
166
|
+
}, {
|
|
167
|
+
readonly name: "paramsHash";
|
|
168
|
+
readonly type: "bytes32";
|
|
169
|
+
readonly internalType: "bytes32";
|
|
170
|
+
}];
|
|
171
|
+
readonly stateMutability: "view";
|
|
172
|
+
}, {
|
|
173
|
+
readonly type: "function";
|
|
174
|
+
readonly name: "getStaticPerpsPricing";
|
|
175
|
+
readonly inputs: readonly [{
|
|
176
|
+
readonly name: "_openingRate";
|
|
177
|
+
readonly type: "uint32";
|
|
178
|
+
readonly internalType: "uint32";
|
|
179
|
+
}, {
|
|
180
|
+
readonly name: "_dailyFundingRate";
|
|
181
|
+
readonly type: "uint32";
|
|
182
|
+
readonly internalType: "uint32";
|
|
183
|
+
}, {
|
|
184
|
+
readonly name: "_minOpeningAmount";
|
|
185
|
+
readonly type: "uint128";
|
|
186
|
+
readonly internalType: "uint128";
|
|
187
|
+
}, {
|
|
188
|
+
readonly name: "_minFundingAmount";
|
|
189
|
+
readonly type: "uint128";
|
|
190
|
+
readonly internalType: "uint128";
|
|
191
|
+
}];
|
|
192
|
+
readonly outputs: readonly [{
|
|
193
|
+
readonly name: "pricing";
|
|
194
|
+
readonly type: "address";
|
|
195
|
+
readonly internalType: "contract StaticPerpsPricing";
|
|
196
|
+
}, {
|
|
197
|
+
readonly name: "paramsHash";
|
|
198
|
+
readonly type: "bytes32";
|
|
199
|
+
readonly internalType: "bytes32";
|
|
200
|
+
}];
|
|
201
|
+
readonly stateMutability: "view";
|
|
104
202
|
}, {
|
|
105
203
|
readonly type: "function";
|
|
106
204
|
readonly name: "optionPricings";
|
package/dist/abis.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as lensAbi, n as quoterAbi, r as optionsMarketAbi, t as stateViewAbi } from "./stateView-BwLZDqqG.js";
|
|
2
|
-
import { n as guardianAbi, r as singleOwnerVaultAbi, t as factoryAbi } from "./factory-
|
|
2
|
+
import { n as guardianAbi, r as singleOwnerVaultAbi, t as factoryAbi } from "./factory-DRw6YTAD.js";
|
|
3
3
|
|
|
4
4
|
//#region src/abis/poolManager.ts
|
|
5
5
|
const poolManagerAbi = [
|
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
const require_graphql = require('./graphql-
|
|
3
|
+
const require_graphql = require('./graphql-kf13KPwy.cjs');
|
|
4
4
|
const require_stateView = require('./stateView-BXg8tiiy.cjs');
|
|
5
|
-
const require_factory = require('./factory-
|
|
5
|
+
const require_factory = require('./factory-AGrigZB6.cjs');
|
|
6
6
|
let viem = require("viem");
|
|
7
7
|
let react = require("react");
|
|
8
8
|
react = require_graphql.__toESM(react);
|
|
@@ -1094,6 +1094,7 @@ const getSavedSignature = (userAddr) => {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
return parsed;
|
|
1096
1096
|
} catch (error) {
|
|
1097
|
+
console.error(error);
|
|
1097
1098
|
clearSignature(userAddr);
|
|
1098
1099
|
throw new Error("Invalid stored signature: " + raw);
|
|
1099
1100
|
}
|
|
@@ -1906,22 +1907,26 @@ const useUpdateMarketFees = (marketAddr) => {
|
|
|
1906
1907
|
const chainId = (0, wagmi.useChainId)();
|
|
1907
1908
|
const { data: { feeStrategy, optionPricing, priceFeed } = {}, error: stateError } = useMarketState(marketAddr);
|
|
1908
1909
|
const { data: { openingFeeRate, extensionFeeRate, minOpeningFee, minExtensionFee, feeRecipient } = {} } = useFeeRates(feeStrategy);
|
|
1909
|
-
const
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1910
|
+
const getOrDeployFeeStrategy = async (factoryAddr, params) => {
|
|
1911
|
+
const args = [
|
|
1912
|
+
params.openingFeeRate,
|
|
1913
|
+
params.extensionFeeRate,
|
|
1914
|
+
params.minOpeningFee,
|
|
1915
|
+
params.minExtensionFee,
|
|
1916
|
+
params.feeRecipient
|
|
1917
|
+
];
|
|
1918
|
+
const [existingFeeStrategy] = await publicClient.readContract({
|
|
1919
|
+
address: factoryAddr,
|
|
1920
|
+
abi: require_factory.factoryAbi,
|
|
1921
|
+
functionName: "getFeeStrategy",
|
|
1922
|
+
args
|
|
1923
|
+
});
|
|
1924
|
+
if (existingFeeStrategy !== viem.zeroAddress) return { feeStrategy: existingFeeStrategy };
|
|
1914
1925
|
const hash = await writeContractAsync({
|
|
1915
1926
|
address: factoryAddr,
|
|
1916
1927
|
abi: require_factory.factoryAbi,
|
|
1917
1928
|
functionName: "deployFeeStrategy",
|
|
1918
|
-
args
|
|
1919
|
-
rates.openingFeeRate ?? openingFeeRate,
|
|
1920
|
-
rates.extensionFeeRate ?? extensionFeeRate,
|
|
1921
|
-
rates.minOpeningFee ?? minOpeningFee,
|
|
1922
|
-
rates.minExtensionFee ?? minExtensionFee,
|
|
1923
|
-
rates.feeRecipient ?? feeRecipient
|
|
1924
|
-
]
|
|
1929
|
+
args
|
|
1925
1930
|
});
|
|
1926
1931
|
const deployEvent = (await publicClient.waitForTransactionReceipt({ hash })).logs.find((log) => log.address.toLowerCase() === factoryAddr);
|
|
1927
1932
|
if (!deployEvent) throw new Error("DeployFeeStrategy event not found");
|
|
@@ -1931,8 +1936,23 @@ const useUpdateMarketFees = (marketAddr) => {
|
|
|
1931
1936
|
topics: deployEvent.topics
|
|
1932
1937
|
});
|
|
1933
1938
|
if (decodedEvent.eventName !== "DeployFeeStrategy") throw new Error("Unexpected event");
|
|
1934
|
-
|
|
1935
|
-
|
|
1939
|
+
return {
|
|
1940
|
+
feeStrategy: decodedEvent.args.feeStrategy,
|
|
1941
|
+
deployHash: hash
|
|
1942
|
+
};
|
|
1943
|
+
};
|
|
1944
|
+
const updateMarketFees = async (rates) => {
|
|
1945
|
+
if (openingFeeRate === void 0 || extensionFeeRate === void 0 || minOpeningFee === void 0 || minExtensionFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
|
|
1946
|
+
if (!optionPricing || !priceFeed) throw new Error("Market state not available: " + (stateError === null || stateError === void 0 ? void 0 : stateError.message));
|
|
1947
|
+
if (!publicClient) throw new Error("Public client not available");
|
|
1948
|
+
const { feeStrategy: newFeeStrategy, deployHash } = await getOrDeployFeeStrategy(require_graphql.timelockFactories[chainId].toLowerCase(), {
|
|
1949
|
+
openingFeeRate: rates.openingFeeRate ?? openingFeeRate,
|
|
1950
|
+
extensionFeeRate: rates.extensionFeeRate ?? extensionFeeRate,
|
|
1951
|
+
minOpeningFee: rates.minOpeningFee ?? minOpeningFee,
|
|
1952
|
+
minExtensionFee: rates.minExtensionFee ?? minExtensionFee,
|
|
1953
|
+
feeRecipient: rates.feeRecipient ?? feeRecipient
|
|
1954
|
+
});
|
|
1955
|
+
const updateHash = await writeContractAsync({
|
|
1936
1956
|
address: marketAddr,
|
|
1937
1957
|
abi: require_stateView.optionsMarketAbi,
|
|
1938
1958
|
functionName: "updateAddresses",
|
|
@@ -1944,8 +1964,8 @@ const useUpdateMarketFees = (marketAddr) => {
|
|
|
1944
1964
|
});
|
|
1945
1965
|
queryClient.invalidateQueries({ queryKey: ["readContract"] });
|
|
1946
1966
|
return {
|
|
1947
|
-
deployHash
|
|
1948
|
-
updateHash
|
|
1967
|
+
deployHash,
|
|
1968
|
+
updateHash,
|
|
1949
1969
|
newFeeStrategy
|
|
1950
1970
|
};
|
|
1951
1971
|
};
|
|
@@ -2063,6 +2083,87 @@ const useUpdateMarketPricing = (marketAddr) => {
|
|
|
2063
2083
|
const chainId = (0, wagmi.useChainId)();
|
|
2064
2084
|
const { data: { feeStrategy, optionPricing, priceFeed } = {}, error: stateError } = useMarketState(marketAddr);
|
|
2065
2085
|
const { data: pricingData, error: pricingError } = usePricingParams(optionPricing);
|
|
2086
|
+
const getOrDeployStaticPricing = async (factoryAddr, params) => {
|
|
2087
|
+
const args = [
|
|
2088
|
+
params.openingRate,
|
|
2089
|
+
params.dailyFundingRate,
|
|
2090
|
+
params.minOpeningAmount,
|
|
2091
|
+
params.minFundingAmount
|
|
2092
|
+
];
|
|
2093
|
+
const [existingPricing] = await publicClient.readContract({
|
|
2094
|
+
address: factoryAddr,
|
|
2095
|
+
abi: require_factory.factoryAbi,
|
|
2096
|
+
functionName: "getStaticPerpsPricing",
|
|
2097
|
+
args
|
|
2098
|
+
});
|
|
2099
|
+
if (existingPricing !== viem.zeroAddress) return { pricingAddr: existingPricing };
|
|
2100
|
+
const hash = await writeContractAsync({
|
|
2101
|
+
address: factoryAddr,
|
|
2102
|
+
abi: require_factory.factoryAbi,
|
|
2103
|
+
functionName: "deployStaticPerpsPricing",
|
|
2104
|
+
args
|
|
2105
|
+
});
|
|
2106
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2107
|
+
const deployEvent = receipt.logs.find((log) => log.address.toLowerCase() === factoryAddr);
|
|
2108
|
+
if (!deployEvent) {
|
|
2109
|
+
console.error(receipt);
|
|
2110
|
+
throw new Error(`Deploy event not found in tx: ${hash}`);
|
|
2111
|
+
}
|
|
2112
|
+
const decodedEvent = (0, viem.decodeEventLog)({
|
|
2113
|
+
abi: require_factory.factoryAbi,
|
|
2114
|
+
data: deployEvent.data,
|
|
2115
|
+
topics: deployEvent.topics
|
|
2116
|
+
});
|
|
2117
|
+
if (decodedEvent.eventName !== "DeployStaticPerpsPricing") {
|
|
2118
|
+
console.error(receipt);
|
|
2119
|
+
throw new Error(`Unexpected event ${decodedEvent.eventName} in tx ${hash}`);
|
|
2120
|
+
}
|
|
2121
|
+
return {
|
|
2122
|
+
pricingAddr: decodedEvent.args.pricing,
|
|
2123
|
+
deployHash: hash
|
|
2124
|
+
};
|
|
2125
|
+
};
|
|
2126
|
+
const getOrDeployOptionPricing = async (factoryAddr, params) => {
|
|
2127
|
+
const args = [
|
|
2128
|
+
params.logicContract,
|
|
2129
|
+
params.iv,
|
|
2130
|
+
params.riskFreeRate,
|
|
2131
|
+
params.minPremiumDailyRate,
|
|
2132
|
+
params.minPremiumAmount
|
|
2133
|
+
];
|
|
2134
|
+
const [existingPricing] = await publicClient.readContract({
|
|
2135
|
+
address: factoryAddr,
|
|
2136
|
+
abi: require_factory.factoryAbi,
|
|
2137
|
+
functionName: "getOptionPricing",
|
|
2138
|
+
args
|
|
2139
|
+
});
|
|
2140
|
+
if (existingPricing !== viem.zeroAddress) return { pricingAddr: existingPricing };
|
|
2141
|
+
const hash = await writeContractAsync({
|
|
2142
|
+
address: factoryAddr,
|
|
2143
|
+
abi: require_factory.factoryAbi,
|
|
2144
|
+
functionName: "deployOptionPricing",
|
|
2145
|
+
args
|
|
2146
|
+
});
|
|
2147
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2148
|
+
const deployEvent = receipt.logs.find((log) => log.address.toLowerCase() === factoryAddr);
|
|
2149
|
+
if (!deployEvent) {
|
|
2150
|
+
console.error(receipt);
|
|
2151
|
+
throw new Error(`Deploy event not found in tx: ${hash}`);
|
|
2152
|
+
}
|
|
2153
|
+
const decodedEvent = (0, viem.decodeEventLog)({
|
|
2154
|
+
abi: require_factory.factoryAbi,
|
|
2155
|
+
data: deployEvent.data,
|
|
2156
|
+
topics: deployEvent.topics
|
|
2157
|
+
});
|
|
2158
|
+
if (decodedEvent.eventName !== "DeployOptionPricing") {
|
|
2159
|
+
console.error(receipt);
|
|
2160
|
+
throw new Error(`Unexpected event ${decodedEvent.eventName} in tx ${hash}`);
|
|
2161
|
+
}
|
|
2162
|
+
return {
|
|
2163
|
+
pricingAddr: decodedEvent.args.pricing,
|
|
2164
|
+
deployHash: hash
|
|
2165
|
+
};
|
|
2166
|
+
};
|
|
2066
2167
|
const updateMarketPricing = async (data) => {
|
|
2067
2168
|
if (!marketAddr) throw new Error("Market address not found");
|
|
2068
2169
|
if (!pricingData) throw new Error("Market pricing data not available: " + (pricingError === null || pricingError === void 0 ? void 0 : pricingError.message));
|
|
@@ -2094,45 +2195,8 @@ const useUpdateMarketPricing = (marketAddr) => {
|
|
|
2094
2195
|
if (data.minPremiumDailyRate === void 0) throw new Error("minPremiumDailyRate is required when switching to option model");
|
|
2095
2196
|
if (data.minPremiumAmount === void 0) throw new Error("minPremiumAmount is required when switching to option model");
|
|
2096
2197
|
}
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2099
|
-
abi: require_factory.factoryAbi,
|
|
2100
|
-
functionName: "deployStaticPerpsPricing",
|
|
2101
|
-
args: [
|
|
2102
|
-
data.openingRate,
|
|
2103
|
-
data.dailyFundingRate,
|
|
2104
|
-
data.minOpeningAmount,
|
|
2105
|
-
data.minFundingAmount
|
|
2106
|
-
]
|
|
2107
|
-
}) : await writeContractAsync({
|
|
2108
|
-
address: factoryAddr,
|
|
2109
|
-
abi: require_factory.factoryAbi,
|
|
2110
|
-
functionName: "deployOptionPricing",
|
|
2111
|
-
args: [
|
|
2112
|
-
data.logicContract,
|
|
2113
|
-
data.iv,
|
|
2114
|
-
data.riskFreeRate,
|
|
2115
|
-
data.minPremiumDailyRate,
|
|
2116
|
-
data.minPremiumAmount
|
|
2117
|
-
]
|
|
2118
|
-
});
|
|
2119
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2120
|
-
const deployEvent = receipt.logs.find((log) => log.address.toLowerCase() === factoryAddr.toLowerCase());
|
|
2121
|
-
if (!deployEvent) {
|
|
2122
|
-
console.error(receipt);
|
|
2123
|
-
throw new Error(`Deploy event not found in tx: ${hash}`);
|
|
2124
|
-
}
|
|
2125
|
-
const decodedEvent = (0, viem.decodeEventLog)({
|
|
2126
|
-
abi: require_factory.factoryAbi,
|
|
2127
|
-
data: deployEvent.data,
|
|
2128
|
-
topics: deployEvent.topics
|
|
2129
|
-
});
|
|
2130
|
-
if (decodedEvent.eventName !== "DeployStaticPerpsPricing" && decodedEvent.eventName !== "DeployOptionPricing") {
|
|
2131
|
-
console.error(receipt);
|
|
2132
|
-
throw new Error(`Unexpected event ${decodedEvent.eventName} in tx ${hash}`);
|
|
2133
|
-
}
|
|
2134
|
-
const pricingAddr = decodedEvent.args.pricing;
|
|
2135
|
-
const hash2 = await writeContractAsync({
|
|
2198
|
+
const { pricingAddr, deployHash } = data.model === "static" ? await getOrDeployStaticPricing(factoryAddr, data) : await getOrDeployOptionPricing(factoryAddr, data);
|
|
2199
|
+
const updateHash = await writeContractAsync({
|
|
2136
2200
|
address: marketAddr,
|
|
2137
2201
|
abi: require_stateView.optionsMarketAbi,
|
|
2138
2202
|
functionName: "updateAddresses",
|
|
@@ -2144,8 +2208,8 @@ const useUpdateMarketPricing = (marketAddr) => {
|
|
|
2144
2208
|
});
|
|
2145
2209
|
queryClient.invalidateQueries({ queryKey: ["readContract"] });
|
|
2146
2210
|
return {
|
|
2147
|
-
deployHash
|
|
2148
|
-
updateHash
|
|
2211
|
+
deployHash,
|
|
2212
|
+
updateHash,
|
|
2149
2213
|
newPricingAddr: pricingAddr
|
|
2150
2214
|
};
|
|
2151
2215
|
};
|