@huma-finance/widgets 0.0.62-beta.714 → 0.0.62-beta.715
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.62-beta.
|
|
3
|
+
"version": "0.0.62-beta.715+4473ca6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@ethersproject/experimental": "^5.7.0",
|
|
30
30
|
"@ethersproject/providers": "^5.6.0",
|
|
31
31
|
"@ethersproject/units": "^5.6.0",
|
|
32
|
-
"@huma-finance/sdk": "^0.0.62-beta.
|
|
33
|
-
"@huma-finance/shared": "^0.0.62-beta.
|
|
34
|
-
"@huma-finance/web-shared": "^0.0.
|
|
32
|
+
"@huma-finance/sdk": "^0.0.62-beta.715+4473ca6",
|
|
33
|
+
"@huma-finance/shared": "^0.0.62-beta.715+4473ca6",
|
|
34
|
+
"@huma-finance/web-shared": "^0.0.62-beta.715+4473ca6",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
37
37
|
"@mui/styles": "^5.0.2",
|
|
@@ -203,5 +203,5 @@
|
|
|
203
203
|
"optionalDependencies": {
|
|
204
204
|
"encoding": "^0.1.13"
|
|
205
205
|
},
|
|
206
|
-
"gitHead": "
|
|
206
|
+
"gitHead": "4473ca6337bf31ce06707d58d522a7d511bac3e9"
|
|
207
207
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CampaignService,
|
|
3
3
|
checkIsDev,
|
|
4
|
+
convertToShares,
|
|
5
|
+
getSentinelAddress,
|
|
4
6
|
getTokenAccounts,
|
|
5
7
|
SolanaPoolInfo,
|
|
6
8
|
SolanaTokenUtils,
|
|
@@ -13,9 +15,14 @@ import {
|
|
|
13
15
|
useHumaProgram,
|
|
14
16
|
useLenderAccounts,
|
|
15
17
|
} from '@huma-finance/web-shared'
|
|
16
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
createApproveCheckedInstruction,
|
|
20
|
+
TOKEN_2022_PROGRAM_ID,
|
|
21
|
+
TOKEN_PROGRAM_ID,
|
|
22
|
+
} from '@solana/spl-token'
|
|
17
23
|
import { useWallet } from '@solana/wallet-adapter-react'
|
|
18
|
-
import { Transaction } from '@solana/web3.js'
|
|
24
|
+
import { PublicKey, Transaction } from '@solana/web3.js'
|
|
25
|
+
import { BN } from '@coral-xyz/anchor'
|
|
19
26
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
20
27
|
import { setPointsAccumulated, setStep } from '../../../store/widgets.reducers'
|
|
21
28
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
@@ -39,6 +46,7 @@ export function Transfer({
|
|
|
39
46
|
const isDev = checkIsDev()
|
|
40
47
|
const dispatch = useAppDispatch()
|
|
41
48
|
const { publicKey } = useWallet()
|
|
49
|
+
const sentinel = getSentinelAddress(poolInfo.chainId)
|
|
42
50
|
const { supplyAmount } = useAppSelector(selectWidgetState)
|
|
43
51
|
const { decimals } = poolInfo.underlyingMint
|
|
44
52
|
const supplyBigNumber = SolanaTokenUtils.parseUnits(
|
|
@@ -51,6 +59,8 @@ export function Transfer({
|
|
|
51
59
|
seniorLenderApprovedAccountPDA,
|
|
52
60
|
seniorLenderStateAccount,
|
|
53
61
|
juniorLenderStateAccount,
|
|
62
|
+
seniorTrancheMintSupply,
|
|
63
|
+
juniorTrancheMintSupply,
|
|
54
64
|
loading: isLoadingLenderAccounts,
|
|
55
65
|
} = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
|
|
56
66
|
const program = useHumaProgram(poolInfo.chainId)
|
|
@@ -145,6 +155,33 @@ export function Transfer({
|
|
|
145
155
|
.transaction()
|
|
146
156
|
tx.add(depositTx)
|
|
147
157
|
|
|
158
|
+
// Approve automatic redemptions
|
|
159
|
+
const sharesAmount = convertToShares(
|
|
160
|
+
selectedTranche === 'senior'
|
|
161
|
+
? new BN(poolState.seniorTrancheAssets ?? 0)
|
|
162
|
+
: new BN(poolState.juniorTrancheAssets ?? 0),
|
|
163
|
+
selectedTranche === 'senior'
|
|
164
|
+
? seniorTrancheMintSupply ?? new BN(0)
|
|
165
|
+
: juniorTrancheMintSupply ?? new BN(0),
|
|
166
|
+
supplyBigNumber,
|
|
167
|
+
)
|
|
168
|
+
tx.add(
|
|
169
|
+
createApproveCheckedInstruction(
|
|
170
|
+
selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
|
|
171
|
+
new PublicKey(
|
|
172
|
+
selectedTranche === 'senior'
|
|
173
|
+
? poolInfo.seniorTrancheMint
|
|
174
|
+
: poolInfo.juniorTrancheMint,
|
|
175
|
+
),
|
|
176
|
+
new PublicKey(sentinel), // delegate
|
|
177
|
+
publicKey, // owner of the wallet
|
|
178
|
+
BigInt(sharesAmount.muln(1.1).toString()), // amount
|
|
179
|
+
poolInfo.trancheDecimals,
|
|
180
|
+
undefined, // multiSigners
|
|
181
|
+
TOKEN_2022_PROGRAM_ID,
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
|
|
148
185
|
setTransaction(tx)
|
|
149
186
|
}
|
|
150
187
|
getTx()
|
|
@@ -152,12 +189,17 @@ export function Transfer({
|
|
|
152
189
|
isLoadingLenderAccounts,
|
|
153
190
|
juniorLenderApprovedAccountPDA,
|
|
154
191
|
juniorLenderStateAccount,
|
|
192
|
+
juniorTrancheMintSupply,
|
|
155
193
|
poolInfo,
|
|
194
|
+
poolState.juniorTrancheAssets,
|
|
195
|
+
poolState.seniorTrancheAssets,
|
|
156
196
|
program.methods,
|
|
157
197
|
publicKey,
|
|
158
198
|
selectedTranche,
|
|
159
199
|
seniorLenderApprovedAccountPDA,
|
|
160
200
|
seniorLenderStateAccount,
|
|
201
|
+
seniorTrancheMintSupply,
|
|
202
|
+
sentinel,
|
|
161
203
|
supplyBigNumber,
|
|
162
204
|
transaction,
|
|
163
205
|
])
|
|
@@ -44,7 +44,7 @@ export function Success({
|
|
|
44
44
|
return [
|
|
45
45
|
`You can begin submitting redemption requests on ${timeUtil.timestampToLL(
|
|
46
46
|
lockupEndTime.unix(),
|
|
47
|
-
)}
|
|
47
|
+
)}. Your deposit will be automatically redeemed and your yield rewards will stop on ${timeUtil.timestampToLL(
|
|
48
48
|
withdrawTime.unix(),
|
|
49
49
|
)}.`,
|
|
50
50
|
]
|