Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ THIRDWEB_CLIENT_ID=
THIRDWEB_SECRET_KEY=

# Hashkey Chain (Inventory Settler)
HASHKEY_RPC_URL=https://hashkeychain-testnet.alt.technology
HASHKEY_RPC_URL=https://testnet.hsk.xyz
GRIFFIN_VAULT_ADDRESS=
GRIFFIN_OPERATOR_PRIVATE_KEY=
GRIFFIN_DEX_ADDRESS=
2 changes: 1 addition & 1 deletion packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Create `.env` file:

```bash
PRIVATE_KEY=your_private_key_here
HASHKEY_RPC_URL=https://hashkeychain-testnet.alt.technology
HASHKEY_RPC_URL=https://testnet.hsk.xyz
```

## Compile
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import * as dotenv from "dotenv";
import dotenv from "dotenv";

dotenv.config();

Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"test": "hardhat test",
"deploy": "hardhat run scripts/deploy.ts",
"deploy:hashkey": "hardhat run scripts/deploy.ts --network hashkey",
"check-balance": "hardhat run scripts/check-balance.ts --network hashkey"
"check-balance": "hardhat run scripts/check-balance.ts --network hashkey",
"deploy:tokens": "hardhat run scripts/deployTokens.ts --network hashkey",
"approve:tokens": "hardhat run scripts/approveTokens.ts --network hashkey"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
Expand Down
56 changes: 56 additions & 0 deletions packages/contracts/scripts/approveTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ethers } from "hardhat";
import dotenv from "dotenv";

dotenv.config();

/**
* Approves GriffinDEX to spend Griffin's vault tokens.
* Must be run before any swap can execute.
*
* Run:
* npx hardhat run scripts/approveTokens.ts --network hashkey
*/

const DEX_ADDRESS = process.env.GRIFFIN_DEX_ADDRESS || "";
const THSK_ADDRESS = "0xb8F355f10569FD2A765296161d082Cc37c5843c2";
const TUSDC_ADDRESS = "0xc4C2841367016C9e2652Fecc49bBA9229787bA82";

const MAX_UINT256 = ethers.MaxUint256;

const ERC20_ABI = [
"function approve(address spender, uint256 amount) returns (bool)",
"function allowance(address owner, address spender) view returns (uint256)",
];

async function main() {
const [signer] = await ethers.getSigners();
console.log("Approving from:", signer.address);
console.log("DEX address: ", DEX_ADDRESS);

const tHSK = new ethers.Contract(THSK_ADDRESS, ERC20_ABI, signer);
const tUSDC = new ethers.Contract(TUSDC_ADDRESS, ERC20_ABI, signer);

console.log("\nApproving tHSK...");
const tx1 = await tHSK.approve(DEX_ADDRESS, MAX_UINT256);
await tx1.wait();
console.log("tHSK approved:", tx1.hash);

console.log("\nApproving tUSDC...");
const tx2 = await tUSDC.approve(DEX_ADDRESS, MAX_UINT256);
await tx2.wait();
console.log("tUSDC approved:", tx2.hash);

// Verify
const allowanceHSK = await tHSK.allowance(signer.address, DEX_ADDRESS);
const allowanceUSDC = await tUSDC.allowance(signer.address, DEX_ADDRESS);
console.log("\nAllowances confirmed:");
console.log(" tHSK: ", allowanceHSK.toString());
console.log(" tUSDC:", allowanceUSDC.toString());
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
99 changes: 99 additions & 0 deletions packages/contracts/scripts/deployTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { ethers } from "hardhat";

/**
* Deploys two MockERC20 tokens (tHSK and tUSDC) to the target network,
* then seeds a GriffinDEX liquidity pool with both tokens.
*
* Prerequisites:
* - PRIVATE_KEY set in .env (deployer wallet, must have gas)
* - GRIFFIN_DEX_ADDRESS set in .env (already deployed GriffinDEX)
*
* Run:
* npx hardhat run scripts/deployTokens.ts --network hashkey
*/

const DEX_ADDRESS = process.env.GRIFFIN_DEX_ADDRESS || "";

// Initial supply minted to deployer for each token
const THSK_SUPPLY = 1_000_000n; // 1M tHSK (18 decimals)
const TUSDC_SUPPLY = 1_000_000n; // 1M tUSDC (6 decimals)

// Liquidity to seed the pool with
const POOL_THSK = ethers.parseUnits("10000", 18); // 10,000 tHSK
const POOL_TUSDC = ethers.parseUnits("10000", 6); // 10,000 tUSDC

async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deployer:", deployer.address);
console.log("Balance:", ethers.formatEther(await ethers.provider.getBalance(deployer.address)), "HSK\n");

// -------------------------------------------------------------------------
// 1. Deploy tHSK
// -------------------------------------------------------------------------
console.log("Deploying tHSK...");
const MockERC20 = await ethers.getContractFactory("MockERC20");
const tHSK = await MockERC20.deploy("Test HSK", "tHSK", 18, THSK_SUPPLY);
await tHSK.waitForDeployment();
const tHSKAddress = await tHSK.getAddress();
console.log("tHSK deployed to:", tHSKAddress);

// -------------------------------------------------------------------------
// 2. Deploy tUSDC
// -------------------------------------------------------------------------
console.log("\nDeploying tUSDC...");
const tUSDC = await MockERC20.deploy("Test USDC", "tUSDC", 6, TUSDC_SUPPLY);
await tUSDC.waitForDeployment();
const tUSDCAddress = await tUSDC.getAddress();
console.log("tUSDC deployed to:", tUSDCAddress);

// -------------------------------------------------------------------------
// 3. Seed GriffinDEX pool (if DEX address is provided)
// -------------------------------------------------------------------------
if (!DEX_ADDRESS) {
console.log("\nGRIFFIN_DEX_ADDRESS not set — skipping pool creation.");
console.log("Set it and re-run to seed the pool.");
} else {
console.log("\nSeeding GriffinDEX pool at", DEX_ADDRESS, "...");

const dex = await ethers.getContractAt("GriffinDEX", DEX_ADDRESS);

// Create pool
const createTx = await dex.createPool(tHSKAddress, tUSDCAddress);
await createTx.wait();
console.log("Pool created");

// Approve DEX to spend deployer's tokens
await (await tHSK.approve(DEX_ADDRESS, POOL_THSK)).wait();
await (await tUSDC.approve(DEX_ADDRESS, POOL_TUSDC)).wait();
console.log("Approvals done");

// Add liquidity
const liquidityTx = await dex.addLiquidity(
tHSKAddress,
tUSDCAddress,
POOL_THSK,
POOL_TUSDC,
);
await liquidityTx.wait();
console.log("Liquidity added: 10,000 tHSK / 10,000 tUSDC");
}

// -------------------------------------------------------------------------
// 4. Print summary
// -------------------------------------------------------------------------
console.log("\n========================================");
console.log("Add these to your orchestrator .env:");
console.log("========================================");
console.log(`THSK_TOKEN_ADDRESS=${tHSKAddress}`);
console.log(`TUSDC_TOKEN_ADDRESS=${tUSDCAddress}`);
console.log("\nAnd register them in ChainService.ts:");
console.log(`{ address: "${tHSKAddress}", symbol: "tHSK", name: "Test HSK", decimals: 18, chainId: "eip155:133" }`);
console.log(`{ address: "${tUSDCAddress}", symbol: "tUSDC", name: "Test USDC", decimals: 6, chainId: "eip155:133" }`);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion packages/orchestrator/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GRIFFIN_STARKENT_ACCOUNT_ADDRESS=
GRIFFIN_STARKNET_PRIV_KEY=

# Hashkey Chain (Inventory Settler)
HASHKEY_RPC_URL=https://hashkeychain-testnet.alt.technology
HASHKEY_RPC_URL=https://testnet.hsk.xyz
GRIFFIN_VAULT_ADDRESS= # Griffin's wallet address holding token reserves
GRIFFIN_OPERATOR_PRIVATE_KEY= # Private key that signs transfer transactions — keep secret
GRIFFIN_DEX_ADDRESS= # Deployed GriffinDEX contract address
Expand Down
Loading
Loading