-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetBoundingCurveData.js
More file actions
155 lines (135 loc) · 5.87 KB
/
GetBoundingCurveData.js
File metadata and controls
155 lines (135 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const { ethers } = require("ethers");
const projects = {
// "Xade finance": "0xd36cc7044e8f737f636cef2f8a92738833f3d7d4",
// "Prismo Technology": "0x34d8581a8f23705bbadbf8b18d99c5d296a84356",
// "x23.ai": "0xd27fe67f60fc7c66ec24c14a4c1474d9ed38997c",
// "The Grand Timeline": "0xac518d2e95fb45480f11801737be147a036c2547",
// "Akarun": "0xf3ef1ddc511587bf16351af9ba9947203f014f72",
// "Melodex by DjookyX": "0x0e784b9882668f521c6749f49bca15df08aec243",
// "Ancient Beast": "0xd7b4689fbebc347c264750a7521794c54c70a3cf",
// "Citizen Wallet": "0x4ee1330e0f0200f588f6b8de798b5a00710c6387"
"Lovel project": "0xc5fd6657f888cbc643b3117d8424cffccdc5ba2e"
};
const CONTRACT_ABI = [
// Minimal ABI with only required methods for this example
{
"inputs": [],
"name": "buyFee",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "sellFee",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getReserveRatioForBuying",
"outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getReserveRatioForSelling",
"outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getStaticPriceForBuying",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getStaticPriceForSelling",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getVirtualCollateralSupply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [],
"name": "getVirtualIssuanceSupply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function",
},
{
"inputs": [{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
];
async function mintTokens(amount, contract) {
try {
const mintAmount = ethers.parseUnits(amount.toString(), 18); // Adjust decimals as needed
const tx = await contract.mint(mintAmount);
await tx.wait();
console.log(`Minted ${amount} tokens.`);
} catch (error) {
console.error("Error minting tokens:", error);
throw error; // Rethrow error or handle as needed
}
}
async function main() {
const provider = new ethers.JsonRpcProvider("https://polygon-rpc.com");
try {
// Connect to the contract
// for (const project in projects) {
// const CONTRACT_ADDRESS = "0xb236c6c907051d91e6231557c4563032ff758822";
const CONTRACT_ADDRESS = "0x9776b3A8E233e1Bc1ad24985BaEcFDDd57D47c56";
// console.log(`\nData for ${project} project:`);
// const privateKey = process.env.PRIVATE_KEY;
// const wallet = new ethers.Wallet(privateKey, provider);
const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, provider);
// Call methods and log their outputs
const buyFee = await contract.buyFee();
console.log("Buy Fee:", buyFee.toString());
const sellFee = await contract.sellFee();
console.log("Sell Fee:", sellFee.toString());
const reserveRatioForBuying = await contract.getReserveRatioForBuying();
console.log("Reserve Ratio for Buying:", reserveRatioForBuying.toString());
const reserveRatioForSelling = await contract.getReserveRatioForSelling();
console.log("Reserve Ratio for Selling:", reserveRatioForSelling.toString());
const staticPriceForBuying = await contract.getStaticPriceForBuying();
console.log("Static Price for Buying:", ethers.formatUnits(staticPriceForBuying, 6)); // Assuming the price is in 18 decimals
const actualBuyPrice = ethers.formatUnits(staticPriceForBuying, 6) * 1.1;
console.log("Actual Buy Price (adding 10% to static price):", actualBuyPrice);
const staticPriceForSelling = await contract.getStaticPriceForSelling();
console.log("Static Price for Selling:", ethers.formatUnits(staticPriceForSelling, 6)); // Assuming the price is in 18 decimals
const actualSellPrice = ethers.formatUnits(staticPriceForSelling, 6) * 0.9;
console.log("Actual Sell Price (subtracting 10% from static price):", actualSellPrice);
const virtualCollateralSupply = await contract.getVirtualCollateralSupply();
console.log("Virtual Collateral Supply:", ethers.formatUnits(virtualCollateralSupply, 18)); // Assuming supply is in 18 decimals
const virtualIssuanceSupply = await contract.getVirtualIssuanceSupply();
console.log("Virtual Issuance Supply:", ethers.formatUnits(virtualIssuanceSupply, 18)); // Assuming supply is in 18 decimals
// const role = ethers.encodeBytes32String(configs.USER_ROLE);
// await authorizerContract.generateRoleId(module, role);
// await mintTokens(21590, contract);
// console.log("minted successfully")
// }
} catch (error) {
console.error("Error calling contract methods:", error);
}
}
main();