New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rholabs/rho-sdk

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rholabs/rho-sdk - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

src/abi/ACM.json

26

lib/types.d.ts

@@ -165,2 +165,14 @@ import { BrowserProvider, JsonRpcSigner, JsonRpcProvider, TransactionReceipt, Wallet, TransactionRequest } from "ethers";

}
export enum UserRole {
PROTOCOL_USER = "PROTOCOL_USER",
PROTOCOL_USER_MANAGER = "PROTOCOL_USER_MANAGER",
ISSUER = "ISSUER",
ORACLE_SIGNER = "ORACLE_SIGNER",
EMERGENCY_MANAGER = "EMERGENCY_MANAGER",
RISK_MANAGER = "RISK_MANAGER",
REWARD_MANAGER = "REWARD_MANAGER",
MATURITY_COURIER = "MATURITY_COURIER",
LIQUIDATOR = "LIQUIDATOR",
SUPER_LIQUIDATOR = "SUPER_LIQUIDATOR"
}
export type RhoSDKNetwork = 'mainnet' | 'testnet' | 'custom';

@@ -173,4 +185,3 @@ export interface RhoSDKParams {

rpcUrl?: string;
oracleServiceUrl?: string;
oracleServiceV2Url?: string;
oracleServiceUrl?: string | string[];
privateKey?: string;

@@ -185,3 +196,3 @@ provider?: JsonRpcProvider | BrowserProvider;

rpcUrl: string;
oracleServiceUrl: string;
oracleServiceUrl: string | string[];
}

@@ -267,4 +278,3 @@ export interface OraclePackagesParams {

export interface OracleAPIConfig {
oracleServiceUrl: string;
oracleServiceV2Url?: string;
oracleServiceUrl: string | string[];
}

@@ -354,4 +364,10 @@ export class OracleAPI {

transferPositionsOwnership(params: TransferPositionsOwnershipParams): Promise<TransactionReceipt>;
getUsers(params: {
role: UserRole;
} & PaginationParams): Promise<string[]>;
getUsersCount(params: {
role: UserRole;
}): Promise<bigint>;
}
//# sourceMappingURL=types.d.ts.map

2

package.json
{
"name": "@rholabs/rho-sdk",
"version": "0.2.12",
"version": "0.2.13",
"description": "Rho Protocol SDK",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

@@ -5,3 +5,4 @@ import RouterABI from './Router.json'

import ERC20ABI from './ERC20.json'
import ACMABI from './ACM.json'
export { RouterABI, ViewABI, QuoterABI, ERC20ABI }
export { RouterABI, ViewABI, QuoterABI, ERC20ABI, ACMABI }

@@ -13,4 +13,3 @@ import axios from 'axios'

export interface OracleAPIConfig {
oracleServiceUrl: string
oracleServiceV2Url?: string
oracleServiceUrl: string | string[]
}

@@ -25,11 +24,14 @@

public async getRates() {
const { data: oracleRecords } = await axios.get<OracleRecord[]>(`${this.config.oracleServiceUrl}/records`)
if(this.config.oracleServiceV2Url) {
const { data: oracleRecordsV2 } = await axios.get<OracleRecord[]>(
`${this.config.oracleServiceV2Url}/records`
)
oracleRecords.push(...oracleRecordsV2)
const oracleUrls = typeof this.config.oracleServiceUrl === 'string'
? [this.config.oracleServiceUrl]
: this.config.oracleServiceUrl
let oracleRecords: OracleRecord[] = []
for(const oracleUrl of oracleUrls) {
const {
data: records
} = await axios.get<OracleRecord[]>(`${oracleUrl}/records`)
oracleRecords.push(...records)
}
return oracleRecords

@@ -36,0 +38,0 @@ }

@@ -8,4 +8,3 @@ import { RhoSDKConfig, RhoSDKParams } from './sdk-typings'

rpcUrl: 'https://arb1.arbitrum.io/rpc',
oracleServiceUrl: 'https://roaracle.app',
oracleServiceV2Url: 'https://v2.roaracle.app'
oracleServiceUrl: ['https://roaracle.app', 'https://v2.roaracle.app'],
}

@@ -18,4 +17,3 @@

rpcUrl: 'https://arbitrum-sepolia.blockpi.network/v1/rpc/public',
oracleServiceUrl: 'https://testnet.roaracle.app',
oracleServiceV2Url: 'https://testnet-v2.roaracle.app'
oracleServiceUrl: ['https://testnet.roaracle.app', 'https://testnet-v2.roaracle.app'],
}

@@ -22,0 +20,0 @@

@@ -1,2 +0,2 @@

import { RouterABI, ViewABI, QuoterABI, ERC20ABI } from './abi'
import { RouterABI, ViewABI, QuoterABI, ERC20ABI, ACMABI } from './abi'
import { parseConfig } from './config'

@@ -12,3 +12,3 @@ import {

OraclePackage,
TradeQuote
TradeQuote, UserRole
} from './typings'

@@ -43,4 +43,5 @@ import {

Wallet,
TransactionRequest
TransactionRequest, toUtf8Bytes, keccak256
} from 'ethers'
import { getUserRoleBytes } from './utils'

@@ -54,2 +55,3 @@ const defaultLimit = 100

private quoter: Contract
private acm?: Contract

@@ -90,3 +92,2 @@ private signer?: Wallet | JsonRpcSigner

oracleServiceUrl: config.oracleServiceUrl,
oracleServiceV2Url: config.oracleServiceV2Url,
})

@@ -383,2 +384,22 @@ }

}
private async getAcmContract() {
if(!this.acm) {
const acmAddress = await this.router.getAcm()
this.acm = new ethers.Contract(acmAddress, ACMABI, this.provider)
}
return this.acm
}
public async getUsers(params: { role: UserRole } & PaginationParams): Promise<string[]> {
const { role, offset = 0, limit = 100 } = params
const acm = await this.getAcmContract()
return await acm.getRoleAddresses(getUserRoleBytes(role), offset, limit)
}
public async getUsersCount(params: { role: UserRole }): Promise<bigint> {
const { role } = params
const acm = await this.getAcmContract()
return await acm.getRoleAddressesCount(getUserRoleBytes(role))
}
}

@@ -385,0 +406,0 @@

@@ -12,4 +12,3 @@ import { BrowserProvider, JsonRpcSigner, JsonRpcProvider } from 'ethers'

rpcUrl?: string
oracleServiceUrl?: string
oracleServiceV2Url?: string
oracleServiceUrl?: string | string[]
privateKey?: string

@@ -25,3 +24,3 @@ provider?: JsonRpcProvider | BrowserProvider

rpcUrl: string
oracleServiceUrl: string
oracleServiceUrl: string | string[]
}

@@ -28,0 +27,0 @@

@@ -189,1 +189,14 @@ export interface ProvisionDistribution {

}
export enum UserRole {
PROTOCOL_USER = 'PROTOCOL_USER',
PROTOCOL_USER_MANAGER = 'PROTOCOL_USER_MANAGER',
ISSUER = 'ISSUER',
ORACLE_SIGNER = 'ORACLE_SIGNER',
EMERGENCY_MANAGER = 'EMERGENCY_MANAGER',
RISK_MANAGER = 'RISK_MANAGER',
REWARD_MANAGER = 'REWARD_MANAGER',
MATURITY_COURIER = 'MATURITY_COURIER',
LIQUIDATOR = 'LIQUIDATOR',
SUPER_LIQUIDATOR = 'SUPER_LIQUIDATOR'
}

@@ -1,2 +0,3 @@

import { Margin, ProfitAndLoss } from './typings'
import { Margin, ProfitAndLoss, UserRole } from './typings'
import { keccak256, toUtf8Bytes } from 'ethers'

@@ -10,1 +11,5 @@ export const profitAndLossTotal = (input: ProfitAndLoss) => {

}
export const getUserRoleBytes = (role: UserRole) => {
return keccak256(toUtf8Bytes(role));
}
import * as dotenv from 'dotenv'
import { describe, expect, test } from '@jest/globals'
import RhoSDK, { LiquidityOperation, RiskDirection } from '../src/index'
import RhoSDK, { LiquidityOperation, RiskDirection, UserRole } from '../src/index'
import { MarketInfo } from '../src'

@@ -401,1 +401,24 @@ import { marginTotal } from '../src/utils'

})
describe('Access Control Manager', () => {
test(
'getUsersCount',
async () => {
const count = await sdk.getUsersCount({ role: UserRole.PROTOCOL_USER })
expect(count).toBeGreaterThan(0)
}
)
test(
'getUsers',
async () => {
const limit = 10
const users = await sdk.getUsers({
role: UserRole.PROTOCOL_USER,
offset: 0,
limit
})
expect(users.length).toBe(limit)
}
)
})

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc