@jup-ag/lend 0.0.69 → 0.0.71
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/earn/index.mjs +6 -1
- package/dist/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.mjs +2 -1
- package/dist/merkle-distributor/index.d.mts +36 -0
- package/dist/merkle-distributor/index.d.ts +36 -0
- package/dist/merkle-distributor/index.mjs +81 -0
- package/dist/shared/lend.BEoyE4dT.mjs +1544 -0
- package/package.json +5 -1
package/dist/earn/index.mjs
CHANGED
|
@@ -117,7 +117,12 @@ async function getWithdrawContext({
|
|
|
117
117
|
const tokenProgram = await getAccountOwner(asset, connection);
|
|
118
118
|
return {
|
|
119
119
|
signer,
|
|
120
|
-
ownerTokenAccount: getAssociatedTokenAddressSync(
|
|
120
|
+
ownerTokenAccount: getAssociatedTokenAddressSync(
|
|
121
|
+
lendingToken,
|
|
122
|
+
signer,
|
|
123
|
+
false,
|
|
124
|
+
tokenProgram
|
|
125
|
+
),
|
|
121
126
|
recipientTokenAccount: getAssociatedTokenAddressSync(
|
|
122
127
|
asset,
|
|
123
128
|
signer,
|
package/dist/index.d.mts
CHANGED
|
@@ -130,6 +130,28 @@ declare namespace flashloan {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
declare const getMerkleAdmin: () => PublicKey;
|
|
134
|
+
declare const ROLE_TO_INDEX: {
|
|
135
|
+
readonly none: 0;
|
|
136
|
+
readonly proposer: 1;
|
|
137
|
+
readonly approver: 2;
|
|
138
|
+
};
|
|
139
|
+
type RoleType = "proposer" | "approver" | "none";
|
|
140
|
+
declare const getRole: (role: RoleType, address: PublicKey) => PublicKey;
|
|
141
|
+
declare const getRewardsDistributor: (rewardToken: PublicKey, nextDistributorId: number) => PublicKey;
|
|
142
|
+
declare const getClaimStatus: (user: PublicKey, positionId: PublicKey) => PublicKey;
|
|
143
|
+
|
|
144
|
+
declare const merkleDistributor_ROLE_TO_INDEX: typeof ROLE_TO_INDEX;
|
|
145
|
+
type merkleDistributor_RoleType = RoleType;
|
|
146
|
+
declare const merkleDistributor_getClaimStatus: typeof getClaimStatus;
|
|
147
|
+
declare const merkleDistributor_getMerkleAdmin: typeof getMerkleAdmin;
|
|
148
|
+
declare const merkleDistributor_getRewardsDistributor: typeof getRewardsDistributor;
|
|
149
|
+
declare const merkleDistributor_getRole: typeof getRole;
|
|
150
|
+
declare namespace merkleDistributor {
|
|
151
|
+
export { merkleDistributor_ROLE_TO_INDEX as ROLE_TO_INDEX, merkleDistributor_getClaimStatus as getClaimStatus, merkleDistributor_getMerkleAdmin as getMerkleAdmin, merkleDistributor_getRewardsDistributor as getRewardsDistributor, merkleDistributor_getRole as getRole };
|
|
152
|
+
export type { merkleDistributor_RoleType as RoleType };
|
|
153
|
+
}
|
|
154
|
+
|
|
133
155
|
declare const version: string;
|
|
134
156
|
|
|
135
|
-
export { borrow as borrowPda, flashloan as flashloanPda, lending as lendingPda, lendingRewardRateModel as lendingRewardRateModelPda, liquidity as liquidityPda, version };
|
|
157
|
+
export { borrow as borrowPda, flashloan as flashloanPda, lending as lendingPda, lendingRewardRateModel as lendingRewardRateModelPda, liquidity as liquidityPda, merkleDistributor as merkleDistributorPda, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,28 @@ declare namespace flashloan {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
declare const getMerkleAdmin: () => PublicKey;
|
|
134
|
+
declare const ROLE_TO_INDEX: {
|
|
135
|
+
readonly none: 0;
|
|
136
|
+
readonly proposer: 1;
|
|
137
|
+
readonly approver: 2;
|
|
138
|
+
};
|
|
139
|
+
type RoleType = "proposer" | "approver" | "none";
|
|
140
|
+
declare const getRole: (role: RoleType, address: PublicKey) => PublicKey;
|
|
141
|
+
declare const getRewardsDistributor: (rewardToken: PublicKey, nextDistributorId: number) => PublicKey;
|
|
142
|
+
declare const getClaimStatus: (user: PublicKey, positionId: PublicKey) => PublicKey;
|
|
143
|
+
|
|
144
|
+
declare const merkleDistributor_ROLE_TO_INDEX: typeof ROLE_TO_INDEX;
|
|
145
|
+
type merkleDistributor_RoleType = RoleType;
|
|
146
|
+
declare const merkleDistributor_getClaimStatus: typeof getClaimStatus;
|
|
147
|
+
declare const merkleDistributor_getMerkleAdmin: typeof getMerkleAdmin;
|
|
148
|
+
declare const merkleDistributor_getRewardsDistributor: typeof getRewardsDistributor;
|
|
149
|
+
declare const merkleDistributor_getRole: typeof getRole;
|
|
150
|
+
declare namespace merkleDistributor {
|
|
151
|
+
export { merkleDistributor_ROLE_TO_INDEX as ROLE_TO_INDEX, merkleDistributor_getClaimStatus as getClaimStatus, merkleDistributor_getMerkleAdmin as getMerkleAdmin, merkleDistributor_getRewardsDistributor as getRewardsDistributor, merkleDistributor_getRole as getRole };
|
|
152
|
+
export type { merkleDistributor_RoleType as RoleType };
|
|
153
|
+
}
|
|
154
|
+
|
|
133
155
|
declare const version: string;
|
|
134
156
|
|
|
135
|
-
export { borrow as borrowPda, flashloan as flashloanPda, lending as lendingPda, lendingRewardRateModel as lendingRewardRateModelPda, liquidity as liquidityPda, version };
|
|
157
|
+
export { borrow as borrowPda, flashloan as flashloanPda, lending as lendingPda, lendingRewardRateModel as lendingRewardRateModelPda, liquidity as liquidityPda, merkleDistributor as merkleDistributorPda, version };
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,12 @@ export { l as lendingPda, a as lendingRewardRateModelPda } from './shared/lend.B
|
|
|
2
2
|
export { l as liquidityPda } from './shared/lend.BzG5ldOV.mjs';
|
|
3
3
|
export { b as borrowPda } from './shared/lend.uRnzld7B.mjs';
|
|
4
4
|
export { f as flashloanPda } from './shared/lend.hlqlrp9r.mjs';
|
|
5
|
+
export { m as merkleDistributorPda } from './shared/lend.BEoyE4dT.mjs';
|
|
5
6
|
import '@solana/web3.js';
|
|
6
7
|
import './shared/lend.CioR9-te.mjs';
|
|
7
8
|
import '@solana/spl-token';
|
|
8
9
|
import 'bn.js';
|
|
9
10
|
|
|
10
|
-
const version = "0.0.
|
|
11
|
+
const version = "0.0.71";
|
|
11
12
|
|
|
12
13
|
export { version };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
|
|
5
|
+
type ConnectionParams = {
|
|
6
|
+
connection: Connection;
|
|
7
|
+
signer: PublicKey;
|
|
8
|
+
};
|
|
9
|
+
type ClaimContextParams = {
|
|
10
|
+
rewardToken: PublicKey;
|
|
11
|
+
distributorId: number;
|
|
12
|
+
positionId: PublicKey;
|
|
13
|
+
} & ConnectionParams;
|
|
14
|
+
type ClaimParams = {
|
|
15
|
+
cumulativeAmount: BN;
|
|
16
|
+
positionType: number;
|
|
17
|
+
cycle: number;
|
|
18
|
+
merkleProof: Uint8Array<ArrayBufferLike>[];
|
|
19
|
+
metadata: Buffer;
|
|
20
|
+
} & ClaimContextParams;
|
|
21
|
+
declare function getClaimRewardsContext({ rewardToken, distributorId, positionId, connection, signer, }: ClaimContextParams): Promise<{
|
|
22
|
+
signer: PublicKey;
|
|
23
|
+
distributor: PublicKey;
|
|
24
|
+
merkleAdmin: PublicKey;
|
|
25
|
+
mint: PublicKey;
|
|
26
|
+
claimStatus: PublicKey;
|
|
27
|
+
vaultTokenAccount: PublicKey;
|
|
28
|
+
recipientTokenAccount: PublicKey;
|
|
29
|
+
tokenProgram: PublicKey;
|
|
30
|
+
associatedTokenProgram: PublicKey;
|
|
31
|
+
systemProgram: PublicKey;
|
|
32
|
+
}>;
|
|
33
|
+
declare function getClaimIx({ cumulativeAmount, positionType, positionId, cycle, merkleProof, metadata, signer, rewardToken, distributorId, connection, }: ClaimParams): Promise<_solana_web3_js.TransactionInstruction>;
|
|
34
|
+
|
|
35
|
+
export { getClaimIx, getClaimRewardsContext };
|
|
36
|
+
export type { ClaimContextParams, ClaimParams, ConnectionParams };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
|
|
5
|
+
type ConnectionParams = {
|
|
6
|
+
connection: Connection;
|
|
7
|
+
signer: PublicKey;
|
|
8
|
+
};
|
|
9
|
+
type ClaimContextParams = {
|
|
10
|
+
rewardToken: PublicKey;
|
|
11
|
+
distributorId: number;
|
|
12
|
+
positionId: PublicKey;
|
|
13
|
+
} & ConnectionParams;
|
|
14
|
+
type ClaimParams = {
|
|
15
|
+
cumulativeAmount: BN;
|
|
16
|
+
positionType: number;
|
|
17
|
+
cycle: number;
|
|
18
|
+
merkleProof: Uint8Array<ArrayBufferLike>[];
|
|
19
|
+
metadata: Buffer;
|
|
20
|
+
} & ClaimContextParams;
|
|
21
|
+
declare function getClaimRewardsContext({ rewardToken, distributorId, positionId, connection, signer, }: ClaimContextParams): Promise<{
|
|
22
|
+
signer: PublicKey;
|
|
23
|
+
distributor: PublicKey;
|
|
24
|
+
merkleAdmin: PublicKey;
|
|
25
|
+
mint: PublicKey;
|
|
26
|
+
claimStatus: PublicKey;
|
|
27
|
+
vaultTokenAccount: PublicKey;
|
|
28
|
+
recipientTokenAccount: PublicKey;
|
|
29
|
+
tokenProgram: PublicKey;
|
|
30
|
+
associatedTokenProgram: PublicKey;
|
|
31
|
+
systemProgram: PublicKey;
|
|
32
|
+
}>;
|
|
33
|
+
declare function getClaimIx({ cumulativeAmount, positionType, positionId, cycle, merkleProof, metadata, signer, rewardToken, distributorId, connection, }: ClaimParams): Promise<_solana_web3_js.TransactionInstruction>;
|
|
34
|
+
|
|
35
|
+
export { getClaimIx, getClaimRewardsContext };
|
|
36
|
+
export type { ClaimContextParams, ClaimParams, ConnectionParams };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SystemProgram } from '@solana/web3.js';
|
|
2
|
+
import { g as getClaimStatus, a as getMerkleAdmin, b as getRewardsDistributor, c as merkleDistributor } from '../shared/lend.BEoyE4dT.mjs';
|
|
3
|
+
import { Program } from '@coral-xyz/anchor';
|
|
4
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
5
|
+
import 'bn.js';
|
|
6
|
+
|
|
7
|
+
const getAccountOwner = async (account, connection) => {
|
|
8
|
+
const info = await connection.getAccountInfo(account);
|
|
9
|
+
if (!info)
|
|
10
|
+
throw new Error(`Account info not found for ${account.toString()}`);
|
|
11
|
+
return info.owner;
|
|
12
|
+
};
|
|
13
|
+
async function getClaimRewardsContext({
|
|
14
|
+
rewardToken,
|
|
15
|
+
distributorId,
|
|
16
|
+
positionId,
|
|
17
|
+
connection,
|
|
18
|
+
signer
|
|
19
|
+
}) {
|
|
20
|
+
const tokenProgram = await getAccountOwner(rewardToken, connection);
|
|
21
|
+
return {
|
|
22
|
+
signer,
|
|
23
|
+
distributor: getRewardsDistributor(
|
|
24
|
+
rewardToken,
|
|
25
|
+
distributorId
|
|
26
|
+
),
|
|
27
|
+
merkleAdmin: getMerkleAdmin(),
|
|
28
|
+
mint: rewardToken,
|
|
29
|
+
claimStatus: getClaimStatus(signer, positionId),
|
|
30
|
+
vaultTokenAccount: getAssociatedTokenAddressSync(
|
|
31
|
+
rewardToken,
|
|
32
|
+
getMerkleAdmin(),
|
|
33
|
+
true,
|
|
34
|
+
tokenProgram
|
|
35
|
+
),
|
|
36
|
+
recipientTokenAccount: getAssociatedTokenAddressSync(
|
|
37
|
+
rewardToken,
|
|
38
|
+
signer,
|
|
39
|
+
false,
|
|
40
|
+
tokenProgram
|
|
41
|
+
),
|
|
42
|
+
tokenProgram,
|
|
43
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
44
|
+
systemProgram: SystemProgram.programId
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function getClaimIx({
|
|
48
|
+
cumulativeAmount,
|
|
49
|
+
positionType,
|
|
50
|
+
positionId,
|
|
51
|
+
cycle,
|
|
52
|
+
merkleProof,
|
|
53
|
+
metadata,
|
|
54
|
+
signer,
|
|
55
|
+
rewardToken,
|
|
56
|
+
distributorId,
|
|
57
|
+
connection
|
|
58
|
+
}) {
|
|
59
|
+
const program = new Program(merkleDistributor, {
|
|
60
|
+
connection,
|
|
61
|
+
publicKey: signer
|
|
62
|
+
});
|
|
63
|
+
const accounts = await getClaimRewardsContext({
|
|
64
|
+
rewardToken,
|
|
65
|
+
distributorId,
|
|
66
|
+
positionId,
|
|
67
|
+
connection,
|
|
68
|
+
signer
|
|
69
|
+
});
|
|
70
|
+
const ix = await program.methods.claim(
|
|
71
|
+
cumulativeAmount,
|
|
72
|
+
positionType,
|
|
73
|
+
positionId,
|
|
74
|
+
cycle,
|
|
75
|
+
merkleProof.map((proof) => [...proof]),
|
|
76
|
+
metadata
|
|
77
|
+
).accounts(accounts).instruction();
|
|
78
|
+
return ix;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { getClaimIx, getClaimRewardsContext };
|