Pitchanai Thitipakorn
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Introduction # API Base url: https://api.homora.alphaventuredao.io/ Swagger: https://api.homora.alphaventuredao.io/doc ## Data Types ### Pool | Attribute | Type | Description | | -------- | -------- | -------- | | `key` | `string` | Pool's key | | `name` | `string` | Pool's name (e.g. ETH/USDT) | | `tokens` | `string[]` | Pool's token addresses in lowercase | | `lpTokenAddress` | `string` | Pool's LP token address in lowercase | | `poolAddress?` | `string` | [optional] Only use with Curve pool since pool address is holding the tokens not LP address | | `wTokenAddress` | `string` | Wrapper contract address | | `exchange` | `IExchange` | [IExchange](#IExchange) | | `type` | `PoolType` | [PoolType](#PoolType) | | `wTokenType` | `WTokenType` | [WTokenType](#WTokenType) | | `pid?` | `number` | [optional] Only use with pools that need to be staked on a Masterchef-like contract and pools which `wTokenType === WTokenType.WLiquidityGauge` | | `gid?` | `number` | [optional] Only use with Curve pool | | `rewardSymbol?` | `string` | [optional] Pool's reward symbol, usually we use reward symbol from `exchange.reward.tokenName` | | `rewardAddress?` | `string` | [optional] Pool's reward address, usually we use reward address from `exchange.reward.rewardTokenAddress` | | `isFarmingDisabled?`| `boolean` | [optional] A pool that's been hidden on the Farm Pool page (deprecated soon) | | `status?`| `'delisting' \| 'delisted'` | [optional] `delisting` = A pool that's going to be delisted soon. `delisted` = A pool that's been delisted. For both of the statuses, we'd recommend users to close their position. | | `stakingAddress?` | `string` | [optional] Masterchef address of that pool. | | `spellAddress?` | `string` | [optional] Pool's spell address, usually we use `spellAddress` from `exchange.spellAddress` | | `migrateTo?` | `string` | [optinal] Pool that need to be migrate to a new pool | | `uniswapV3Info` | `UniswapV3Pool` | [UniswapV3Pool](#UniswapV3Pool) | ### IExchange | Attribute | Type | Description | | -------- | -------- | -------- | | `name` | `Exchange` | Exchange Enum | | `logo` | `string` | Logo source for Homora's frontend | | `spellAddress?` | `string` | [optional] Exchange's spell address | | `stakingAddress?` | `string` | [optional] Exchange's staking address | | `reward` | `IExchangeReward` | Exchange's liquidity mining reward | ### IExchangeReward | Attribute | Type | Description | | -------- | -------- | -------- | | `tokenName` | `string` | Exchange's liquidity mining reward name | | `rewardTokenAddress` | `string` | Exchange's liquidity mining reward address | ### Safebox | Attribute | Type | Description | | -------- | -------- | -------- | | `address` | `string` | Asset address | | `safeboxAddress` | `string` | Homora [safebox](https://hackmd.io/@PhhCdDESRme9EK6zwT-9Pw/BJsYdyrw9#Alpha-Homora-Components) address | | `cyTokenAddress` | `string` | Iron Bank lending address | ### PoolAPY | Attribute | Type | Description | | -------- | -------- | -------- | | `totalAPY` | `string` | Total APY | | `tradingFeeAPY` | `string` | Trading Fee APY | | `farminigAPY` | `string` | Yield Farming APY | ### TokenDetails | Attribute | Type | Description | | -------- | -------- | -------- | | `name` | `string` | Token's name | | `logo` | `string` | Logo source for Homora frontend | | `decimals` | `number` | Token's decimals | ### UniswapV3Pool | Attribute | Type | Description | | -------- | -------- | -------- | | `priceRatioBps` | `[number, number, number]` | Recommended price range BPS, sorted from safe to risky range | | `poolFeeBps` | `number` | Pool's Fee BPS | | `tickSpacing` | `number` | Pool's tick spacing `(1 / 10 / 60 / 200)` | ### UniswapV3PriceRangeInfo | Attribute | Type | Description | | -------- | -------- | -------- | | `lastUpdatedTimestamp` | `number` | Last update timestamp in ms | | `lastUpdatedTick` | `number` | Latest pool's tick | | `priceRanges` | `[PriceRange, PriceRange, PriceRange]` | Recommended price range, sorted from safe to risky range | ### PriceRange | Attribute | Type | Description | | -------- | -------- | -------- | | `apr` | `number` | Price range APR | | `lower` | `TickInfo` | Lower tick info | | `upper` | `TickInfo` | Upper tick info | ### TickInfo | Attribute | Type | Description | | -------- | -------- | -------- | | `tick` | `number` | Tick number | | `price0` | `string` | Price of token0 / token1 | | `price1` | `string` | Price of token1 / token0 | ### UniswapV3Position | Attribute | Type | Description | | -------- | -------- | -------- | | `positionId` | `string` | Uniswap V3 position ID (not Homora position ID) | | `tickLower` | `number` | Position's tick lower | | `tickUpper` | `number` | Position's tick upper | | `liquidity` | `string` | Position's liquidity size (Each position has a different LP price due to the diverse price range of each position.) | | `apr` | `number` | Position's APR | ## Enum ### PoolType ```typescript enum PoolType { LiquidityProviding = 'Liquidity Providing', YieldFarming = 'Yield Farming', } ``` ### Exchange ```typescript enum Exchange { UniswapV2 = 'Uniswap V2', UniswapV3 = 'Uniswap V3', Sushiswap = 'Sushiswap', Curve = 'Curve', TraderJoe = 'Trader Joe', TraderJoeMasterChefV3 = 'Trader Joe MasterChef V3', TraderJoeBoostedMasterChef = 'Trader Joe Boosted MasterChef', Pangolin = 'Pangolin', PangolinV2 = 'Pangolin V2', SpookySwap = 'SpookySwap', SpookySwapV2 = 'SpookySwap V2', SpiritSwap = 'SpiritSwap', Beethovenx = 'Beethovenx', } ``` ### WTokenType ```typescript enum WTokenType { WERC20 = 'WERC20', WStakingRewards = 'WStakingRewards', WMasterChef = 'WMasterChef', WMasterChefJoeV3 = 'WMasterChefJoeV3', WBoostedMasterChefJoe = 'WBoostedMasterChefJoe', WLiquidityGauge = 'WLiquidityGauge', WMiniChef = 'WMiniChef', WMiniChefV2 = 'WMiniChefV2', WMasterChefBeets = 'WMasterChefBeets', WMasterChefBoolV2 = 'WMasterChefBoolV2', WUniswapV3 = 'WUniswapV3', } ``` ## API Endpoint ### Farm Pools To get all of the farming pools of each chain. Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/pools` Example: https://api.homora.alphaventuredao.io/v2/43114/pools return type: [Pool[]](#Pool) ### Lend Pools To get all of the lending pools of each chain Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/safeboxes` Example: https://api.homora.alphaventuredao.io/v2/43114/safeboxes return type: [Safebox[]](#Safebox) ### APYs To get all of the farming pool's APYs of each chain (except for UniswapV3 Pools) Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/apys` Example: https://api.homora.alphaventuredao.io/v2/43114/apys return type: Record<string, [PoolAPY](#PoolAPY)> // `Record<Pool's key, PoolAPY>` ### Token Details To get all of the token details with the name and decimals of each chain Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/tokens` Example: https://api.homora.alphaventuredao.io/v2/43114/tokens return type: Record<string, [TokenDetails](#TokenDetails)> // `Record<Token's address, TokenDetails>` ### All Positions To get all of the positions sorted by highest to lowest debt ratio of each chain. Only use with liquidation page only. Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/positions` Example: https://api.homora.alphaventuredao.io/v2/43114/positions ### (UniswapV3) Pool's price range & APR To get all of the Uniswap V3 pool's price ranges and APRs Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/uniswapv3/price-range` Example: https://api.homora.alphaventuredao.io/v2/10/uniswapv3/price-range return type: Record<string, [UniswapV3PriceRangeInfo](#UniswapV3PriceRangeInfo)> // `Record<Pool's key, UniswapV3PriceRangeInfo>` ### (UniswapV3) Positions Info To get user's Uniswap V3 position info Endpoint: `https://api.homora.alphaventuredao.io/v2/[chainId]/uniswapv3/positions` Example: https://api.homora.alphaventuredao.io/v2/10/uniswapv3/positions return type: Record<string, [UniswapV3Position](#UniswapV3Position)> // `Record<Homora position ID, UniswapV3Position>` ## Subgraph ### Endpoint - Ethereum: https://api.thegraph.com/subgraphs/name/hermioneeth/alpha-homora-v2-relaunch - Avalanche: https://api.thegraph.com/subgraphs/name/alphafinancelab/alpha-homora-v2-avax - Fantom: https://api.thegraph.com/subgraphs/name/alphafinancelab/alpha-homora-v2-fantom - Optimism: https://api.thegraph.com/subgraphs/name/mintcnn/optimism ### Query ```graphql positions { id owner collateralSize collateralToken { token tokenId } } ``` ### Data - `id` : Position ID - `owner` : Position owner address - `collateralSize` : The size of the collateral (if 0 then the position is closed because there's no collateral left) - `collateralToken - token` : Wrap token contract address. It's an ERC-1155 contract that keep user positions. - `collateralToken - token` : Token ID that determine the position info like LP address or PID. # Calculation ### Pool's Best Leverage The pool's best leverage is calculated by borrowing each token to the maximum borrowing amount and check that which one gives the best APY, then use that leverage as the pool's max leverage. **Please note that the pool best leverage showing in the Homora V2's UI aren't always the pool max leverage because in some situation, the borrow APY is quite high from high utilization of the lending pool so the UI won't suggest that leverage.* `tokenMaxLeverage` or the max leverage of each borrowing token is calculated as: ```jsx tokenMaxLeverage = borrowFactor / (borrowFactor - (collateralFactor * cappedDebtRatio)) ``` **Default `cappedDebtRatio` is set to `0.95`* [Read more about collateral and borrow credit](https://docs.alphaventuredao.io/homora-v2/additional-info/understanding-collateral-credit-and-borrowing-credit). The total APY of that `tokenMaxLeverage` is calculated as: ```jsx totalAPY = ((farmingAPR + tradingFeeAPY) * tokenMaxLeverage) + (totalRewardAPY * (tokenMaxLeverage - 1)) - (tokenBorrowApy * (tokenMaxLeverage - 1)) ``` **The rewardAPY and borrowAPY is multiplied by (maxLeverage-1) because the interest only happens when the leverage is >1* Then compared totalAPY of each borrowing token (also with the totalAPY if has no leverage) to see which one gives the best APY. <!-- # Oracle --> # Contracts https://hackmd.io/@PhhCdDESRme9EK6zwT-9Pw/BJsYdyrw9 <!-- # UI ## Farm Pool ## Your Positions ## Lend Pool -->

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully