Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@mithraic-labs/psyfi-sdk
Advanced tools
Last updated v1.0.6
yarn
yarn add @solana/web3.js
Program ID | Mainnet Public Key | Devnet Public Key |
---|---|---|
PSYFI_V2 | PSYFiYqguvMXwpDooGdYV6mju92YEbFobbvW617VNcq | 95q3X9ADJv5hWt93oSaPqABPnP1rqfmjgrnto9v83LPK |
PSYSTAKE | pSystkitWgLkzprdAvraP8DSBiXwee715wiSXGJe8yr | 5LrZkBFgDkFiKEePeT2N9VuKfd2k8Rrad9PG6mKGbCRk |
yarn add @mithraic-labs/psyfi-sdk
yarn publish --public
const getVaultsInfo(isMainnet: boolean);
import { getVaultsInfo } from "psyfi-sdk";
const data = await getVaultsInfo(true);
|-- vaults
|-- id: ID of the vault
|-- name: Name of the vault
|-- staking
|-- metadata
|-- isValuePerVaultToken: Price of each vault token
|-- stakePoolKey: Staking Key of vault tokens
|-- stakingApr: Annual percentage rate (0, 30, 60, 180, 360) days.
|-- poolRewards
|-- rewardTokensPerWeek: Amount of reward tokens given out by the vault each week.
|-- multiplier
|-- metadata
|-- usdValuePerRewardToken: Price of the reward token
|-- rewardInUsdPerYearPerRewardUnit: Number of unit rewards staker is eligible for (size of their position * lock up period selected)
|-- rewardPoolApr: Annual percentage rate (0, 30, 60, 180, 360) days.
|-- rewardPoolKey: Vault pool reward address
|-- rewardMintAddress: Reward token address
|-- tokenSymbol: Short form of the token name
|-- poolId: Unique identifier for the pool
|-- deposits
|-- current: Deposit amount in vault
|-- max: Max deposit amount for the vault
|-- strategyType: 0 (Covered Call), 1 (Secured Put)
|-- accounts
|-- optionsUnderlyingMint: SPL token address used as underlying asset for options minted
|-- collateralAssetMint: SPL token address of asset used as collateral for options minted
|-- feeTokenAccount: Solana account for fee collection
|-- vaultOwnershipTokenMint: SPL token address of vault ownership token
|-- vaultAddress: Solana account address for the vault
|-- pythPriceOracle: Price oracle address used for settlement
|-- status
|-- optionsActive: If any option are minted from vault
|-- currentEpoch: Epoch number
|-- nextOptionMintTime: Time for next option mint
|-- nextEpochStartTime: Next epoch start time
|-- isDeprecated: If the vault is deprecated
|-- visibility: 0 - production, 1 - staging, 2 - development
|-- selectedStrike: Strike price for options minted
|-- fees
|-- performance: Performance fee in percentage
|-- withdrawal: Withdrawal fee in percentage
|-- id: Unique identifier for the vault
|-- version: Version of the vaults
|-- valuePerVaultToken: Current value of vault token in collateral asset
|-- apy:
|-- stakingApy: Apy from SOL staking (When collateral asset is a liquid staking token)
|-- weightedApy:
|-- targetDelta: Delta used for strike selection
|-- epochsCounted: Number of epochs included in the calculation
|-- apyAfterFees: Apy after fee deductions
|-- averageSaleYield: Average yield generated from option sale
|-- apyBeforeFees: Apy before fee deductions
|-- averageHistoricalLoss: Average percentage loss when option expire in the money
|-- currentEpochApy: Apy based on projected current epoch yield
|-- movingAverageApy:
|-- apyAfterFees: Apy after fee deductions
|-- epochsCounted: Number of epochs included in the calculation
|-- averageEpochYield: Average yield generated from option sale
|-- apyBeforeFees: Apy before fee deductions
|-- vaultHistory: Array of each epoch's history
|-- epoch: Epoch Number
|-- endingValuePerVaultToken: Value of token at the end of epoch in collateral asset
|-- saleAmount: Amount option was sold for in collateral asset.
|-- percentageLossOnCollateral: Percentage loss on collateral at the end of epoch.
|-- epochHistoryKey: Account storing epoch history
|-- startDate: Epoch start date
|-- optionMinted: Formatted string of option minted with strike price
|-- priceAtExpiry: Price of underlying at expiry
|-- strikePrice: Strike price of option minted
|-- overallYield: Overall yield earned from epoch
|-- saleYield: Yield earned from option sale
{
"vaults":{
"btc-put":{
"name":"BTC SECURED PUT",
"staking":{
"metadata":{
"usdValuePerVaultToken":0.8799150861566609
},
"stakePoolKey":"7waRUqnzcLopivSH3FCBrTPXij63XY4qGnFJ99XjVRaB",
"stakingApr":[
13.623659938287103,
15.667208929030169,
18.663123213214559,
22,
901231231232142
],
"poolRewards":[
{
"rewardTokensPerWeek":1470,
"multiplier":1,
"metadata":{
"usdValuePerRewardToken":1.051,
"rewardInUsdPerYearPerRewardUnit":1.1987663908366946e-7,
"rewardPoolApr":[
13.623659938287103,
15.667208929030169,
18.663123213214559,
22,
901231231232142
]
},
"rewardPoolKey":"33LYcoXVPWzvj4jpihfX5bLMw4irfx614jGoeENF3VTa",
"rewardMintAddress":"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt",
"tokenSymbol":"SRM",
"poolId":1
}
]
},
"deposits":{
"current":528072.232153,
"max":850000
},
"strategyType":1,
"accounts":{
"optionsUnderlyingMint":"9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E",
"collateralAssetMint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"feeTokenAccount":"EfNdRWbRU6NpNd3KZq85PDsdTdsp1SBiG1S6Pebo9yA2",
"vaultOwnershipTokenMint":"Df312h5rL4LxGBmUGvRxD1F5gTUwVbsezNKYMRQteeg4",
"vaultAddress":"792ELQdQ6nZBSBrKjRiJXxH1ZFpNjHktnpMdp2auyXMF",
"pythPriceOracle":"GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU"
},
"status":{
"optionsActive":true,
"currentEpoch":9,
"nextOptionMintTime":1659083400,
"nextEpochStartTime":1659081600,
"isDeprecated":false
},
"visibility":0,
"selectedStrike":18500,
"fees":{
"performance":10,
"withdrawal":0.1
},
"id":"btc-put",
"version":2,
"valuePerVaultToken":0.8803702375694843,
"apy":{
"weightedApy":{
"targetDelta":0.075,
"epochsCounted":5,
"apyAfterFees":9.160780173655736,
"averageSaleYield":0.16870302234227325,
"apyBeforeFees":10.22809414018675,
"averageHistoricalLoss":0
},
"currentEpochApy":13.55016666193871,
"stakingApy":0,
"movingAverageApy":{
"apyAfterFees":10.171200641996037,
"epochsCounted":4,
"averageEpochYield":0.20717011873986652,
"apyBeforeFees":11.362117467964561
}
},
"vaultHistory":[
{
"epoch":3,
"endingValuePerVaultToken":0.862161239511,
"saleAmount":429.3282,
"percentageLossOnCollateral":13.997020408163266,
"epochHistoryKey":"EfsEWATN4LL7hhMedinKxaayH4rPGzK6WhKDxMmYGYmT",
"startDate":1654848000,
"optionMinted":"17 JUN EXP - BTC PUT STRIKE $24500",
"priceAtExpiry":21070.73,
"strikePrice":24500,
"overallYield":-13.783876048900002,
"saleYield":0.21314435926326425
},
{
"strikePrice":15000,
"saleAmount":2437.82448,
"optionMinted":"24 JUN EXP - BTC PUT STRIKE $15000",
"priceAtExpiry":20911.0525,
"epoch":4,
"startDate":1655452800,
"overallYield":0.8392309928133335,
"saleYield":0.8392309928133335,
"endingValuePerVaultToken":0.869396763841,
"percentageLossOnCollateral":0,
"epochHistoryKey":"68u71YZfA3msFjvRwrAKV7eC2JQstevzYyGjGs7MAWgD"
}
]
}
}
}
const getAllUserVaultPositions = async (
userWallet: PublicKey,
connection: Connection,
isMainnet = true
)
import { getAllUserVaultPositions } from "psyfi-sdk";
const userWallet = new PublicKey(
"Fbhqzu1S9x9dik7Sjxt3iWZbUXUU2WSfFyeqGcKuBoR7"
);
const connection = new Connection("https://ssc-dao.genesysgo.net/");
const userPosition = await getAllUserVaultPositions(
userWallet,
connection,
);
{
scnsol-sol-call': {
totalUserVaultTokens: 0,
valuePerVaultToken: 1.0251216147403115,
rewardMultiplier: 1,
pendingWithdrawalInVaultTokens: 0,
claimableRewards: {
SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt: {
totalClaimableAmount: 0.186569,
tokenSymbol: 'SRM',
epochsToClaim: { '1': [Array] }
}
},
vaultTokensInWallet: 0,
vaultTokensStaked: 0,
remainingLockupInSeconds: 0,
vaultTokenDecimals: 9,
pendingCollateralAssetDeposits: 0
},
'stsol-call': {
totalUserVaultTokens: 8403485,
valuePerVaultToken: 1.0251216147403115,
rewardMultiplier: 1,
pendingWithdrawalInVaultTokens: 0,
claimableRewards: {
SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt: {
totalClaimableAmount: 0.186569,
tokenSymbol: 'SRM',
epochsToClaim: { '1': [Array] }
}
},
vaultTokensInWallet: 0,
vaultTokensStaked: 8403485,
remainingLockupInSeconds: 86400, // Staked tokes are locked up 1 more day.
vaultTokenDecimals: 9,
pendingCollateralAssetDeposits: 0
}
}
const getUserVaultPosition = async (
walletAddress: PublicKey,
vaultName: string,
connection: Connection,
isMainnet = true
)
import { getUserVaultPosition } from "psyfi-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://ssc-dao.genesysgo.net/");
const userWallet = new PublicKey(
"Fbhqzu1S9x9dik7Sjxt3iWZbUXUU2WSfFyeqGcKuBoR7"
);
const userPosition = await getUserVaultPosition(
userWallet,
"sol-call",
connection,
);
{
totalUserVaultTokens: 8403485,
valuePerVaultToken: 1.0251216147403115,
rewardMultiplier: 1,
pendingWithdrawalInVaultTokens: 0,
claimableRewards: {
SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt: {
totalClaimableAmount: 0.186569,
tokenSymbol: 'SRM',
epochsToClaim: { '1': [Array] }
}
},
vaultTokensInWallet: 0,
vaultTokensStaked: 8403485,
remainingLockupInSeconds: 0,
vaultTokenDecimals: 9,
pendingCollateralAssetDeposits: 0
}
import { pdas } from "psyfi-sdk";
const userAuthority = pdas.derivePoolAuthority();
const deriveUnderlyingPoolKey = (underlyingMint: PublicKey)
const deriveStablePoolKey = (stableMint: PublicKey)
const deriveCallOptionMint = (euroMetaKey: PublicKey)
const deriveCallWriterMint = (euroMetaKey: PublicKey)
const derivePutOptionMint = (euroMetaKey: PublicKey)
const derivePutWriterMint = (euroMetaKey: PublicKey)
const derivePoolAuthority();
const deriveStakingRecord = async (
programId: PublicKey,
recordOwner: PublicKey,
stakePool: PublicKey
)
const deriveRewardRecord = async (
programId: PublicKey,
rewardPool: PublicKey,
rewardEpoch: number
)
const deriveVaultAccount = async (
programKey: PublicKey,
collateralAssetMint: PublicKey,
quoteAssetMint: PublicKey,
uniqueSeed: number,
strategyType: number
)
const deriveEpochHistory = async (
programKey: PublicKey,
vaultAccount: PublicKey,
epoch: number
)
const deriveVaultAuthority = async (
programKey: PublicKey,
vaultAccount: PublicKey
)
const deriveVaultCollateralAccount = async (
programKey: PublicKey,
vaultAccount: PublicKey
)
const deriveVaultTokenMint = async (
programKey: PublicKey,
vaultAccount: PublicKey
)
const deriveVaultTokenAccount = async (
programKey: PublicKey,
vaultAccount: PublicKey
)
const deriveWithdrawalCollateralAccount = async (
programKey: PublicKey,
vaultAccount: PublicKey
)
const deriveDepositReceipt = async (
programKey: PublicKey,
userAuthority: PublicKey,
vaultAccount: PublicKey,
epoch: number
)
const deriveWithdrawalReceipt = async (
programKey: PublicKey,
userAuthority: PublicKey,
vaultAccount: PublicKey,
epoch: number
)
const deriveOpenOrdersAddress = async (
serumMarket: PublicKey,
authority: PublicKey,
serumDexProgramKey: PublicKey
)
const deriveMarketAuthority = async (
serumMarketKey: PublicKey,
serumDexProgramKey: PublicKey
)
const deriveRequestQueue = (
optionMintKey: PublicKey,
priceCurrencyKey: PublicKey
)
const deriveCoinVault = (
optionMintKey: PublicKey,
priceCurrencyKey: PublicKey
)
const derivePCVault = (
optionMintKey: PublicKey,
priceCurrencyKey: PublicKey
)
const deriveSerumMarketAddress = (
optionMintKey: PublicKey,
priceCurrencyKey: PublicKey
)
const deriveSerumVaultOwner = async (
serumMarket: PublicKey,
serumDexProgramKey: PublicKey
)
const getActiveVaultMarkets = async (
isMainnet = true
)
import { vaultBidding } from "psyfi-sdk";
const activeVaultBiddingMarkets = await vaultBidding.getActiveVaultMarkets(true);
[
{
"isCall": true,
"amount": 3.8,
"serumMarketKey": "GAzxTQhujhitUt36TWkPuxxR7o9CN2qPSFMKJrgkZeCn",
"expirationTimestamp": 1664687098000,
"strike": 30000,
"endTimestamp": 1664601637000,
"collateralKey": "E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF",
"optionMintKey": "BtqTXRHhLLkqM2fibfqg4fRBpGpTXU4x8PajFpzBfoH4",
"euroMetaAddress": "XsoQc96WEBai5TJpFFUMZEYTSBomo3YZWGZys4bciuU",
"underlyingMint": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
"stableMint": "E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF"
},
{
"isCall": true,
"amount": 3.8,
"serumMarketKey": "BnLsvJa9SmpQXqawKaR7C8mrW4EbGwqkmhfXYfpXWtTB",
"expirationTimestamp": 1664687098000,
"strike": 30000,
"endTimestamp": 1664601637000,
"euroMetaAddress": "XsoQc96WEBai5TJpFFUMZEYTSBomo3YZWGZys4bciuU",
"collateralKey": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
"optionMintKey": "BtqTXRHhLLkqM2fibfqg4fRBpGpTXU4x8PajFpzBfoH4",
"underlyingMint": "C6kYXcaRUMqeBF5fhg165RWU7AnpT9z92fvKNoMqjmz6",
"stableMint": "E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF"
},
{
"isCall": false,
"amount": 50,
"serumMarketKey": "BNw1rt21EZQw5KfZLaAUCAziQ9vecvMh1JNdvdz6TfHW",
"expirationTimestamp": 1672387300000,
"strike": 20,
"endTimestamp": 1672387200000,
"collateralKey": "E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF",
"optionMintKey": "58nC3yncBnir2p9CDeAPzezR9rfVmmzpWym53svxeTq6",
"euroMetaAddress": "3CykuF8d1FrQYTfANZzZSCmmQUdkkJFj7ZZzTdxpwS7o",
"underlyingMint": "So11111111111111111111111111111111111111112",
"stableMint": "E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF"
}
]
const placeBid = async (
euroMetaAddress: string,
collateralKey: string,
optionMintKey: string,
price: number,
size: number,
wallet: AnchorWallet,
isMainnet: boolean,
)
import { vaultBidding } from "psyfi-sdk";
import { useAnchorWallet } from '@solana/wallet-adapter-react';
const wallet = useAnchorWallet();
await vaultBidding.placeBid(
"3CykuF8d1FrQYTfANZzZSCmmQUdkkJFj7ZZzTdxpwS7o", // euroMeta address
"E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF", // collateralKey
"58nC3yncBnir2p9CDeAPzezR9rfVmmzpWym53svxeTq6", // optionMintKey
200, // price per contract
2, // contract quantity
wallet,
true // mainnet
)
Calling the function will prompt the user to sign the transaction with their connected wallet Once the transaction is confirmed, the function returns the transaction signature:
"3Nhc34rD1aiZNj6XHjVezXp9anPumDhm9ZErFSsEp3SfwPgds94Sjnb3ugUzdDjF425KsDxi16sZ1uGh9Dcspbkp"
const cancelAllBidsForMarket = async (
serumMarketKey: string,
euroMetaAddress: string,
collateralKey: string,
optionMintKey: string
wallet: AnchorWallet,
isMainnet = true,
)
import { vaultBidding } from "psyfi-sdk";
import { useAnchorWallet } from '@solana/wallet-adapter-react';
const wallet = useAnchorWallet();
await vaultBidding.cancelAllBidsForMarket(
"BNw1rt21EZQw5KfZLaAUCAziQ9vecvMh1JNdvdz6TfHW",
"3CykuF8d1FrQYTfANZzZSCmmQUdkkJFj7ZZzTdxpwS7o",
"E6Z6zLzk8MWY3TY8E87mr88FhGowEPJTeMWzkqtL6qkF",
"58nC3yncBnir2p9CDeAPzezR9rfVmmzpWym53svxeTq6"
wallet,
false,
)
Calling the function will prompt the user to sign the transaction with their connected wallet Once the transaction is confirmed, the function returns the transaction signature:
"3Nhc34rD1aiZNj6XHjVezXp9anPumDhm9ZErFSsEp3SfwPgds94Sjnb3ugUzdDjF425KsDxi16sZ1uGh9Dcspbkp"
FAQs
yarn
The npm package @mithraic-labs/psyfi-sdk receives a total of 55 weekly downloads. As such, @mithraic-labs/psyfi-sdk popularity was classified as not popular.
We found that @mithraic-labs/psyfi-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.