@gearbox-protocol/sdk 3.0.0-vfour.317 → 3.0.0-vfour.319
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/cjs/dev/create2.js +53 -0
- package/dist/cjs/dev/index.js +2 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +10 -6
- package/dist/esm/dev/create2.js +27 -0
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +10 -6
- package/dist/types/dev/create2.d.ts +23 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var create2_exports = {};
|
|
20
|
+
__export(create2_exports, {
|
|
21
|
+
PUBLIC_CREATE2_FACTORY: () => PUBLIC_CREATE2_FACTORY,
|
|
22
|
+
deployUsingPublicCreate2: () => deployUsingPublicCreate2,
|
|
23
|
+
getCreate2AddressPublicFactory: () => getCreate2AddressPublicFactory
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(create2_exports);
|
|
26
|
+
var import_viem = require("viem");
|
|
27
|
+
var import_actions = require("viem/actions");
|
|
28
|
+
const PUBLIC_CREATE2_FACTORY = "0x4e59b44847b379578588920ca78fbf26c0b4956c";
|
|
29
|
+
async function deployUsingPublicCreate2(walletClient, parameters) {
|
|
30
|
+
const { bytecode, salt, ...request } = parameters;
|
|
31
|
+
const data = `${(0, import_viem.stringToHex)(salt, { size: 32 })}${bytecode.replace(
|
|
32
|
+
"0x",
|
|
33
|
+
""
|
|
34
|
+
)}`;
|
|
35
|
+
return (0, import_actions.sendTransaction)(walletClient, {
|
|
36
|
+
to: PUBLIC_CREATE2_FACTORY,
|
|
37
|
+
data,
|
|
38
|
+
...request
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function getCreate2AddressPublicFactory(salt, bytecode) {
|
|
42
|
+
return (0, import_viem.getCreate2Address)({
|
|
43
|
+
from: PUBLIC_CREATE2_FACTORY,
|
|
44
|
+
salt: (0, import_viem.stringToHex)(salt, { size: 32 }),
|
|
45
|
+
bytecode
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
PUBLIC_CREATE2_FACTORY,
|
|
51
|
+
deployUsingPublicCreate2,
|
|
52
|
+
getCreate2AddressPublicFactory
|
|
53
|
+
});
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var dev_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(dev_exports);
|
|
18
18
|
__reExport(dev_exports, require("./AccountOpener.js"), module.exports);
|
|
19
19
|
__reExport(dev_exports, require("./calcLiquidatableLTs.js"), module.exports);
|
|
20
|
+
__reExport(dev_exports, require("./create2.js"), module.exports);
|
|
20
21
|
__reExport(dev_exports, require("./createAnvilClient.js"), module.exports);
|
|
21
22
|
__reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
|
|
22
23
|
__reExport(dev_exports, require("./PriceFeedStore.js"), module.exports);
|
|
@@ -26,6 +27,7 @@ __reExport(dev_exports, require("./setLTZero.js"), module.exports);
|
|
|
26
27
|
0 && (module.exports = {
|
|
27
28
|
...require("./AccountOpener.js"),
|
|
28
29
|
...require("./calcLiquidatableLTs.js"),
|
|
30
|
+
...require("./create2.js"),
|
|
29
31
|
...require("./createAnvilClient.js"),
|
|
30
32
|
...require("./migrateFaucet.js"),
|
|
31
33
|
...require("./PriceFeedStore.js"),
|
|
@@ -233,20 +233,24 @@ class PriceOracleBaseContract extends import_base.BaseContract {
|
|
|
233
233
|
const price = node?.answer?.price;
|
|
234
234
|
if (reserve) {
|
|
235
235
|
this.reservePriceFeeds.upsert(token, ref);
|
|
236
|
-
if (price) {
|
|
236
|
+
if (price !== void 0) {
|
|
237
237
|
this.reservePrices.upsert(token, price);
|
|
238
|
-
}
|
|
238
|
+
}
|
|
239
|
+
if (!price) {
|
|
239
240
|
this.logger?.warn(
|
|
240
|
-
|
|
241
|
+
node ?? {},
|
|
242
|
+
`answer not found for reserve price feed ${this.labelAddress(priceFeed)}`
|
|
241
243
|
);
|
|
242
244
|
}
|
|
243
245
|
} else {
|
|
244
246
|
this.mainPriceFeeds.upsert(token, ref);
|
|
245
|
-
if (price) {
|
|
247
|
+
if (price !== void 0) {
|
|
246
248
|
this.mainPrices.upsert(token, price);
|
|
247
|
-
}
|
|
249
|
+
}
|
|
250
|
+
if (!price) {
|
|
248
251
|
this.logger?.warn(
|
|
249
|
-
|
|
252
|
+
node ?? {},
|
|
253
|
+
`answer not found for main price feed ${this.labelAddress(priceFeed)}`
|
|
250
254
|
);
|
|
251
255
|
}
|
|
252
256
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getCreate2Address, stringToHex } from "viem";
|
|
2
|
+
import { sendTransaction } from "viem/actions";
|
|
3
|
+
const PUBLIC_CREATE2_FACTORY = "0x4e59b44847b379578588920ca78fbf26c0b4956c";
|
|
4
|
+
async function deployUsingPublicCreate2(walletClient, parameters) {
|
|
5
|
+
const { bytecode, salt, ...request } = parameters;
|
|
6
|
+
const data = `${stringToHex(salt, { size: 32 })}${bytecode.replace(
|
|
7
|
+
"0x",
|
|
8
|
+
""
|
|
9
|
+
)}`;
|
|
10
|
+
return sendTransaction(walletClient, {
|
|
11
|
+
to: PUBLIC_CREATE2_FACTORY,
|
|
12
|
+
data,
|
|
13
|
+
...request
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function getCreate2AddressPublicFactory(salt, bytecode) {
|
|
17
|
+
return getCreate2Address({
|
|
18
|
+
from: PUBLIC_CREATE2_FACTORY,
|
|
19
|
+
salt: stringToHex(salt, { size: 32 }),
|
|
20
|
+
bytecode
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
PUBLIC_CREATE2_FACTORY,
|
|
25
|
+
deployUsingPublicCreate2,
|
|
26
|
+
getCreate2AddressPublicFactory
|
|
27
|
+
};
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -210,20 +210,24 @@ class PriceOracleBaseContract extends BaseContract {
|
|
|
210
210
|
const price = node?.answer?.price;
|
|
211
211
|
if (reserve) {
|
|
212
212
|
this.reservePriceFeeds.upsert(token, ref);
|
|
213
|
-
if (price) {
|
|
213
|
+
if (price !== void 0) {
|
|
214
214
|
this.reservePrices.upsert(token, price);
|
|
215
|
-
}
|
|
215
|
+
}
|
|
216
|
+
if (!price) {
|
|
216
217
|
this.logger?.warn(
|
|
217
|
-
|
|
218
|
+
node ?? {},
|
|
219
|
+
`answer not found for reserve price feed ${this.labelAddress(priceFeed)}`
|
|
218
220
|
);
|
|
219
221
|
}
|
|
220
222
|
} else {
|
|
221
223
|
this.mainPriceFeeds.upsert(token, ref);
|
|
222
|
-
if (price) {
|
|
224
|
+
if (price !== void 0) {
|
|
223
225
|
this.mainPrices.upsert(token, price);
|
|
224
|
-
}
|
|
226
|
+
}
|
|
227
|
+
if (!price) {
|
|
225
228
|
this.logger?.warn(
|
|
226
|
-
|
|
229
|
+
node ?? {},
|
|
230
|
+
`answer not found for main price feed ${this.labelAddress(priceFeed)}`
|
|
227
231
|
);
|
|
228
232
|
}
|
|
229
233
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Client, Hex, SendTransactionParameters, SendTransactionReturnType, Transport, UnionOmit } from "viem";
|
|
2
|
+
export declare const PUBLIC_CREATE2_FACTORY: Address;
|
|
3
|
+
export type Create2Parameters<chain extends Chain | undefined, account extends Account | undefined, chainOverride extends Chain | undefined = undefined> = UnionOmit<SendTransactionParameters<chain, account, chainOverride>, "chain" | "to" | "data"> & {
|
|
4
|
+
/**
|
|
5
|
+
* The contract bytecode to deploy
|
|
6
|
+
*/
|
|
7
|
+
bytecode: Hex;
|
|
8
|
+
/**
|
|
9
|
+
* Salt for the CREATE2 deployment (will be padded to 32 bytes)
|
|
10
|
+
*/
|
|
11
|
+
salt: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Viem action that deploys a contract using the public CREATE2 factory
|
|
15
|
+
*/
|
|
16
|
+
export declare function deployUsingPublicCreate2<chain extends Chain | undefined, account extends Account | undefined, chainOverride extends Chain | undefined = undefined>(walletClient: Client<Transport, chain, account>, parameters: Create2Parameters<chain, account, chainOverride>): Promise<SendTransactionReturnType>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the address of a contract deployed using the public CREATE2 factory
|
|
19
|
+
* @param salt - Salt for the CREATE2 deployment (will be padded to 32 bytes)
|
|
20
|
+
* @param bytecode - The contract bytecode to deploy
|
|
21
|
+
* @returns Address of the deployed contract
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCreate2AddressPublicFactory(salt: string, bytecode: Hex): Promise<Address>;
|