@kamino-finance/klend-sdk 7.4.0-beta.0 → 7.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts +3 -51
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +6 -39
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -24
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +21 -24
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +1 -1
- package/dist/@codegen/klend/accounts/UserState.d.ts +75 -0
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +25 -0
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +1 -89
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +1 -155
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +0 -4
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +1 -6
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/types/AssetTier.d.ts +45 -0
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +1 -0
- package/dist/@codegen/klend/types/AssetTier.js +132 -0
- package/dist/@codegen/klend/types/AssetTier.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +5 -35
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +7 -17
- package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
- package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
- package/dist/@codegen/klend/types/ReserveConfig.d.ts +5 -60
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +7 -36
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +7 -33
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +13 -61
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -52
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -97
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/index.d.ts +8 -8
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +3 -5
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +5 -8
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +14 -17
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts +21 -91
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +141 -119
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/actionTypes.d.ts +310 -0
- package/dist/classes/actionTypes.d.ts.map +1 -0
- package/dist/classes/actionTypes.js +3 -0
- package/dist/classes/actionTypes.js.map +1 -0
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +0 -4
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +5 -11
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +29 -21
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +9 -9
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +49 -51
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +6 -3
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +1 -3
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/client/commands/borrow.d.ts +1 -1
- package/dist/client/commands/borrow.d.ts.map +1 -1
- package/dist/client/commands/borrow.js +11 -2
- package/dist/client/commands/borrow.js.map +1 -1
- package/dist/client/commands/deposit.d.ts +1 -1
- package/dist/client/commands/deposit.d.ts.map +1 -1
- package/dist/client/commands/deposit.js +11 -2
- package/dist/client/commands/deposit.js.map +1 -1
- package/dist/client/commands/printReserve.d.ts +1 -1
- package/dist/client/commands/printReserve.d.ts.map +1 -1
- package/dist/client/commands/printReserve.js +2 -4
- package/dist/client/commands/printReserve.js.map +1 -1
- package/dist/client/commands/repay.d.ts +1 -1
- package/dist/client/commands/repay.d.ts.map +1 -1
- package/dist/client/commands/repay.js +12 -2
- package/dist/client/commands/repay.js.map +1 -1
- package/dist/client/commands/withdraw.d.ts +1 -1
- package/dist/client/commands/withdraw.d.ts.map +1 -1
- package/dist/client/commands/withdraw.js +11 -2
- package/dist/client/commands/withdraw.js.map +1 -1
- package/dist/idl/klend.json +54 -581
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +43 -10
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +40 -21
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +6 -6
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +167 -52
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +2 -2
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/manager/client_kamino_manager.js +6 -12
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/obligation_orders/price_based.js +1 -0
- package/dist/obligation_orders/price_based.js.map +1 -1
- package/dist/utils/ObligationType.d.ts +33 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +81 -2
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +1 -3
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +2 -2
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +49 -25
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +8 -79
- package/src/@codegen/klend/accounts/Obligation.ts +31 -42
- package/src/@codegen/klend/accounts/Reserve.ts +1 -1
- package/src/@codegen/klend/accounts/UserState.ts +75 -0
- package/src/@codegen/klend/errors/custom.ts +0 -172
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +3 -0
- package/src/@codegen/klend/instructions/index.ts +0 -7
- package/src/@codegen/klend/types/AssetTier.ts +119 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +9 -39
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +9 -72
- package/src/@codegen/klend/types/UpdateConfigMode.ts +13 -73
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -120
- package/src/@codegen/klend/types/index.ts +14 -21
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +14 -17
- package/src/classes/action.ts +321 -347
- package/src/classes/actionTypes.ts +295 -0
- package/src/classes/manager.ts +0 -5
- package/src/classes/market.ts +42 -32
- package/src/classes/obligation.ts +55 -54
- package/src/classes/obligationOrder.ts +6 -3
- package/src/classes/reserve.ts +1 -3
- package/src/classes/shared.ts +2 -0
- package/src/client/client.ts +17 -18
- package/src/client/commands/borrow.ts +10 -9
- package/src/client/commands/deposit.ts +10 -9
- package/src/client/commands/printReserve.ts +2 -4
- package/src/client/commands/repay.ts +11 -10
- package/src/client/commands/withdraw.ts +15 -9
- package/src/idl/klend.json +54 -581
- package/src/lending_operations/repay_with_collateral_calcs.ts +3 -4
- package/src/lending_operations/repay_with_collateral_operations.ts +40 -38
- package/src/lending_operations/swap_collateral_operations.ts +47 -41
- package/src/leverage/operations.ts +168 -129
- package/src/leverage/types.ts +2 -2
- package/src/manager/client_kamino_manager.ts +6 -12
- package/src/obligation_orders/price_based.ts +1 -0
- package/src/utils/ObligationType.ts +92 -1
- package/src/utils/managerTypes.ts +1 -3
- package/src/utils/userMetadata.ts +64 -30
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +0 -36
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +0 -49
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +0 -33
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -66
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +0 -192
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.js +0 -194
- package/dist/@codegen/klend/types/BorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +0 -39
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +0 -100
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +0 -1
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -81
- package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import {
|
|
3
|
-
Address,
|
|
4
|
-
isSome,
|
|
5
|
-
AccountMeta,
|
|
6
|
-
AccountSignerMeta,
|
|
7
|
-
Instruction,
|
|
8
|
-
Option,
|
|
9
|
-
TransactionSigner,
|
|
10
|
-
} from "@solana/kit"
|
|
11
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
12
|
-
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
-
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
-
import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
-
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
-
import { PROGRAM_ID } from "../programId"
|
|
17
|
-
|
|
18
|
-
export const DISCRIMINATOR = Buffer.from([177, 186, 45, 61, 235, 91, 68, 139])
|
|
19
|
-
|
|
20
|
-
export interface SetBorrowOrderArgs {
|
|
21
|
-
orderConfig: types.BorrowOrderConfigArgsFields
|
|
22
|
-
minExpectedCurrentRemainingDebtAmount: BN
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface SetBorrowOrderAccounts {
|
|
26
|
-
/** The [Self::obligation]'s owner. */
|
|
27
|
-
owner: TransactionSigner
|
|
28
|
-
/** The obligation to set the [BorrowOrder] on. */
|
|
29
|
-
obligation: Address
|
|
30
|
-
/** The [Self::obligation]'s market - needed only to validate the borrow orders' feature flag. */
|
|
31
|
-
lendingMarket: Address
|
|
32
|
-
/**
|
|
33
|
-
* The [BorrowOrder::filled_debt_destination] to set on order creation. Not editable on order
|
|
34
|
-
* updates.
|
|
35
|
-
* Ignored when cancelling the order.
|
|
36
|
-
*/
|
|
37
|
-
filledDebtDestination: Address
|
|
38
|
-
/**
|
|
39
|
-
* The [BorrowOrder::debt_liquidity_mint] to set on order creation. Not editable on order
|
|
40
|
-
* updates.
|
|
41
|
-
* Ignored when cancelling the order.
|
|
42
|
-
*/
|
|
43
|
-
debtLiquidityMint: Address
|
|
44
|
-
eventAuthority: Address
|
|
45
|
-
program: Address
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const layout = borsh.struct<SetBorrowOrderArgs>([
|
|
49
|
-
types.BorrowOrderConfigArgs.layout("orderConfig"),
|
|
50
|
-
borsh.u64("minExpectedCurrentRemainingDebtAmount"),
|
|
51
|
-
])
|
|
52
|
-
|
|
53
|
-
export function setBorrowOrder(
|
|
54
|
-
args: SetBorrowOrderArgs,
|
|
55
|
-
accounts: SetBorrowOrderAccounts,
|
|
56
|
-
remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
|
|
57
|
-
programAddress: Address = PROGRAM_ID
|
|
58
|
-
) {
|
|
59
|
-
const keys: Array<AccountMeta | AccountSignerMeta> = [
|
|
60
|
-
{ address: accounts.owner.address, role: 2, signer: accounts.owner },
|
|
61
|
-
{ address: accounts.obligation, role: 1 },
|
|
62
|
-
{ address: accounts.lendingMarket, role: 0 },
|
|
63
|
-
{ address: accounts.filledDebtDestination, role: 0 },
|
|
64
|
-
{ address: accounts.debtLiquidityMint, role: 0 },
|
|
65
|
-
{ address: accounts.eventAuthority, role: 0 },
|
|
66
|
-
{ address: accounts.program, role: 0 },
|
|
67
|
-
...remainingAccounts,
|
|
68
|
-
]
|
|
69
|
-
const buffer = Buffer.alloc(1000)
|
|
70
|
-
const len = layout.encode(
|
|
71
|
-
{
|
|
72
|
-
orderConfig: types.BorrowOrderConfigArgs.toEncodable(args.orderConfig),
|
|
73
|
-
minExpectedCurrentRemainingDebtAmount:
|
|
74
|
-
args.minExpectedCurrentRemainingDebtAmount,
|
|
75
|
-
},
|
|
76
|
-
buffer
|
|
77
|
-
)
|
|
78
|
-
const data = Buffer.concat([DISCRIMINATOR, buffer]).slice(0, 8 + len)
|
|
79
|
-
const ix: Instruction = { accounts: keys, programAddress, data }
|
|
80
|
-
return ix
|
|
81
|
-
}
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
-
import { borshAddress } from "../utils"
|
|
6
|
-
|
|
7
|
-
export interface BorrowOrderFields {
|
|
8
|
-
/**
|
|
9
|
-
* The asset to be borrowed.
|
|
10
|
-
* The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
|
|
11
|
-
*/
|
|
12
|
-
debtLiquidityMint: Address
|
|
13
|
-
/** The amount of debt that still needs to be filled, in lamports. */
|
|
14
|
-
remainingDebtAmount: BN
|
|
15
|
-
/**
|
|
16
|
-
* The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
|
|
17
|
-
* where the filled funds should be transferred to.
|
|
18
|
-
*/
|
|
19
|
-
filledDebtDestination: Address
|
|
20
|
-
/**
|
|
21
|
-
* The minimum allowed debt term that the obligation owner agrees to.
|
|
22
|
-
* The reserves used to fill this order *cannot* define their debt term *lower* than this.
|
|
23
|
-
*
|
|
24
|
-
* If zeroed, then only indefinite-term reserves may be used.
|
|
25
|
-
*/
|
|
26
|
-
minDebtTermSeconds: BN
|
|
27
|
-
/** The time until which the borrow order can still be filled. */
|
|
28
|
-
fillableUntilTimestamp: BN
|
|
29
|
-
/**
|
|
30
|
-
* The time at which this order was placed.
|
|
31
|
-
* Currently, this is only a piece of metadata.
|
|
32
|
-
*/
|
|
33
|
-
placedAtTimestamp: BN
|
|
34
|
-
/**
|
|
35
|
-
* The time at which this order was most-recently updated (including: created).
|
|
36
|
-
* Currently, this is only a piece of metadata.
|
|
37
|
-
*/
|
|
38
|
-
lastUpdatedAtTimestamp: BN
|
|
39
|
-
/**
|
|
40
|
-
* The amount of debt that was originally requested when this order was most-recently updated.
|
|
41
|
-
* In other words: this field holds a value of [Self::remaining_debt_amount] captured at
|
|
42
|
-
* [Self::last_updated_at_timestamp].
|
|
43
|
-
* Currently, this is only a piece of metadata.
|
|
44
|
-
*/
|
|
45
|
-
requestedDebtAmount: BN
|
|
46
|
-
/**
|
|
47
|
-
* The maximum borrow rate that the obligation owner agrees to.
|
|
48
|
-
* The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
|
|
49
|
-
* *higher* than this.
|
|
50
|
-
*/
|
|
51
|
-
maxBorrowRateBps: number
|
|
52
|
-
/** Alignment padding. */
|
|
53
|
-
padding1: Array<number>
|
|
54
|
-
/** End padding. */
|
|
55
|
-
endPadding: Array<BN>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface BorrowOrderJSON {
|
|
59
|
-
/**
|
|
60
|
-
* The asset to be borrowed.
|
|
61
|
-
* The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
|
|
62
|
-
*/
|
|
63
|
-
debtLiquidityMint: string
|
|
64
|
-
/** The amount of debt that still needs to be filled, in lamports. */
|
|
65
|
-
remainingDebtAmount: string
|
|
66
|
-
/**
|
|
67
|
-
* The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
|
|
68
|
-
* where the filled funds should be transferred to.
|
|
69
|
-
*/
|
|
70
|
-
filledDebtDestination: string
|
|
71
|
-
/**
|
|
72
|
-
* The minimum allowed debt term that the obligation owner agrees to.
|
|
73
|
-
* The reserves used to fill this order *cannot* define their debt term *lower* than this.
|
|
74
|
-
*
|
|
75
|
-
* If zeroed, then only indefinite-term reserves may be used.
|
|
76
|
-
*/
|
|
77
|
-
minDebtTermSeconds: string
|
|
78
|
-
/** The time until which the borrow order can still be filled. */
|
|
79
|
-
fillableUntilTimestamp: string
|
|
80
|
-
/**
|
|
81
|
-
* The time at which this order was placed.
|
|
82
|
-
* Currently, this is only a piece of metadata.
|
|
83
|
-
*/
|
|
84
|
-
placedAtTimestamp: string
|
|
85
|
-
/**
|
|
86
|
-
* The time at which this order was most-recently updated (including: created).
|
|
87
|
-
* Currently, this is only a piece of metadata.
|
|
88
|
-
*/
|
|
89
|
-
lastUpdatedAtTimestamp: string
|
|
90
|
-
/**
|
|
91
|
-
* The amount of debt that was originally requested when this order was most-recently updated.
|
|
92
|
-
* In other words: this field holds a value of [Self::remaining_debt_amount] captured at
|
|
93
|
-
* [Self::last_updated_at_timestamp].
|
|
94
|
-
* Currently, this is only a piece of metadata.
|
|
95
|
-
*/
|
|
96
|
-
requestedDebtAmount: string
|
|
97
|
-
/**
|
|
98
|
-
* The maximum borrow rate that the obligation owner agrees to.
|
|
99
|
-
* The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
|
|
100
|
-
* *higher* than this.
|
|
101
|
-
*/
|
|
102
|
-
maxBorrowRateBps: number
|
|
103
|
-
/** Alignment padding. */
|
|
104
|
-
padding1: Array<number>
|
|
105
|
-
/** End padding. */
|
|
106
|
-
endPadding: Array<string>
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A borrow order.
|
|
111
|
-
*
|
|
112
|
-
* When the [Obligation::borrow_order] is populated (i.e. non-zeroed) on an Obligation, then the
|
|
113
|
-
* permissionless "fill" operations may borrow liquidity to the owner according to this
|
|
114
|
-
* specification.
|
|
115
|
-
*/
|
|
116
|
-
export class BorrowOrder {
|
|
117
|
-
/**
|
|
118
|
-
* The asset to be borrowed.
|
|
119
|
-
* The reserves used for [Obligation::borrows] *must* all provide exactly this asset.
|
|
120
|
-
*/
|
|
121
|
-
readonly debtLiquidityMint: Address
|
|
122
|
-
/** The amount of debt that still needs to be filled, in lamports. */
|
|
123
|
-
readonly remainingDebtAmount: BN
|
|
124
|
-
/**
|
|
125
|
-
* The token account owned by the [Obligation::owner] and holding [Self::debt_liquidity_mint],
|
|
126
|
-
* where the filled funds should be transferred to.
|
|
127
|
-
*/
|
|
128
|
-
readonly filledDebtDestination: Address
|
|
129
|
-
/**
|
|
130
|
-
* The minimum allowed debt term that the obligation owner agrees to.
|
|
131
|
-
* The reserves used to fill this order *cannot* define their debt term *lower* than this.
|
|
132
|
-
*
|
|
133
|
-
* If zeroed, then only indefinite-term reserves may be used.
|
|
134
|
-
*/
|
|
135
|
-
readonly minDebtTermSeconds: BN
|
|
136
|
-
/** The time until which the borrow order can still be filled. */
|
|
137
|
-
readonly fillableUntilTimestamp: BN
|
|
138
|
-
/**
|
|
139
|
-
* The time at which this order was placed.
|
|
140
|
-
* Currently, this is only a piece of metadata.
|
|
141
|
-
*/
|
|
142
|
-
readonly placedAtTimestamp: BN
|
|
143
|
-
/**
|
|
144
|
-
* The time at which this order was most-recently updated (including: created).
|
|
145
|
-
* Currently, this is only a piece of metadata.
|
|
146
|
-
*/
|
|
147
|
-
readonly lastUpdatedAtTimestamp: BN
|
|
148
|
-
/**
|
|
149
|
-
* The amount of debt that was originally requested when this order was most-recently updated.
|
|
150
|
-
* In other words: this field holds a value of [Self::remaining_debt_amount] captured at
|
|
151
|
-
* [Self::last_updated_at_timestamp].
|
|
152
|
-
* Currently, this is only a piece of metadata.
|
|
153
|
-
*/
|
|
154
|
-
readonly requestedDebtAmount: BN
|
|
155
|
-
/**
|
|
156
|
-
* The maximum borrow rate that the obligation owner agrees to.
|
|
157
|
-
* The reserves used for [Obligation::borrows] *cannot* define their maximum borrow rate
|
|
158
|
-
* *higher* than this.
|
|
159
|
-
*/
|
|
160
|
-
readonly maxBorrowRateBps: number
|
|
161
|
-
/** Alignment padding. */
|
|
162
|
-
readonly padding1: Array<number>
|
|
163
|
-
/** End padding. */
|
|
164
|
-
readonly endPadding: Array<BN>
|
|
165
|
-
|
|
166
|
-
constructor(fields: BorrowOrderFields) {
|
|
167
|
-
this.debtLiquidityMint = fields.debtLiquidityMint
|
|
168
|
-
this.remainingDebtAmount = fields.remainingDebtAmount
|
|
169
|
-
this.filledDebtDestination = fields.filledDebtDestination
|
|
170
|
-
this.minDebtTermSeconds = fields.minDebtTermSeconds
|
|
171
|
-
this.fillableUntilTimestamp = fields.fillableUntilTimestamp
|
|
172
|
-
this.placedAtTimestamp = fields.placedAtTimestamp
|
|
173
|
-
this.lastUpdatedAtTimestamp = fields.lastUpdatedAtTimestamp
|
|
174
|
-
this.requestedDebtAmount = fields.requestedDebtAmount
|
|
175
|
-
this.maxBorrowRateBps = fields.maxBorrowRateBps
|
|
176
|
-
this.padding1 = fields.padding1
|
|
177
|
-
this.endPadding = fields.endPadding
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
static layout(property?: string) {
|
|
181
|
-
return borsh.struct(
|
|
182
|
-
[
|
|
183
|
-
borshAddress("debtLiquidityMint"),
|
|
184
|
-
borsh.u64("remainingDebtAmount"),
|
|
185
|
-
borshAddress("filledDebtDestination"),
|
|
186
|
-
borsh.u64("minDebtTermSeconds"),
|
|
187
|
-
borsh.u64("fillableUntilTimestamp"),
|
|
188
|
-
borsh.u64("placedAtTimestamp"),
|
|
189
|
-
borsh.u64("lastUpdatedAtTimestamp"),
|
|
190
|
-
borsh.u64("requestedDebtAmount"),
|
|
191
|
-
borsh.u32("maxBorrowRateBps"),
|
|
192
|
-
borsh.array(borsh.u8(), 4, "padding1"),
|
|
193
|
-
borsh.array(borsh.u64(), 5, "endPadding"),
|
|
194
|
-
],
|
|
195
|
-
property
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
-
static fromDecoded(obj: any) {
|
|
201
|
-
return new BorrowOrder({
|
|
202
|
-
debtLiquidityMint: obj.debtLiquidityMint,
|
|
203
|
-
remainingDebtAmount: obj.remainingDebtAmount,
|
|
204
|
-
filledDebtDestination: obj.filledDebtDestination,
|
|
205
|
-
minDebtTermSeconds: obj.minDebtTermSeconds,
|
|
206
|
-
fillableUntilTimestamp: obj.fillableUntilTimestamp,
|
|
207
|
-
placedAtTimestamp: obj.placedAtTimestamp,
|
|
208
|
-
lastUpdatedAtTimestamp: obj.lastUpdatedAtTimestamp,
|
|
209
|
-
requestedDebtAmount: obj.requestedDebtAmount,
|
|
210
|
-
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
211
|
-
padding1: obj.padding1,
|
|
212
|
-
endPadding: obj.endPadding,
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
static toEncodable(fields: BorrowOrderFields) {
|
|
217
|
-
return {
|
|
218
|
-
debtLiquidityMint: fields.debtLiquidityMint,
|
|
219
|
-
remainingDebtAmount: fields.remainingDebtAmount,
|
|
220
|
-
filledDebtDestination: fields.filledDebtDestination,
|
|
221
|
-
minDebtTermSeconds: fields.minDebtTermSeconds,
|
|
222
|
-
fillableUntilTimestamp: fields.fillableUntilTimestamp,
|
|
223
|
-
placedAtTimestamp: fields.placedAtTimestamp,
|
|
224
|
-
lastUpdatedAtTimestamp: fields.lastUpdatedAtTimestamp,
|
|
225
|
-
requestedDebtAmount: fields.requestedDebtAmount,
|
|
226
|
-
maxBorrowRateBps: fields.maxBorrowRateBps,
|
|
227
|
-
padding1: fields.padding1,
|
|
228
|
-
endPadding: fields.endPadding,
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
toJSON(): BorrowOrderJSON {
|
|
233
|
-
return {
|
|
234
|
-
debtLiquidityMint: this.debtLiquidityMint,
|
|
235
|
-
remainingDebtAmount: this.remainingDebtAmount.toString(),
|
|
236
|
-
filledDebtDestination: this.filledDebtDestination,
|
|
237
|
-
minDebtTermSeconds: this.minDebtTermSeconds.toString(),
|
|
238
|
-
fillableUntilTimestamp: this.fillableUntilTimestamp.toString(),
|
|
239
|
-
placedAtTimestamp: this.placedAtTimestamp.toString(),
|
|
240
|
-
lastUpdatedAtTimestamp: this.lastUpdatedAtTimestamp.toString(),
|
|
241
|
-
requestedDebtAmount: this.requestedDebtAmount.toString(),
|
|
242
|
-
maxBorrowRateBps: this.maxBorrowRateBps,
|
|
243
|
-
padding1: this.padding1,
|
|
244
|
-
endPadding: this.endPadding.map((item) => item.toString()),
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
static fromJSON(obj: BorrowOrderJSON): BorrowOrder {
|
|
249
|
-
return new BorrowOrder({
|
|
250
|
-
debtLiquidityMint: address(obj.debtLiquidityMint),
|
|
251
|
-
remainingDebtAmount: new BN(obj.remainingDebtAmount),
|
|
252
|
-
filledDebtDestination: address(obj.filledDebtDestination),
|
|
253
|
-
minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
|
|
254
|
-
fillableUntilTimestamp: new BN(obj.fillableUntilTimestamp),
|
|
255
|
-
placedAtTimestamp: new BN(obj.placedAtTimestamp),
|
|
256
|
-
lastUpdatedAtTimestamp: new BN(obj.lastUpdatedAtTimestamp),
|
|
257
|
-
requestedDebtAmount: new BN(obj.requestedDebtAmount),
|
|
258
|
-
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
259
|
-
padding1: obj.padding1,
|
|
260
|
-
endPadding: obj.endPadding.map((item) => new BN(item)),
|
|
261
|
-
})
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
toEncodable() {
|
|
265
|
-
return BorrowOrder.toEncodable(this)
|
|
266
|
-
}
|
|
267
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
-
import { borshAddress } from "../utils"
|
|
6
|
-
|
|
7
|
-
export interface BorrowOrderConfigArgsFields {
|
|
8
|
-
remainingDebtAmount: BN
|
|
9
|
-
maxBorrowRateBps: number
|
|
10
|
-
minDebtTermSeconds: BN
|
|
11
|
-
fillableUntilTimestamp: BN
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface BorrowOrderConfigArgsJSON {
|
|
15
|
-
remainingDebtAmount: string
|
|
16
|
-
maxBorrowRateBps: number
|
|
17
|
-
minDebtTermSeconds: string
|
|
18
|
-
fillableUntilTimestamp: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** A subset of [BorrowOrderConfig] excluding the accounts passed via [SetBorrowOrder]. */
|
|
22
|
-
export class BorrowOrderConfigArgs {
|
|
23
|
-
readonly remainingDebtAmount: BN
|
|
24
|
-
readonly maxBorrowRateBps: number
|
|
25
|
-
readonly minDebtTermSeconds: BN
|
|
26
|
-
readonly fillableUntilTimestamp: BN
|
|
27
|
-
|
|
28
|
-
constructor(fields: BorrowOrderConfigArgsFields) {
|
|
29
|
-
this.remainingDebtAmount = fields.remainingDebtAmount
|
|
30
|
-
this.maxBorrowRateBps = fields.maxBorrowRateBps
|
|
31
|
-
this.minDebtTermSeconds = fields.minDebtTermSeconds
|
|
32
|
-
this.fillableUntilTimestamp = fields.fillableUntilTimestamp
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static layout(property?: string) {
|
|
36
|
-
return borsh.struct(
|
|
37
|
-
[
|
|
38
|
-
borsh.u64("remainingDebtAmount"),
|
|
39
|
-
borsh.u32("maxBorrowRateBps"),
|
|
40
|
-
borsh.u64("minDebtTermSeconds"),
|
|
41
|
-
borsh.u64("fillableUntilTimestamp"),
|
|
42
|
-
],
|
|
43
|
-
property
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
static fromDecoded(obj: any) {
|
|
49
|
-
return new BorrowOrderConfigArgs({
|
|
50
|
-
remainingDebtAmount: obj.remainingDebtAmount,
|
|
51
|
-
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
52
|
-
minDebtTermSeconds: obj.minDebtTermSeconds,
|
|
53
|
-
fillableUntilTimestamp: obj.fillableUntilTimestamp,
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static toEncodable(fields: BorrowOrderConfigArgsFields) {
|
|
58
|
-
return {
|
|
59
|
-
remainingDebtAmount: fields.remainingDebtAmount,
|
|
60
|
-
maxBorrowRateBps: fields.maxBorrowRateBps,
|
|
61
|
-
minDebtTermSeconds: fields.minDebtTermSeconds,
|
|
62
|
-
fillableUntilTimestamp: fields.fillableUntilTimestamp,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
toJSON(): BorrowOrderConfigArgsJSON {
|
|
67
|
-
return {
|
|
68
|
-
remainingDebtAmount: this.remainingDebtAmount.toString(),
|
|
69
|
-
maxBorrowRateBps: this.maxBorrowRateBps,
|
|
70
|
-
minDebtTermSeconds: this.minDebtTermSeconds.toString(),
|
|
71
|
-
fillableUntilTimestamp: this.fillableUntilTimestamp.toString(),
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static fromJSON(obj: BorrowOrderConfigArgsJSON): BorrowOrderConfigArgs {
|
|
76
|
-
return new BorrowOrderConfigArgs({
|
|
77
|
-
remainingDebtAmount: new BN(obj.remainingDebtAmount),
|
|
78
|
-
maxBorrowRateBps: obj.maxBorrowRateBps,
|
|
79
|
-
minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
|
|
80
|
-
fillableUntilTimestamp: new BN(obj.fillableUntilTimestamp),
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
toEncodable() {
|
|
85
|
-
return BorrowOrderConfigArgs.toEncodable(this)
|
|
86
|
-
}
|
|
87
|
-
}
|