Skip to content

Types from Rust documentation Levana Perps in TypeScript

License

Notifications You must be signed in to change notification settings

nktkas/levana-perps-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LevanaPerpsTypes

Types from Rust documentation of Levana Perps in TypeScript

Installation

npm i @nktkas/levana-perps-types

Deno, Yarn, pnpm, Bun from JSR

deno add @nktkas/levana-perps-types
yarn dlx jsr add @nktkas/levana-perps-types
pnpm dlx jsr add @nktkas/levana-perps-types
bunx jsr add @nktkas/levana-perps-types

Usage

Query to Levana

import type { LevanaCosmWasmClient } from "@nktkas/levana-perps-types";
import { CosmWasmClient } from "@cosmjs/cosmwasm-stargate";

// Testnet factory address
const FACTORY_ADDRESS = "osmo1ymuvx9nydujjghgxxug28w48ptzcu9ysvnynqdw78qgteafj0syq247w5u";

// Osmosis testnet RPC endpoint
const RPC_ENDPOINT = "https://rpc.osmotest5.osmosis.zone";

// TypeScript automatically recognizes a query, offers certain hints, and returns the appropriate response type for the query
const levanaCosmWasmClient = await CosmWasmClient.connect(RPC_ENDPOINT) as LevanaCosmWasmClient;

const marketsResp = await levanaCosmWasmClient.queryContractSmart(FACTORY_ADDRESS, {
    markets: {},
});
console.log("Markets maintained by this factory:", marketsResp);

const marketInfoResponse = await levanaCosmWasmClient.queryContractSmart(FACTORY_ADDRESS, {
    market_info: {
        market_id: marketsResp.markets[0],
    },
});
console.log("Information about a specific market:", marketInfoResponse);

const statusResp = await levanaCosmWasmClient.queryContractSmart(marketInfoResponse.market_addr, {
    status: {},
});
console.log("Overall market status information:", statusResp);

const nftContractInfo = await levanaCosmWasmClient.queryContractSmart(marketInfoResponse.market_addr, {
    nft_proxy: {
        nft_msg: {
            contract_info: {},
        },
    },
});
console.log("Top-level metadata about the position contract:", nftContractInfo);

License

This project is licensed under the MIT License. Check the License file for more info.

About

Types from Rust documentation Levana Perps in TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published