@gearbox-protocol/sdk 8.19.6 → 8.20.0

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.
@@ -23,6 +23,7 @@ __export(ZappersPlugin_exports, {
23
23
  module.exports = __toCommonJS(ZappersPlugin_exports);
24
24
  var import_compressors = require("../../abi/compressors.js");
25
25
  var import_sdk = require("../../sdk/index.js");
26
+ var import_extraZappers = require("./extraZappers.js");
26
27
  class ZappersPlugin extends import_sdk.BasePlugin {
27
28
  #zappers;
28
29
  async load(force) {
@@ -64,9 +65,26 @@ class ZappersPlugin extends import_sdk.BasePlugin {
64
65
  );
65
66
  }
66
67
  }
68
+ this.#addExtraZappers();
67
69
  this.#loadZapperTokens();
68
70
  return this.state;
69
71
  }
72
+ #addExtraZappers() {
73
+ const zaps = import_extraZappers.extraZappers[this.sdk.provider.networkType] ?? [];
74
+ for (const z of zaps) {
75
+ const existing = this.#zappers?.get(z.pool);
76
+ if (existing) {
77
+ const hasZapper = existing.some(
78
+ (zz) => (0, import_sdk.hexEq)(zz.baseParams.addr, z.baseParams.addr)
79
+ );
80
+ if (!hasZapper) {
81
+ existing.push(z);
82
+ }
83
+ } else {
84
+ this.#zappers?.upsert(z.pool, [z]);
85
+ }
86
+ }
87
+ }
70
88
  get zappers() {
71
89
  if (!this.#zappers) {
72
90
  throw new Error("zappers plugin not attached");
@@ -0,0 +1,73 @@
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 extraZappers_exports = {};
20
+ __export(extraZappers_exports, {
21
+ extraZappers: () => extraZappers
22
+ });
23
+ module.exports = __toCommonJS(extraZappers_exports);
24
+ const extraZappers = {
25
+ Mainnet: [
26
+ {
27
+ baseParams: {
28
+ addr: "0x2512bb303b66C541C32D764F65eCdB62875F0140",
29
+ version: 310n,
30
+ contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
31
+ serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
32
+ },
33
+ tokenIn: {
34
+ addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
35
+ symbol: "dUSDCV3",
36
+ name: "Trade USDC v3",
37
+ decimals: 6
38
+ },
39
+ tokenOut: {
40
+ addr: "0xC155444481854c60e7a29f4150373f479988F32D",
41
+ symbol: "USDC",
42
+ name: "USDC",
43
+ decimals: 6
44
+ },
45
+ pool: "0xC155444481854c60e7a29f4150373f479988F32D"
46
+ },
47
+ {
48
+ baseParams: {
49
+ addr: "0x18b33ee1cd4cb7912867d0b2cc8678a78f82136b",
50
+ version: 310n,
51
+ contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
52
+ serializedParams: "0x0000000000000000000000000418feb7d0b25c411eb77cd654305d29fcbff685000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
53
+ },
54
+ tokenIn: {
55
+ addr: "0x0418fEB7d0B25C411EB77cD654305d29FcbFf685",
56
+ symbol: "farmdWETHV3",
57
+ name: "Farming of Trade WETH v3",
58
+ decimals: 18
59
+ },
60
+ tokenOut: {
61
+ addr: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A",
62
+ symbol: "dWETHV3-cp0x",
63
+ name: "Gearbox WETH v3",
64
+ decimals: 18
65
+ },
66
+ pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
67
+ }
68
+ ]
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ extraZappers
73
+ });
@@ -24,14 +24,13 @@ module.exports = __toCommonJS(sendRawTx_exports);
24
24
  var import_actions = require("viem/actions");
25
25
  var import_utils = require("viem/utils");
26
26
  async function sendRawTx(client, params) {
27
- const { account, tx } = params;
27
+ const { tx, ...rest } = params;
28
28
  return (0, import_utils.getAction)(
29
29
  client,
30
30
  import_actions.sendTransaction,
31
31
  "sendTransaction"
32
32
  )({
33
- // @ts-expect-error
34
- account,
33
+ ...rest,
35
34
  data: tx.callData,
36
35
  to: tx.to,
37
36
  value: BigInt(tx.value)
@@ -3,8 +3,10 @@ import {
3
3
  AddressMap,
4
4
  AP_PERIPHERY_COMPRESSOR,
5
5
  BasePlugin,
6
+ hexEq,
6
7
  VERSION_RANGE_310
7
8
  } from "../../sdk/index.js";
9
+ import { extraZappers } from "./extraZappers.js";
8
10
  class ZappersPlugin extends BasePlugin {
9
11
  #zappers;
10
12
  async load(force) {
@@ -46,9 +48,26 @@ class ZappersPlugin extends BasePlugin {
46
48
  );
47
49
  }
48
50
  }
51
+ this.#addExtraZappers();
49
52
  this.#loadZapperTokens();
50
53
  return this.state;
51
54
  }
55
+ #addExtraZappers() {
56
+ const zaps = extraZappers[this.sdk.provider.networkType] ?? [];
57
+ for (const z of zaps) {
58
+ const existing = this.#zappers?.get(z.pool);
59
+ if (existing) {
60
+ const hasZapper = existing.some(
61
+ (zz) => hexEq(zz.baseParams.addr, z.baseParams.addr)
62
+ );
63
+ if (!hasZapper) {
64
+ existing.push(z);
65
+ }
66
+ } else {
67
+ this.#zappers?.upsert(z.pool, [z]);
68
+ }
69
+ }
70
+ }
52
71
  get zappers() {
53
72
  if (!this.#zappers) {
54
73
  throw new Error("zappers plugin not attached");
@@ -0,0 +1,49 @@
1
+ const extraZappers = {
2
+ Mainnet: [
3
+ {
4
+ baseParams: {
5
+ addr: "0x2512bb303b66C541C32D764F65eCdB62875F0140",
6
+ version: 310n,
7
+ contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
8
+ serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
9
+ },
10
+ tokenIn: {
11
+ addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
12
+ symbol: "dUSDCV3",
13
+ name: "Trade USDC v3",
14
+ decimals: 6
15
+ },
16
+ tokenOut: {
17
+ addr: "0xC155444481854c60e7a29f4150373f479988F32D",
18
+ symbol: "USDC",
19
+ name: "USDC",
20
+ decimals: 6
21
+ },
22
+ pool: "0xC155444481854c60e7a29f4150373f479988F32D"
23
+ },
24
+ {
25
+ baseParams: {
26
+ addr: "0x18b33ee1cd4cb7912867d0b2cc8678a78f82136b",
27
+ version: 310n,
28
+ contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
29
+ serializedParams: "0x0000000000000000000000000418feb7d0b25c411eb77cd654305d29fcbff685000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
30
+ },
31
+ tokenIn: {
32
+ addr: "0x0418fEB7d0B25C411EB77cD654305d29FcbFf685",
33
+ symbol: "farmdWETHV3",
34
+ name: "Farming of Trade WETH v3",
35
+ decimals: 18
36
+ },
37
+ tokenOut: {
38
+ addr: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A",
39
+ symbol: "dWETHV3-cp0x",
40
+ name: "Gearbox WETH v3",
41
+ decimals: 18
42
+ },
43
+ pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
44
+ }
45
+ ]
46
+ };
47
+ export {
48
+ extraZappers
49
+ };
@@ -1,14 +1,13 @@
1
1
  import { sendTransaction } from "viem/actions";
2
2
  import { getAction } from "viem/utils";
3
3
  async function sendRawTx(client, params) {
4
- const { account, tx } = params;
4
+ const { tx, ...rest } = params;
5
5
  return getAction(
6
6
  client,
7
7
  sendTransaction,
8
8
  "sendTransaction"
9
9
  )({
10
- // @ts-expect-error
11
- account,
10
+ ...rest,
12
11
  data: tx.callData,
13
12
  to: tx.to,
14
13
  value: BigInt(tx.value)
@@ -0,0 +1,6 @@
1
+ import type { NetworkType } from "../../sdk";
2
+ import type { ZapperDataFull } from "./types";
3
+ /**
4
+ * Temprary zappers
5
+ */
6
+ export declare const extraZappers: Partial<Record<NetworkType, ZapperDataFull[]>>;
@@ -1,7 +1,7 @@
1
- import type { Account, Chain, Client, SendTransactionReturnType, Transport } from "viem";
1
+ import type { Account, Chain, Client, SendTransactionRequest, SendTransactionReturnType, Transport } from "viem";
2
+ import { type SendTransactionParameters } from "viem/actions";
2
3
  import type { RawTx } from "../../types/index.js";
3
- export interface SendRawTxParameters {
4
- account?: Account;
4
+ export type SendRawTxParameters<chain extends Chain, account extends Account | undefined, request extends SendTransactionRequest<chain, chainOverride>, chainOverride extends Chain | undefined = undefined> = Omit<SendTransactionParameters<chain, account, chainOverride, request>, "data" | "to" | "value"> & {
5
5
  tx: Pick<RawTx, "to" | "callData" | "value">;
6
- }
7
- export declare function sendRawTx<chain extends Chain | undefined = Chain | undefined>(client: Client<Transport, chain, Account | undefined>, params: SendRawTxParameters): Promise<SendTransactionReturnType>;
6
+ };
7
+ export declare function sendRawTx<chain extends Chain, account extends Account | undefined, const request extends SendTransactionRequest<chain, chainOverride>, chainOverride extends Chain | undefined>(client: Client<Transport, chain, account>, params: SendRawTxParameters<chain, account, request, chainOverride>): Promise<SendTransactionReturnType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.19.6",
3
+ "version": "8.20.0",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",