Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phuture-finance/phuture-sdk
Integrate Phuture protocol into any Web or Node.js project
https://github.com/phuture-finance/phuture-sdk
Last synced: about 2 months ago
JSON representation
Integrate Phuture protocol into any Web or Node.js project
- Host: GitHub
- URL: https://github.com/phuture-finance/phuture-sdk
- Owner: Phuture-Finance
- License: mit
- Created: 2022-06-01T11:57:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-05T11:27:14.000Z (2 months ago)
- Last Synced: 2024-11-05T11:44:29.539Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.99 MB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Phuture SDK
Phuture SDK is a JS library for using functionality related to defi indices made by [Phuture Finance](https://www.phuture.finance/) team.
## Installation
```bash
npm i @phuture/sdk
```## Usage
### AutoRouter
AutoRouter package has been created to find the best deal to buy or sell an index based on gas price and returned amount. Depending on results this package can return mint/redeem transaction from Phuture's IndexRouter contract or 0x swap transaction.
```typescript
import {
AutoRouter,
Erc20,
IndexRouter,
ZeroExAggregator,
} from '@phuture/sdk'
import { ethers } from 'ethers'const amount = '1000'
const account = new ethers.Wallet('PRIVATE_KEY', ethers.getDefaultProvider())const indexRouter = new IndexRouter(account)
const zeroAggregator = new ZeroExAggregator()const autoRouter = new AutoRouter(indexRouter, zeroAggregator)
// handle buy
autoRouter.autoBuy(indexTokenInterface, amount, erc20)// handle sell
autoRouter.autoSell(indexTokenInterface, amount, erc20)
```### 0x Aggregator
ZeroEx Aggregator package has been created to use methods related for managing Phuture's Index on most compatible defi exchanges
```typescript
import { Index, ZeroExAggregator } from '@phuture/sdk'
import { ethers } from 'ethers'const amount = '1000000000000000';
const indexPDI = 'INDEX_CONTRACT';const zeroAggregator = new ZeroExAggregator()
// get WETH/PDI swap params
const {
buyAmount: buyAssetMinAmount,
to: swapTarget,
data: assetQuote,
} = await zeroEx.quote(
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // WETH
indexPDI,
amount,
)
```