@kamino-finance/klend-sdk 7.3.9 → 7.4.0-beta.0
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 +51 -3
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +39 -6
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +24 -15
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +24 -21
- 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 +0 -75
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +0 -25
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +89 -1
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +155 -1
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +36 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +49 -0
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +0 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +0 -2
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +4 -0
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +6 -1
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +33 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +66 -0
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +192 -0
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrder.js +194 -0
- package/dist/@codegen/klend/types/BorrowOrder.js.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +39 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +1 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +100 -0
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +35 -5
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +17 -7
- 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 +60 -5
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +36 -7
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +33 -7
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +61 -13
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +52 -0
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +97 -1
- 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 +5 -3
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +8 -5
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +17 -14
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +4 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +6 -0
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +8 -0
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +3 -1
- package/dist/classes/reserve.js.map +1 -1
- package/dist/idl/klend.json +581 -54
- package/dist/manager/client_kamino_manager.js +12 -6
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/Logger.d.ts +14 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +12 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/api.d.ts +13 -4
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +33 -31
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +3 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +79 -8
- package/src/@codegen/klend/accounts/Obligation.ts +42 -31
- package/src/@codegen/klend/accounts/Reserve.ts +1 -1
- package/src/@codegen/klend/accounts/UserState.ts +0 -75
- package/src/@codegen/klend/errors/custom.ts +172 -0
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +96 -0
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +0 -3
- package/src/@codegen/klend/instructions/index.ts +7 -0
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +81 -0
- package/src/@codegen/klend/types/BorrowOrder.ts +267 -0
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +87 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +39 -9
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +72 -9
- package/src/@codegen/klend/types/UpdateConfigMode.ts +73 -13
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +120 -0
- package/src/@codegen/klend/types/index.ts +21 -14
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +17 -14
- package/src/classes/manager.ts +5 -0
- package/src/classes/market.ts +16 -0
- package/src/classes/obligation.ts +1 -1
- package/src/classes/reserve.ts +3 -1
- package/src/idl/klend.json +581 -54
- package/src/manager/client_kamino_manager.ts +12 -6
- package/src/utils/Logger.ts +14 -0
- package/src/utils/api.ts +56 -33
- package/src/utils/managerTypes.ts +3 -1
- package/dist/@codegen/klend/types/AssetTier.d.ts +0 -45
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +0 -1
- package/dist/@codegen/klend/types/AssetTier.js +0 -132
- package/dist/@codegen/klend/types/AssetTier.js.map +0 -1
- package/src/@codegen/klend/types/AssetTier.ts +0 -119
|
@@ -132,6 +132,17 @@ export type CustomError =
|
|
|
132
132
|
| InitialAdminDepositExecuted
|
|
133
133
|
| ReserveHasNotReceivedInitialDeposit
|
|
134
134
|
| CTokenUsageBlocked
|
|
135
|
+
| CannotUseSameReserve
|
|
136
|
+
| TransactionIncludesRestrictedPrograms
|
|
137
|
+
| BorrowOrderDebtLiquidityMintMismatch
|
|
138
|
+
| BorrowOrderMaxBorrowRateExceeded
|
|
139
|
+
| BorrowOrderMinDebtTermInsufficient
|
|
140
|
+
| BorrowOrderFillTimeLimitExceeded
|
|
141
|
+
| ReserveDebtMaturityReached
|
|
142
|
+
| NonUpdatableOrderConfiguration
|
|
143
|
+
| BorrowOrderExecutionDisabled
|
|
144
|
+
| DebtReachedReserveDebtTerm
|
|
145
|
+
| ExpectationNotMet
|
|
135
146
|
|
|
136
147
|
export class InvalidMarketAuthority extends Error {
|
|
137
148
|
static readonly code = 6000
|
|
@@ -1680,6 +1691,145 @@ export class CTokenUsageBlocked extends Error {
|
|
|
1680
1691
|
}
|
|
1681
1692
|
}
|
|
1682
1693
|
|
|
1694
|
+
export class CannotUseSameReserve extends Error {
|
|
1695
|
+
static readonly code = 6133
|
|
1696
|
+
readonly code = 6133
|
|
1697
|
+
readonly name = "CannotUseSameReserve"
|
|
1698
|
+
readonly msg = "Cannot call ix with same reserve"
|
|
1699
|
+
|
|
1700
|
+
constructor(readonly logs?: string[]) {
|
|
1701
|
+
super("6133: Cannot call ix with same reserve")
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
export class TransactionIncludesRestrictedPrograms extends Error {
|
|
1706
|
+
static readonly code = 6134
|
|
1707
|
+
readonly code = 6134
|
|
1708
|
+
readonly name = "TransactionIncludesRestrictedPrograms"
|
|
1709
|
+
readonly msg = "Transaction includes restricted programs"
|
|
1710
|
+
|
|
1711
|
+
constructor(readonly logs?: string[]) {
|
|
1712
|
+
super("6134: Transaction includes restricted programs")
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
export class BorrowOrderDebtLiquidityMintMismatch extends Error {
|
|
1717
|
+
static readonly code = 6135
|
|
1718
|
+
readonly code = 6135
|
|
1719
|
+
readonly name = "BorrowOrderDebtLiquidityMintMismatch"
|
|
1720
|
+
readonly msg = "There is no borrow order requesting debt in the given asset"
|
|
1721
|
+
|
|
1722
|
+
constructor(readonly logs?: string[]) {
|
|
1723
|
+
super("6135: There is no borrow order requesting debt in the given asset")
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
export class BorrowOrderMaxBorrowRateExceeded extends Error {
|
|
1728
|
+
static readonly code = 6136
|
|
1729
|
+
readonly code = 6136
|
|
1730
|
+
readonly name = "BorrowOrderMaxBorrowRateExceeded"
|
|
1731
|
+
readonly msg =
|
|
1732
|
+
"Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1733
|
+
|
|
1734
|
+
constructor(readonly logs?: string[]) {
|
|
1735
|
+
super(
|
|
1736
|
+
"6136: Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1737
|
+
)
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
export class BorrowOrderMinDebtTermInsufficient extends Error {
|
|
1742
|
+
static readonly code = 6137
|
|
1743
|
+
readonly code = 6137
|
|
1744
|
+
readonly name = "BorrowOrderMinDebtTermInsufficient"
|
|
1745
|
+
readonly msg =
|
|
1746
|
+
"Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1747
|
+
|
|
1748
|
+
constructor(readonly logs?: string[]) {
|
|
1749
|
+
super(
|
|
1750
|
+
"6137: Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1751
|
+
)
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
export class BorrowOrderFillTimeLimitExceeded extends Error {
|
|
1756
|
+
static readonly code = 6138
|
|
1757
|
+
readonly code = 6138
|
|
1758
|
+
readonly name = "BorrowOrderFillTimeLimitExceeded"
|
|
1759
|
+
readonly msg = "Borrow order can no longer be filled"
|
|
1760
|
+
|
|
1761
|
+
constructor(readonly logs?: string[]) {
|
|
1762
|
+
super("6138: Borrow order can no longer be filled")
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
export class ReserveDebtMaturityReached extends Error {
|
|
1767
|
+
static readonly code = 6139
|
|
1768
|
+
readonly code = 6139
|
|
1769
|
+
readonly name = "ReserveDebtMaturityReached"
|
|
1770
|
+
readonly msg =
|
|
1771
|
+
"Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1772
|
+
|
|
1773
|
+
constructor(readonly logs?: string[]) {
|
|
1774
|
+
super(
|
|
1775
|
+
"6139: Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1776
|
+
)
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
export class NonUpdatableOrderConfiguration extends Error {
|
|
1781
|
+
static readonly code = 6140
|
|
1782
|
+
readonly code = 6140
|
|
1783
|
+
readonly name = "NonUpdatableOrderConfiguration"
|
|
1784
|
+
readonly msg =
|
|
1785
|
+
"Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1786
|
+
|
|
1787
|
+
constructor(readonly logs?: string[]) {
|
|
1788
|
+
super(
|
|
1789
|
+
"6140: Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1790
|
+
)
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
export class BorrowOrderExecutionDisabled extends Error {
|
|
1795
|
+
static readonly code = 6141
|
|
1796
|
+
readonly code = 6141
|
|
1797
|
+
readonly name = "BorrowOrderExecutionDisabled"
|
|
1798
|
+
readonly msg = "Execution of borrow orders is disabled"
|
|
1799
|
+
|
|
1800
|
+
constructor(readonly logs?: string[]) {
|
|
1801
|
+
super("6141: Execution of borrow orders is disabled")
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
export class DebtReachedReserveDebtTerm extends Error {
|
|
1806
|
+
static readonly code = 6142
|
|
1807
|
+
readonly code = 6142
|
|
1808
|
+
readonly name = "DebtReachedReserveDebtTerm"
|
|
1809
|
+
readonly msg =
|
|
1810
|
+
"Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1811
|
+
|
|
1812
|
+
constructor(readonly logs?: string[]) {
|
|
1813
|
+
super(
|
|
1814
|
+
"6142: Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1815
|
+
)
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
export class ExpectationNotMet extends Error {
|
|
1820
|
+
static readonly code = 6143
|
|
1821
|
+
readonly code = 6143
|
|
1822
|
+
readonly name = "ExpectationNotMet"
|
|
1823
|
+
readonly msg =
|
|
1824
|
+
"The on-chain state does not meet expectation specified by the caller, so the operation must be aborted (to avoid race conditions)"
|
|
1825
|
+
|
|
1826
|
+
constructor(readonly logs?: string[]) {
|
|
1827
|
+
super(
|
|
1828
|
+
"6143: The on-chain state does not meet expectation specified by the caller, so the operation must be aborted (to avoid race conditions)"
|
|
1829
|
+
)
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1683
1833
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1684
1834
|
switch (code) {
|
|
1685
1835
|
case 6000:
|
|
@@ -1948,6 +2098,28 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1948
2098
|
return new ReserveHasNotReceivedInitialDeposit(logs)
|
|
1949
2099
|
case 6132:
|
|
1950
2100
|
return new CTokenUsageBlocked(logs)
|
|
2101
|
+
case 6133:
|
|
2102
|
+
return new CannotUseSameReserve(logs)
|
|
2103
|
+
case 6134:
|
|
2104
|
+
return new TransactionIncludesRestrictedPrograms(logs)
|
|
2105
|
+
case 6135:
|
|
2106
|
+
return new BorrowOrderDebtLiquidityMintMismatch(logs)
|
|
2107
|
+
case 6136:
|
|
2108
|
+
return new BorrowOrderMaxBorrowRateExceeded(logs)
|
|
2109
|
+
case 6137:
|
|
2110
|
+
return new BorrowOrderMinDebtTermInsufficient(logs)
|
|
2111
|
+
case 6138:
|
|
2112
|
+
return new BorrowOrderFillTimeLimitExceeded(logs)
|
|
2113
|
+
case 6139:
|
|
2114
|
+
return new ReserveDebtMaturityReached(logs)
|
|
2115
|
+
case 6140:
|
|
2116
|
+
return new NonUpdatableOrderConfiguration(logs)
|
|
2117
|
+
case 6141:
|
|
2118
|
+
return new BorrowOrderExecutionDisabled(logs)
|
|
2119
|
+
case 6142:
|
|
2120
|
+
return new DebtReachedReserveDebtTerm(logs)
|
|
2121
|
+
case 6143:
|
|
2122
|
+
return new ExpectationNotMet(logs)
|
|
1951
2123
|
}
|
|
1952
2124
|
|
|
1953
2125
|
return null
|
|
@@ -0,0 +1,96 @@
|
|
|
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([102, 4, 167, 76, 131, 170, 93, 19])
|
|
19
|
+
|
|
20
|
+
export interface FillBorrowOrderAccounts {
|
|
21
|
+
borrowAccounts: {
|
|
22
|
+
payer: TransactionSigner
|
|
23
|
+
/** The obligation with a [BorrowOrder]. */
|
|
24
|
+
obligation: Address
|
|
25
|
+
/** The [Self::obligation]'s market - needed for borrowing-related configuration. */
|
|
26
|
+
lendingMarket: Address
|
|
27
|
+
/** The [Self::lending_market]'s authority, needed to transfer the newly-borrowed funds out of the [Self::reserve_source_liquidity]. */
|
|
28
|
+
lendingMarketAuthority: Address
|
|
29
|
+
/** The reserve to borrow from. Its mint must match the asset requested by the [BorrowOrder::debt_liquidity_mint]. */
|
|
30
|
+
borrowReserve: Address
|
|
31
|
+
/** The mint of [Self::borrow_reserve] - needed to execute the transfer. */
|
|
32
|
+
borrowReserveLiquidityMint: Address
|
|
33
|
+
/** The vault of [Self::borrow_reserve], from which the funds are transferred. */
|
|
34
|
+
reserveSourceLiquidity: Address
|
|
35
|
+
/** The fee vault of [Self::borrow_reserve], to which the fees are transferred. */
|
|
36
|
+
borrowReserveLiquidityFeeReceiver: Address
|
|
37
|
+
/** The destination token account that should receive the newly borrowed funds. It must match [BorrowOrder::filled_debt_destination], owner and mint. **Warning:** An altered destination account will prevent an order from being filled. */
|
|
38
|
+
userDestinationLiquidity: Address
|
|
39
|
+
/** The referrer's account, for accumulating fees - needed if the [Obligation::has_referrer]. */
|
|
40
|
+
referrerTokenState: Option<Address>
|
|
41
|
+
/** The token program of [Self::borrow_reserve] - needed to execute the transfer. */
|
|
42
|
+
tokenProgram: Address
|
|
43
|
+
}
|
|
44
|
+
farmsAccounts: {
|
|
45
|
+
obligationFarmUserState: Option<Address>
|
|
46
|
+
reserveFarmState: Option<Address>
|
|
47
|
+
}
|
|
48
|
+
farmsProgram: Address
|
|
49
|
+
eventAuthority: Address
|
|
50
|
+
program: Address
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function fillBorrowOrder(
|
|
54
|
+
accounts: FillBorrowOrderAccounts,
|
|
55
|
+
remainingAccounts: Array<AccountMeta | AccountSignerMeta> = [],
|
|
56
|
+
programAddress: Address = PROGRAM_ID
|
|
57
|
+
) {
|
|
58
|
+
const keys: Array<AccountMeta | AccountSignerMeta> = [
|
|
59
|
+
{
|
|
60
|
+
address: accounts.borrowAccounts.payer.address,
|
|
61
|
+
role: 2,
|
|
62
|
+
signer: accounts.borrowAccounts.payer,
|
|
63
|
+
},
|
|
64
|
+
{ address: accounts.borrowAccounts.obligation, role: 1 },
|
|
65
|
+
{ address: accounts.borrowAccounts.lendingMarket, role: 0 },
|
|
66
|
+
{ address: accounts.borrowAccounts.lendingMarketAuthority, role: 0 },
|
|
67
|
+
{ address: accounts.borrowAccounts.borrowReserve, role: 1 },
|
|
68
|
+
{ address: accounts.borrowAccounts.borrowReserveLiquidityMint, role: 0 },
|
|
69
|
+
{ address: accounts.borrowAccounts.reserveSourceLiquidity, role: 1 },
|
|
70
|
+
{
|
|
71
|
+
address: accounts.borrowAccounts.borrowReserveLiquidityFeeReceiver,
|
|
72
|
+
role: 1,
|
|
73
|
+
},
|
|
74
|
+
{ address: accounts.borrowAccounts.userDestinationLiquidity, role: 1 },
|
|
75
|
+
isSome(accounts.borrowAccounts.referrerTokenState)
|
|
76
|
+
? { address: accounts.borrowAccounts.referrerTokenState.value, role: 1 }
|
|
77
|
+
: { address: programAddress, role: 0 },
|
|
78
|
+
{ address: accounts.borrowAccounts.tokenProgram, role: 0 },
|
|
79
|
+
isSome(accounts.farmsAccounts.obligationFarmUserState)
|
|
80
|
+
? {
|
|
81
|
+
address: accounts.farmsAccounts.obligationFarmUserState.value,
|
|
82
|
+
role: 1,
|
|
83
|
+
}
|
|
84
|
+
: { address: programAddress, role: 0 },
|
|
85
|
+
isSome(accounts.farmsAccounts.reserveFarmState)
|
|
86
|
+
? { address: accounts.farmsAccounts.reserveFarmState.value, role: 1 }
|
|
87
|
+
: { address: programAddress, role: 0 },
|
|
88
|
+
{ address: accounts.farmsProgram, role: 0 },
|
|
89
|
+
{ address: accounts.eventAuthority, role: 0 },
|
|
90
|
+
{ address: accounts.program, role: 0 },
|
|
91
|
+
...remainingAccounts,
|
|
92
|
+
]
|
|
93
|
+
const data = DISCRIMINATOR
|
|
94
|
+
const ix: Instruction = { accounts: keys, programAddress, data }
|
|
95
|
+
return ix
|
|
96
|
+
}
|
|
@@ -19,7 +19,6 @@ export const DISCRIMINATOR = Buffer.from([130, 80, 38, 153, 80, 212, 182, 253])
|
|
|
19
19
|
|
|
20
20
|
export interface IdlMissingTypesArgs {
|
|
21
21
|
reserveFarmKind: types.ReserveFarmKindKind
|
|
22
|
-
assetTier: types.AssetTierKind
|
|
23
22
|
feeCalculation: types.FeeCalculationKind
|
|
24
23
|
reserveStatus: types.ReserveStatusKind
|
|
25
24
|
updateConfigMode: types.UpdateConfigModeKind
|
|
@@ -36,7 +35,6 @@ export interface IdlMissingTypesAccounts {
|
|
|
36
35
|
|
|
37
36
|
export const layout = borsh.struct([
|
|
38
37
|
types.ReserveFarmKind.layout("reserveFarmKind"),
|
|
39
|
-
types.AssetTier.layout("assetTier"),
|
|
40
38
|
types.FeeCalculation.layout("feeCalculation"),
|
|
41
39
|
types.ReserveStatus.layout("reserveStatus"),
|
|
42
40
|
types.UpdateConfigMode.layout("updateConfigMode"),
|
|
@@ -61,7 +59,6 @@ export function idlMissingTypes(
|
|
|
61
59
|
const len = layout.encode(
|
|
62
60
|
{
|
|
63
61
|
reserveFarmKind: args.reserveFarmKind.toEncodable(),
|
|
64
|
-
assetTier: args.assetTier.toEncodable(),
|
|
65
62
|
feeCalculation: args.feeCalculation.toEncodable(),
|
|
66
63
|
reserveStatus: args.reserveStatus.toEncodable(),
|
|
67
64
|
updateConfigMode: args.updateConfigMode.toEncodable(),
|
|
@@ -190,6 +190,13 @@ export type {
|
|
|
190
190
|
SetObligationOrderArgs,
|
|
191
191
|
SetObligationOrderAccounts,
|
|
192
192
|
} from "./setObligationOrder"
|
|
193
|
+
export { setBorrowOrder } from "./setBorrowOrder"
|
|
194
|
+
export type {
|
|
195
|
+
SetBorrowOrderArgs,
|
|
196
|
+
SetBorrowOrderAccounts,
|
|
197
|
+
} from "./setBorrowOrder"
|
|
198
|
+
export { fillBorrowOrder } from "./fillBorrowOrder"
|
|
199
|
+
export type { FillBorrowOrderAccounts } from "./fillBorrowOrder"
|
|
193
200
|
export { initGlobalConfig } from "./initGlobalConfig"
|
|
194
201
|
export type { InitGlobalConfigAccounts } from "./initGlobalConfig"
|
|
195
202
|
export { updateGlobalConfig } from "./updateGlobalConfig"
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
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
|
+
}
|