Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
Another-DevX committed Dec 3, 2023
1 parent 5b29646 commit 333e983
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion kiwi/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { title } from 'process'
export default function Home () {
const draw = {
hidden: { pathLength: 0, opacity: 0 },
visible: i => {
visible: (i: any) => {
const delay = 1 + i * 0.5
return {
pathLength: 1,
Expand Down
22 changes: 11 additions & 11 deletions kiwi/src/components/CurrentLoans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,30 @@ const minValue = 800
const maxValue = 5000

function CurrentLoans () {
const [id, setId] = useState(null)
const [id, setId] = useState<string | null>(null)
const { writeAsync: payLend } = usePayLend()

const form = useForm()

async function onSubmit (values) {
async function onSubmit (values: any) {
console.debug({ values }, id)
await payLend({
args: [parseInt(id), parseEther(values.value)]
args: [parseInt(id as string), parseEther(values.value)]
})
}

const setMinValue = minValue => {
const setMinValue = (minValue: any) => {
form.setValue('value', minValue, { shouldValidate: true })
}

const { data, isLoading } = useLendHistory()

const lendingHistory: Lend[] = data as Lend[]

function getTotalValue (data) {
function getTotalValue (data: any) {
if (!data) return 0
let currentValue = 0
data.forEach(element => {
data.forEach((element: any) => {
const some = Number(element.netAmount)
currentValue = currentValue + some / 10 ** 18
})
Expand Down Expand Up @@ -113,7 +113,7 @@ function CurrentLoans () {
</TableRow>
) : (
lendingHistory.map(currentLend => (
<TableRow key={Number(currentLend.id) }>
<TableRow key={Number(currentLend.id)}>
<Dialog>
<DialogTrigger className='cursor-pointer' asChild>
<TableCell className='font-medium text-blue-600 font-bold'>
Expand All @@ -138,16 +138,16 @@ function CurrentLoans () {
rules={{
required: 'Este campo es requerido',
min: {
value: Math.floor(
value:
formatEther(
currentLend.netAmount / currentLend.quotas
)
),
message: `El monto debe ser mayor a: ${Math.floor(
,
message: `El monto debe ser mayor a: ${
formatEther(
currentLend.netAmount / currentLend.quotas
)
)}`
}`
},
max: {
value: formatEther(currentLend.netAmount),
Expand Down
4 changes: 2 additions & 2 deletions kiwi/src/components/FundLoan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function FundLoan () {
const { data: limit } = useLendLimits()
const { writeAsync: approve } = useErc20Approve()

async function onSubmit (values) {
async function onSubmit (values: any) {
await approve({
args: [lendingManagerAddress, parseEther(values.value)]
})
Expand All @@ -54,7 +54,7 @@ function FundLoan () {
if (fund) await fund()
}

async function onLoanSubmit (values) {
async function onLoanSubmit (values: any) {
console.debug(values)
await loan({
args: [parseEther(values.value), values.months]
Expand Down
8 changes: 7 additions & 1 deletion kiwi/src/components/TotalFunds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ function TotalFunds () {
{BigInt(totalValue as bigint) == BigInt(0) ||
BigInt(interest as bigint) == BigInt(0)
? 0
: formatEther(initialValue / totalValue) * 10 ** 17 * 100}
: parseFloat(
formatEther(
(initialValue as bigint) / (totalValue as bigint)
)
) *
10 ** 17 *
100}
% en total
</p>
<p className='text-xs text-accent'>
Expand Down

0 comments on commit 333e983

Please sign in to comment.