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

onering-solana-sdk

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onering-solana-sdk - npm Package Compare versions

Comparing version 1.5.6 to 1.5.7

src/utils.d.ts

19

package.json
{
"name": "onering-solana-sdk",
"version": "1.5.6",
"version": "1.5.7",
"main": "src/index.js",

@@ -8,18 +8,19 @@ "types": "src/index.d.ts",

"dependencies": {
"@project-serum/anchor": "^0.24.2",
"@quarryprotocol/quarry-sdk": "^5.1.0",
"@saberhq/anchor-contrib": "^1.13.29",
"@saberhq/solana-contrib": "^1.13.29",
"@saberhq/stableswap-sdk": "^1.13.29",
"@saberhq/token-utils": "^1.13.29",
"@saberhq/anchor-contrib": "^1.13.30",
"@saberhq/solana-contrib": "^1.13.30",
"@saberhq/stableswap-sdk": "^1.13.30",
"@saberhq/token-utils": "^1.13.30",
"@solana/buffer-layout": "^4.0.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.43.1",
"@solana/web3.js": "^1.44.2",
"bn.js": "^5.2.1",
"jsbi": "^4.3.0"
"jsbi": "^4.3.0",
"node-fetch": "^2.6.7"
},
"devDependencies": {
"@types/big.js": "^6.1.3",
"@types/bn.js": "^5.1.0"
"@types/bn.js": "^5.1.0",
"@types/node-fetch": "^2.6.2"
}
}

@@ -16,3 +16,2 @@ import type { AnchorTypes } from "@saberhq/anchor-contrib";

declare type Accounts = CollateralManagerTypes["Accounts"];
declare type Defines = CollateralManagerTypes["Defined"];
export declare type RealmData = Accounts["realm"] & {

@@ -43,4 +42,6 @@ depositFeeBasisPoints: number;

};
declare type Defines = CollateralManagerTypes["Defined"];
export declare type CreateRealmArgs = Defines["CreateRealmArgs"];
export declare type UpdateRealmArgs = Defines["UpdateRealmArgs"];
export declare type CollateralManagerError = CollateralManagerTypes["Error"];
export declare type CollateralManagerProgram = CollateralManagerTypes["Program"];

@@ -10,7 +10,8 @@ import type { AnchorTypes } from "@saberhq/anchor-contrib";

declare type Accounts = RouterSaberTypes["Accounts"];
declare type Defines = RouterSaberTypes["Defined"];
export declare type SaberReceiptData = Accounts["receipt"] & {
totalInputUiAmount: number;
};
declare type Defines = RouterSaberTypes["Defined"];
export declare type CreateSaberReceiptArgs = Defines["CreateReceiptArgs"];
export declare type RouterSaberError = RouterSaberTypes["Error"];
export declare type RouterSaberProgram = RouterSaberTypes["Program"];

@@ -10,4 +10,4 @@ import { TransactionEnvelope } from "@saberhq/solana-contrib";

readonly address: PublicKey;
readonly program: CollateralManagerProgram;
private _authority?;
readonly program: CollateralManagerProgram;
constructor(sdk: OneRingSDK, address: PublicKey);

@@ -14,0 +14,0 @@ get provider(): import("@saberhq/solana-contrib").AugmentedProvider;

@@ -16,3 +16,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class PoolWrapper {

@@ -30,6 +30,6 @@ constructor(sdk, address) {

const data = yield this.program.account.pool.fetch(this.address);
data.dustUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.dustAmount);
data.totalLpUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.totalLpAmount);
data.lastYieldUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.lastYieldAmount);
data.currentYieldUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.currentYieldAmount);
data.dustUiAmount = (0, utils_1.getUiAmountSync)(data.dustAmount);
data.totalLpUiAmount = (0, utils_1.getUiAmountSync)(data.totalLpAmount);
data.lastYieldUiAmount = (0, utils_1.getUiAmountSync)(data.lastYieldAmount);
data.currentYieldUiAmount = (0, utils_1.getUiAmountSync)(data.currentYieldAmount);
data.lpIndexBasisPoints = data.lpIndex.basisPoints / 10000;

@@ -36,0 +36,0 @@ data.apyBasisPoints = (0, utils_1.getAPY)(data.totalLpAmount.muln(data.lpIndex.basisPoints).divn(10000), data.lastYieldAmount, data.compoundingTick);

@@ -9,4 +9,4 @@ import { TransactionEnvelope } from "@saberhq/solana-contrib";

readonly address: PublicKey;
readonly program: CollateralManagerProgram;
private _authority?;
readonly program: CollateralManagerProgram;
constructor(sdk: OneRingSDK, address: PublicKey);

@@ -13,0 +13,0 @@ get provider(): import("@saberhq/solana-contrib").AugmentedProvider;

@@ -16,3 +16,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class RealmWrapper {

@@ -31,3 +31,3 @@ constructor(sdk, address) {

const collatMintInfo = yield (0, token_utils_1.getMintInfo)(this.provider, realmData.collatMint);
realmData.collatTotalSupply = (0, utils_1.getUiAmount4Wrapped)(collatMintInfo.supply);
realmData.collatTotalSupply = (0, utils_1.getUiAmountSync)(collatMintInfo.supply);
realmData.depositFeeBasisPoints = realmData.depositFee.basisPoints / 10000;

@@ -71,7 +71,7 @@ realmData.redemptionFeeBasisPoints =

return __awaiter(this, void 0, void 0, function* () {
args.depositFeeBasisPoints = Math.trunc(args.depositFeeBasisPoints * 1e4);
args.redemptionFeeBasisPoints = Math.trunc(args.redemptionFeeBasisPoints * 1e4);
args.stakingFeeBasisPoints = Math.trunc(args.stakingFeeBasisPoints * 1e4);
args.unstakingFeeBasisPoints = Math.trunc(args.unstakingFeeBasisPoints * 1e4);
args.performFeeBasisPoints = Math.trunc(args.performFeeBasisPoints * 1e4);
args.depositFeeBasisPoints = (0, utils_1.getRawBps)(args.depositFeeBasisPoints);
args.redemptionFeeBasisPoints = (0, utils_1.getRawBps)(args.redemptionFeeBasisPoints);
args.stakingFeeBasisPoints = (0, utils_1.getRawBps)(args.stakingFeeBasisPoints);
args.unstakingFeeBasisPoints = (0, utils_1.getRawBps)(args.unstakingFeeBasisPoints);
args.performFeeBasisPoints = (0, utils_1.getRawBps)(args.performFeeBasisPoints);
return new solana_contrib_1.TransactionEnvelope(this.provider, [

@@ -97,12 +97,12 @@ web3_js_1.SystemProgram.createAccount({

return __awaiter(this, void 0, void 0, function* () {
if (args.depositFeeBasisPoints)
args.depositFeeBasisPoints = Math.trunc(args.depositFeeBasisPoints * 1e4);
if (args.redemptionFeeBasisPoints)
args.redemptionFeeBasisPoints = Math.trunc(args.redemptionFeeBasisPoints * 1e4);
if (args.stakingFeeBasisPoints)
args.stakingFeeBasisPoints = Math.trunc(args.stakingFeeBasisPoints * 1e4);
if (args.unstakingFeeBasisPoints)
args.unstakingFeeBasisPoints = Math.trunc(args.unstakingFeeBasisPoints * 1e4);
if (args.performFeeBasisPoints)
args.performFeeBasisPoints = Math.trunc(args.performFeeBasisPoints * 1e4);
if (args.depositFeeBasisPoints !== null)
args.depositFeeBasisPoints = (0, utils_1.getRawBps)(args.depositFeeBasisPoints);
if (args.redemptionFeeBasisPoints !== null)
args.redemptionFeeBasisPoints = (0, utils_1.getRawBps)(args.redemptionFeeBasisPoints);
if (args.stakingFeeBasisPoints !== null)
args.stakingFeeBasisPoints = (0, utils_1.getRawBps)(args.stakingFeeBasisPoints);
if (args.unstakingFeeBasisPoints !== null)
args.unstakingFeeBasisPoints = (0, utils_1.getRawBps)(args.unstakingFeeBasisPoints);
if (args.performFeeBasisPoints !== null)
args.performFeeBasisPoints = (0, utils_1.getRawBps)(args.performFeeBasisPoints);
return new solana_contrib_1.TransactionEnvelope(this.provider, [

@@ -109,0 +109,0 @@ yield this.program.methods

@@ -16,3 +16,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class StrategyWrapper {

@@ -67,3 +67,7 @@ constructor(sdk, address) {

}),
(0, utils_1.getMantissaAmount)(this.provider, vaultData.treasuryMint, amount),
(0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: vaultData.treasuryMint,
amount,
}),
]);

@@ -70,0 +74,0 @@ if (strategyTreasury.instruction) {

@@ -16,3 +16,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class UserWrapper {

@@ -47,3 +47,7 @@ constructor(sdk, address) {

data.rewardUiAmount =
(yield (0, utils_1.getUiAmount)(this.provider, realmData.collatMint, data.lpAmount.muln(poolData.lpIndex.basisPoints))) / 10000;
(yield (0, utils_1.getUiAmount)({
provider: this.provider,
mintKey: realmData.collatMint,
amount: data.lpAmount.muln(poolData.lpIndex.basisPoints),
})) / 10000;
}

@@ -160,3 +164,7 @@ return data;

instructions.push(yield this.program.methods
.deposit(yield (0, utils_1.getMantissaAmount)(this.provider, vaultData.treasuryMint, amount))
.deposit(yield (0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: vaultData.treasuryMint,
amount,
}))
.accounts({

@@ -220,3 +228,7 @@ user: this.address,

instructions.push(yield this.program.methods
.withdraw(yield (0, utils_1.getMantissaAmount)(this.provider, realmData.collatMint, amount))
.withdraw(yield (0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: realmData.collatMint,
amount,
}))
.accounts({

@@ -263,3 +275,3 @@ redeem: {

]);
const [userCollatAta, poolCollat] = yield Promise.all([
const [userCollatAta, poolCollat, rawAmount] = yield Promise.all([
this.findAssociatedTokenAccountFor(realmData.collatMint),

@@ -271,2 +283,7 @@ (0, token_utils_1.getOrCreateATA)({

}),
(0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: realmData.collatMint,
amount,
}),
]);

@@ -281,3 +298,3 @@ if (poolCollat.instruction) {

instructions.push(yield this.program.methods
.stake(yield (0, utils_1.getMantissaAmount)(this.provider, realmData.collatMint, amount))
.stake(rawAmount)
.accounts({

@@ -318,3 +335,3 @@ user: this.address,

]);
const [userCollatAta, poolCollat] = yield Promise.all([
const [userCollatAta, poolCollat, rawAmount] = yield Promise.all([
this.findAssociatedTokenAccountFor(realmData.collatMint),

@@ -326,2 +343,7 @@ (0, token_utils_1.getOrCreateATA)({

}),
(0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: realmData.collatMint,
amount,
}),
]);

@@ -332,3 +354,3 @@ if (poolCollat.instruction) {

instructions.push(yield this.program.methods
.unstake(yield (0, utils_1.getMantissaAmount)(this.provider, realmData.collatMint, amount))
.unstake(rawAmount)
.accounts({

@@ -335,0 +357,0 @@ user: this.address,

@@ -10,4 +10,4 @@ import { TransactionEnvelope } from "@saberhq/solana-contrib";

readonly address: PublicKey;
readonly program: CollateralManagerProgram;
private _authority?;
readonly program: CollateralManagerProgram;
constructor(sdk: OneRingSDK, address: PublicKey);

@@ -14,0 +14,0 @@ get provider(): import("@saberhq/solana-contrib").AugmentedProvider;

@@ -16,3 +16,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class VaultWrapper {

@@ -30,4 +30,4 @@ constructor(sdk, address) {

const data = yield this.program.account.vault.fetch(this.address);
data.totalInputUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.totalInputAmount);
data.totalOutputUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.totalOutputAmount);
data.totalInputUiAmount = (0, utils_1.getUiAmountSync)(data.totalInputAmount);
data.totalOutputUiAmount = (0, utils_1.getUiAmountSync)(data.totalOutputAmount);
return data;

@@ -90,3 +90,3 @@ });

]);
const [userTreasuryAta, realmTreasuryAta, vaultTreasuryAta, poolCollatAta] = yield Promise.all([
const [userTreasuryAta, realmTreasuryAta, vaultTreasuryAta, poolCollatAta, rawAmount,] = yield Promise.all([
user.findAssociatedTokenAccountFor(vaultData.treasuryMint),

@@ -96,6 +96,11 @@ realm.findAssociatedTokenAccountFor(vaultData.treasuryMint),

pool.findAssociatedTokenAccountFor(realmData.collatMint),
(0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: vaultData.treasuryMint,
amount,
}),
]);
return new solana_contrib_1.TransactionEnvelope(this.provider, [
yield this.program.methods
.depositToVault(yield (0, utils_1.getMantissaAmount)(this.provider, vaultData.treasuryMint, amount))
.depositToVault(rawAmount)
.accounts({

@@ -102,0 +107,0 @@ compounder: {

@@ -52,3 +52,3 @@ import BN from "bn.js";

accounts?: Record<any, any>;
mantissaAmount?: BN;
rawAmount?: BN;
}>;

@@ -55,0 +55,0 @@ withdrawOne({ realm, vault, user, amount, }: WithdrawOne): Promise<TransactionEnvelope>;

@@ -18,3 +18,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const utils_1 = require("../../helpers/utils");
const utils_1 = require("../../utils");
class SaberReceiptWrapper {

@@ -37,3 +37,3 @@ constructor(sdk, address) {

const data = yield this.program.account.receipt.fetch(this.address);
data.totalInputUiAmount = (0, utils_1.getUiAmount4Wrapped)(data.totalInputAmount);
data.totalInputUiAmount = (0, utils_1.getUiAmountSync)(data.totalInputAmount);
this._receipt = {

@@ -153,3 +153,3 @@ data,

instructions.push(yield this.program.methods
.deposit(Math.trunc(tolerance * 1e4))
.deposit((0, utils_1.getRawBps)(tolerance))
.accounts({

@@ -187,3 +187,3 @@ bot: botKey || this.provider.wallet.publicKey,

const instructions = [];
let mantissaAmount;
let rawAmount;
let accounts;

@@ -260,3 +260,7 @@ const depositReceiptData = yield user.fetchDepositReceipt(realm);

};
mantissaAmount = yield (0, utils_1.getMantissaAmount)(this.provider, realmData.collatMint, amount);
rawAmount = yield (0, utils_1.getRawAmount)({
provider: this.provider,
mintKey: realmData.collatMint,
amount,
});
}

@@ -266,3 +270,3 @@ return {

accounts,
mantissaAmount,
rawAmount,
};

@@ -273,3 +277,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
const { instructions, accounts, mantissaAmount } = yield this._withdrawInstructions({
const { instructions, accounts, rawAmount } = yield this._withdrawInstructions({
realm,

@@ -280,5 +284,5 @@ vault,

});
if (accounts && mantissaAmount) {
if (accounts && rawAmount) {
instructions.push(yield this.program.methods
.withdrawOne(mantissaAmount)
.withdrawOne(rawAmount)
.accounts(accounts)

@@ -292,3 +296,3 @@ .instruction());

return __awaiter(this, void 0, void 0, function* () {
const { instructions, accounts, mantissaAmount } = yield this._withdrawInstructions({
const { instructions, accounts, rawAmount } = yield this._withdrawInstructions({
realm,

@@ -299,5 +303,5 @@ vault,

});
if (accounts && mantissaAmount) {
if (accounts && rawAmount) {
instructions.push(yield this.program.methods
.withdrawFull(mantissaAmount)
.withdrawFull(rawAmount)
.accounts({

@@ -304,0 +308,0 @@ withdrawOne: accounts,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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