Socket
Socket
Sign inDemoInstall

nft-lend

Package Overview
Dependencies
7
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.3.1

dist/src/setup.d.ts

8

dist/src/generated/instructions/repay.d.ts

@@ -30,9 +30,5 @@ /**

discriminator: Array<number>;
interest: bigint;
};
export type RepayInstructionDataArgs = {
interest: number | bigint;
};
export type RepayInstructionDataArgs = {};
export declare function getRepayInstructionDataSerializer(): Serializer<RepayInstructionDataArgs, RepayInstructionData>;
export type RepayInstructionArgs = RepayInstructionDataArgs;
export declare function repay(context: Pick<Context, 'programs'>, input: RepayInstructionAccounts & RepayInstructionArgs): TransactionBuilder;
export declare function repay(context: Pick<Context, 'programs'>, input: RepayInstructionAccounts): TransactionBuilder;

@@ -15,6 +15,3 @@ "use strict";

function getRepayInstructionDataSerializer() {
return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([
['discriminator', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 8 })],
['interest', (0, serializers_1.u64)()],
], { description: 'RepayInstructionData' }), (value) => ({
return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([['discriminator', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 8 })]], { description: 'RepayInstructionData' }), (value) => ({
...value,

@@ -80,4 +77,2 @@ discriminator: [234, 103, 67, 82, 208, 234, 219, 166],

};
// Arguments.
const resolvedArgs = { ...input };
// Default values.

@@ -104,3 +99,3 @@ if (!resolvedAccounts.sysvarInstructions.value) {

// Data.
const data = getRepayInstructionDataSerializer().serialize(resolvedArgs);
const data = getRepayInstructionDataSerializer().serialize({});
// Bytes Created On Chain.

@@ -107,0 +102,0 @@ const bytesCreatedOnChain = 0;

@@ -12,12 +12,12 @@ /**

mint: Option<PublicKey>;
basisPoints: bigint;
principal: bigint;
decimals: number;
interest: Option<bigint>;
interestBps: Option<bigint>;
};
export type AmountArgs = {
mint: OptionOrNullable<PublicKey>;
basisPoints: number | bigint;
principal: number | bigint;
decimals: number;
interest: OptionOrNullable<number | bigint>;
interestBps: OptionOrNullable<number | bigint>;
};
export declare function getAmountSerializer(): Serializer<AmountArgs, Amount>;

@@ -15,5 +15,5 @@ "use strict";

['mint', (0, serializers_1.option)((0, serializers_1.publicKey)())],
['basisPoints', (0, serializers_1.u64)()],
['principal', (0, serializers_1.u64)()],
['decimals', (0, serializers_1.u8)()],
['interest', (0, serializers_1.option)((0, serializers_1.u64)())],
['interestBps', (0, serializers_1.option)((0, serializers_1.u64)())],
], { description: 'Amount' });

@@ -20,0 +20,0 @@ }

export * from "./generated";
export * from "./plugin";
export * from "./setup";
export * from "./utils";

@@ -19,2 +19,4 @@ "use strict";

__exportStar(require("./plugin"), exports);
__exportStar(require("./setup"), exports);
__exportStar(require("./utils"), exports);
//# sourceMappingURL=index.js.map

@@ -41,6 +41,6 @@ "use strict";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -143,6 +143,6 @@ duration: 1000,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -261,3 +261,3 @@ duration: 1000,

});
const amount_bps = 100e6;
const principal = 100;
const createLoanIx = (0, src_1.createLoan)(umi, {

@@ -274,6 +274,6 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -291,3 +291,3 @@ duration: 1000,

const escrowTokenAccount = await (0, mpl_toolbox_1.fetchToken)(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount) / Math.pow(10, 6), principal);
const borrower = await (0, umi_bundle_tests_1.generateSignerWithSol)(umi);

@@ -294,0 +294,0 @@ const nftMint = (0, umi_1.generateSigner)(umi);

@@ -41,6 +41,6 @@ "use strict";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -99,3 +99,3 @@ duration: 1000,

});
const amount_bps = 100e6;
const principal = 100;
const createLoanIx = (0, src_1.createLoan)(umi, {

@@ -112,6 +112,6 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -118,0 +118,0 @@ duration: 1000,

@@ -41,6 +41,6 @@ "use strict";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -187,6 +187,6 @@ duration: 1000,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -193,0 +193,0 @@ duration: 1000,

@@ -41,6 +41,6 @@ "use strict";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -94,3 +94,3 @@ duration: 1000,

});
const amount_bps = 100e6;
const principal = 100;
const createLoanIx = (0, src_1.createLoan)(umi, {

@@ -107,8 +107,8 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)()
},
duration: 1000,
duration: 3,
apyBps: 1000,

@@ -124,4 +124,4 @@ },

const escrowTokenAccount = await (0, mpl_toolbox_1.fetchToken)(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount) / Math.pow(10, decimals), principal);
});
//# sourceMappingURL=createLoan.test.js.map

@@ -41,6 +41,6 @@ "use strict";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -116,3 +116,2 @@ duration: 1000,

});
let interest = 100;
await (0, src_1.repay)(umi, {

@@ -124,3 +123,2 @@ borrower,

borrowerNftToken,
interest,
lender: lender.publicKey,

@@ -172,6 +170,6 @@ borrowerNftTokenRecord,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: (0, umi_1.none)(),
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},

@@ -251,3 +249,2 @@ duration: 1000,

});
let interest = 100;
await (0, src_1.repay)(umi, {

@@ -259,3 +256,2 @@ borrower,

borrowerNftToken,
interest,
lender: lender.publicKey,

@@ -282,2 +278,3 @@ borrowerNftTokenRecord,

(0, ava_1.default)("it repays loan with spl tokens", async (t) => {
t.fail("mint spl tokens for borrower");
const umi = await (0, _setup_1.createUmi)();

@@ -320,3 +317,3 @@ const lender = await (0, umi_bundle_tests_1.generateSignerWithSol)(umi);

});
const amount_bps = 100e6;
const principal = 100;
const createLoanIx = (0, src_1.createLoan)(umi, {

@@ -333,8 +330,8 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: (0, umi_1.none)(),
interestBps: (0, umi_1.none)(),
},
duration: 1000,
duration: 6,
apyBps: 1000,

@@ -350,5 +347,9 @@ },

const escrowTokenAccount = await (0, mpl_toolbox_1.fetchToken)(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount), principal);
const borrower = await (0, umi_bundle_tests_1.generateSignerWithSol)(umi);
const nftMint = (0, umi_1.generateSigner)(umi);
const [borrowerToken] = (0, mpl_toolbox_1.findAssociatedTokenPda)(umi, {
mint: mint.publicKey,
owner: borrower.publicKey,
});
const [delegate, delegateBump] = umi.eddsa.findPda(src_1.NFT_LEND_PROGRAM_ID, [

@@ -372,6 +373,2 @@ (0, serializers_1.string)({ size: "variable" }).serialize("delegate"),

});
const [borrowerToken] = (0, mpl_toolbox_1.findAssociatedTokenPda)(umi, {
mint: mint.publicKey,
owner: borrower.publicKey,
});
const [borrowerNftTokenRecord] = (0, mpl_token_metadata_1.findTokenRecordPda)(umi, {

@@ -429,3 +426,2 @@ mint: nftMint.publicKey,

});
let interest = 0;
await (0, src_1.repay)(umi, {

@@ -437,3 +433,2 @@ borrower,

borrowerNftToken,
interest,
borrowerToken,

@@ -440,0 +435,0 @@ lenderToken,

{
"name": "nft-lend",
"version": "1.2.1",
"version": "1.3.1",
"description": "NFT lending and borrowing protocol",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -23,3 +23,2 @@ /**

struct,
u64,
u8,

@@ -54,8 +53,5 @@ } from '@metaplex-foundation/umi/serializers';

// Data.
export type RepayInstructionData = {
discriminator: Array<number>;
interest: bigint;
};
export type RepayInstructionData = { discriminator: Array<number> };
export type RepayInstructionDataArgs = { interest: number | bigint };
export type RepayInstructionDataArgs = {};

@@ -68,6 +64,3 @@ export function getRepayInstructionDataSerializer(): Serializer<

struct<RepayInstructionData>(
[
['discriminator', array(u8(), { size: 8 })],
['interest', u64()],
],
[['discriminator', array(u8(), { size: 8 })]],
{ description: 'RepayInstructionData' }

@@ -82,9 +75,6 @@ ),

// Args.
export type RepayInstructionArgs = RepayInstructionDataArgs;
// Instruction.
export function repay(
context: Pick<Context, 'programs'>,
input: RepayInstructionAccounts & RepayInstructionArgs
input: RepayInstructionAccounts
): TransactionBuilder {

@@ -149,5 +139,2 @@ // Program ID.

// Arguments.
const resolvedArgs: RepayInstructionArgs = { ...input };
// Default values.

@@ -194,5 +181,3 @@ if (!resolvedAccounts.sysvarInstructions.value) {

// Data.
const data = getRepayInstructionDataSerializer().serialize(
resolvedArgs as RepayInstructionDataArgs
);
const data = getRepayInstructionDataSerializer().serialize({});

@@ -199,0 +184,0 @@ // Bytes Created On Chain.

@@ -21,5 +21,5 @@ /**

mint: Option<PublicKey>;
basisPoints: bigint;
principal: bigint;
decimals: number;
interest: Option<bigint>;
interestBps: Option<bigint>;
};

@@ -29,5 +29,5 @@

mint: OptionOrNullable<PublicKey>;
basisPoints: number | bigint;
principal: number | bigint;
decimals: number;
interest: OptionOrNullable<number | bigint>;
interestBps: OptionOrNullable<number | bigint>;
};

@@ -39,5 +39,5 @@

['mint', option(publicKeySerializer())],
['basisPoints', u64()],
['principal', u64()],
['decimals', u8()],
['interest', option(u64())],
['interestBps', option(u64())],
],

@@ -44,0 +44,0 @@ { description: 'Amount' }

export * from "./generated";
export * from "./plugin";
export * from "./setup";
export * from "./setup";
export * from "./utils";

@@ -64,6 +64,6 @@ import {

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -191,6 +191,6 @@ duration: 1000,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -339,3 +339,3 @@ duration: 1000,

const amount_bps = 100e6;
const principal = 100;
const createLoanIx = createLoan(umi, {

@@ -352,6 +352,6 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: none(),
interestBps: none(),
},

@@ -372,3 +372,3 @@ duration: 1000,

const escrowTokenAccount = await fetchToken(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount) / Math.pow(10, 6), principal);

@@ -375,0 +375,0 @@ const borrower = await generateSignerWithSol(umi);

@@ -52,6 +52,6 @@ import { createNft } from "@metaplex-foundation/mpl-token-metadata";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -123,3 +123,3 @@ duration: 1000,

const amount_bps = 100e6;
const principal = 100;
const createLoanIx = createLoan(umi, {

@@ -136,6 +136,6 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: none(),
interestBps: none(),
},

@@ -142,0 +142,0 @@ duration: 1000,

@@ -63,6 +63,6 @@ import {

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -247,6 +247,6 @@ duration: 1000,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -253,0 +253,0 @@ duration: 1000,

@@ -52,6 +52,6 @@ import { createNft } from "@metaplex-foundation/mpl-token-metadata";

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -117,3 +117,3 @@ duration: 1000,

const amount_bps = 100e6;
const principal = 100;
const createLoanIx = createLoan(umi, {

@@ -130,8 +130,8 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: none(),
interestBps: none()
},
duration: 1000,
duration: 3,
apyBps: 1000,

@@ -150,3 +150,3 @@ },

const escrowTokenAccount = await fetchToken(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount) / Math.pow(10, decimals), principal);
});

@@ -10,3 +10,3 @@ import {

findMetadataPda,
findTokenRecordPda,
findTokenRecordPda
} from "@metaplex-foundation/mpl-token-metadata";

@@ -17,3 +17,3 @@ import {

fetchToken,
findAssociatedTokenPda,
findAssociatedTokenPda
} from "@metaplex-foundation/mpl-toolbox";

@@ -66,6 +66,6 @@ import {

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -162,3 +162,2 @@ duration: 1000,

let interest = 100;
await repay(umi, {

@@ -170,3 +169,2 @@ borrower,

borrowerNftToken,
interest,
lender: lender.publicKey,

@@ -231,6 +229,6 @@ borrowerNftTokenRecord,

amount: {
basisPoints: principal,
principal,
decimals: 9,
mint: none(),
interest: none(),
interestBps: none(),
},

@@ -331,3 +329,2 @@ duration: 1000,

let interest = 100;
await repay(umi, {

@@ -339,3 +336,2 @@ borrower,

borrowerNftToken,
interest,
lender: lender.publicKey,

@@ -371,2 +367,3 @@ borrowerNftTokenRecord,

test("it repays loan with spl tokens", async (t) => {
t.fail("mint spl tokens for borrower");
const umi = await createUmi();

@@ -418,3 +415,3 @@

const amount_bps = 100e6;
const principal = 100;
const createLoanIx = createLoan(umi, {

@@ -431,8 +428,8 @@ lender,

amount: {
basisPoints: amount_bps,
principal,
decimals,
mint: mint.publicKey,
interest: none(),
interestBps: none(),
},
duration: 1000,
duration: 6,
apyBps: 1000,

@@ -451,3 +448,3 @@ },

const escrowTokenAccount = await fetchToken(umi, escrowToken);
t.is(Number(escrowTokenAccount.amount), amount_bps);
t.is(Number(escrowTokenAccount.amount), principal);

@@ -457,2 +454,7 @@ const borrower = await generateSignerWithSol(umi);

const [borrowerToken] = findAssociatedTokenPda(umi, {
mint: mint.publicKey,
owner: borrower.publicKey,
});
const [delegate, delegateBump] = umi.eddsa.findPda(NFT_LEND_PROGRAM_ID, [

@@ -481,7 +483,2 @@ string({ size: "variable" }).serialize("delegate"),

const [borrowerToken] = findAssociatedTokenPda(umi, {
mint: mint.publicKey,
owner: borrower.publicKey,
});
const [borrowerNftTokenRecord] = findTokenRecordPda(umi, {

@@ -553,3 +550,2 @@ mint: nftMint.publicKey,

let interest = 0;
await repay(umi, {

@@ -561,3 +557,2 @@ borrower,

borrowerNftToken,
interest,
borrowerToken,

@@ -564,0 +559,0 @@ lenderToken,

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc