@gearbox-protocol/sdk 2.1.18 → 2.1.20

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,10 +23,10 @@ const APY_DICTIONARY = {
23
23
  crvCVXETH: "crypto-4",
24
24
  crvUSDTWBTCWETH: "factory-tricrypto-1",
25
25
  LDOETH: "factory-crypto-204",
26
- crvUSDUSDC: "",
27
- crvUSDUSDT: "",
28
- crvUSDFRAX: "",
29
- crvUSDETHCRV: "",
26
+ crvUSDUSDC: "factory-crvusd-0",
27
+ crvUSDUSDT: "factory-crvusd-1",
28
+ crvUSDFRAX: "factory-crvusd-4",
29
+ crvUSDETHCRV: "factory-tricrypto-4", // 0x4eBdF703948ddCEA3B11f675B4D1Fba9d2414A14
30
30
  };
31
31
  const CRV_APY_RESPONSE_DECIMALS = 100;
32
32
  // const CRYPTO = "https://api.curve.fi/api/getPools/ethereum/crypto";
@@ -36,26 +36,24 @@ const CURVE_MAIN_URL = "https://api.curve.fi/api/getPools/ethereum/main";
36
36
  const CURVE_FACTORY_CRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/factory-crypto";
37
37
  const CURVE_CRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/crypto";
38
38
  const CURVE_FACTORY_TRICRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/factory-tricrypto";
39
+ const CURVE_FACTORY_CRVUSD_URL = "https://api.curve.fi/api/getPools/ethereum/factory-crvusd";
39
40
  async function getCurveAPY() {
40
41
  try {
41
- const [{ data: apyData }, { data: main }, { data: factoryCrypto }, { data: crypto }, { data: factoryTricrypto },] = await Promise.all([
42
+ const [{ data: apyData }, ...restData] = await Promise.all([
42
43
  axios_1.default.get(CURVE_APY_URL),
43
44
  axios_1.default.get(CURVE_MAIN_URL),
44
45
  axios_1.default.get(CURVE_FACTORY_CRYPTO_URL),
45
46
  axios_1.default.get(CURVE_CRYPTO_URL),
46
47
  axios_1.default.get(CURVE_FACTORY_TRICRYPTO_URL),
48
+ axios_1.default.get(CURVE_FACTORY_CRVUSD_URL),
47
49
  ]);
48
50
  const { apys } = apyData || {};
49
- const { poolData: mainPoolData = [] } = main?.data || {};
50
- const { poolData: factoryCryptoPoolData = [] } = factoryCrypto?.data || {};
51
- const { poolData: cryptoPoolData = [] } = crypto?.data || {};
52
- const { poolData: factoryTricryptoPoolData = [] } = factoryTricrypto?.data || {};
53
- const poolDataByID = Object.fromEntries([
54
- ...mainPoolData.map(p => [p.id, p]),
55
- ...factoryCryptoPoolData.map(p => [p.id, p]),
56
- ...cryptoPoolData.map(p => [p.id, p]),
57
- ...factoryTricryptoPoolData.map(p => [p.id, p]),
58
- ]);
51
+ const poolDataByID = Object.fromEntries(restData
52
+ .map(resp => {
53
+ const { poolData = [] } = resp?.data?.data || {};
54
+ return poolData.map(p => [p.id, p]);
55
+ })
56
+ .flat(1));
59
57
  const curveAPY = mappers_1.TypedObjectUtils.entries(APY_DICTIONARY).reduce((acc, [curveSymbol, poolId]) => {
60
58
  const { baseApy, crvApy } = apys[poolId] || {};
61
59
  if (baseApy === undefined)
@@ -786,4 +786,43 @@ exports.priceFeedsByToken = {
786
786
  type: pricefeedType_1.PriceFeedType.COMPOUND_V2_ORACLE,
787
787
  underlying: "WETH",
788
788
  },
789
+ MKR: {
790
+ type: pricefeedType_1.PriceFeedType.NETWORK_DEPENDENT,
791
+ feeds: {
792
+ Mainnet: {
793
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
794
+ address: "0xec1d1b3b0443256cc3860e24a46f108e699484aa",
795
+ },
796
+ Arbitrum: {
797
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
798
+ address: "0xde9f0894670c4efcacf370426f10c3ad2cdf147e",
799
+ },
800
+ },
801
+ },
802
+ RPL: {
803
+ type: pricefeedType_1.PriceFeedType.NETWORK_DEPENDENT,
804
+ feeds: {
805
+ Mainnet: {
806
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
807
+ address: "0x4e155ed98afe9034b7a5962f6c84c86d869daa9d",
808
+ },
809
+ Arbitrum: {
810
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
811
+ address: "0x4e155ed98afe9034b7a5962f6c84c86d869daa9d",
812
+ },
813
+ },
814
+ },
815
+ APE: {
816
+ type: pricefeedType_1.PriceFeedType.NETWORK_DEPENDENT,
817
+ feeds: {
818
+ Mainnet: {
819
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
820
+ address: "0xd10abbc76679a20055e167bb80a24ac851b37056",
821
+ },
822
+ Arbitrum: {
823
+ type: pricefeedType_1.PriceFeedType.CHAINLINK_ORACLE,
824
+ address: "0x221912ce795669f628c51c69b7d0873eda9c03bb",
825
+ },
826
+ },
827
+ },
789
828
  };
@@ -11,14 +11,19 @@ const GAS_PER_BLOCK = 400e6;
11
11
  class PathFinder {
12
12
  pathFinder;
13
13
  network;
14
- static connectors = ["USDC", "WETH", "DAI"];
14
+ static connectors = [
15
+ "USDC",
16
+ "WETH",
17
+ "DAI",
18
+ "FRAX",
19
+ ];
15
20
  _connectors;
16
21
  constructor(address, provider, network = "Mainnet", connectors = PathFinder.connectors) {
17
22
  this.pathFinder = types_1.IRouter__factory.connect(address, provider);
18
23
  this.network = network;
19
24
  this._connectors = connectors
20
25
  .map(c => token_1.tokenDataByNetwork[this.network][c]?.toLowerCase())
21
- .filter(t => !t);
26
+ .filter(t => !!t);
22
27
  }
23
28
  async findAllSwaps(creditAccount, swapOperation, tokenIn, tokenOut, amount, slippage) {
24
29
  const connectors = this.getAvailableConnectors(creditAccount.balances);
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const chai_1 = require("chai");
4
+ const ethers_1 = require("ethers");
4
5
  const constants_1 = require("../core/constants");
6
+ const token_1 = require("../tokens/token");
5
7
  const pathfinder_1 = require("./pathfinder");
6
8
  describe("PathFinder test", () => {
7
9
  it("compare works correctly", () => {
@@ -20,4 +22,19 @@ describe("PathFinder test", () => {
20
22
  result = pathfinder_1.PathFinder.compare(r1, r2, constants_1.RAY * 2n);
21
23
  (0, chai_1.expect)(result).to.be.eql(r1);
22
24
  });
25
+ it("has all expected connectors", () => {
26
+ const pf = new pathfinder_1.PathFinder("", new ethers_1.providers.JsonRpcProvider(), "Mainnet");
27
+ const allowedTokens = {
28
+ [token_1.tokenDataByNetwork.Mainnet.USDC.toLowerCase()]: true,
29
+ [token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: true,
30
+ [token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: true,
31
+ [token_1.tokenDataByNetwork.Mainnet.FRAX.toLowerCase()]: true,
32
+ };
33
+ (0, chai_1.expect)(pf.getAvailableConnectors(allowedTokens)).to.be.deep.equal([
34
+ token_1.tokenDataByNetwork.Mainnet.USDC.toLowerCase(),
35
+ token_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase(),
36
+ token_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase(),
37
+ token_1.tokenDataByNetwork.Mainnet.FRAX.toLowerCase(),
38
+ ]);
39
+ });
23
40
  });
@@ -34,6 +34,9 @@ exports.decimals = {
34
34
  ARB: 18,
35
35
  RDNT: 18,
36
36
  BAL: 18,
37
+ MKR: 18,
38
+ RPL: 18,
39
+ APE: 18,
37
40
  "3Crv": 18,
38
41
  crvFRAX: 18,
39
42
  OHMFRAXBP: 18,
@@ -1,7 +1,7 @@
1
1
  import { TradeAction } from "../pathfinder/tradeTypes";
2
2
  import type { TokenBase } from "./token";
3
3
  import { TokenType } from "./tokenType";
4
- export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL" | "ARB" | "SHIB" | "crvUSD";
4
+ export type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "wstETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "OHM" | "MIM" | "SPELL" | "GMX" | "ARB" | "RDNT" | "BAL" | "ARB" | "MKR" | "RPL" | "APE" | "SHIB" | "crvUSD";
5
5
  export type NormalTokenData = {
6
6
  symbol: NormalToken;
7
7
  type: TokenType.NORMAL_TOKEN;
@@ -850,6 +850,63 @@ exports.normalTokens = {
850
850
  },
851
851
  ],
852
852
  },
853
+ MKR: {
854
+ name: "MKR",
855
+ symbol: "MKR",
856
+ type: tokenType_1.TokenType.NORMAL_TOKEN,
857
+ swapActions: [
858
+ {
859
+ type: tradeTypes_1.TradeType.UniswapV3Swap,
860
+ contract: "UNISWAP_V3_ROUTER",
861
+ },
862
+ {
863
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
864
+ contract: "UNISWAP_V2_ROUTER",
865
+ },
866
+ {
867
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
868
+ contract: "SUSHISWAP_ROUTER",
869
+ },
870
+ ],
871
+ },
872
+ RPL: {
873
+ name: "RPL",
874
+ symbol: "RPL",
875
+ type: tokenType_1.TokenType.NORMAL_TOKEN,
876
+ swapActions: [
877
+ {
878
+ type: tradeTypes_1.TradeType.UniswapV3Swap,
879
+ contract: "UNISWAP_V3_ROUTER",
880
+ },
881
+ {
882
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
883
+ contract: "UNISWAP_V2_ROUTER",
884
+ },
885
+ {
886
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
887
+ contract: "SUSHISWAP_ROUTER",
888
+ },
889
+ ],
890
+ },
891
+ APE: {
892
+ name: "APE",
893
+ symbol: "APE",
894
+ type: tokenType_1.TokenType.NORMAL_TOKEN,
895
+ swapActions: [
896
+ {
897
+ type: tradeTypes_1.TradeType.UniswapV3Swap,
898
+ contract: "UNISWAP_V3_ROUTER",
899
+ },
900
+ {
901
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
902
+ contract: "UNISWAP_V2_ROUTER",
903
+ },
904
+ {
905
+ type: tradeTypes_1.TradeType.UniswapV2Swap,
906
+ contract: "SUSHISWAP_ROUTER",
907
+ },
908
+ ],
909
+ },
853
910
  };
854
911
  const isNormalToken = (t) => typeof t === "string" && !!exports.normalTokens[t];
855
912
  exports.isNormalToken = isNormalToken;
@@ -0,0 +1,3 @@
1
+ import { NetworkType } from "../core/chains";
2
+ import { SupportedToken } from "./token";
3
+ export declare const nonQuoted: Record<NetworkType, Array<SupportedToken>>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nonQuoted = void 0;
4
+ exports.nonQuoted = {
5
+ Mainnet: ["WETH", "DAI", "USDC", "FRAX"],
6
+ Arbitrum: ["WETH", "DAI", "USDC", "WBTC"],
7
+ };
@@ -64,6 +64,9 @@ exports.tokenDataByNetwork = {
64
64
  sUSD: "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51",
65
65
  GUSD: "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd",
66
66
  LQTY: "0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D",
67
+ MKR: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2",
68
+ RPL: "0xB4EFd85c19999D84251304bDA99E90B92300Bd93",
69
+ APE: "0x4d224452801ACEd8B2F0aebE155379bb5D594381",
67
70
  // CURVE LP TOKENS
68
71
  "3Crv": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
69
72
  crvFRAX: "0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC",
@@ -184,6 +187,9 @@ exports.tokenDataByNetwork = {
184
187
  sUSD: "0xA970AF1a584579B618be4d69aD6F73459D112F95",
185
188
  GUSD: constants_1.NOT_DEPLOYED,
186
189
  LQTY: "0xfb9E5D956D889D91a82737B9bFCDaC1DCE3e1449",
190
+ MKR: constants_1.NOT_DEPLOYED,
191
+ RPL: constants_1.NOT_DEPLOYED,
192
+ APE: constants_1.NOT_DEPLOYED,
187
193
  // REDSTONE
188
194
  SHIB: constants_1.NOT_DEPLOYED,
189
195
  // YEARN TOKENS
@@ -22,20 +22,7 @@ class TokenData {
22
22
  }
23
23
  exports.TokenData = TokenData;
24
24
  exports.connectors = {
25
- Mainnet: [
26
- "WETH",
27
- "1INCH",
28
- "DAI",
29
- "USDC",
30
- // "USDT",
31
- "WBTC",
32
- // "stETH",
33
- // "PAX",
34
- // "TUSD",
35
- // "BNT",
36
- // "BAL",
37
- // "sUSD",
38
- ],
25
+ Mainnet: ["WETH", "DAI", "USDC", "FRAX"],
39
26
  Arbitrum: ["WETH", "DAI", "USDC", "WBTC"],
40
27
  };
41
28
  function getConnectors(networkType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "2.1.18",
3
+ "version": "2.1.20",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",