Skip to content

Commit

Permalink
Add hosted SDK migrations guide (#10)
Browse files Browse the repository at this point in the history
* Add hosted SDK migrations

* Format
  • Loading branch information
tientran3 authored Sep 13, 2024
1 parent 759d049 commit bd2abfa
Show file tree
Hide file tree
Showing 6 changed files with 531 additions and 0 deletions.
142 changes: 142 additions & 0 deletions hosted-sdk-demo/src/migrations/add-liquidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Add Liquidity
The examples below will add liquidity to the stETH (30 Dec 2027) Pool on Ethereum.

| Token | Address |
|--------|---------|
| Pool/LP | `0x34280882267ffa6383b363e278b027be083bbe3b` |
| SY | `0xcbc72d92b2dc8187414f6734718563898740c0bc` |
| PT | `0xb253eff1104802b97ac7e3ac9fdd73aece295a2c` |
| stETH | `0xae7ab96520de3a18e5e111b5eaab095312d7fe84` |

## addLiquidityDualSyAndPt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidityDual

- Pass the SY address into the `tokenIn` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountSyDesired | amountTokenIn |
| amountPtDesired | amountPtIn |

Example: Add liquidity 1 SY and 1 PT to the pool.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquidityDualSyAndPt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountSyDesired=1000000000000000000&amountPtDesired=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity-dual?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xcbc72d92b2dc8187414f6734718563898740c0bc&amountTokenIn=1000000000000000000&amountPtIn=1000000000000000000`

## addLiquidityDualTokenAndPt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidityDual

- Pass the token address into the `tokenIn` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| tokenInAddr | tokenIn |
| amountTokenDesired | amountTokenIn |
| amountPtDesired | amountPtIn |

Example: Add liquidity 1 stETH and 1 PT to the pool.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquidityDualTokenAndPt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&tokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountTokenDesired=1000000000000000000&amountPtDesired=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity-dual?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountTokenIn=1000000000000000000&amountPtIn=1000000000000000000`

## addLiquiditySinglePt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidity

- Pass the PT address into the `tokenIn` parameter.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountPtIn | amountIn |

Example: Add liquidity 1 PT to the pool.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquiditySinglePt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountPtIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xb253eff1104802b97ac7e3ac9fdd73aece295a2c&amountIn=1000000000000000000`

## addLiquiditySingleSy
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidity

- Pass the SY address into the `tokenIn` parameter.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountSyIn | amountIn |

Example: Add liquidity 1 SY to the pool.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquiditySingleSy?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountSyIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xcbc72d92b2dc8187414f6734718563898740c0bc&amountIn=1000000000000000000`

## addLiquiditySingleSyKeepYt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidity

- Pass the SY address into the `tokenIn` parameter.
- Set `zpi` to `true`.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountSyIn | amountIn |

Example: Add liquidity 1 SY to the pool and keep YT.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquiditySingleSyKeepYt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountSyIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xcbc72d92b2dc8187414f6734718563898740c0bc&amountIn=1000000000000000000&zpi=true`

## addLiquiditySingleToken
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidity

- Pass the token address into the `tokenIn` parameter.
- If `tokenIn` is not an input token of the pool, set `enableAggregator` to `true`.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| tokenInAddr | tokenIn |
| amountTokenIn | amountIn |

Example: Add liquidity 1 stETH to the pool.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquiditySingleToken?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&tokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountTokenIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountIn=1000000000000000000&zpi=false`

## addLiquiditySingleTokenKeepYt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_addLiquidity

- Pass the token address into the `tokenIn` parameter.
- Set `zpi` to `true`.
- If `tokenIn` is not an input token of the pool, set `enableAggregator` to `true`.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| tokenInAddr | tokenIn |
| amountTokenIn | amountIn |

Example: Add liquidity 1 stETH to the pool and keep YT.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/addLiquiditySingleTokenKeepYt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&tokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountTokenIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/add-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&tokenIn=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountIn=1000000000000000000&zpi=true`
47 changes: 47 additions & 0 deletions hosted-sdk-demo/src/migrations/mint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Mint PT & YT
The examples below will mint PT stETH (30 Dec 2027) and YT stETH (30 Dec 2027) on Ethereum.

| Token | Address |
|--------|---------|
| SY | `0xcbc72d92b2dc8187414f6734718563898740c0bc` |
| PT | `0xb253eff1104802b97ac7e3ac9fdd73aece295a2c` |
| YT | `0x04b7fa1e727d7290d6e24fa9b426d0c940283a95` |
| stETH | `0xae7ab96520de3a18e5e111b5eaab095312d7fe84` |

## mintPyFromSy
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_mint

- Pass the SY stETH address into the `tokenIn` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| ytAddr | yt |
| amountSyToMint | amountIn |

Example: Mint PT and YT from 1 SY.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/mintPyFromSy?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&ytAddr=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&amountSyToMint=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/mint?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&yt=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&tokenIn=0xcbc72d92b2dc8187414f6734718563898740c0bc&amountIn=1000000000000000000`

## mintPyFromToken
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_mint

- Pass the token address into the `tokenIn` parameter.
- If `tokenIn` is not an input token of SY stETH, set `enableAggregator` to `true`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| ytAddr | yt |
| tokenInAddr | tokenIn |
| amountTokenIn | amountIn |

Example: Mint PT and YT from 1 stETH.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/mintPyFromToken?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&ytAddr=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&tokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenInAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountTokenIn=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/mint?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&yt=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&tokenIn=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&amountIn=1000000000000000000`
46 changes: 46 additions & 0 deletions hosted-sdk-demo/src/migrations/redeem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Redeem PT & YT
The examples below will redeem PT stETH (30 Dec 2027) and YT stETH (30 Dec 2027) on Ethereum.

| Token | Address |
|--------|---------|
| SY | `0xcbc72d92b2dc8187414f6734718563898740c0bc` |
| PT | `0xb253eff1104802b97ac7e3ac9fdd73aece295a2c` |
| YT | `0x04b7fa1e727d7290d6e24fa9b426d0c940283a95` |
| stETH | `0xae7ab96520de3a18e5e111b5eaab095312d7fe84` |

## redeemPyToSy
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_redeem

- Pass the SY stETH address into the `tokenOut` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| ytAddr | yt |
| amountPyToRedeem | amountIn |

Example: Redeem 1 PT and 1 YT to SY.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/redeemPyToSy?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&ytAddr=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&amountPyToRedeem=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/redeem?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&yt=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&amountIn=1000000000000000000&tokenOut=0xcbc72d92b2dc8187414f6734718563898740c0bc`

## redeemPyToToken
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_redeem

- Pass the token address into the `tokenOut` parameter.
- If `tokenOut` is not an output token of SY stETH, set `enableAggregator` to `true`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| ytAddr | yt |
| amountPyIn | amountIn |

Example: Redeem 1 PT and 1 YT to stETH.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/redeemPyToToken?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&ytAddr=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&amountPyIn=1000000000000000000&tokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/redeem?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&yt=0x04b7fa1e727d7290d6e24fa9b426d0c940283a95&amountIn=1000000000000000000&tokenOut=0xae7ab96520de3a18e5e111b5eaab095312d7fe84`
101 changes: 101 additions & 0 deletions hosted-sdk-demo/src/migrations/remove-liquidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Remove Liquidity

The examples below will remove liquidity from the stETH (30 Dec 2027) Pool on Ethereum:

| Token | Address |
|--------|---------|
| Pool/LP | `0x34280882267ffa6383b363e278b027be083bbe3b` |
| SY | `0xcbc72d92b2dc8187414f6734718563898740c0bc` |
| PT | `0xb253eff1104802b97ac7e3ac9fdd73aece295a2c` |
| stETH | `0xae7ab96520de3a18e5e111b5eaab095312d7fe84` |

## removeLiquidityDualSyAndPt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_removeLiquidityDual

- Pass the SY address into the `tokenOut` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountLpToRemove | amountIn |

Example: Remove 1 LP to SY and PT.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/removeLiquidityDualSyAndPt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountLpToRemove=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/remove-liquidity-dual?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&amountIn=1000000000000000000&tokenOut=0xcbc72d92b2dc8187414f6734718563898740c0bc`

## removeLiquidityDualTokenAndPt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_removeLiquidityDual

- Pass the token address into the `tokenOut` parameter.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountLpToRemove | amountIn |
| tokenOutAddr | tokenOut |

Example: Remove 1 LP to stETH and PT.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/removeLiquidityDualTokenAndPt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountLpToRemove=1000000000000000000&tokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/remove-liquidity-dual?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&amountIn=1000000000000000000&tokenOut=0xae7ab96520de3a18e5e111b5eaab095312d7fe84`

## removeLiquiditySinglePt
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_removeLiquidity

- Pass the PT address into the `tokenOut` parameter.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountLpToRemove | amountIn |

Example: Remove 1 LP to PT.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/removeLiquiditySinglePt?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountLpToRemove=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/remove-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&amountIn=1000000000000000000&tokenOut=0xb253eff1104802b97ac7e3ac9fdd73aece295a2c`

## removeLiquiditySingleSy
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_removeLiquidity

- Pass the SY address into the `tokenOut` parameter.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountLpToRemove | amountIn |

Example: Remove 1 LP to SY.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/removeLiquiditySingleSy?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountLpToRemove=1000000000000000000&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/remove-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&amountIn=1000000000000000000&tokenOut=0xcbc72d92b2dc8187414f6734718563898740c0bc`

## removeLiquiditySingleToken
New API docs: https://api-v2.pendle.finance/core/docs#/SDK/SdkController_removeLiquidity

- Pass the token address into the `tokenOut` parameter.
- If `tokenOut` is not an output token of SY stETH, set `enableAggregator` to `true`.
- If `impliedApy` is required in the API response, set `additionalData` to `impliedApy`.
- Parameter changes:

| Old | New |
|-----|-----|
| receiverAddr | receiver |
| amountLpToRemove | amountIn |
| tokenOutAddr | tokenOut |

Example: Remove 1 LP to stETH.

Old query: `https://api-v2.pendle.finance/sdk/api/v1/removeLiquiditySingleToken?chainId=1&receiverAddr=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&marketAddr=0x34280882267ffa6383b363e278b027be083bbe3b&amountLpToRemove=1000000000000000000&tokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&syTokenOutAddr=0xae7ab96520de3a18e5e111b5eaab095312d7fe84&slippage=0.001`

New query: `https://api-v2.pendle.finance/core/v1/sdk/1/markets/0x34280882267ffa6383b363e278b027be083bbe3b/remove-liquidity?receiver=0xbD525dfF925DF9c063C77B29d5Eec8f977B79476&slippage=0.001&amountIn=1000000000000000000&tokenOut=0xae7ab96520de3a18e5e111b5eaab095312d7fe84`
Loading

0 comments on commit bd2abfa

Please sign in to comment.