@everlend/general-pool
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -5,2 +5,2 @@ export * from './poolMarket'; | ||
export * from './withdrawalRequests'; | ||
export * from './userWithdrawRequest'; | ||
export * from './withdrawRequest'; |
@@ -17,3 +17,3 @@ "use strict"; | ||
__exportStar(require("./withdrawalRequests"), exports); | ||
__exportStar(require("./userWithdrawRequest"), exports); | ||
__exportStar(require("./withdrawRequest"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -11,4 +11,4 @@ /// <reference types="node" /> | ||
mint: PublicKey; | ||
lastRequestId: BN; | ||
lastProcessedRequestId: BN; | ||
nextTicket: BN; | ||
nextProcessTicket: BN; | ||
liquiditySupply: BN; | ||
@@ -21,4 +21,4 @@ }; | ||
mint: PublicKey; | ||
lastRequestId: BN; | ||
lastProcessedRequestId: BN; | ||
nextTicket: BN; | ||
nextProcessTicket: BN; | ||
liquiditySupply: BN; | ||
@@ -25,0 +25,0 @@ } |
@@ -17,4 +17,4 @@ "use strict"; | ||
['mint', 'publicKey'], | ||
['lastRequestId', 'u64'], | ||
['lastProcessedRequestId', 'u64'], | ||
['nextTicket', 'u64'], | ||
['nextProcessTicket', 'u64'], | ||
['liquiditySupply', 'u64'], | ||
@@ -21,0 +21,0 @@ ]); |
@@ -14,4 +14,4 @@ import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js'; | ||
export declare const deposit: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, amount: BN, source: PublicKey, destination?: PublicKey) => Promise<ActionResult>; | ||
export declare const withdrawRequest: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, amount: BN, source: PublicKey, destination?: PublicKey) => Promise<ActionResult>; | ||
export declare const withdrawRequest: ({ connection, payerPublicKey }: ActionOptions, pool: PublicKey, collateralAmount: BN, source: PublicKey, destination?: 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>; |
@@ -11,5 +11,2 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,3 +16,2 @@ exports.repay = exports.borrow = exports.withdrawRequest = exports.deposit = exports.createPool = exports.initPoolMarket = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const accounts_1 = require("./accounts"); | ||
@@ -96,7 +92,6 @@ const program_1 = require("./program"); | ||
exports.deposit = deposit; | ||
const withdrawRequest = ({ connection, payerPublicKey }, pool, amount, source, destination) => __awaiter(void 0, void 0, void 0, function* () { | ||
const withdrawRequest = ({ connection, payerPublicKey }, pool, collateralAmount, source, destination) => __awaiter(void 0, void 0, void 0, function* () { | ||
const { data: { tokenMint, poolMarket, tokenAccount, poolMint }, } = yield accounts_1.Pool.load(connection, pool); | ||
const withdrawRequests = yield accounts_1.WithdrawalRequests.getPDA(poolMarket, tokenMint); | ||
const { data: { lastRequestId }, } = yield accounts_1.WithdrawalRequests.load(connection, withdrawRequests); | ||
const userWithdrawRequest = yield accounts_1.UserWithdrawRequest.getPDA(poolMarket, tokenMint, lastRequestId.add(new bn_js_1.default(1, 10))); | ||
const withdrawalRequest = yield accounts_1.WithdrawalRequest.getPDA(withdrawRequests, payerPublicKey); | ||
const collateralTransit = yield program_1.GeneralPoolsProgram.findProgramAddress([ | ||
@@ -118,3 +113,3 @@ buffer_1.Buffer.from('transit'), | ||
withdrawRequests, | ||
userWithdrawRequest, | ||
withdrawalRequest, | ||
source, | ||
@@ -125,3 +120,3 @@ destination, | ||
poolMint, | ||
amount, | ||
collateralAmount, | ||
})); | ||
@@ -128,0 +123,0 @@ return { tx }; |
@@ -8,3 +8,4 @@ import { PublicKey } from '@solana/web3.js'; | ||
PoolBorrowAuthority = 3, | ||
WithdrawRequests = 4 | ||
WithdrawRequests = 4, | ||
WithdrawRequest = 5 | ||
} | ||
@@ -11,0 +12,0 @@ export declare class GeneralPoolsProgram extends Program { |
@@ -13,2 +13,3 @@ "use strict"; | ||
AccountType[AccountType["WithdrawRequests"] = 4] = "WithdrawRequests"; | ||
AccountType[AccountType["WithdrawRequest"] = 5] = "WithdrawRequest"; | ||
})(AccountType = exports.AccountType || (exports.AccountType = {})); | ||
@@ -15,0 +16,0 @@ class GeneralPoolsProgram extends common_1.Program { |
@@ -5,3 +5,3 @@ import { PublicKey, Transaction, TransactionCtorFields } from '@solana/web3.js'; | ||
export declare class WithdrawRequestArgs extends Borsh.Data<{ | ||
amount: BN; | ||
collateralAmount: BN; | ||
}> { | ||
@@ -14,4 +14,5 @@ static readonly SCHEMA: any; | ||
pool: PublicKey; | ||
poolMint: PublicKey; | ||
withdrawRequests: PublicKey; | ||
userWithdrawRequest: PublicKey; | ||
withdrawalRequest: PublicKey; | ||
source: PublicKey; | ||
@@ -21,4 +22,3 @@ destination: PublicKey; | ||
collateralTransit: PublicKey; | ||
poolMint: PublicKey; | ||
amount: BN; | ||
collateralAmount: BN; | ||
}; | ||
@@ -25,0 +25,0 @@ export declare class WithdrawRequest extends Transaction { |
@@ -19,3 +19,3 @@ "use strict"; | ||
['instruction', 'u8'], | ||
['amount', 'u64'], | ||
['collateralAmount', 'u64'], | ||
]); | ||
@@ -26,4 +26,4 @@ class WithdrawRequest extends web3_js_1.Transaction { | ||
const { feePayer } = options; | ||
const { poolMarket, pool, withdrawRequests, userWithdrawRequest, source, destination, tokenAccount, collateralTransit, poolMint, amount, } = params; | ||
const data = WithdrawRequestArgs.serialize({ amount }); | ||
const { poolMarket, pool, withdrawRequests, withdrawalRequest, source, destination, tokenAccount, collateralTransit, poolMint, collateralAmount, } = params; | ||
const data = WithdrawRequestArgs.serialize({ collateralAmount }); | ||
this.add(new web3_js_1.TransactionInstruction({ | ||
@@ -33,4 +33,5 @@ keys: [ | ||
{ pubkey: pool, isSigner: false, isWritable: false }, | ||
{ pubkey: poolMint, isSigner: false, isWritable: true }, | ||
{ pubkey: withdrawRequests, isSigner: false, isWritable: true }, | ||
{ pubkey: userWithdrawRequest, isSigner: false, isWritable: true }, | ||
{ pubkey: withdrawalRequest, isSigner: false, isWritable: true }, | ||
{ pubkey: source, isSigner: false, isWritable: true }, | ||
@@ -40,3 +41,2 @@ { pubkey: destination, isSigner: false, isWritable: true }, | ||
{ pubkey: collateralTransit, isSigner: false, isWritable: true }, | ||
{ pubkey: poolMint, isSigner: false, isWritable: true }, | ||
{ pubkey: feePayer, isSigner: true, isWritable: false }, | ||
@@ -43,0 +43,0 @@ { pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false }, |
{ | ||
"name": "@everlend/general-pool", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,2 +5,2 @@ export * from './poolMarket' | ||
export * from './withdrawalRequests' | ||
export * from './userWithdrawRequest' | ||
export * from './withdrawRequest' |
@@ -11,4 +11,4 @@ import { AccountType, GeneralPoolsProgram } from '../program' | ||
mint: PublicKey | ||
lastRequestId: BN | ||
lastProcessedRequestId: BN | ||
nextTicket: BN | ||
nextProcessTicket: BN | ||
liquiditySupply: BN | ||
@@ -22,4 +22,4 @@ } | ||
['mint', 'publicKey'], | ||
['lastRequestId', 'u64'], | ||
['lastProcessedRequestId', 'u64'], | ||
['nextTicket', 'u64'], | ||
['nextProcessTicket', 'u64'], | ||
['liquiditySupply', 'u64'], | ||
@@ -31,4 +31,4 @@ ]) | ||
mint: PublicKey | ||
lastRequestId: BN | ||
lastProcessedRequestId: BN | ||
nextTicket: BN | ||
nextProcessTicket: BN | ||
liquiditySupply: BN | ||
@@ -35,0 +35,0 @@ } |
@@ -8,3 +8,3 @@ import { AccountLayout, MintLayout, TOKEN_PROGRAM_ID } from '@solana/spl-token' | ||
PoolMarket, | ||
UserWithdrawRequest, | ||
WithdrawalRequest, | ||
WithdrawalRequests, | ||
@@ -157,3 +157,3 @@ } from './accounts' | ||
pool: PublicKey, | ||
amount: BN, | ||
collateralAmount: BN, | ||
source: PublicKey, | ||
@@ -167,13 +167,4 @@ destination?: PublicKey, | ||
const withdrawRequests = await WithdrawalRequests.getPDA(poolMarket, tokenMint) | ||
const withdrawalRequest = await WithdrawalRequest.getPDA(withdrawRequests, payerPublicKey) | ||
const { | ||
data: { lastRequestId }, | ||
} = await WithdrawalRequests.load(connection, withdrawRequests) | ||
const userWithdrawRequest = await UserWithdrawRequest.getPDA( | ||
poolMarket, | ||
tokenMint, | ||
lastRequestId.add(new BN(1, 10)), | ||
) | ||
const collateralTransit = await GeneralPoolsProgram.findProgramAddress([ | ||
@@ -207,3 +198,3 @@ Buffer.from('transit'), | ||
withdrawRequests, | ||
userWithdrawRequest, | ||
withdrawalRequest, | ||
source, | ||
@@ -214,3 +205,3 @@ destination, | ||
poolMint, | ||
amount, | ||
collateralAmount, | ||
}, | ||
@@ -217,0 +208,0 @@ ), |
@@ -10,2 +10,3 @@ import { PublicKey } from '@solana/web3.js' | ||
WithdrawRequests = 4, | ||
WithdrawRequest = 5, | ||
} | ||
@@ -12,0 +13,0 @@ |
@@ -14,6 +14,6 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token' | ||
export class WithdrawRequestArgs extends Borsh.Data<{ amount: BN }> { | ||
export class WithdrawRequestArgs extends Borsh.Data<{ collateralAmount: BN }> { | ||
static readonly SCHEMA = this.struct([ | ||
['instruction', 'u8'], | ||
['amount', 'u64'], | ||
['collateralAmount', 'u64'], | ||
]) | ||
@@ -27,4 +27,5 @@ | ||
pool: PublicKey | ||
poolMint: PublicKey | ||
withdrawRequests: PublicKey | ||
userWithdrawRequest: PublicKey | ||
withdrawalRequest: PublicKey | ||
source: PublicKey | ||
@@ -34,4 +35,3 @@ destination: PublicKey | ||
collateralTransit: PublicKey | ||
poolMint: PublicKey | ||
amount: BN | ||
collateralAmount: BN | ||
} | ||
@@ -47,3 +47,3 @@ | ||
withdrawRequests, | ||
userWithdrawRequest, | ||
withdrawalRequest, | ||
source, | ||
@@ -54,6 +54,6 @@ destination, | ||
poolMint, | ||
amount, | ||
collateralAmount, | ||
} = params | ||
const data = WithdrawRequestArgs.serialize({ amount }) | ||
const data = WithdrawRequestArgs.serialize({ collateralAmount }) | ||
@@ -65,4 +65,5 @@ this.add( | ||
{ pubkey: pool, isSigner: false, isWritable: false }, | ||
{ pubkey: poolMint, isSigner: false, isWritable: true }, | ||
{ pubkey: withdrawRequests, isSigner: false, isWritable: true }, | ||
{ pubkey: userWithdrawRequest, isSigner: false, isWritable: true }, | ||
{ pubkey: withdrawalRequest, isSigner: false, isWritable: true }, | ||
{ pubkey: source, isSigner: false, isWritable: true }, | ||
@@ -72,3 +73,2 @@ { pubkey: destination, isSigner: false, isWritable: true }, | ||
{ pubkey: collateralTransit, isSigner: false, isWritable: true }, | ||
{ pubkey: poolMint, isSigner: false, isWritable: true }, | ||
{ pubkey: feePayer, isSigner: true, isWritable: false }, | ||
@@ -75,0 +75,0 @@ { pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false }, |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2476
115643