@jup-ag/lend 0.1.7 → 0.1.8
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/borrow/index.d.mts +28 -23
- package/dist/borrow/index.d.ts +28 -23
- package/dist/borrow/index.mjs +2 -2
- package/dist/earn/index.d.mts +19 -15
- package/dist/earn/index.d.ts +19 -15
- package/dist/earn/index.mjs +46 -43
- package/dist/flashloan/index.d.mts +4 -4
- package/dist/flashloan/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/merkle-distributor/index.d.mts +2 -2
- package/dist/merkle-distributor/index.d.ts +2 -2
- package/dist/refinance/index.d.mts +1 -1
- package/dist/refinance/index.d.ts +1 -1
- package/dist/refinance/index.mjs +1 -1
- package/dist/shared/{lend.Bh9Wk7OH.mjs → lend.BSHVKmia.mjs} +16 -12
- package/dist/shared/{lend.D69BluYU.d.mts → lend.Cg37G_AM.d.mts} +7 -7
- package/dist/shared/{lend.D69BluYU.d.ts → lend.Cg37G_AM.d.ts} +7 -7
- package/package.json +1 -1
package/dist/borrow/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V as Vaults, L as LiquidateParams } from '../shared/lend.
|
|
2
|
-
export { C as ConnectionParams, I as InitPositionIxParams, e as LiquidateContextParams, O as OperateContextParams, a as OperateParams, c as getInitPositionContext, b as getInitPositionIx, f as getLiquidateContext, h as getLiquidateIx, g as getOperateContext, d as getOperateIx } from '../shared/lend.
|
|
1
|
+
import { V as Vaults, L as LiquidateParams } from '../shared/lend.Cg37G_AM.mjs';
|
|
2
|
+
export { C as ConnectionParams, I as InitPositionIxParams, e as LiquidateContextParams, O as OperateContextParams, a as OperateParams, c as getInitPositionContext, b as getInitPositionIx, f as getLiquidateContext, h as getLiquidateIx, g as getOperateContext, d as getOperateIx } from '../shared/lend.Cg37G_AM.mjs';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
|
-
import
|
|
4
|
+
import BN__default from 'bn.js';
|
|
5
5
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
6
6
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
7
7
|
|
|
@@ -22,14 +22,19 @@ declare const getVaultsProgram: ({ connection, signer, }: {
|
|
|
22
22
|
signer: PublicKey;
|
|
23
23
|
}) => Program<Vaults>;
|
|
24
24
|
declare const INIT_TICK = -2147483648;
|
|
25
|
+
declare const MIN_I128: BN__default;
|
|
26
|
+
/** Use as `debtAmount` in getOperateIx to repay all debt. */
|
|
27
|
+
declare const MAX_REPAY_AMOUNT: BN__default;
|
|
28
|
+
/** Use as `colAmount` in getOperateIx to withdraw all collateral (subject to LTV). */
|
|
29
|
+
declare const MAX_WITHDRAW_AMOUNT: BN__default;
|
|
25
30
|
declare const getAccountOwner: (account: PublicKey, connection: Connection) => Promise<PublicKey>;
|
|
26
31
|
declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
|
|
27
32
|
tick: number;
|
|
28
33
|
tickId: number;
|
|
29
|
-
colRaw:
|
|
30
|
-
finalAmount:
|
|
31
|
-
debtRaw:
|
|
32
|
-
dustDebtRaw:
|
|
34
|
+
colRaw: BN__default;
|
|
35
|
+
finalAmount: BN__default;
|
|
36
|
+
debtRaw: BN__default;
|
|
37
|
+
dustDebtRaw: BN__default;
|
|
33
38
|
isSupplyOnlyPosition: boolean;
|
|
34
39
|
userLiquidationStatus: boolean;
|
|
35
40
|
postLiquidationBranchId: number;
|
|
@@ -37,10 +42,10 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
37
42
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
38
43
|
tick: number;
|
|
39
44
|
tickId: number;
|
|
40
|
-
colRaw:
|
|
41
|
-
finalAmount:
|
|
42
|
-
debtRaw:
|
|
43
|
-
dustDebtRaw:
|
|
45
|
+
colRaw: BN__default;
|
|
46
|
+
finalAmount: BN__default;
|
|
47
|
+
debtRaw: BN__default;
|
|
48
|
+
dustDebtRaw: BN__default;
|
|
44
49
|
isSupplyOnlyPosition: boolean;
|
|
45
50
|
userLiquidationStatus: boolean;
|
|
46
51
|
postLiquidationBranchId: number;
|
|
@@ -48,18 +53,18 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
48
53
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
49
54
|
vaultId: number;
|
|
50
55
|
currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
|
|
51
|
-
newColAmount:
|
|
52
|
-
newDebtAmount:
|
|
56
|
+
newColAmount: BN__default;
|
|
57
|
+
newDebtAmount: BN__default;
|
|
53
58
|
program?: Program<Vaults>;
|
|
54
59
|
connection: Connection;
|
|
55
60
|
signer: PublicKey;
|
|
56
61
|
}) => Promise<{
|
|
57
62
|
tick: number;
|
|
58
63
|
tickId: number;
|
|
59
|
-
colRaw:
|
|
60
|
-
debtRaw:
|
|
61
|
-
dustDebtRaw:
|
|
62
|
-
finalAmount:
|
|
64
|
+
colRaw: BN__default;
|
|
65
|
+
debtRaw: BN__default;
|
|
66
|
+
dustDebtRaw: BN__default;
|
|
67
|
+
finalAmount: BN__default;
|
|
63
68
|
isSupplyOnlyPosition: boolean;
|
|
64
69
|
}>;
|
|
65
70
|
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, postLiquidationBranchId: number, program: Program<Vaults>): Promise<number[]>;
|
|
@@ -82,8 +87,8 @@ declare function readOraclePrice({ connection, signer, oracle, }: {
|
|
|
82
87
|
oracleSources: {
|
|
83
88
|
source: PublicKey;
|
|
84
89
|
invert: boolean;
|
|
85
|
-
multiplier:
|
|
86
|
-
divisor:
|
|
90
|
+
multiplier: BN__default;
|
|
91
|
+
divisor: BN__default;
|
|
87
92
|
sourceType: ({
|
|
88
93
|
stakePool?: undefined;
|
|
89
94
|
msolPool?: undefined;
|
|
@@ -153,14 +158,14 @@ declare function readOraclePrice({ connection, signer, oracle, }: {
|
|
|
153
158
|
|
|
154
159
|
declare const MIN_TICK = -16383;
|
|
155
160
|
declare const MAX_TICK = 16383;
|
|
156
|
-
declare const ZERO_TICK_SCALED_RATIO:
|
|
161
|
+
declare const ZERO_TICK_SCALED_RATIO: BN__default;
|
|
157
162
|
declare const TICK_HAS_DEBT_ARRAY_SIZE = 8;
|
|
158
163
|
declare const TICKS_PER_TICK_HAS_DEBT: number;
|
|
159
164
|
declare const TICK_HAS_DEBT_CHILDREN_SIZE = 32;
|
|
160
165
|
declare const TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS = 256;
|
|
161
166
|
declare const TOTAL_INDICES_NEEDED = 16;
|
|
162
|
-
declare function getRatioAtTick(tick: number):
|
|
163
|
-
declare function getTickAtRatio(ratioX48:
|
|
167
|
+
declare function getRatioAtTick(tick: number): BN__default;
|
|
168
|
+
declare function getTickAtRatio(ratioX48: BN__default): number;
|
|
164
169
|
declare function getFirstTickForIndex(index: number): number;
|
|
165
170
|
declare function getTickIndices(tick: number): {
|
|
166
171
|
arrayIndex: number;
|
|
@@ -196,4 +201,4 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
|
|
|
196
201
|
}[];
|
|
197
202
|
}[]>;
|
|
198
203
|
|
|
199
|
-
export { INIT_TICK, LiquidateParams, MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getLiquidations, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
|
204
|
+
export { INIT_TICK, LiquidateParams, MAX_REPAY_AMOUNT, MAX_TICK, MAX_WITHDRAW_AMOUNT, MIN_I128, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getLiquidations, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
package/dist/borrow/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V as Vaults, L as LiquidateParams } from '../shared/lend.
|
|
2
|
-
export { C as ConnectionParams, I as InitPositionIxParams, e as LiquidateContextParams, O as OperateContextParams, a as OperateParams, c as getInitPositionContext, b as getInitPositionIx, f as getLiquidateContext, h as getLiquidateIx, g as getOperateContext, d as getOperateIx } from '../shared/lend.
|
|
1
|
+
import { V as Vaults, L as LiquidateParams } from '../shared/lend.Cg37G_AM.js';
|
|
2
|
+
export { C as ConnectionParams, I as InitPositionIxParams, e as LiquidateContextParams, O as OperateContextParams, a as OperateParams, c as getInitPositionContext, b as getInitPositionIx, f as getLiquidateContext, h as getLiquidateIx, g as getOperateContext, d as getOperateIx } from '../shared/lend.Cg37G_AM.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
|
-
import
|
|
4
|
+
import BN__default from 'bn.js';
|
|
5
5
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
6
6
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
7
7
|
|
|
@@ -22,14 +22,19 @@ declare const getVaultsProgram: ({ connection, signer, }: {
|
|
|
22
22
|
signer: PublicKey;
|
|
23
23
|
}) => Program<Vaults>;
|
|
24
24
|
declare const INIT_TICK = -2147483648;
|
|
25
|
+
declare const MIN_I128: BN__default;
|
|
26
|
+
/** Use as `debtAmount` in getOperateIx to repay all debt. */
|
|
27
|
+
declare const MAX_REPAY_AMOUNT: BN__default;
|
|
28
|
+
/** Use as `colAmount` in getOperateIx to withdraw all collateral (subject to LTV). */
|
|
29
|
+
declare const MAX_WITHDRAW_AMOUNT: BN__default;
|
|
25
30
|
declare const getAccountOwner: (account: PublicKey, connection: Connection) => Promise<PublicKey>;
|
|
26
31
|
declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
|
|
27
32
|
tick: number;
|
|
28
33
|
tickId: number;
|
|
29
|
-
colRaw:
|
|
30
|
-
finalAmount:
|
|
31
|
-
debtRaw:
|
|
32
|
-
dustDebtRaw:
|
|
34
|
+
colRaw: BN__default;
|
|
35
|
+
finalAmount: BN__default;
|
|
36
|
+
debtRaw: BN__default;
|
|
37
|
+
dustDebtRaw: BN__default;
|
|
33
38
|
isSupplyOnlyPosition: boolean;
|
|
34
39
|
userLiquidationStatus: boolean;
|
|
35
40
|
postLiquidationBranchId: number;
|
|
@@ -37,10 +42,10 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
37
42
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
38
43
|
tick: number;
|
|
39
44
|
tickId: number;
|
|
40
|
-
colRaw:
|
|
41
|
-
finalAmount:
|
|
42
|
-
debtRaw:
|
|
43
|
-
dustDebtRaw:
|
|
45
|
+
colRaw: BN__default;
|
|
46
|
+
finalAmount: BN__default;
|
|
47
|
+
debtRaw: BN__default;
|
|
48
|
+
dustDebtRaw: BN__default;
|
|
44
49
|
isSupplyOnlyPosition: boolean;
|
|
45
50
|
userLiquidationStatus: boolean;
|
|
46
51
|
postLiquidationBranchId: number;
|
|
@@ -48,18 +53,18 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
48
53
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
49
54
|
vaultId: number;
|
|
50
55
|
currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
|
|
51
|
-
newColAmount:
|
|
52
|
-
newDebtAmount:
|
|
56
|
+
newColAmount: BN__default;
|
|
57
|
+
newDebtAmount: BN__default;
|
|
53
58
|
program?: Program<Vaults>;
|
|
54
59
|
connection: Connection;
|
|
55
60
|
signer: PublicKey;
|
|
56
61
|
}) => Promise<{
|
|
57
62
|
tick: number;
|
|
58
63
|
tickId: number;
|
|
59
|
-
colRaw:
|
|
60
|
-
debtRaw:
|
|
61
|
-
dustDebtRaw:
|
|
62
|
-
finalAmount:
|
|
64
|
+
colRaw: BN__default;
|
|
65
|
+
debtRaw: BN__default;
|
|
66
|
+
dustDebtRaw: BN__default;
|
|
67
|
+
finalAmount: BN__default;
|
|
63
68
|
isSupplyOnlyPosition: boolean;
|
|
64
69
|
}>;
|
|
65
70
|
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, postLiquidationBranchId: number, program: Program<Vaults>): Promise<number[]>;
|
|
@@ -82,8 +87,8 @@ declare function readOraclePrice({ connection, signer, oracle, }: {
|
|
|
82
87
|
oracleSources: {
|
|
83
88
|
source: PublicKey;
|
|
84
89
|
invert: boolean;
|
|
85
|
-
multiplier:
|
|
86
|
-
divisor:
|
|
90
|
+
multiplier: BN__default;
|
|
91
|
+
divisor: BN__default;
|
|
87
92
|
sourceType: ({
|
|
88
93
|
stakePool?: undefined;
|
|
89
94
|
msolPool?: undefined;
|
|
@@ -153,14 +158,14 @@ declare function readOraclePrice({ connection, signer, oracle, }: {
|
|
|
153
158
|
|
|
154
159
|
declare const MIN_TICK = -16383;
|
|
155
160
|
declare const MAX_TICK = 16383;
|
|
156
|
-
declare const ZERO_TICK_SCALED_RATIO:
|
|
161
|
+
declare const ZERO_TICK_SCALED_RATIO: BN__default;
|
|
157
162
|
declare const TICK_HAS_DEBT_ARRAY_SIZE = 8;
|
|
158
163
|
declare const TICKS_PER_TICK_HAS_DEBT: number;
|
|
159
164
|
declare const TICK_HAS_DEBT_CHILDREN_SIZE = 32;
|
|
160
165
|
declare const TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS = 256;
|
|
161
166
|
declare const TOTAL_INDICES_NEEDED = 16;
|
|
162
|
-
declare function getRatioAtTick(tick: number):
|
|
163
|
-
declare function getTickAtRatio(ratioX48:
|
|
167
|
+
declare function getRatioAtTick(tick: number): BN__default;
|
|
168
|
+
declare function getTickAtRatio(ratioX48: BN__default): number;
|
|
164
169
|
declare function getFirstTickForIndex(index: number): number;
|
|
165
170
|
declare function getTickIndices(tick: number): {
|
|
166
171
|
arrayIndex: number;
|
|
@@ -196,4 +201,4 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
|
|
|
196
201
|
}[];
|
|
197
202
|
}[]>;
|
|
198
203
|
|
|
199
|
-
export { INIT_TICK, LiquidateParams, MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getLiquidations, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
|
204
|
+
export { INIT_TICK, LiquidateParams, MAX_REPAY_AMOUNT, MAX_TICK, MAX_WITHDRAW_AMOUNT, MIN_I128, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getLiquidations, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
package/dist/borrow/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getLiquidateIx, a as getVaultsProgram } from '../shared/lend.
|
|
2
|
-
export { I as INIT_TICK,
|
|
1
|
+
import { g as getLiquidateIx, a as getVaultsProgram } from '../shared/lend.BSHVKmia.mjs';
|
|
2
|
+
export { I as INIT_TICK, h as MAX_REPAY_AMOUNT, t as MAX_TICK, i as MAX_WITHDRAW_AMOUNT, M as MIN_I128, s as MIN_TICK, u as TICKS_PER_TICK_HAS_DEBT, T as TICK_HAS_DEBT_ARRAY_SIZE, v as TICK_HAS_DEBT_CHILDREN_SIZE, w as TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, x as TOTAL_INDICES_NEEDED, Z as ZERO_TICK_SCALED_RATIO, D as findNextTickWithDebt, j as getAccountOwner, k as getCurrentPosition, l as getCurrentPositionState, m as getFinalPosition, A as getFirstTickForIndex, d as getInitPositionContext, c as getInitPositionIx, f as getLiquidateContext, b as getOperateContext, e as getOperateIx, y as getRatioAtTick, z as getTickAtRatio, B as getTickIndices, n as loadRelevantBranches, q as loadRelevantBranchesForLiquidate, o as loadRelevantTicksHasDebtArrays, p as loadRelevantTicksHasDebtArraysLiquidate, r as readOraclePrice, C as readTickHasDebtArray } from '../shared/lend.BSHVKmia.mjs';
|
|
3
3
|
import { PublicKey, TransactionMessage, ComputeBudgetProgram, VersionedTransaction } from '@solana/web3.js';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
5
|
import { g as getVaultAdmin } from '../shared/lend.CsYeVtpe.mjs';
|
package/dist/earn/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
-
import BN from 'bn.js';
|
|
2
|
+
import * as BN from 'bn.js';
|
|
3
|
+
import BN__default from 'bn.js';
|
|
3
4
|
import { Program } from '@coral-xyz/anchor';
|
|
4
5
|
|
|
5
6
|
type ConnectionParams = {
|
|
@@ -11,10 +12,10 @@ type DepositContextParams = {
|
|
|
11
12
|
signer: PublicKey;
|
|
12
13
|
} & ConnectionParams;
|
|
13
14
|
type DepositParams = {
|
|
14
|
-
amount:
|
|
15
|
+
amount: BN__default;
|
|
15
16
|
} & DepositContextParams;
|
|
16
17
|
type MintParams = {
|
|
17
|
-
shares:
|
|
18
|
+
shares: BN__default;
|
|
18
19
|
} & DepositContextParams;
|
|
19
20
|
declare function getDepositContext({ asset, signer, connection, }: DepositContextParams): Promise<{
|
|
20
21
|
signer: PublicKey;
|
|
@@ -64,10 +65,10 @@ type WithdrawContextParams = {
|
|
|
64
65
|
signer: PublicKey;
|
|
65
66
|
} & ConnectionParams;
|
|
66
67
|
type WithdrawParams = {
|
|
67
|
-
amount:
|
|
68
|
+
amount: BN__default;
|
|
68
69
|
} & WithdrawContextParams;
|
|
69
70
|
type RedeemParams = {
|
|
70
|
-
shares:
|
|
71
|
+
shares: BN__default;
|
|
71
72
|
} & WithdrawContextParams;
|
|
72
73
|
declare function getWithdrawContext({ asset, signer, connection, }: WithdrawContextParams): Promise<{
|
|
73
74
|
signer: PublicKey;
|
|
@@ -1854,6 +1855,9 @@ type Lending = {
|
|
|
1854
1855
|
];
|
|
1855
1856
|
};
|
|
1856
1857
|
|
|
1858
|
+
declare const U64_MAX: BN;
|
|
1859
|
+
declare const MAX_DEPOSIT: BN;
|
|
1860
|
+
declare const MAX_WITHDRAW: BN;
|
|
1857
1861
|
declare const getLendingProgram: ({ connection, signer, }: {
|
|
1858
1862
|
connection: Connection;
|
|
1859
1863
|
signer?: PublicKey;
|
|
@@ -1872,22 +1876,22 @@ declare const getLendingTokenDetails: ({ lendingToken, connection, }: {
|
|
|
1872
1876
|
address: PublicKey;
|
|
1873
1877
|
asset: PublicKey;
|
|
1874
1878
|
decimals: number;
|
|
1875
|
-
totalAssets:
|
|
1876
|
-
totalSupply:
|
|
1877
|
-
convertToShares:
|
|
1878
|
-
convertToAssets:
|
|
1879
|
-
rewardsRate:
|
|
1880
|
-
supplyRate:
|
|
1879
|
+
totalAssets: BN__default;
|
|
1880
|
+
totalSupply: BN__default;
|
|
1881
|
+
convertToShares: BN__default;
|
|
1882
|
+
convertToAssets: BN__default;
|
|
1883
|
+
rewardsRate: BN__default;
|
|
1884
|
+
supplyRate: BN__default;
|
|
1881
1885
|
}>;
|
|
1882
1886
|
declare const getUserLendingPositionByAsset: ({ user, asset, connection, }: {
|
|
1883
1887
|
user: PublicKey;
|
|
1884
1888
|
asset: PublicKey;
|
|
1885
1889
|
connection: Connection;
|
|
1886
1890
|
}) => Promise<{
|
|
1887
|
-
lendingTokenShares:
|
|
1888
|
-
underlyingAssets:
|
|
1889
|
-
underlyingBalance:
|
|
1891
|
+
lendingTokenShares: BN__default;
|
|
1892
|
+
underlyingAssets: BN__default;
|
|
1893
|
+
underlyingBalance: BN__default;
|
|
1890
1894
|
}>;
|
|
1891
1895
|
|
|
1892
|
-
export { getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
1896
|
+
export { MAX_DEPOSIT, MAX_WITHDRAW, U64_MAX, getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
1893
1897
|
export type { ConnectionParams, DepositContextParams, DepositParams, MintParams, RedeemParams, WithdrawContextParams, WithdrawParams };
|
package/dist/earn/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
-
import BN from 'bn.js';
|
|
2
|
+
import * as BN from 'bn.js';
|
|
3
|
+
import BN__default from 'bn.js';
|
|
3
4
|
import { Program } from '@coral-xyz/anchor';
|
|
4
5
|
|
|
5
6
|
type ConnectionParams = {
|
|
@@ -11,10 +12,10 @@ type DepositContextParams = {
|
|
|
11
12
|
signer: PublicKey;
|
|
12
13
|
} & ConnectionParams;
|
|
13
14
|
type DepositParams = {
|
|
14
|
-
amount:
|
|
15
|
+
amount: BN__default;
|
|
15
16
|
} & DepositContextParams;
|
|
16
17
|
type MintParams = {
|
|
17
|
-
shares:
|
|
18
|
+
shares: BN__default;
|
|
18
19
|
} & DepositContextParams;
|
|
19
20
|
declare function getDepositContext({ asset, signer, connection, }: DepositContextParams): Promise<{
|
|
20
21
|
signer: PublicKey;
|
|
@@ -64,10 +65,10 @@ type WithdrawContextParams = {
|
|
|
64
65
|
signer: PublicKey;
|
|
65
66
|
} & ConnectionParams;
|
|
66
67
|
type WithdrawParams = {
|
|
67
|
-
amount:
|
|
68
|
+
amount: BN__default;
|
|
68
69
|
} & WithdrawContextParams;
|
|
69
70
|
type RedeemParams = {
|
|
70
|
-
shares:
|
|
71
|
+
shares: BN__default;
|
|
71
72
|
} & WithdrawContextParams;
|
|
72
73
|
declare function getWithdrawContext({ asset, signer, connection, }: WithdrawContextParams): Promise<{
|
|
73
74
|
signer: PublicKey;
|
|
@@ -1854,6 +1855,9 @@ type Lending = {
|
|
|
1854
1855
|
];
|
|
1855
1856
|
};
|
|
1856
1857
|
|
|
1858
|
+
declare const U64_MAX: BN;
|
|
1859
|
+
declare const MAX_DEPOSIT: BN;
|
|
1860
|
+
declare const MAX_WITHDRAW: BN;
|
|
1857
1861
|
declare const getLendingProgram: ({ connection, signer, }: {
|
|
1858
1862
|
connection: Connection;
|
|
1859
1863
|
signer?: PublicKey;
|
|
@@ -1872,22 +1876,22 @@ declare const getLendingTokenDetails: ({ lendingToken, connection, }: {
|
|
|
1872
1876
|
address: PublicKey;
|
|
1873
1877
|
asset: PublicKey;
|
|
1874
1878
|
decimals: number;
|
|
1875
|
-
totalAssets:
|
|
1876
|
-
totalSupply:
|
|
1877
|
-
convertToShares:
|
|
1878
|
-
convertToAssets:
|
|
1879
|
-
rewardsRate:
|
|
1880
|
-
supplyRate:
|
|
1879
|
+
totalAssets: BN__default;
|
|
1880
|
+
totalSupply: BN__default;
|
|
1881
|
+
convertToShares: BN__default;
|
|
1882
|
+
convertToAssets: BN__default;
|
|
1883
|
+
rewardsRate: BN__default;
|
|
1884
|
+
supplyRate: BN__default;
|
|
1881
1885
|
}>;
|
|
1882
1886
|
declare const getUserLendingPositionByAsset: ({ user, asset, connection, }: {
|
|
1883
1887
|
user: PublicKey;
|
|
1884
1888
|
asset: PublicKey;
|
|
1885
1889
|
connection: Connection;
|
|
1886
1890
|
}) => Promise<{
|
|
1887
|
-
lendingTokenShares:
|
|
1888
|
-
underlyingAssets:
|
|
1889
|
-
underlyingBalance:
|
|
1891
|
+
lendingTokenShares: BN__default;
|
|
1892
|
+
underlyingAssets: BN__default;
|
|
1893
|
+
underlyingBalance: BN__default;
|
|
1890
1894
|
}>;
|
|
1891
1895
|
|
|
1892
|
-
export { getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
1896
|
+
export { MAX_DEPOSIT, MAX_WITHDRAW, U64_MAX, getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
1893
1897
|
export type { ConnectionParams, DepositContextParams, DepositParams, MintParams, RedeemParams, WithdrawContextParams, WithdrawParams };
|
package/dist/earn/index.mjs
CHANGED
|
@@ -3,9 +3,12 @@ import { getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInst
|
|
|
3
3
|
import { l as liquidity } from '../shared/lend.CioR9-te.mjs';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { b as lending, g as getLendingToken, c as getLending, d as getLendingRewardsRateModel, e as getClaimAccount, f as getLendingAdmin } from '../shared/lend.DS0KoPpL.mjs';
|
|
6
|
+
import BN$1, { BN } from 'bn.js';
|
|
6
7
|
import { g as getLiquidity, a as getRateModel, b as getUserBorrowPosition, c as getUserSupplyPosition, d as getTokenReserveFromAsset, e as getReserve } from '../shared/lend.BzG5ldOV.mjs';
|
|
7
|
-
import BN from 'bn.js';
|
|
8
8
|
|
|
9
|
+
const U64_MAX = new BN("18446744073709551615");
|
|
10
|
+
const MAX_DEPOSIT = U64_MAX;
|
|
11
|
+
const MAX_WITHDRAW = U64_MAX;
|
|
9
12
|
const getLendingProgram = ({
|
|
10
13
|
connection,
|
|
11
14
|
signer
|
|
@@ -265,10 +268,10 @@ const getRedeemIxs = async ({
|
|
|
265
268
|
};
|
|
266
269
|
|
|
267
270
|
const LENDING_CONSTANTS = {
|
|
268
|
-
EXCHANGE_PRICES_PRECISION: new BN(1e12),
|
|
271
|
+
EXCHANGE_PRICES_PRECISION: new BN$1(1e12),
|
|
269
272
|
// 1e12
|
|
270
|
-
SECONDS_PER_YEAR: new BN(31536e3),
|
|
271
|
-
MAX_REWARDS_RATE: new BN(50 * 1e12)
|
|
273
|
+
SECONDS_PER_YEAR: new BN$1(31536e3),
|
|
274
|
+
MAX_REWARDS_RATE: new BN$1(50 * 1e12)
|
|
272
275
|
// 50%
|
|
273
276
|
};
|
|
274
277
|
async function getLendingData(address, program) {
|
|
@@ -287,8 +290,8 @@ async function getLendingData(address, program) {
|
|
|
287
290
|
return lendingRes.account;
|
|
288
291
|
}
|
|
289
292
|
function calculateTotalAssets(lending, totalSupply) {
|
|
290
|
-
const tokenExchangePrice = new BN(lending.tokenExchangePrice.toString());
|
|
291
|
-
const totalSupplyBN = typeof totalSupply === "number" || typeof totalSupply === "string" ? new BN(String(totalSupply)) : totalSupply;
|
|
293
|
+
const tokenExchangePrice = new BN$1(lending.tokenExchangePrice.toString());
|
|
294
|
+
const totalSupplyBN = typeof totalSupply === "number" || typeof totalSupply === "string" ? new BN$1(String(totalSupply)) : totalSupply;
|
|
292
295
|
return Number.parseInt(
|
|
293
296
|
tokenExchangePrice.mul(totalSupplyBN).div(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION).toString()
|
|
294
297
|
);
|
|
@@ -326,7 +329,7 @@ async function getRewardsRate(asset, totalAssets, connection) {
|
|
|
326
329
|
);
|
|
327
330
|
if (totalAssets.lt(currentRateModel.startTvl)) {
|
|
328
331
|
return {
|
|
329
|
-
rate: new BN(0),
|
|
332
|
+
rate: new BN$1(0),
|
|
330
333
|
rewardsEnded: false,
|
|
331
334
|
rewardsStartTime: currentRateModel.startTime
|
|
332
335
|
};
|
|
@@ -354,11 +357,11 @@ async function getLiquidityExchangePricesAndConfig(assetAddress, connection) {
|
|
|
354
357
|
mint: account.mint,
|
|
355
358
|
supplyExchangePrice: account.supplyExchangePrice,
|
|
356
359
|
borrowExchangePrice: account.borrowExchangePrice,
|
|
357
|
-
borrowRate: new BN(account.borrowRate || 0),
|
|
358
|
-
fee: new BN(account.feeOnInterest || 0),
|
|
359
|
-
lastStoredUtilization: new BN(account.lastUtilization || 0),
|
|
360
|
+
borrowRate: new BN$1(account.borrowRate || 0),
|
|
361
|
+
fee: new BN$1(account.feeOnInterest || 0),
|
|
362
|
+
lastStoredUtilization: new BN$1(account.lastUtilization || 0),
|
|
360
363
|
lastUpdateTimestamp: account.lastUpdateTimestamp,
|
|
361
|
-
maxUtilization: new BN(account.maxUtilization || 9500),
|
|
364
|
+
maxUtilization: new BN$1(account.maxUtilization || 9500),
|
|
362
365
|
supplyInterest: account.totalSupplyWithInterest,
|
|
363
366
|
supplyInterestFree: account.totalSupplyInterestFree,
|
|
364
367
|
borrowInterest: account.totalBorrowWithInterest,
|
|
@@ -371,41 +374,41 @@ async function getLiquidityExchangePricesAndConfig(assetAddress, connection) {
|
|
|
371
374
|
fee: tokenReserve.fee,
|
|
372
375
|
lastStoredUtilization: tokenReserve.lastStoredUtilization,
|
|
373
376
|
lastUpdateTimestamp: tokenReserve.lastUpdateTimestamp,
|
|
374
|
-
maxUtilization: tokenReserve.maxUtilization || new BN(9500)
|
|
377
|
+
maxUtilization: tokenReserve.maxUtilization || new BN$1(9500)
|
|
375
378
|
};
|
|
376
379
|
}
|
|
377
380
|
async function getNewExchangePrice(lending, connection) {
|
|
378
381
|
const { supplyExchangePrice: liquidityExchangePrice } = await getLiquidityExchangePricesAndConfig(lending.mint, connection);
|
|
379
|
-
const oldTokenExchangePrice = new BN(lending.tokenExchangePrice.toString());
|
|
380
|
-
const oldLiquidityExchangePrice = new BN(
|
|
382
|
+
const oldTokenExchangePrice = new BN$1(lending.tokenExchangePrice.toString());
|
|
383
|
+
const oldLiquidityExchangePrice = new BN$1(
|
|
381
384
|
lending.liquidityExchangePrice.toString()
|
|
382
385
|
);
|
|
383
|
-
let totalReturnPercent = new BN(0);
|
|
386
|
+
let totalReturnPercent = new BN$1(0);
|
|
384
387
|
const totalSupply = await getTokenTotalSupply(lending.fTokenMint, connection);
|
|
385
|
-
const totalAssets = oldTokenExchangePrice.mul(new BN(totalSupply)).div(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
388
|
+
const totalAssets = oldTokenExchangePrice.mul(new BN$1(totalSupply)).div(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
386
389
|
let rewardsRate = await getRewardsRate(lending.mint, totalAssets, connection);
|
|
387
390
|
if (rewardsRate.rate.gt(LENDING_CONSTANTS.MAX_REWARDS_RATE)) {
|
|
388
|
-
rewardsRate.rate = new BN(0);
|
|
391
|
+
rewardsRate.rate = new BN$1(0);
|
|
389
392
|
}
|
|
390
|
-
let lastUpdateTime = new BN(lending.lastUpdateTimestamp.toString());
|
|
393
|
+
let lastUpdateTime = new BN$1(lending.lastUpdateTimestamp.toString());
|
|
391
394
|
if (lastUpdateTime < rewardsRate.rewardsStartTime) {
|
|
392
395
|
lastUpdateTime = rewardsRate.rewardsStartTime;
|
|
393
396
|
}
|
|
394
|
-
totalReturnPercent = rewardsRate.rate.mul(new BN(Math.floor(Date.now() / 1e3)).sub(lastUpdateTime)).div(LENDING_CONSTANTS.SECONDS_PER_YEAR);
|
|
395
|
-
const delta = new BN(liquidityExchangePrice).sub(oldLiquidityExchangePrice);
|
|
397
|
+
totalReturnPercent = rewardsRate.rate.mul(new BN$1(Math.floor(Date.now() / 1e3)).sub(lastUpdateTime)).div(LENDING_CONSTANTS.SECONDS_PER_YEAR);
|
|
398
|
+
const delta = new BN$1(liquidityExchangePrice).sub(oldLiquidityExchangePrice);
|
|
396
399
|
totalReturnPercent = totalReturnPercent.add(
|
|
397
|
-
delta.mul(new BN(1e14)).div(oldLiquidityExchangePrice)
|
|
400
|
+
delta.mul(new BN$1(1e14)).div(oldLiquidityExchangePrice)
|
|
398
401
|
);
|
|
399
402
|
return oldTokenExchangePrice.add(
|
|
400
|
-
oldTokenExchangePrice.mul(totalReturnPercent).div(new BN(1e14))
|
|
403
|
+
oldTokenExchangePrice.mul(totalReturnPercent).div(new BN$1(1e14))
|
|
401
404
|
);
|
|
402
405
|
}
|
|
403
406
|
async function calculateRewardsRate(currentModel, totalAssets) {
|
|
404
|
-
const currentTimestamp = new BN(Math.floor(Date.now() / 1e3));
|
|
407
|
+
const currentTimestamp = new BN$1(Math.floor(Date.now() / 1e3));
|
|
405
408
|
const defaultResult = {
|
|
406
|
-
rewardsRate: new BN(0),
|
|
409
|
+
rewardsRate: new BN$1(0),
|
|
407
410
|
rewardsEnded: false,
|
|
408
|
-
rewardsStartTime: new BN(currentModel.startTime.toString())
|
|
411
|
+
rewardsStartTime: new BN$1(currentModel.startTime.toString())
|
|
409
412
|
};
|
|
410
413
|
if (currentModel.startTime.isZero() || currentModel.duration.isZero()) {
|
|
411
414
|
return defaultResult;
|
|
@@ -416,21 +419,21 @@ async function calculateRewardsRate(currentModel, totalAssets) {
|
|
|
416
419
|
rewardsEnded: true
|
|
417
420
|
};
|
|
418
421
|
}
|
|
419
|
-
if (new BN(totalAssets).lt(currentModel.startTvl)) {
|
|
422
|
+
if (new BN$1(totalAssets).lt(currentModel.startTvl)) {
|
|
420
423
|
return defaultResult;
|
|
421
424
|
}
|
|
422
|
-
let rewardsRate = new BN(currentModel.yearlyReward.toString()).mul(new BN(1e4)).div(new BN(totalAssets.toString()));
|
|
425
|
+
let rewardsRate = new BN$1(currentModel.yearlyReward.toString()).mul(new BN$1(1e4)).div(new BN$1(totalAssets.toString()));
|
|
423
426
|
if (rewardsRate.gt(LENDING_CONSTANTS.MAX_REWARDS_RATE)) {
|
|
424
427
|
rewardsRate = LENDING_CONSTANTS.MAX_REWARDS_RATE;
|
|
425
428
|
}
|
|
426
429
|
return {
|
|
427
430
|
rewardsRate,
|
|
428
431
|
rewardsEnded: false,
|
|
429
|
-
rewardsStartTime: new BN(currentModel.startTime.toString())
|
|
432
|
+
rewardsStartTime: new BN$1(currentModel.startTime.toString())
|
|
430
433
|
};
|
|
431
434
|
}
|
|
432
435
|
async function getLendingTokenRewards(lending, connection) {
|
|
433
|
-
let rewardsRate = new BN(0);
|
|
436
|
+
let rewardsRate = new BN$1(0);
|
|
434
437
|
if (!lending.rewardsRateModel.equals(PublicKey.default)) {
|
|
435
438
|
try {
|
|
436
439
|
const fTokenSupply = await getTokenTotalSupply(
|
|
@@ -491,11 +494,11 @@ async function getTokenReserveAccount(asset, connection) {
|
|
|
491
494
|
mint: account.mint,
|
|
492
495
|
supplyExchangePrice: account.supplyExchangePrice,
|
|
493
496
|
borrowExchangePrice: account.borrowExchangePrice,
|
|
494
|
-
borrowRate: new BN(account.borrowRate || 0),
|
|
495
|
-
fee: new BN(account.feeOnInterest || 0),
|
|
496
|
-
lastStoredUtilization: new BN(account.lastUtilization || 0),
|
|
497
|
+
borrowRate: new BN$1(account.borrowRate || 0),
|
|
498
|
+
fee: new BN$1(account.feeOnInterest || 0),
|
|
499
|
+
lastStoredUtilization: new BN$1(account.lastUtilization || 0),
|
|
497
500
|
lastUpdateTimestamp: account.lastUpdateTimestamp,
|
|
498
|
-
maxUtilization: new BN(account.maxUtilization || 9500),
|
|
501
|
+
maxUtilization: new BN$1(account.maxUtilization || 9500),
|
|
499
502
|
supplyInterest: account.totalSupplyWithInterest,
|
|
500
503
|
supplyInterestFree: account.totalSupplyInterestFree,
|
|
501
504
|
borrowInterest: account.totalBorrowWithInterest,
|
|
@@ -522,7 +525,7 @@ async function getLiquidityAssetSupplyRate(asset, connection) {
|
|
|
522
525
|
getLiquidityExchangePricesAndConfig(asset, connection),
|
|
523
526
|
getTotalAmounts(asset, connection)
|
|
524
527
|
]);
|
|
525
|
-
let supplyRate = new BN(0);
|
|
528
|
+
let supplyRate = new BN$1(0);
|
|
526
529
|
if (!totalAmounts) {
|
|
527
530
|
return supplyRate;
|
|
528
531
|
}
|
|
@@ -532,7 +535,7 @@ async function getLiquidityAssetSupplyRate(asset, connection) {
|
|
|
532
535
|
const borrowWithInterestForRate = totalAmounts.borrowRawInterest.mul(exchangePricesAndConfig.borrowExchangePrice).div(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
533
536
|
const supplyWithInterestForRate = totalAmounts.supplyRawInterest.mul(exchangePricesAndConfig.supplyExchangePrice).div(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
534
537
|
if (!supplyWithInterestForRate.isZero()) {
|
|
535
|
-
supplyRate = borrowRate.mul(new BN(1e4).sub(fee)).mul(borrowWithInterestForRate).div(supplyWithInterestForRate.mul(new BN(1e4)));
|
|
538
|
+
supplyRate = borrowRate.mul(new BN$1(1e4).sub(fee)).mul(borrowWithInterestForRate).div(supplyWithInterestForRate.mul(new BN$1(1e4)));
|
|
536
539
|
}
|
|
537
540
|
}
|
|
538
541
|
return supplyRate;
|
|
@@ -558,16 +561,16 @@ const getLendingTokenDetails = async ({
|
|
|
558
561
|
getNewExchangePrice(lendingData, connection),
|
|
559
562
|
getLendingTokenRewards(lendingData, connection)
|
|
560
563
|
]);
|
|
561
|
-
const convertToShares = new BN(10).pow(new BN(lendingData.decimals)).mul(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION).divRound(exchangePrice);
|
|
562
|
-
const convertToAssets2 = new BN(10).pow(new BN(lendingData.decimals)).mul(exchangePrice).divRound(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
564
|
+
const convertToShares = new BN$1(10).pow(new BN$1(lendingData.decimals)).mul(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION).divRound(exchangePrice);
|
|
565
|
+
const convertToAssets2 = new BN$1(10).pow(new BN$1(lendingData.decimals)).mul(exchangePrice).divRound(LENDING_CONSTANTS.EXCHANGE_PRICES_PRECISION);
|
|
563
566
|
const totalAssets = calculateTotalAssets(lendingData, assetTotalSupply);
|
|
564
567
|
return {
|
|
565
568
|
id: lendingData.lendingId,
|
|
566
569
|
address: lendingData.fTokenMint,
|
|
567
570
|
asset: lendingData.mint,
|
|
568
571
|
decimals: lendingData.decimals,
|
|
569
|
-
totalAssets: new BN(totalAssets.toString()),
|
|
570
|
-
totalSupply: new BN(assetTotalSupply),
|
|
572
|
+
totalAssets: new BN$1(totalAssets.toString()),
|
|
573
|
+
totalSupply: new BN$1(assetTotalSupply),
|
|
571
574
|
convertToShares,
|
|
572
575
|
convertToAssets: convertToAssets2,
|
|
573
576
|
rewardsRate,
|
|
@@ -587,14 +590,14 @@ const getUserLendingPositionByAsset = async ({
|
|
|
587
590
|
const underlyingBalance = await getTokenBalance(user, asset, connection);
|
|
588
591
|
const assets = await convertToAssets(
|
|
589
592
|
asset,
|
|
590
|
-
new BN(lendingTokenBalance.toString()),
|
|
593
|
+
new BN$1(lendingTokenBalance.toString()),
|
|
591
594
|
connection
|
|
592
595
|
);
|
|
593
596
|
return {
|
|
594
|
-
lendingTokenShares: new BN(lendingTokenBalance.toString()),
|
|
597
|
+
lendingTokenShares: new BN$1(lendingTokenBalance.toString()),
|
|
595
598
|
underlyingAssets: assets,
|
|
596
|
-
underlyingBalance: new BN(underlyingBalance.toString())
|
|
599
|
+
underlyingBalance: new BN$1(underlyingBalance.toString())
|
|
597
600
|
};
|
|
598
601
|
};
|
|
599
602
|
|
|
600
|
-
export { getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
603
|
+
export { MAX_DEPOSIT, MAX_WITHDRAW, U64_MAX, getAccountOwner, getDepositContext, getDepositIxs, getLendingProgram, getLendingTokenDetails, getLendingTokens, getMintIxs, getOrCreateATAInstruction, getRedeemIxs, getUserLendingPositionByAsset, getWithdrawContext, getWithdrawIxs };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type ConnectionParams = {
|
|
6
6
|
connection: Connection;
|
|
@@ -11,13 +11,13 @@ type FlashloanContextParams = {
|
|
|
11
11
|
signer: PublicKey;
|
|
12
12
|
} & ConnectionParams;
|
|
13
13
|
type FlashloanParams = {
|
|
14
|
-
amount:
|
|
14
|
+
amount: BN__default;
|
|
15
15
|
} & FlashloanContextParams;
|
|
16
16
|
type FlashPaybackParams = {
|
|
17
|
-
amount:
|
|
17
|
+
amount: BN__default;
|
|
18
18
|
} & FlashloanContextParams;
|
|
19
19
|
type FlashBorrowParams = {
|
|
20
|
-
amount:
|
|
20
|
+
amount: BN__default;
|
|
21
21
|
} & FlashloanContextParams;
|
|
22
22
|
declare function getFlashloanContext({ signer, asset, connection, }: FlashloanContextParams): Promise<{
|
|
23
23
|
signer: PublicKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type ConnectionParams = {
|
|
6
6
|
connection: Connection;
|
|
@@ -11,13 +11,13 @@ type FlashloanContextParams = {
|
|
|
11
11
|
signer: PublicKey;
|
|
12
12
|
} & ConnectionParams;
|
|
13
13
|
type FlashloanParams = {
|
|
14
|
-
amount:
|
|
14
|
+
amount: BN__default;
|
|
15
15
|
} & FlashloanContextParams;
|
|
16
16
|
type FlashPaybackParams = {
|
|
17
|
-
amount:
|
|
17
|
+
amount: BN__default;
|
|
18
18
|
} & FlashloanContextParams;
|
|
19
19
|
type FlashBorrowParams = {
|
|
20
|
-
amount:
|
|
20
|
+
amount: BN__default;
|
|
21
21
|
} & FlashloanContextParams;
|
|
22
22
|
declare function getFlashloanContext({ signer, asset, connection, }: FlashloanContextParams): Promise<{
|
|
23
23
|
signer: PublicKey;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type ConnectionParams = {
|
|
6
6
|
connection: Connection;
|
|
@@ -12,7 +12,7 @@ type ClaimContextParams = {
|
|
|
12
12
|
positionId: PublicKey;
|
|
13
13
|
} & ConnectionParams;
|
|
14
14
|
type ClaimParams = {
|
|
15
|
-
cumulativeAmount:
|
|
15
|
+
cumulativeAmount: BN__default;
|
|
16
16
|
positionType: number;
|
|
17
17
|
cycle: number;
|
|
18
18
|
merkleProof: Uint8Array<ArrayBufferLike>[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
|
|
5
5
|
type ConnectionParams = {
|
|
6
6
|
connection: Connection;
|
|
@@ -12,7 +12,7 @@ type ClaimContextParams = {
|
|
|
12
12
|
positionId: PublicKey;
|
|
13
13
|
} & ConnectionParams;
|
|
14
14
|
type ClaimParams = {
|
|
15
|
-
cumulativeAmount:
|
|
15
|
+
cumulativeAmount: BN__default;
|
|
16
16
|
positionType: number;
|
|
17
17
|
cycle: number;
|
|
18
18
|
merkleProof: Uint8Array<ArrayBufferLike>[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { O as OperateContextParams } from '../shared/lend.
|
|
3
|
+
import { O as OperateContextParams } from '../shared/lend.Cg37G_AM.mjs';
|
|
4
4
|
import 'bn.js';
|
|
5
5
|
import '@coral-xyz/anchor';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { O as OperateContextParams } from '../shared/lend.
|
|
3
|
+
import { O as OperateContextParams } from '../shared/lend.Cg37G_AM.js';
|
|
4
4
|
import 'bn.js';
|
|
5
5
|
import '@coral-xyz/anchor';
|
|
6
6
|
|
package/dist/refinance/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as vaultsIdl } from '../shared/lend.CsYeVtpe.mjs';
|
|
2
|
-
import { e as getOperateIx } from '../shared/lend.
|
|
2
|
+
import { e as getOperateIx } from '../shared/lend.BSHVKmia.mjs';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import '../shared/lend.CioR9-te.mjs';
|
|
@@ -1022,7 +1022,9 @@ const EXCHANGE_PRICES_PRECISION = new BN(10).pow(new BN(12));
|
|
|
1022
1022
|
const ZERO_TICK_SCALED_RATIO = new BN(281474976710656);
|
|
1023
1023
|
const TICK_SPACING = new BN(10015);
|
|
1024
1024
|
const X30 = new BN(1073741823);
|
|
1025
|
-
const MIN_I128
|
|
1025
|
+
const MIN_I128 = new BN("170141183460469231731687303715884105728").neg();
|
|
1026
|
+
const MAX_REPAY_AMOUNT = MIN_I128;
|
|
1027
|
+
const MAX_WITHDRAW_AMOUNT = MIN_I128;
|
|
1026
1028
|
const getAccountOwner = async (account, connection) => {
|
|
1027
1029
|
const info = await connection.getAccountInfo(account);
|
|
1028
1030
|
if (!info)
|
|
@@ -1295,10 +1297,10 @@ const getFinalPosition = async ({
|
|
|
1295
1297
|
colRaw = colRaw.add(supplyRaw);
|
|
1296
1298
|
} else if (newColAmount.lt(new BN(0))) {
|
|
1297
1299
|
let withdrawRaw = new BN(0);
|
|
1298
|
-
if (newColAmount.gt(MIN_I128
|
|
1300
|
+
if (newColAmount.gt(MIN_I128)) {
|
|
1299
1301
|
withdrawRaw = newColAmount.abs().mul(EXCHANGE_PRICES_PRECISION).div(supplyExPrice).sub(new BN(1));
|
|
1300
1302
|
colRaw = colRaw.sub(withdrawRaw);
|
|
1301
|
-
} else if (newColAmount.eq(MIN_I128
|
|
1303
|
+
} else if (newColAmount.eq(MIN_I128)) {
|
|
1302
1304
|
withdrawRaw = colRaw.mul(supplyExPrice).div(EXCHANGE_PRICES_PRECISION).mul(new BN(-1)).add(new BN(1));
|
|
1303
1305
|
colRaw = new BN(0);
|
|
1304
1306
|
} else {
|
|
@@ -1311,10 +1313,10 @@ const getFinalPosition = async ({
|
|
|
1311
1313
|
const borrowAmountWithFee = borrowRaw.add(feeAmount);
|
|
1312
1314
|
debtRaw = debtRaw.add(borrowAmountWithFee);
|
|
1313
1315
|
} else if (newDebtAmount.lt(new BN(0))) {
|
|
1314
|
-
if (newDebtAmount.gt(MIN_I128
|
|
1316
|
+
if (newDebtAmount.gt(MIN_I128)) {
|
|
1315
1317
|
const payback_amount = newDebtAmount.abs().mul(EXCHANGE_PRICES_PRECISION).div(borrowExPrice).add(new BN(1));
|
|
1316
1318
|
debtRaw = debtRaw.sub(payback_amount);
|
|
1317
|
-
} else if (newDebtAmount.eq(MIN_I128
|
|
1319
|
+
} else if (newDebtAmount.eq(MIN_I128)) {
|
|
1318
1320
|
debtRaw = new BN(0);
|
|
1319
1321
|
} else {
|
|
1320
1322
|
throw new Error("Invalid newDebtAmount");
|
|
@@ -1552,7 +1554,6 @@ const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey(
|
|
|
1552
1554
|
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
|
|
1553
1555
|
);
|
|
1554
1556
|
const LIQUIDITY_PROGRAM_ID = new PublicKey(liquidity.address);
|
|
1555
|
-
const MIN_I128 = new BN("170141183460469231731687303715884105728").neg();
|
|
1556
1557
|
async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition, finalPosition, currentTick, currentTickId, program, signer) {
|
|
1557
1558
|
const otherIxs = [];
|
|
1558
1559
|
const tickToRead = [currentTick];
|
|
@@ -1958,11 +1959,14 @@ const getOperateIx = async ({
|
|
|
1958
1959
|
program
|
|
1959
1960
|
});
|
|
1960
1961
|
if (accounts.borrowToken.toString() !== NATIVE_MINT.toString() && debtAmount.lt(new BN(0))) {
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1962
|
+
try {
|
|
1963
|
+
const userDebtTokenBalance = await connection.getTokenAccountBalance(
|
|
1964
|
+
accounts.signerBorrowTokenAccount
|
|
1965
|
+
);
|
|
1966
|
+
if (userDebtTokenBalance.value.amount === debtAmount.abs().toString()) {
|
|
1967
|
+
debtAmount = debtAmount.add(new BN(1));
|
|
1968
|
+
}
|
|
1969
|
+
} catch (error) {
|
|
1966
1970
|
}
|
|
1967
1971
|
}
|
|
1968
1972
|
const [operateIx, addressLookupTable] = await Promise.all([
|
|
@@ -2320,4 +2324,4 @@ async function getRemainingAccountsLiquidate(vaultId, vaultState, vaultConfig, o
|
|
|
2320
2324
|
};
|
|
2321
2325
|
}
|
|
2322
2326
|
|
|
2323
|
-
export {
|
|
2327
|
+
export { getFirstTickForIndex as A, getTickIndices as B, readTickHasDebtArray as C, findNextTickWithDebt as D, INIT_TICK as I, MIN_I128 as M, TICK_HAS_DEBT_ARRAY_SIZE as T, ZERO_TICK_SCALED_RATIO$1 as Z, getVaultsProgram as a, getOperateContext as b, getInitPositionIx as c, getInitPositionContext as d, getOperateIx as e, getLiquidateContext as f, getLiquidateIx as g, MAX_REPAY_AMOUNT as h, MAX_WITHDRAW_AMOUNT as i, getAccountOwner as j, getCurrentPosition as k, getCurrentPositionState as l, getFinalPosition as m, loadRelevantBranches as n, loadRelevantTicksHasDebtArrays as o, loadRelevantTicksHasDebtArraysLiquidate as p, loadRelevantBranchesForLiquidate as q, readOraclePrice as r, MIN_TICK$1 as s, MAX_TICK$1 as t, TICKS_PER_TICK_HAS_DEBT as u, TICK_HAS_DEBT_CHILDREN_SIZE as v, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS as w, TOTAL_INDICES_NEEDED as x, getRatioAtTick as y, getTickAtRatio as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -4004,8 +4004,8 @@ type ConnectionParams = {
|
|
|
4004
4004
|
type OperateContextParams = {
|
|
4005
4005
|
vaultId: number;
|
|
4006
4006
|
positionId: number;
|
|
4007
|
-
colAmount:
|
|
4008
|
-
debtAmount:
|
|
4007
|
+
colAmount: BN__default;
|
|
4008
|
+
debtAmount: BN__default;
|
|
4009
4009
|
recipient?: PublicKey;
|
|
4010
4010
|
positionOwner?: PublicKey;
|
|
4011
4011
|
program?: Program<Vaults>;
|
|
@@ -4013,8 +4013,8 @@ type OperateContextParams = {
|
|
|
4013
4013
|
type OperateParams = {
|
|
4014
4014
|
vaultId: number;
|
|
4015
4015
|
positionId: number;
|
|
4016
|
-
colAmount:
|
|
4017
|
-
debtAmount:
|
|
4016
|
+
colAmount: BN__default;
|
|
4017
|
+
debtAmount: BN__default;
|
|
4018
4018
|
recipient?: PublicKey;
|
|
4019
4019
|
positionOwner?: PublicKey;
|
|
4020
4020
|
} & ConnectionParams;
|
|
@@ -4142,8 +4142,8 @@ declare const getOperateIx: ({ vaultId, positionId, colAmount, debtAmount, conne
|
|
|
4142
4142
|
}>;
|
|
4143
4143
|
type LiquidateParams = {
|
|
4144
4144
|
vaultId: number;
|
|
4145
|
-
debtAmount:
|
|
4146
|
-
colPerUnitDebt?:
|
|
4145
|
+
debtAmount: BN__default;
|
|
4146
|
+
colPerUnitDebt?: BN__default;
|
|
4147
4147
|
absorb?: boolean;
|
|
4148
4148
|
to?: PublicKey;
|
|
4149
4149
|
} & ConnectionParams;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
-
import
|
|
3
|
+
import BN__default from 'bn.js';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -4004,8 +4004,8 @@ type ConnectionParams = {
|
|
|
4004
4004
|
type OperateContextParams = {
|
|
4005
4005
|
vaultId: number;
|
|
4006
4006
|
positionId: number;
|
|
4007
|
-
colAmount:
|
|
4008
|
-
debtAmount:
|
|
4007
|
+
colAmount: BN__default;
|
|
4008
|
+
debtAmount: BN__default;
|
|
4009
4009
|
recipient?: PublicKey;
|
|
4010
4010
|
positionOwner?: PublicKey;
|
|
4011
4011
|
program?: Program<Vaults>;
|
|
@@ -4013,8 +4013,8 @@ type OperateContextParams = {
|
|
|
4013
4013
|
type OperateParams = {
|
|
4014
4014
|
vaultId: number;
|
|
4015
4015
|
positionId: number;
|
|
4016
|
-
colAmount:
|
|
4017
|
-
debtAmount:
|
|
4016
|
+
colAmount: BN__default;
|
|
4017
|
+
debtAmount: BN__default;
|
|
4018
4018
|
recipient?: PublicKey;
|
|
4019
4019
|
positionOwner?: PublicKey;
|
|
4020
4020
|
} & ConnectionParams;
|
|
@@ -4142,8 +4142,8 @@ declare const getOperateIx: ({ vaultId, positionId, colAmount, debtAmount, conne
|
|
|
4142
4142
|
}>;
|
|
4143
4143
|
type LiquidateParams = {
|
|
4144
4144
|
vaultId: number;
|
|
4145
|
-
debtAmount:
|
|
4146
|
-
colPerUnitDebt?:
|
|
4145
|
+
debtAmount: BN__default;
|
|
4146
|
+
colPerUnitDebt?: BN__default;
|
|
4147
4147
|
absorb?: boolean;
|
|
4148
4148
|
to?: PublicKey;
|
|
4149
4149
|
} & ConnectionParams;
|