diff --git a/apps/contracts/src/deploy_hodl.ts b/apps/contracts/src/deploy_hodl.ts
index ff71ad4e..5e5fc14b 100644
--- a/apps/contracts/src/deploy_hodl.ts
+++ b/apps/contracts/src/deploy_hodl.ts
@@ -1,4 +1,4 @@
-import { Address, nativeToScVal, xdr, Asset, Networks } from "@stellar/stellar-sdk";
+import { Address, Asset, Networks, xdr } from "@stellar/stellar-sdk";
import { AddressBook } from "./utils/address_book.js";
import {
airdropAccount,
@@ -45,6 +45,9 @@ export async function deployContracts(addressBook: AddressBook) {
const xlmAddress = new Address(xlmContractId);
const xlmScVal = xlmAddress.toScVal();
+ const soroswapUSDC = new Address("CAAFIHB4I7WQMJMKC22CZVQNNX7EONWSOMT6SUXK6I3G3F6J4XFRWNDI");
+ const usdcScVal = soroswapUSDC.toScVal();
+
const emptyVecScVal = xdr.ScVal.scvVec([]);
console.log("Initializing DeFindex HODL Strategy");
@@ -52,7 +55,7 @@ export async function deployContracts(addressBook: AddressBook) {
"hodl_strategy",
addressBook,
"initialize",
- [xlmScVal, emptyVecScVal],
+ [usdcScVal, emptyVecScVal],
loadedConfig.admin
);
}
diff --git a/apps/dapp/app/page.tsx b/apps/dapp/app/page.tsx
index 5e0585e9..42d76f47 100644
--- a/apps/dapp/app/page.tsx
+++ b/apps/dapp/app/page.tsx
@@ -1,10 +1,11 @@
"use client";
-import { Container } from '@chakra-ui/react'
-import { useSorobanReact } from '@soroban-react/core'
import ManageVaults from '@/components/ManageVaults/ManageVaults';
+import { TestTokens } from '@/components/TestTokens';
+import { Container } from '@chakra-ui/react';
+import { useSorobanReact } from '@soroban-react/core';
import {
- Chart as ChartJS,
ArcElement,
+ Chart as ChartJS,
} from 'chart.js';
ChartJS.register(ArcElement);
@@ -15,6 +16,7 @@ export default function Home() {
return (
+ {address && ()}
diff --git a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx
index fbf7df71..86ff3b42 100644
--- a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx
+++ b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx
@@ -1,6 +1,17 @@
'use client'
-import React from 'react'
-import { useEffect, useState } from 'react'
+import {
+ DialogBackdrop,
+ DialogBody,
+ DialogContent,
+ DialogFooter,
+ DialogRoot,
+ DialogTrigger,
+} from '@/components/ui/dialog'
+import { getTokenSymbol } from '@/helpers/getTokenInfo'
+import { StrategyMethod, useStrategyCallback } from '@/hooks/useStrategy'
+import { getDefaultStrategies, pushAmount, pushAsset } from '@/store/lib/features/vaultStore'
+import { useAppDispatch } from '@/store/lib/storeHooks'
+import { Asset, Strategy } from '@/store/lib/types'
import {
Button,
For,
@@ -12,25 +23,13 @@ import {
Stack,
Text,
} from '@chakra-ui/react'
-import { MdAdd } from 'react-icons/md'
-import {
- DialogBackdrop,
- DialogBody,
- DialogContent,
- DialogFooter,
- DialogRoot,
- DialogTrigger,
-} from '@/components/ui/dialog'
-import { useAppDispatch, useAppSelector } from '@/store/lib/storeHooks'
-import { getDefaultStrategies, pushAmount, pushAsset } from '@/store/lib/features/vaultStore'
import { useSorobanReact } from '@soroban-react/core'
-import { Asset, Strategy } from '@/store/lib/types'
-import { CheckboxCard } from '../ui/checkbox-card'
-import { getTokenSymbol } from '@/helpers/getTokenInfo'
-import { StrategyMethod, useStrategyCallback } from '@/hooks/useStrategy'
import { scValToNative, xdr } from '@stellar/stellar-sdk'
-import { InputGroup } from '../ui/input-group'
+import { useEffect, useState } from 'react'
+import { MdAdd } from 'react-icons/md'
import { Checkbox } from '../ui/checkbox'
+import { CheckboxCard } from '../ui/checkbox-card'
+import { InputGroup } from '../ui/input-group'
interface AmountInputProps {
amount: number
@@ -151,7 +150,7 @@ function AddNewStrategyButton() {
size="md"
textAlign={'end'}
disabled={defaultStrategies.length === 0}>
- Add new assets
+ Add Strategy
diff --git a/apps/dapp/src/components/TestTokens.tsx b/apps/dapp/src/components/TestTokens.tsx
new file mode 100644
index 00000000..a5dc14c4
--- /dev/null
+++ b/apps/dapp/src/components/TestTokens.tsx
@@ -0,0 +1,98 @@
+import { useSorobanReact } from "@soroban-react/core";
+
+import { HStack, Text } from "@chakra-ui/react";
+import { contractInvoke } from "@soroban-react/contracts";
+import { Address, Keypair, nativeToScVal, scValToNative, xdr } from "@stellar/stellar-sdk";
+import { useEffect, useState } from "react";
+import { Button } from "./ui/button";
+
+export const TestTokens = () => {
+ const sorobanContext = useSorobanReact();
+ const { address, activeChain, server } = sorobanContext;
+ const networkPassphrase = activeChain?.networkPassphrase ?? '';
+ const [isSubmitting, setSubmitting] = useState(false);
+ const [balance, setBalance] = useState("0");
+
+ const testnetUSDC = "CAAFIHB4I7WQMJMKC22CZVQNNX7EONWSOMT6SUXK6I3G3F6J4XFRWNDI";
+ const admin_account = Keypair.fromSecret(
+ process.env.NEXT_PUBLIC_TEST_TOKENS_ADMIN as string,
+ );
+
+ const fetchBalance = async () => {
+ if (!address) return;
+ contractInvoke({
+ contractAddress: testnetUSDC,
+ method: 'balance',
+ args: [new Address(address).toScVal()],
+ sorobanContext,
+ signAndSend: false,
+ }).then((result) => {
+ let balance = scValToNative(result as xdr.ScVal);
+ balance = BigInt(BigInt(balance) / BigInt(1e7)).toString();
+ setBalance(balance);
+
+ }).catch ((error) => {
+ console.log('🚀 « error:', error);
+ })
+ }
+
+ useEffect(() => {
+ fetchBalance();
+ }, [address])
+
+ const handleMint = async () => {
+ console.log("Minting");
+ setSubmitting(true);
+
+ const amount = 1000000000000
+
+ let adminSource;
+
+ try {
+ adminSource = await server?.getAccount(admin_account.publicKey());
+ } catch (error) {
+ alert('Your wallet or the token admin wallet might not be funded');
+ setSubmitting(false);
+ return;
+ }
+
+ if (!address) {
+ return;
+ }
+ if (!adminSource) {
+ return;
+ }
+
+ try {
+ let result = await contractInvoke({
+ contractAddress: testnetUSDC,
+ method: 'mint',
+ args: [new Address(address).toScVal(), nativeToScVal(amount, {type: 'i128'})],
+ sorobanContext,
+ signAndSend: true,
+ secretKey: admin_account.secret(),
+ });
+ if (result) {
+ fetchBalance();
+ }
+ } catch (error) {
+ console.log('🚀 « error:', error);
+ }
+
+ setSubmitting(false);
+ }
+
+ return (
+
+ Current Balance: {balance} USDC
+
+
+ );
+};
diff --git a/apps/dapp/src/components/ui/button.tsx b/apps/dapp/src/components/ui/button.tsx
new file mode 100644
index 00000000..21d5f4b5
--- /dev/null
+++ b/apps/dapp/src/components/ui/button.tsx
@@ -0,0 +1,40 @@
+import type { ButtonProps as ChakraButtonProps } from "@chakra-ui/react"
+import {
+ AbsoluteCenter,
+ Button as ChakraButton,
+ Span,
+ Spinner,
+} from "@chakra-ui/react"
+import * as React from "react"
+
+interface ButtonLoadingProps {
+ loading?: boolean
+ loadingText?: React.ReactNode
+}
+
+export interface ButtonProps extends ChakraButtonProps, ButtonLoadingProps {}
+
+export const Button = React.forwardRef(
+ function Button(props, ref) {
+ const { loading, disabled, loadingText, children, ...rest } = props
+ return (
+
+ {loading && !loadingText ? (
+ <>
+
+
+
+ {children}
+ >
+ ) : loading && loadingText ? (
+ <>
+
+ {loadingText}
+ >
+ ) : (
+ children
+ )}
+
+ )
+ },
+)
diff --git a/public/testnet.contracts.json b/public/testnet.contracts.json
index 222db3d1..c00c6f35 100644
--- a/public/testnet.contracts.json
+++ b/public/testnet.contracts.json
@@ -1,7 +1,7 @@
{
"ids": {
- "hodl_strategy": "CDY2ZG5A4253BXSVI4MRY43AIDLUII4XUGZ35MR36D65BLL7EKQQ7U7V",
- "defindex_factory": "CBZSKTHG7Y3JUDB2LK5MMWYEV25UYRFK7JHRESW6X5UVIP5VYCTI6MNA"
+ "hodl_strategy": "CAEYFO6TY5MMPHSX6CMUKSDHPFVLJKV4TFPHE4ZXAEER2NEIB5GSVBVG",
+ "defindex_factory": "CBHW3ETUDAZ4FKKEEASONLALSZAYR6IMBA2THXKRPGRAVRG7UQLZFEKP"
},
"hashes": {
"hodl_strategy": "fcdb4a3c11525a1f32611951741bca5bc4196f58fd1633af37d5b35d30fdf5b0",