![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@jet-lab/margin
Advanced tools
Add your preferred library to your project.
with npm
$ npm i @jet-lab/margin
...or with yarn
$ yarn add @jet-lab/margin
View the typedocs for the full package documentation and available API.
View more examples for usage reference.
Loading first margin account if local wallet created the first margin account
import { MarginAccount, MarginClient } from "@jet-lab/margin"
import { AnchorProvider, Wallet } from "@project-serum/anchor"
import { Connection, Keypair } from "@solana/web3.js"
const connection = new Connection("https://api.devnet.solana.com", "recent")
const options = AnchorProvider.defaultOptions()
const wallet = Wallet.local()
const provider = new AnchorProvider(connection, wallet, options)
const programs = MarginClient.getPrograms(provider, "devnet")
const marginAccount = await MarginAccount.load(programs, provider, wallet.publicKey, 0)
Loading margin accounts and getting a margin account's risk indicator
import { MarginAccount, MarginClient, PoolManager } from "@jet-lab/margin"
import { Connection } from "@solana/web3.js"
import { AnchorProvider, Wallet } from "@project-serum/anchor"
const config = await MarginClient.getConfig("devnet")
const connection = new Connection("https://api.devnet.solana.com", options.commitment)
const options = AnchorProvider.defaultOptions()
const wallet = Wallet.local()
const localWalletPubkey = wallet.publicKey
const provider = new AnchorProvider(connection, wallet, options)
const programs = MarginClient.getPrograms(provider, config)
//Load margin pools
const poolManager = new PoolManager(programs, provider)
const pools = await poolManager.loadAll()
//Load wallet tokens
const walletTokens = await MarginAccount.loadTokens(poolManager.programs, localWalletPubkey)
//Load all margin accounts - users can have multiple margin accounts eventually
const marginAccounts = await MarginAccount.loadAllByOwner({
programs: poolManager.programs,
provider: poolManager.provider,
pools,
walletTokens,
owner: localWalletPubkey
})
//Print risk level of a margin account
if (marginAccounts) {
console.log(
`Public key ${localWalletPubkey} risk indicator is ${marginAccounts[0].riskIndicator}`
)
} else {
console.log("We have trouble getting margin accounts")
}
In scenarios where the integration process needs to create instructions without sending transactions. The following example creates instruction for creating a new margin account.
View more examples for creating instructions associated with the MarginAccount Class:
import {
MarginClient,
MarginPrograms,
MarginAccount,
Pool,
PoolManager,
PoolTokenChange,
MarginConfig,
} from "@jet-lab/margin"
import { Connection, Keypair, LAMPORTS_PER_SOL, TransactionInstruction } from "@solana/web3.js"
import { AnchorProvider, Wallet } from "@project-serum/anchor"
// Setup
const walletKepair = Keypair.generate()
const walletPubkey = walletKepair.publicKey
const options = AnchorProvider.defaultOptions()
const connection = new Connection("https://api.devnet.solana.com", options.commitment)
const wallet = new Wallet(walletKepair)
const provider = new AnchorProvider(connection, wallet, options)
let config: MarginConfig
let programs: MarginPrograms
let poolManager: PoolManager
let pools: Record<string, Pool>
let marginAccount: MarginAccount
const instructions: TransactionInstruction[] = []
// Airdrop
await connection.requestAirdrop(walletPubkey, LAMPORTS_PER_SOL)
// Load programs
config = await MarginClient.getConfig("devnet")
programs = MarginClient.getPrograms(provider, config)
// Load margin pools
poolManager = new PoolManager(programs, provider)
pools = await poolManager.loadAll()
// Create MarginAccount
marginAccount = await MarginAccount.createAccount({
programs,
provider,
owner: walletPubkey,
seed: 0,
pools
})
await marginAccount.refresh()
// Creates instruction for create a new margin account for wallet
await marginAccount.withCreateAccount(instructions)
FAQs
Library for interacting with the Jet margin on-chain programs
The npm package @jet-lab/margin receives a total of 30 weekly downloads. As such, @jet-lab/margin popularity was classified as not popular.
We found that @jet-lab/margin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.