Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add info for developers and partners #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,87 @@ Join us!
* [/sugar](https://github.com/velodrome-finance/sugar) — Our on-chain _API_
* [/oracle](https://github.com/velodrome-finance/oracle) — Our on-chain prices oracle
* [@velodrome on Paragraph](https://paragraph.xyz/@velodrome) — Development Newsletter
* [Deployments](https://velodrome.finance/security#contracts) — Mainnet smart contract addresses

<br clear="left"/>

# Developer and Partner Info

## Pools

The architecture of the basic and concentrated pools closely mimic that of Uniswap v2 and Uniswap v3 respectively.

###### Basic swap example:
```
Router.swapExactTokensForTokens (
uint256 amountIn, // amount of input token
uint256 amountOutMin, // minimum amount of output token received, revert otherwise
Route[] calldata routes, // swap route, represented as array of Route structs
address to, // recipient of output tokens of swap
uint256 deadline // maximum deadline timestamp of transaction, revert otherwise
)
```

The `Route` structs are formatted as follows:
```
struct Route {
address from; // token to swap from
address to; // token to swap to
bool stable; // pool to swap using, either stable or volatile
address factory; // pool factory contract to use
}
```

###### Direct swap UI link example:
`https://velodrome.finance/swap?from={FROM_TOKEN_ADDRESS}&to={TO_TOKEN_ADDRESS}`

###### Direct LP deposit UI link example:
`https://velodrome.finance/deposit?token0={FIRST_TOKEN_ADDRESS}&token1={SECOND_TOKEN_ADDRESS}&type={POOL_TYPE_INTEGER}`

`POOL_TYPE_INTEGER` in the above link must be formatted as follows:
```
-1: Basic volatile pool
0: Basic stable pool
1: Concentrated pool
```

## Onchain Data

For data, Velodrome uses a suite of read-only smart contracts called ["Sugar"](https://github.com/velodrome-finance/sugar) in place of centralized APIs or subgraphs.

###### Fetching Velodrome pool data
```
LpSugar.all (
uint256 _limit, // limit of pools to return
uint256 _offset // offset of where to begin returning pools, pagination recommended
)
```

###### Fetching Relay data
```
RelaySugar.all (
uint256 _account, // account to retrieve potential deposits, can be left as burn address to return generic Relay data
)
```

###### Fetching Velodrome veNFT data
```
VeSugar.all (
uint256 _limit, // limit of veNFTs to return
uint256 _offset // offset of where to begin returning veNFTs, pagination recommended
)
```

## Oracles and Price Data

For displaying prices, Velodrome uses a [custom read-only smart contract](https://github.com/velodrome-finance/oracle) in place of centralized APIs. Please note that the prices returned by this smart contract are intended for read-only use, and are not intended to be used in high stakes smart contract integrations such as with lending markets.

Both Velodrome basic and concentrated pools do provide Uniswap-style oracles through the `Pool.observations` field. Observations are updated at most every 30 minutes for basic pools and at most every 15 seconds for concentrated pools.

The VELO token is not yet supported by major third-party oracle services such as Chainlink.

## Token Logos

Velodrome uses [SmolDapp's decentralized tokenlist](https://github.com/SmolDapp/tokenAssets) to fetch token logos. Token issuers should follow the instructions in SmolDapp's readme and create a pull request adding their token logo. After creating the pull request, a review must be requested from any of the SmolDapp maintainers on the dropdown. As soon as the pull request is merged, the token logo will be viewable on the Velodrome UI.

Please note that the svg logo added to SmolDapp must be a true svg, and not a base64 encoded png or jpg.