# @renec-foundation/oracle-sdk

> Typescript SDK to interact with Oracle program.

Latest version **0.1.13** (published 2024-08-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @renec-foundation/oracle-sdk
pnpm add @renec-foundation/oracle-sdk
yarn add @renec-foundation/oracle-sdk
bun add @renec-foundation/oracle-sdk
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.13 |
| Published | 2024-08-27 |
| First published | 2023-06-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 215.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | tunghoang@remitano.com |
| Maintainers | renec-foundation |

## Links

- npm: https://www.npmjs.com/package/@renec-foundation/oracle-sdk
- npm.io page: https://npm.io/package/@renec-foundation/oracle-sdk

## Dependencies (9)

- [figlet](https://npm.io/package/figlet.md) ^1.6.0
- [commander](https://npm.io/package/commander.md) ^11.0.0
- [decimal.js](https://npm.io/package/decimal.js.md) ^10.3.1
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.191
- [tiny-invariant](https://npm.io/package/tiny-invariant.md) ^1.3.1
- [@solana/web3.js](https://npm.io/package/@solana/web3.js.md) 1.66.0
- [@solana/spl-token](https://npm.io/package/@solana/spl-token.md) ^0.1.8
- [@orca-so/common-sdk](https://npm.io/package/@orca-so/common-sdk.md) 0.1.11
- [@project-serum/anchor](https://npm.io/package/@project-serum/anchor.md) 0.20.1

## Recent versions

- 0.1.13 (latest) — 2024-08-27
- 0.1.12 — 2024-06-22
- 0.1.11 — 2024-06-19
- 0.1.10 — 2024-06-17
- 0.1.5 — 2024-03-01
- 0.1.4 — 2023-11-28
- 0.1.3 — 2023-09-27
- 0.1.2 — 2023-07-11
- 0.1.1 — 2023-07-04
- 0.1.0 — 2023-06-30

## README

# oracle-sdk

## How to use
```javascript
import {
  PublicKey,
  Connection,
  Keypair,
  Commitment,
} from "@solana/web3.js";
import { AnchorProvider, Wallet, BN, Address } from "@project-serum/anchor";
import { Context, ProductClient, 
  ORACLE_PROGRAM_ID, REUSD, REVND, VERSION 
} from "@renec-foundation/oracle-sdk";


...
// yourKey = Keypair.fromSecretKey(Uint8Array.from([124, 149, 222, 31, 236, 142, 29, 95...]));

const commitment: Commitment = "confirmed";
const connection = new Connection(consts.RPC_ENDPOINT_URL, { commitment });
const wallet = new Wallet(yourKey);
const provider = new AnchorProvider(connection, wallet, { commitment });

const ctx = Context.withProvider(provider, ORACLE_PROGRAM_ID);


const base = REUSD;
const quote = REVND;
const newPrice = 24500.35;

const productClient = await ProductClient.getProduct(ctx, quote, base, VERSION);
const tx = await productClient.postPrice(
    newPrice,
    productClient.ctx.wallet.publicKey
);

await tx.buildAndExecute();
await productClient.refresh();

const price = await productClient.getPrice();
console.log("price", price);
```

+ Output
```json
price {
  "price": 25000,
  "symbol": "VND/USD",
  "timestamp": 1686731721,
  "numberPublishers": 1
}
```

---
_Source: https://npm.io/package/@renec-foundation/oracle-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
