Skip to content

Commit

Permalink
Add hosted SDK migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tientran3 committed Sep 11, 2024
1 parent 759d049 commit 9d991a8
Show file tree
Hide file tree
Showing 6 changed files with 535 additions and 0 deletions.
144 changes: 144 additions & 0 deletions hosted-sdk-demo/src/migrations/add-liquidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Add Liquidity
Examples below will add liquidity to 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 SY address into `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 token address into `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 PT address into `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 SY address into `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 SY address into `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 token address into `tokenIn` paramter.
- If `tokenIn` is not a input tokens 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 token address into `tokenIn` paramter.
- Set `zpi` to `true`.
- If `tokenIn` is not a input tokens 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`
48 changes: 48 additions & 0 deletions hosted-sdk-demo/src/migrations/mint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Mint PT & YT
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 SY stETH address into `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 token address into `tokenIn` parameter.
- If `tokenIn` is not a input tokens 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`
47 changes: 47 additions & 0 deletions hosted-sdk-demo/src/migrations/redeem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Redeem PT & YT
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 SY stETH address into `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 token address into `tokenOut` parameter.
- If `tokenOut` is not a output tokens of SY stETH, set `enableAggregator` to `true`.
- Parameter changes:

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

Example: Redeem 1 PT and 1 YT from 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

Examples below will remove liquidity from 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 SY address into `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 token address into `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 PT address into `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 SY address into `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 token address into `tokenOut` parameter.
- If `tokenOut` is not a output tokens 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 9d991a8

Please sign in to comment.