@dhedge/v2-sdk 2.1.1 → 2.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -8,7 +8,7 @@ import PTAbi from "../../abi/pendle/PT.json";
8
8
  import SYAbi from "../../abi/pendle/SY.json";
9
9
  import BigNumber from "bignumber.js";
10
10
 
11
- const pendleBaseUrl = "https://api-v2.pendle.finance/core/v1";
11
+ const pendleBaseUrl = "https://api-v2.pendle.finance/core";
12
12
 
13
13
  export async function getPendleSwapTxData(
14
14
  pool: Pool,
@@ -41,7 +41,7 @@ export async function getPendleSwapTxData(
41
41
  const market = await getMarket(pool, tokenIn, tokenOut);
42
42
  try {
43
43
  const swapResult = await axios.get(
44
- `${pendleBaseUrl}/sdk/${
44
+ `${pendleBaseUrl}/v2/sdk/${
45
45
  networkChainIdMap[pool.network]
46
46
  }/markets/${market}/swap`,
47
47
  { params }
@@ -70,9 +70,10 @@ export async function getMarket(
70
70
  const networkId = networkChainIdMap[pool.network];
71
71
  let marketResult;
72
72
  try {
73
- marketResult = await axios.get(
74
- `${pendleBaseUrl}/${networkId}/markets/active`
75
- );
73
+ const params = { isActive: true, chainId: networkId };
74
+ marketResult = await axios.get(`${pendleBaseUrl}/v1/markets/all`, {
75
+ params
76
+ });
76
77
  } catch (e) {
77
78
  console.error("Error in Pendle API request:", e);
78
79
  throw new ApiError("Pendle api request failed");
@@ -103,9 +104,10 @@ const checkExitPostExpPT = async (
103
104
  const networkId = networkChainIdMap[pool.network];
104
105
  let inactiveMarketResult;
105
106
  try {
106
- inactiveMarketResult = await axios.get(
107
- `${pendleBaseUrl}/${networkId}/markets/inactive`
108
- );
107
+ const params = { isActive: false, chainId: networkId };
108
+ inactiveMarketResult = await axios.get(`${pendleBaseUrl}/v1/markets/all`, {
109
+ params
110
+ });
109
111
  } catch (e) {
110
112
  console.error("Error in Pendle API request:", e);
111
113
  throw new ApiError("Pendle api request failed");
@@ -18,7 +18,7 @@ import { balanceDelta } from "./utils/token";
18
18
  const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
19
19
  const USDC = CONTRACT_ADDRESS[network].USDC;
20
20
  const weETH = "0x35751007a407ca6feffe80b3cb397736d2cf4dbe";
21
- // const PTweETH = "0xb33808ea0e883138680ba29311a220a7377cdb92";
21
+ const PTweETH = "0xab7f3837e6e721abbc826927b655180af6a04388";
22
22
  const PTweETH_matured = "0xe2b2d203577c7cb3d043e89ccf90b5e24d19b66f";
23
23
 
24
24
  let dhedge: Dhedge;
@@ -53,24 +53,24 @@ const testPendle = ({ wallet, network, provider }: TestingRunParams) => {
53
53
  );
54
54
  });
55
55
 
56
- // it("swaps weETH to PTweETH on Pendle", async () => {
57
- // await pool.approve(Dapp.PENDLE, weETH, MAX_AMOUNT);
58
- // const weEthBalance = await pool.utils.getBalance(weETH, pool.address);
59
- // await pool.trade(
60
- // Dapp.PENDLE,
61
- // weETH,
62
- // PTweETH,
63
- // weEthBalance,
64
- // 0.5,
65
- // await getTxOptions(network)
66
- // );
67
- // const ptWeEthBalanceDelta = await balanceDelta(
68
- // pool.address,
69
- // PTweETH,
70
- // pool.signer
71
- // );
72
- // expect(ptWeEthBalanceDelta.gt(0));
73
- // });
56
+ it("swaps weETH to PTweETH on Pendle", async () => {
57
+ await pool.approve(Dapp.PENDLE, weETH, MAX_AMOUNT);
58
+ const weEthBalance = await pool.utils.getBalance(weETH, pool.address);
59
+ await pool.trade(
60
+ Dapp.PENDLE,
61
+ weETH,
62
+ PTweETH,
63
+ weEthBalance,
64
+ 0.5,
65
+ await getTxOptions(network)
66
+ );
67
+ const ptWeEthBalanceDelta = await balanceDelta(
68
+ pool.address,
69
+ PTweETH,
70
+ pool.signer
71
+ );
72
+ expect(ptWeEthBalanceDelta.gt(0));
73
+ });
74
74
 
75
75
  // it("swaps PTweETH to weETH on Pendle", async () => {
76
76
  // await pool.approve(Dapp.PENDLE, PTweETH, MAX_AMOUNT);