Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@everlend/general-pool

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@everlend/general-pool - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

dist/accounts/withdrawalRequest.d.ts

2

dist/accounts/index.d.ts

@@ -5,2 +5,2 @@ export * from './poolMarket';

export * from './withdrawalRequests';
export * from './withdrawRequest';
export * from './withdrawalRequest';

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

__exportStar(require("./withdrawalRequests"), exports);
__exportStar(require("./withdrawRequest"), exports);
__exportStar(require("./withdrawalRequest"), exports);
//# sourceMappingURL=index.js.map

@@ -15,3 +15,4 @@ import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js';

export declare const withdrawRequest: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, registry: PublicKey, collateralAmount: BN, source: PublicKey, destination?: PublicKey) => Promise<ActionResult>;
export declare const withdraw: ({ connection, payerPublicKey }: ActionOptions, withdrawalRequest: PublicKey) => Promise<ActionResult>;
export declare const borrow: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, amount: BN, destination?: PublicKey) => Promise<ActionResult>;
export declare const repay: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, amount: BN, interestAmount: BN, source: PublicKey) => Promise<ActionResult>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.repay = exports.borrow = exports.withdrawRequest = exports.deposit = exports.createPool = exports.initPoolMarket = void 0;
exports.repay = exports.borrow = exports.withdraw = exports.withdrawRequest = exports.deposit = exports.createPool = exports.initPoolMarket = void 0;
const spl_token_1 = require("@solana/spl-token");

@@ -128,2 +128,33 @@ const web3_js_1 = require("@solana/web3.js");

exports.withdrawRequest = withdrawRequest;
const withdraw = ({ connection, payerPublicKey }, withdrawalRequest) => __awaiter(void 0, void 0, void 0, function* () {
const { data: { from, destination, pool }, } = yield accounts_1.WithdrawalRequest.load(connection, withdrawalRequest);
const { data: { tokenMint, poolMarket, poolMint, tokenAccount }, } = yield accounts_1.Pool.load(connection, pool);
const withdrawalRequests = yield accounts_1.WithdrawalRequests.getPDA(poolMarket, tokenMint);
const poolMarketAuthority = yield program_1.GeneralPoolsProgram.findProgramAddress([poolMarket.toBuffer()]);
const collateralTransit = yield program_1.GeneralPoolsProgram.findProgramAddress([
buffer_1.Buffer.from('transit'),
poolMarket.toBuffer(),
poolMint.toBuffer(),
]);
const tx = new web3_js_1.Transaction();
!(yield connection.getAccountInfo(destination)) &&
tx.add(new common_1.CreateAssociatedTokenAccount({ feePayer: payerPublicKey }, {
associatedTokenAddress: destination,
tokenMint,
}));
tx.add(new transactions_1.Withdraw({ feePayer: payerPublicKey }, {
poolMarket,
pool,
poolMarketAuthority,
poolMint,
withdrawalRequests,
withdrawalRequest,
from,
destination,
tokenAccount,
collateralTransit,
}));
return { tx };
});
exports.withdraw = withdraw;
const borrow = ({ connection, payerPublicKey }, pool, amount, destination) => __awaiter(void 0, void 0, void 0, function* () {

@@ -130,0 +161,0 @@ const { data: { poolMarket, tokenAccount, tokenMint }, } = yield accounts_1.Pool.load(connection, pool);

@@ -8,3 +8,4 @@ export * from './initPoolMarket';

export * from './withdraw_request';
export * from './withdraw';
export * from './borrow';
export * from './repay';

@@ -20,4 +20,5 @@ "use strict";

__exportStar(require("./withdraw_request"), exports);
__exportStar(require("./withdraw"), exports);
__exportStar(require("./borrow"), exports);
__exportStar(require("./repay"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@everlend/general-pool",
"version": "0.0.10",
"version": "0.0.11",
"license": "MIT",

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

@@ -5,2 +5,2 @@ export * from './poolMarket'

export * from './withdrawalRequests'
export * from './withdrawRequest'
export * from './withdrawalRequest'

@@ -12,4 +12,16 @@ import { AccountLayout, MintLayout, TOKEN_PROGRAM_ID } from '@solana/spl-token'

import { GeneralPoolsProgram } from './program'
import { CreateAssociatedTokenAccount, findAssociatedTokenAccount, findRegistryPoolConfigAccount } from '@everlend/common'
import { Borrow, CreatePool, Deposit, InitPoolMarket, Repay, WithdrawRequest } from './transactions'
import {
CreateAssociatedTokenAccount,
findAssociatedTokenAccount,
findRegistryPoolConfigAccount,
} from '@everlend/common'
import {
Borrow,
CreatePool,
Deposit,
InitPoolMarket,
Repay,
WithdrawRequest,
Withdraw,
} from './transactions'
import { Buffer } from 'buffer'

@@ -218,2 +230,58 @@

export const withdraw = async (
{ connection, payerPublicKey }: ActionOptions,
withdrawalRequest: PublicKey,
): Promise<ActionResult> => {
const {
data: { from, destination, pool },
} = await WithdrawalRequest.load(connection, withdrawalRequest)
const {
data: { tokenMint, poolMarket, poolMint, tokenAccount },
} = await Pool.load(connection, pool)
const withdrawalRequests = await WithdrawalRequests.getPDA(poolMarket, tokenMint)
const poolMarketAuthority = await GeneralPoolsProgram.findProgramAddress([poolMarket.toBuffer()])
const collateralTransit = await GeneralPoolsProgram.findProgramAddress([
Buffer.from('transit'),
poolMarket.toBuffer(),
poolMint.toBuffer(),
])
const tx = new Transaction()
// Create destination account for token mint if doesn't exist
!(await connection.getAccountInfo(destination)) &&
tx.add(
new CreateAssociatedTokenAccount(
{ feePayer: payerPublicKey },
{
associatedTokenAddress: destination,
tokenMint,
},
),
)
tx.add(
new Withdraw(
{ feePayer: payerPublicKey },
{
poolMarket,
pool,
poolMarketAuthority,
poolMint,
withdrawalRequests,
withdrawalRequest,
from,
destination,
tokenAccount,
collateralTransit,
},
),
)
return { tx }
}
export const borrow = async (

@@ -220,0 +288,0 @@ { connection, payerPublicKey }: ActionOptions,

@@ -8,3 +8,4 @@ export * from './initPoolMarket'

export * from './withdraw_request'
export * from './withdraw'
export * from './borrow'
export * from './repay'

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