@rholabs/rho-sdk
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -70,3 +70,4 @@ import { BrowserProvider, JsonRpcSigner, JsonRpcProvider, TransactionReceipt, Wallet } from "ethers"; | ||
tokensPair: FixedAndFloatTokensPair; | ||
marketRate: bigint; | ||
marketRateBefore: bigint; | ||
marketRateAfter: bigint; | ||
tradeRate: bigint; | ||
@@ -157,4 +158,4 @@ lpFee: bigint; | ||
export interface LiquidityDistribution { | ||
totalNotional: bigint; | ||
currentSwapRate: bigint; | ||
provisionDistribution: ProvisionDistribution; | ||
currentFutureRate: bigint; | ||
intervalLiquidity: IntervalLiquidity[]; | ||
@@ -199,7 +200,44 @@ } | ||
} | ||
export interface OracleAPIConfig { | ||
oracleServiceUrl: string; | ||
} | ||
export class OracleAPI { | ||
constructor(config: RhoSDKConfig); | ||
constructor(config: OracleAPIConfig); | ||
getRates(): Promise<OracleRecord[]>; | ||
getMarketRate(marketId: string): Promise<OracleRecord>; | ||
} | ||
export interface SubgraphAPIConfig { | ||
apiUrl: string; | ||
} | ||
export interface CommonEventProps { | ||
id: string; | ||
marketId: string; | ||
transactionHash: string; | ||
blockNumber: string; | ||
blockTimestamp: string; | ||
owner: string; | ||
} | ||
export interface TradeEvent extends CommonEventProps { | ||
futureId: string; | ||
initiator: string; | ||
notional: bigint; | ||
openInterest: bigint; | ||
direction: number; | ||
tradeRate: bigint; | ||
protocolFee: bigint; | ||
lpFee: bigint; | ||
} | ||
export interface EventsFilter { | ||
userAddress?: string; | ||
marketIds?: string[]; | ||
futureIds?: string[]; | ||
timestampFrom?: number; | ||
timestampTo?: number; | ||
offset?: number; | ||
limit?: number; | ||
} | ||
export class SubgraphAPI { | ||
constructor(config: SubgraphAPIConfig); | ||
getTrades(filter?: EventsFilter): Promise<TradeEvent[]>; | ||
} | ||
export default class RhoSDK { | ||
@@ -206,0 +244,0 @@ config: RhoSDKConfig; |
{ | ||
"name": "@rholabs/rho-sdk", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Rho Protocol SDK", | ||
@@ -19,2 +19,3 @@ "source": "src/index.ts", | ||
"test": "yarn build && jest index.test.ts --no-cache", | ||
"test_subgraph": "yarn build && jest subgraph-api.test.ts --no-cache", | ||
"prepack": "yarn build" | ||
@@ -21,0 +22,0 @@ }, |
@@ -68,3 +68,5 @@ import {RouterABI, ViewABI, QuoterABI, ERC20ABI} from './abi' | ||
this.oracleAPI = new OracleAPI(config); | ||
this.oracleAPI = new OracleAPI({ | ||
oracleServiceUrl: config.oracleServiceUrl | ||
}); | ||
} | ||
@@ -214,7 +216,7 @@ | ||
const [ totalNotional, currentSwapRate, intervalLiquidity ] = Object.values(data) as any | ||
const [ provisionDistribution, currentFutureRate, intervalLiquidity ] = Object.values(data) as any | ||
return { | ||
totalNotional, | ||
currentSwapRate, | ||
provisionDistribution, | ||
currentFutureRate, | ||
intervalLiquidity | ||
@@ -487,1 +489,2 @@ } | ||
export * from './api/oracle' | ||
export * from './api/subgraph' |
@@ -79,3 +79,4 @@ export interface ProvisionDistribution { | ||
tokensPair: FixedAndFloatTokensPair; | ||
marketRate: bigint; | ||
marketRateBefore: bigint; | ||
marketRateAfter: bigint; | ||
tradeRate: bigint; | ||
@@ -180,4 +181,4 @@ lpFee: bigint | ||
export interface LiquidityDistribution { | ||
totalNotional: bigint | ||
currentSwapRate: bigint | ||
provisionDistribution: ProvisionDistribution | ||
currentFutureRate: bigint | ||
intervalLiquidity: IntervalLiquidity[] | ||
@@ -184,0 +185,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5071687
30
13487