-
Notifications
You must be signed in to change notification settings - Fork 1
/
curve_get_d.vy_tester.js
36 lines (28 loc) · 5.21 KB
/
curve_get_d.vy_tester.js
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
const ethers = require('ethers');
bytecode = "0x61067f56600436101561000d57610675565b600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052639123128a600051141561037e5734156100ba57600080fd5b60006101405261018060006003818352015b6020610180510260040135610160526101408051610160518181830110156100f357600080fd5b808201905090508152505b81516001018083528114156100cc575b505061014051151561012657600060005260206000f3505b60006101a052610140516101c0526117706101e052610200600060ff818352015b6101c0516102205261026060006003818352015b602061026051026004013561024052610220516101c051808202821582848304141761018657600080fd5b8090509050905061024051600380820282158284830414176101a757600080fd5b8090509050905060018181830110156101bf57600080fd5b8082019050905080806101d157600080fd5b820490509050610220525b815160010180835281141561015b575b50506101c0516101a0526101e05161014051808202821582848304141761021257600080fd5b80905090509050610220516003808202821582848304141761023357600080fd5b8090509050905081818301101561024957600080fd5b808201905090506101c051808202821582848304141761026857600080fd5b809050905090506101e05160018082101561028257600080fd5b808203905090506101c05180820282158284830414176102a157600080fd5b8090509050905060046102205180820282158284830414176102c257600080fd5b809050905090508181830110156102d857600080fd5b8082019050905080806102ea57600080fd5b8204905090506101c0526101a0516101c05111156103315760016101c0516101a0518082101561031957600080fd5b8082039050905011151561032c5761036d565b61035c565b60016101a0516101c0518082101561034857600080fd5b8082039050905011151561035b5761036d565b5b5b8151600101808352811415610147575b50506101c05160005260206000f350005b6323ceeb59600051141561067457341561039757600080fd5b60006101405261018060006003818352015b6020610180510260040135610160526101408051610160518181830110156103d057600080fd5b808201905090508152505b81516001018083528114156103a9575b505061014051151561040357600060005260206000f3505b60006101a052610140516101c0526117706101e052610200600060ff818352015b6101c0516102205261026060006003818352015b602061026051026004013561024052610220516101c051808202821582848304141761046357600080fd5b80905090509050610240516003808202821582848304141761048457600080fd5b80905090509050600181818301101561049c57600080fd5b8082019050905080806104ae57600080fd5b820490509050610220525b8151600101808352811415610438575b50506101c0516101a0526101e0516101405180820282158284830414176104ef57600080fd5b80905090509050610220516003808202821582848304141761051057600080fd5b8090509050905081818301101561052657600080fd5b808201905090506101c051808202821582848304141761054557600080fd5b809050905090506101e05160018082101561055f57600080fd5b808203905090506101c051808202821582848304141761057e57600080fd5b80905090509050600461022051808202821582848304141761059f57600080fd5b809050905090508181830110156105b557600080fd5b8082019050905080806105c757600080fd5b8204905090506101c0526101a0516101c05111156106175760016101c0516101a051808210156105f657600080fd5b80820390509050111515610612576102005160005260206000f3505b61064b565b60016101a0516101c0518082101561062e57600080fd5b8082039050905011151561064a576102005160005260206000f3505b5b5b8151600101808352811415610424575b50506103e8610280526102805160005260206000f350005b5b60006000fd5b61000461067f0361000460003961000461067f036000f3"
abi = [{"name": "get_D", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256[3]", "name": "xp"}], "constant": true, "payable": false, "type": "function", "gas": 1199257}, {"name": "get_I", "outputs": [{"type": "int128", "name": "out"}], "inputs": [{"type": "uint256[3]", "name": "xp"}], "constant": true, "payable": false, "type": "function", "gas": 1206439}]
publicKey = '0xd19af7f1eE49B84C6c75b55bC57b4FDBfc79c0a8'
privatekey = "0xc29c1e85ff7d862460fd05a94945052a5d26f9bb9a9f506f836f723ffc18372e"
const url = "http://127.0.0.1:8545/"
const networkId = 4447
const ethersOptions = { gasLimit: 1500000, gasPrice: 0};
const provider = new ethers.providers.JsonRpcProvider(url);
let wallet = new ethers.Wallet(privatekey, provider);
async function func() {
const factory = new ethers.ContractFactory(abi, bytecode, wallet);
// If your contract requires constructor args, you can specify them here
const contract = await factory.deploy(ethersOptions);
console.log(contract.address);
console.log(contract.deployTransaction);
let coins = ["456749846006512464301838", "778033904303774201784467", "200709219245000000000000"]
i = await contract.get_I([ethers.BigNumber.from(coins[0]), ethers.BigNumber.from(coins[1]), ethers.BigNumber.from(coins[2])])
d = await contract.get_D([ethers.BigNumber.from(coins[0]), ethers.BigNumber.from(coins[1]), ethers.BigNumber.from(coins[2])])
console.log("result GET_i:" + i)
console.log("result GET_d:" + d)
coins = ["1304085406509187237878713", "1682895262442761141953712", "1074915999621000000000000"]
i = await contract.get_I([ethers.BigNumber.from(coins[0]), ethers.BigNumber.from(coins[1]), ethers.BigNumber.from(coins[2])])
d = await contract.get_D([ethers.BigNumber.from(coins[0]), ethers.BigNumber.from(coins[1]), ethers.BigNumber.from(coins[2])])
console.log("result GET_i:" + i)
console.log("result GET_d:" + d)
}
func()