@frakters/nft-lending-v2
Version:
Client library for interacting with nft lenging solana program
810 lines (809 loc) • 29.4 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PoolWhitelistData = exports.BidData = exports.AuctionData = exports.VaultData = exports.getSafetyDepositBoxAddress = exports.activateVault = exports.getSafetyDepositBox = exports.addToWhitelist = exports.initVault = exports.withdrawNFT = exports.depositNFT = exports.decodeSafetyDeposit = exports.decodeExternalPriceAccount = exports.decodeVault = exports.decodeAuction = exports.decodeBid = exports.decodePoolWhitelist = exports.VAULT_SCHEMA = exports.Auction = exports.ExternalPriceAccount = exports.SafetyDepositBox = exports.Vault = exports.MAX_EXTERNAL_ACCOUNT_SIZE = exports.MAX_POOL_WHITELIST_SIZE = exports.MAX_BID_SIZE = exports.MAX_AUCTION_SIZE = exports.MAX_SAFETY_DEPOSIT_SIZE = exports.MAX_VAULT_SIZE = exports.VaultState = exports.WhitelistType = exports.VaultKey = exports.VAULT_PREFIX = exports.findProgramAddress = exports.toPublicKey = void 0;
const web3_js_1 = require("@solana/web3.js");
const ids_1 = require("./utils/ids");
const borsh_1 = require("borsh");
const Borsh = __importStar(require("./utils/borsh"));
Borsh.extendBorsh();
// import { toPublicKey } from './utils';
exports.toPublicKey = (key) => {
if (typeof key !== 'string') {
return key;
}
const result = new web3_js_1.PublicKey(key);
return result;
};
exports.findProgramAddress = (seeds, programId) => __awaiter(void 0, void 0, void 0, function* () {
const key = 'pda-' + seeds.reduce((agg, item) => agg + item.toString('hex'), '') + programId.toString();
// let cached = localStorage.getItem(key);
// if (cached) {
// const value = JSON.parse(cached);
// return [new PublicKey(value.key), parseInt(value.nonce)] as [
// PublicKey,
// number,
// ];
// }
const result = yield web3_js_1.PublicKey.findProgramAddress(seeds, programId);
// localStorage.setItem(
// key,
// JSON.stringify({
// key: result[0].toBase58(),
// nonce: result[1],
// }),
// );
return result;
});
exports.VAULT_PREFIX = 'vault';
var VaultKey;
(function (VaultKey) {
VaultKey[VaultKey["Uninitialized"] = 0] = "Uninitialized";
VaultKey[VaultKey["VaultV1"] = 3] = "VaultV1";
VaultKey[VaultKey["SafetyDepositBoxV1"] = 1] = "SafetyDepositBoxV1";
VaultKey[VaultKey["ExternalPriceAccountV1"] = 2] = "ExternalPriceAccountV1";
VaultKey[VaultKey["AuctionV1"] = 4] = "AuctionV1";
VaultKey[VaultKey["BidV1"] = 5] = "BidV1";
VaultKey[VaultKey["PoolWhitelistV1"] = 6] = "PoolWhitelistV1";
})(VaultKey = exports.VaultKey || (exports.VaultKey = {}));
var WhitelistType;
(function (WhitelistType) {
WhitelistType[WhitelistType["CreatorWhitelist"] = 0] = "CreatorWhitelist";
WhitelistType[WhitelistType["SingleNFTWhitelist"] = 1] = "SingleNFTWhitelist";
})(WhitelistType = exports.WhitelistType || (exports.WhitelistType = {}));
var VaultState;
(function (VaultState) {
VaultState[VaultState["Inactive"] = 0] = "Inactive";
VaultState[VaultState["Active"] = 1] = "Active";
VaultState[VaultState["Combined"] = 2] = "Combined";
VaultState[VaultState["Deactivated"] = 3] = "Deactivated";
VaultState[VaultState["AuctionStarted"] = 4] = "AuctionStarted";
})(VaultState = exports.VaultState || (exports.VaultState = {}));
exports.MAX_VAULT_SIZE = 1 + 32 + 32 + 32 + 32 + 1 + 32 + 1 + 32 + 1 + 1 + 8 + 32 + 8 + 7 + 8; // added priceMint and fractionsSupply
exports.MAX_SAFETY_DEPOSIT_SIZE = 1 + 32 + 32 + 32 + 8;
exports.MAX_AUCTION_SIZE = 1 + 32 + 32 + 8 + 8 + 8 + 8 + 8 + 1 + 1 + 8 + 1 + 8;
exports.MAX_BID_SIZE = 1 + 32 + 32 + 8 + 8 + 8 + 1;
exports.MAX_POOL_WHITELIST_SIZE = 1 + 32 + 32 + 1;
exports.MAX_EXTERNAL_ACCOUNT_SIZE = 1 + 8 + 32 + 1;
class Vault {
constructor(args) {
this.key = VaultKey.VaultV1;
this.tokenProgram = args.tokenProgram;
this.fractionMint = args.fractionMint;
this.authority = args.authority;
this.fractionTreasury = args.fractionTreasury;
this.redeemTreasury = args.redeemTreasury;
this.allowFurtherShareCreation = args.allowFurtherShareCreation;
this.pricingLookupAddress = args.pricingLookupAddress;
this.priceMint = args.priceMint;
this.fractionsSupply = args.fractionsSupply;
this.tokenTypeCount = args.tokenTypeCount;
this.state = args.state;
this.lockedPricePerShare = args.lockedPricePerShare;
}
}
exports.Vault = Vault;
class SafetyDepositBox {
constructor(args) {
this.key = VaultKey.SafetyDepositBoxV1;
this.vault = args.vault;
this.tokenMint = args.tokenMint;
this.store = args.store;
this.order = args.order;
}
}
exports.SafetyDepositBox = SafetyDepositBox;
class ExternalPriceAccount {
constructor(args) {
this.key = VaultKey.ExternalPriceAccountV1;
this.pricePerShare = args.pricePerShare;
this.priceMint = args.priceMint;
this.allowedToCombine = args.allowedToCombine;
}
}
exports.ExternalPriceAccount = ExternalPriceAccount;
class Auction {
constructor(args) {
this.key = VaultKey.AuctionV1;
this.vault = args.vault;
this.current_winning_bid = args.current_winning_bid;
this.version = args.version;
this.started_at = args.started_at;
this.ending_at = args.ending_at;
this.end_auction_gap = args.end_auction_gap;
this.min_tick_size = args.min_tick_size;
this.is_started = args.is_started;
this.is_enabled = args.is_enabled;
this.total_uncancelled_bids = args.total_uncancelled_bids;
this.gap_tick_size_percentage = args.gap_tick_size_percentage;
this.instant_sale_price = args.instant_sale_price;
}
}
exports.Auction = Auction;
class InitVaultArgs {
constructor(args) {
this.instruction = 0;
this.allowFurtherShareCreation = false;
this.allowFurtherShareCreation = args.allowFurtherShareCreation;
}
}
class AddToWhitelistArgs {
constructor(args) {
this.is_creator = args.is_creator;
this.instruction = args.instruction;
}
}
// class WithdrawFractionalSharesArgs {
// instruction: number = 7;
// allowFurtherShareCreation: BN;
// constructor(args: { amount: BN }) {
// this.allowFurtherShareCreation = args.allowFurtherShareCreation;
// }
// }
class AmountArgs {
constructor(args) {
this.instruction = args.instruction;
this.amount = args.amount;
}
}
class InstructionArgs {
constructor(args) {
this.instruction = args.instruction;
}
}
class NumberOfShareArgs {
constructor(args) {
this.instruction = args.instruction;
this.numberOfShares = args.numberOfShares;
}
}
class ActivateVaultArgs {
constructor(args) {
this.instruction = args.instruction;
this.numberOfShares = args.numberOfShares;
this.pricePerShare = args.pricePerShare;
}
}
class UpdateExternalPriceAccountArgs {
constructor(args) {
this.instruction = 9;
this.externalPriceAccount = args.externalPriceAccount;
}
}
exports.VAULT_SCHEMA = new Map([
[
InitVaultArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['allowFurtherShareCreation', 'u8'],
],
},
],
[
AmountArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['amount', 'u64'],
],
},
],
[
InstructionArgs,
{
kind: 'struct',
fields: [['instruction', 'u8']],
},
],
[
AddToWhitelistArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['is_creator', 'u8'],
],
},
],
[
NumberOfShareArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['numberOfShares', 'u64'],
],
},
],
[
ActivateVaultArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['numberOfShares', 'u64'],
['pricePerShare', 'u64'],
],
},
],
[
UpdateExternalPriceAccountArgs,
{
kind: 'struct',
fields: [
['instruction', 'u8'],
['externalPriceAccount', ExternalPriceAccount],
],
},
],
[
Vault,
{
kind: 'struct',
fields: [
['key', 'u8'],
['tokenProgram', 'pubkeyAsString'],
['fractionMint', 'pubkeyAsString'],
['authority', 'pubkeyAsString'],
['fractionTreasury', 'pubkeyAsString'],
['redeemTreasury', 'pubkeyAsString'],
['allowFurtherShareCreation', 'u8'],
['pricingLookupAddress', 'pubkeyAsString'],
['price_mint', 'pubkeyAsString'],
['fractions_supply', 'u64'],
['tokenTypeCount', 'u8'],
['state', 'u8'],
['lockedPricePerShare', 'u64'],
],
},
],
[
SafetyDepositBox,
{
kind: 'struct',
fields: [
['key', 'u8'],
['vault', 'pubkeyAsString'],
['tokenMint', 'pubkeyAsString'],
['store', 'pubkeyAsString'],
['order', 'u64'],
],
},
],
[
ExternalPriceAccount,
{
kind: 'struct',
fields: [
['key', 'u8'],
['pricePerShare', 'u64'],
['priceMint', 'pubkeyAsString'],
['allowedToCombine', 'u8'],
],
},
],
]);
exports.decodePoolWhitelist = (buffer) => {
// const metadata = deserializeUnchecked(
// METADATA_SCHEMA,
// Metadata,
// buffer,
// ) as Metadata;
// return metadata;
return PoolWhitelistData.deserialize(buffer);
// return deserializeUnchecked(VAULT_SCHEMA, Vault, buffer) as Vault;
};
exports.decodeBid = (buffer) => {
// const metadata = deserializeUnchecked(
// METADATA_SCHEMA,
// Metadata,
// buffer,
// ) as Metadata;
// return metadata;
return BidData.deserialize(buffer);
// return deserializeUnchecked(VAULT_SCHEMA, Vault, buffer) as Vault;
};
exports.decodeAuction = (buffer) => {
// const metadata = deserializeUnchecked(
// METADATA_SCHEMA,
// Metadata,
// buffer,
// ) as Metadata;
// return metadata;
return AuctionData.deserialize(buffer);
// return deserializeUnchecked(VAULT_SCHEMA, Vault, buffer) as Vault;
};
exports.decodeVault = (buffer) => {
// const metadata = deserializeUnchecked(
// METADATA_SCHEMA,
// Metadata,
// buffer,
// ) as Metadata;
// return metadata;
return VaultData.deserialize(buffer);
// return deserializeUnchecked(VAULT_SCHEMA, Vault, buffer) as Vault;
};
exports.decodeExternalPriceAccount = (buffer) => {
return borsh_1.deserializeUnchecked(exports.VAULT_SCHEMA, ExternalPriceAccount, buffer);
};
exports.decodeSafetyDeposit = (buffer) => {
return borsh_1.deserializeUnchecked(exports.VAULT_SCHEMA, SafetyDepositBox, buffer);
};
function depositNFT(poolWhitelist, userNftTokenAccount, nftMint, store, userPubkey, transfer_authority_info, fractionalTreasury, fractionMint, userFractionsTokenAccount, vault, instructions, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
const data = Buffer.from(borsh_1.serialize(exports.VAULT_SCHEMA, new InstructionArgs({ instruction: 2 })));
const fractionMintAuthority = (yield exports.findProgramAddress([Buffer.from(exports.VAULT_PREFIX), exports.toPublicKey(vaultProgramId).toBuffer(), exports.toPublicKey(vault).toBuffer()], exports.toPublicKey(vaultProgramId)))[0];
// console.log('fractionMintAuthority: ', fractionMintAuthority.toBase58());
const safetyDepositBox = yield getSafetyDepositBox(vault, nftMint, vaultProgramId);
const keys = [
{
pubkey: exports.toPublicKey(safetyDepositBox),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(userNftTokenAccount),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(nftMint),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(store),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(userPubkey),
isSigner: true,
isWritable: true,
},
{
pubkey: exports.toPublicKey(transfer_authority_info),
isSigner: true,
isWritable: true,
},
{
pubkey: ids_1.programIds().token,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SystemProgram.programId,
isSigner: false,
isWritable: false,
},
{
pubkey: exports.toPublicKey(fractionalTreasury),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(fractionMint),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(fractionMintAuthority),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(userFractionsTokenAccount),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(poolWhitelist),
isSigner: false,
isWritable: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: exports.toPublicKey(vaultProgramId),
data: data,
}));
});
}
exports.depositNFT = depositNFT;
function withdrawNFT(userPubkey, userNftTokenAccount, nftMint, store,
// userPubkey: StringPublicKey,
fractions_transfer_authority_info, fractionalTreasury, fractionMint, userFractionsTokenAccount, vault, instructions, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
const data = Buffer.from(borsh_1.serialize(exports.VAULT_SCHEMA, new InstructionArgs({ instruction: 3 })));
const nftTransferAuthority = (yield exports.findProgramAddress([Buffer.from(exports.VAULT_PREFIX), exports.toPublicKey(vaultProgramId).toBuffer(), exports.toPublicKey(vault).toBuffer()], exports.toPublicKey(vaultProgramId)))[0];
// console.log('fractions_transfer_authority_info: ', fractions_transfer_authority_info)
// console.log('nftTransferAuthority: ', nftTransferAuthority.toBase58())
const safetyDepositBox = yield getSafetyDepositBox(vault, nftMint, vaultProgramId);
console.log({
userPubkey,
userNftTokenAccount,
nftMint,
store,
// userPubkey: StringPublicKey,
fractions_transfer_authority_info,
fractionalTreasury,
fractionMint,
userFractionsTokenAccount,
vault,
instructions,
vaultProgramId,
});
// let destination_info = next_account_info(account_info_iter)?;
// let safety_deposit_info = next_account_info(account_info_iter)?;
// let store_info = next_account_info(account_info_iter)?;
// let vault_info = next_account_info(account_info_iter)?;
// let fraction_mint_info = next_account_info(account_info_iter)?;
// let transfer_authority_info = next_account_info(account_info_iter)?;
// let token_program_info = next_account_info(account_info_iter)?;
// let rent_info = next_account_info(account_info_iter)?;
// let source_info = next_account_info(account_info_iter)?;
// let fraction_treasury_info = next_account_info(account_info_iter)?;
// let vault_info = next_account_info(account_info_iter)?;
// let user_transfer_authority_info = next_account_info(account_info_iter)?;
const keys = [
{
pubkey: exports.toPublicKey(userNftTokenAccount),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(safetyDepositBox),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(store),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(fractionMint),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(nftTransferAuthority),
isSigner: false,
isWritable: true,
},
{
pubkey: ids_1.programIds().token,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: exports.toPublicKey(userFractionsTokenAccount),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(fractionalTreasury),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(userPubkey),
isSigner: true,
isWritable: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: exports.toPublicKey(vaultProgramId),
data: data,
}));
});
}
exports.withdrawNFT = withdrawNFT;
function initVault(allowFurtherShareCreation, fractionalMint, priceMint, redeemTreasury, fractionalTreasury, vault, vaultAuthority,
// pricingLookupAddress: StringPublicKey,
instructions, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
const data = Buffer.from(borsh_1.serialize(exports.VAULT_SCHEMA, new InstructionArgs({ instruction: 0 })));
const keys = [
{
pubkey: exports.toPublicKey(fractionalMint),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(priceMint),
isSigner: false,
isWritable: false,
},
{
pubkey: exports.toPublicKey(redeemTreasury),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(fractionalTreasury),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vaultAuthority),
isSigner: false,
isWritable: false,
},
// {
// pubkey: toPublicKey(pricingLookupAddress),
// isSigner: false,
// isWritable: false,
// },
{
pubkey: ids_1.programIds().token,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: exports.toPublicKey(vaultProgramId),
data: data,
}));
});
}
exports.initVault = initVault;
function addToWhitelist(is_creator, userPubkey, whitelisted_address, whitelist_info, vault, instructions, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
const data = Buffer.from(borsh_1.serialize(exports.VAULT_SCHEMA, new AddToWhitelistArgs({ instruction: 4, is_creator })));
const keys = [
{
pubkey: exports.toPublicKey(userPubkey),
isSigner: true,
isWritable: true,
},
{
pubkey: exports.toPublicKey(whitelist_info),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(whitelisted_address),
isSigner: false,
isWritable: true,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: ids_1.programIds().token,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: exports.toPublicKey(vaultProgramId),
data: data,
}));
});
}
exports.addToWhitelist = addToWhitelist;
function getSafetyDepositBox(vault, tokenMint, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
return (yield exports.findProgramAddress([Buffer.from(exports.VAULT_PREFIX), exports.toPublicKey(vault).toBuffer(), exports.toPublicKey(tokenMint).toBuffer()], exports.toPublicKey(vaultProgramId)))[0].toBase58();
});
}
exports.getSafetyDepositBox = getSafetyDepositBox;
function activateVault(vault, adminPubkey, vaultAuthority, instructions, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
const value = new InstructionArgs({ instruction: 1 });
const data = Buffer.from(borsh_1.serialize(exports.VAULT_SCHEMA, value));
// let vault_info = next_account_info(account_info_iter)?;
// let admin_info = next_account_info(account_info_iter)?;
// let vault_authority_info = next_account_info(account_info_iter)?;
// let token_program_info = next_account_info(account_info_iter)?;
// let clock_account_info = next_account_info(account_info_iter)?;
// let system_program_info = next_account_info(account_info_iter)?;
const keys = [
{
pubkey: exports.toPublicKey(vault),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(adminPubkey),
isSigner: false,
isWritable: true,
},
{
pubkey: exports.toPublicKey(vaultAuthority),
isSigner: true,
isWritable: false,
},
{
pubkey: ids_1.programIds().token,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SystemProgram.programId,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: exports.toPublicKey(vaultProgramId),
data,
}));
});
}
exports.activateVault = activateVault;
function getSafetyDepositBoxAddress(vault, tokenMint, vaultProgramId) {
return __awaiter(this, void 0, void 0, function* () {
return (yield exports.findProgramAddress([Buffer.from(exports.VAULT_PREFIX), exports.toPublicKey(vault).toBuffer(), exports.toPublicKey(tokenMint).toBuffer()], exports.toPublicKey(vaultProgramId)))[0].toBase58();
});
}
exports.getSafetyDepositBoxAddress = getSafetyDepositBoxAddress;
class VaultData extends Borsh.Data {
constructor(args) {
super(args);
this.key = VaultKey.VaultV1;
}
}
exports.VaultData = VaultData;
VaultData.SCHEMA = Borsh.struct(VaultData, [
['key', 'u8'],
['tokenProgram', 'pubkeyAsString'],
['fractionMint', 'pubkeyAsString'],
['authority', 'pubkeyAsString'],
['fractionTreasury', 'pubkeyAsString'],
['redeemTreasury', 'pubkeyAsString'],
['allowFurtherShareCreation', 'u8'],
['pricingLookupAddress', 'pubkeyAsString'],
['priceMint', 'pubkeyAsString'],
['fractionsSupply', 'u64'],
['createdAt', 'u64'],
['tokenTypeCount', 'u64'],
['state', 'u8'],
['lockedPricePerShare', 'u64'],
]);
class AuctionData extends Borsh.Data {
constructor(args) {
super(args);
this.key = VaultKey.AuctionV1;
}
}
exports.AuctionData = AuctionData;
AuctionData.SCHEMA = Borsh.struct(AuctionData, [
['key', 'u8'],
['vault', 'pubkeyAsString'],
['current_winning_bid', 'pubkeyAsString'],
['version', 'u64'],
['started_at', 'u64'],
['ending_at', 'u64'],
['end_auction_gap', 'u64'],
['min_tick_size', 'u64'],
['is_started', 'u8'],
['is_enabled', 'u8'],
['total_uncancelled_bids', 'u64'],
['gap_tick_size_percentage', 'u8'],
['instant_sale_price', 'u64'],
]);
// pub key: Key,
// /// Store token program used
// pub auction: Pubkey,
// pub bidder: Pubkey,
// pub bid_amount_per_share: u64,
// pub version: u64,
// pub placed_at: u64,
// pub is_canceled: bool,
class BidData extends Borsh.Data {
constructor(args) {
super(args);
this.key = VaultKey.BidV1;
}
}
exports.BidData = BidData;
BidData.SCHEMA = Borsh.struct(BidData, [
['key', 'u8'],
['auction', 'pubkeyAsString'],
['bidder', 'pubkeyAsString'],
['bid_amount_per_share', 'u64'],
['version', 'u64'],
['placed_at', 'u64'],
['is_canceled', 'u8'],
]);
// pub key: Key,
// /// Store token program used
// pub vault: Pubkey,
// pub whitelisted_address: Pubkey,
// pub whitelist_type: WhitelistType,
class PoolWhitelistData extends Borsh.Data {
constructor(args) {
super(args);
this.key = VaultKey.PoolWhitelistV1;
}
}
exports.PoolWhitelistData = PoolWhitelistData;
PoolWhitelistData.SCHEMA = Borsh.struct(PoolWhitelistData, [
['key', 'u8'],
['vault', 'pubkeyAsString'],
['whitelisted_address', 'pubkeyAsString'],
['whitelist_type', 'u8'],
]);