@venusprotocol/oracle 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -0
- package/deploy/oracles.ts +104 -0
- package/package.json +2 -2
- package/deploy/oracles.d.ts +0 -5
- package/deploy/oracles.d.ts.map +0 -1
- package/deploy/oracles.js +0 -105
- package/deploy/oracles.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Venus Oracle
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
### Pre Requisites
|
|
6
|
+
|
|
7
|
+
Before running any command, you need to create a `.env` file and set a BIP-39 compatible mnemonic as an environment
|
|
8
|
+
variable. Follow the example in `.env.example`. If you don't already have a mnemonic, use this [website](https://iancoleman.io/bip39/) to generate one.
|
|
9
|
+
|
|
10
|
+
Then, proceed with installing dependencies:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
$ yarn install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Compile
|
|
17
|
+
|
|
18
|
+
Compile the smart contracts with Hardhat:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
$ yarn compile
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### TypeChain
|
|
25
|
+
|
|
26
|
+
Compile the smart contracts and generate TypeChain artifacts:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
$ yarn typechain
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Lint Solidity
|
|
33
|
+
|
|
34
|
+
Lint the Solidity code:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
$ yarn lint:sol
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Lint TypeScript
|
|
41
|
+
|
|
42
|
+
Lint the TypeScript code:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
$ yarn lint:ts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Test
|
|
49
|
+
|
|
50
|
+
Run the Mocha tests:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
$ yarn test
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Coverage
|
|
57
|
+
|
|
58
|
+
Generate the code coverage report:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
$ yarn coverage
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Report Gas
|
|
65
|
+
|
|
66
|
+
See the gas usage per unit test and average gas per method call:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
$ REPORT_GAS=true yarn test
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Clean
|
|
73
|
+
|
|
74
|
+
Delete the smart contract artifacts, the coverage reports and the Hardhat cache:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
$ yarn clean
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Deploy
|
|
81
|
+
|
|
82
|
+
Deploy the contracts to Hardhat Network:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
$ yarn deploy --greeting "Bonjour, le monde!" --network bsctestnet
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Verify
|
|
89
|
+
|
|
90
|
+
Verify the contracts through `hardhat-deploy`
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
$ yarn etherscan-verify --network bsctestnet
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Syntax Highlighting
|
|
97
|
+
|
|
98
|
+
If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the [hardhat-vscode](https://github.com/NomicFoundation/hardhat-vscode) extension.
|
|
99
|
+
|
|
100
|
+
## Caveats
|
|
101
|
+
|
|
102
|
+
### Ethers and Waffle
|
|
103
|
+
|
|
104
|
+
If you can't get the [Waffle matchers](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html) to work, try to
|
|
105
|
+
make your `ethers` package version match the version used by the `@ethereum-waffle/chai` package. Seem
|
|
106
|
+
[#111](https://github.com/paulrberg/solidity-template/issues/111) for more details.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// npx hardhat deploy --network bsctestnet
|
|
2
|
+
import networks from "@venusprotocol/venus-protocol/networks/mainnet.json";
|
|
3
|
+
import hre from "hardhat";
|
|
4
|
+
import { DeployFunction } from "hardhat-deploy/dist/types";
|
|
5
|
+
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
6
|
+
|
|
7
|
+
const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
|
|
8
|
+
const { deploy } = deployments;
|
|
9
|
+
const { deployer } = await getNamedAccounts();
|
|
10
|
+
|
|
11
|
+
await deploy("BoundValidator", {
|
|
12
|
+
from: deployer,
|
|
13
|
+
log: true,
|
|
14
|
+
deterministicDeployment: false,
|
|
15
|
+
proxy: {
|
|
16
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
17
|
+
execute: {
|
|
18
|
+
methodName: "initialize",
|
|
19
|
+
args: [],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const boundValidator = await hre.ethers.getContract("BoundValidator");
|
|
25
|
+
|
|
26
|
+
await deploy("ResilientOracle", {
|
|
27
|
+
from: deployer,
|
|
28
|
+
log: true,
|
|
29
|
+
deterministicDeployment: false,
|
|
30
|
+
proxy: {
|
|
31
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
32
|
+
execute: {
|
|
33
|
+
methodName: "initialize",
|
|
34
|
+
args: [boundValidator.address],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await deploy("ChainlinkOracle", {
|
|
40
|
+
contract: network.live ? "ChainlinkOracle" : "MockChainlinkOracle",
|
|
41
|
+
from: deployer,
|
|
42
|
+
log: true,
|
|
43
|
+
deterministicDeployment: false,
|
|
44
|
+
proxy: {
|
|
45
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
46
|
+
execute: {
|
|
47
|
+
methodName: "initialize",
|
|
48
|
+
args: [],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const vBNBAddress = networks.Contracts.vBNB;
|
|
54
|
+
|
|
55
|
+
await deploy("PivotTwapOracle", {
|
|
56
|
+
contract: network.live ? "PivotTwapOracle" : "MockTwapOracle",
|
|
57
|
+
from: deployer,
|
|
58
|
+
log: true,
|
|
59
|
+
deterministicDeployment: false,
|
|
60
|
+
proxy: {
|
|
61
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
62
|
+
execute: {
|
|
63
|
+
methodName: "initialize",
|
|
64
|
+
args: [vBNBAddress],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// @todo: just testnet address, will be replaced to mainnet version in the future
|
|
70
|
+
const actualPythOracleAddress = "0xd7308b14BF4008e7C7196eC35610B1427C5702EA";
|
|
71
|
+
|
|
72
|
+
await deploy("PythOracle", {
|
|
73
|
+
contract: network.live ? "PythOracle" : "MockPythOracle",
|
|
74
|
+
from: deployer,
|
|
75
|
+
log: true,
|
|
76
|
+
deterministicDeployment: false,
|
|
77
|
+
proxy: {
|
|
78
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
79
|
+
execute: {
|
|
80
|
+
methodName: "initialize",
|
|
81
|
+
args: [actualPythOracleAddress],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// @todo: just testnet address, will be replaced to mainnet version in the future
|
|
87
|
+
const actualBinanceFeedRegistryAddress = "0x999DD49FeFdC043fDAC4FE12Bb1e4bb31cB4c47B";
|
|
88
|
+
|
|
89
|
+
await deploy("BinanceOracle", {
|
|
90
|
+
contract: network.live ? "BinanceOracle" : "MockBinanceOracle",
|
|
91
|
+
from: deployer,
|
|
92
|
+
log: true,
|
|
93
|
+
deterministicDeployment: false,
|
|
94
|
+
proxy: {
|
|
95
|
+
proxyContract: "OptimizedTransparentProxy",
|
|
96
|
+
execute: {
|
|
97
|
+
methodName: "initialize",
|
|
98
|
+
args: [actualBinanceFeedRegistryAddress],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default func;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venusprotocol/oracle",
|
|
3
3
|
"description": "Venus Protocol Price Oracle",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"author": "",
|
|
6
6
|
"files": [
|
|
7
7
|
"artifacts",
|
|
@@ -96,4 +96,4 @@
|
|
|
96
96
|
"@nomiclabs/hardhat-ethers": "node_modules/hardhat-deploy-ethers",
|
|
97
97
|
"@nomiclabs/hardhat-ethers/types": "hardhat-deploy-ethers/types"
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
}
|
package/deploy/oracles.d.ts
DELETED
package/deploy/oracles.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oracles.d.ts","sourceRoot":"","sources":["../../deploy/oracles.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,QAAA,MAAM,IAAI,EAAE,cA+FX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/deploy/oracles.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
require("hardhat-deploy-ethers");
|
|
16
|
-
const mainnet_json_1 = __importDefault(require("@venusprotocol/venus-protocol/networks/mainnet.json"));
|
|
17
|
-
const hardhat_1 = require("hardhat");
|
|
18
|
-
const func = function ({ getNamedAccounts, deployments, network }) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const { deploy } = deployments;
|
|
21
|
-
const { deployer } = yield getNamedAccounts();
|
|
22
|
-
yield deploy("BoundValidator", {
|
|
23
|
-
from: deployer,
|
|
24
|
-
log: true,
|
|
25
|
-
deterministicDeployment: false,
|
|
26
|
-
proxy: {
|
|
27
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
28
|
-
execute: {
|
|
29
|
-
methodName: "initialize",
|
|
30
|
-
args: [],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
const boundValidator = yield hardhat_1.ethers.getContract("BoundValidator");
|
|
35
|
-
yield deploy("ResilientOracle", {
|
|
36
|
-
from: deployer,
|
|
37
|
-
log: true,
|
|
38
|
-
deterministicDeployment: false,
|
|
39
|
-
proxy: {
|
|
40
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
41
|
-
execute: {
|
|
42
|
-
methodName: "initialize",
|
|
43
|
-
args: [boundValidator.address],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
yield deploy("ChainlinkOracle", {
|
|
48
|
-
contract: network.live ? "ChainlinkOracle" : "MockChainlinkOracle",
|
|
49
|
-
from: deployer,
|
|
50
|
-
log: true,
|
|
51
|
-
deterministicDeployment: false,
|
|
52
|
-
proxy: {
|
|
53
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
54
|
-
execute: {
|
|
55
|
-
methodName: "initialize",
|
|
56
|
-
args: [],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
const vBNBAddress = mainnet_json_1.default.Contracts.vBNB;
|
|
61
|
-
yield deploy("PivotTwapOracle", {
|
|
62
|
-
contract: network.live ? "PivotTwapOracle" : "MockTwapOracle",
|
|
63
|
-
from: deployer,
|
|
64
|
-
log: true,
|
|
65
|
-
deterministicDeployment: false,
|
|
66
|
-
proxy: {
|
|
67
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
68
|
-
execute: {
|
|
69
|
-
methodName: "initialize",
|
|
70
|
-
args: [vBNBAddress],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
const actualPythOracleAddress = "0xd7308b14BF4008e7C7196eC35610B1427C5702EA";
|
|
75
|
-
yield deploy("PythOracle", {
|
|
76
|
-
contract: network.live ? "PythOracle" : "MockPythOracle",
|
|
77
|
-
from: deployer,
|
|
78
|
-
log: true,
|
|
79
|
-
deterministicDeployment: false,
|
|
80
|
-
proxy: {
|
|
81
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
82
|
-
execute: {
|
|
83
|
-
methodName: "initialize",
|
|
84
|
-
args: [actualPythOracleAddress],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
const actualBinanceFeedRegistryAddress = "0x999DD49FeFdC043fDAC4FE12Bb1e4bb31cB4c47B";
|
|
89
|
-
yield deploy("BinanceOracle", {
|
|
90
|
-
contract: network.live ? "BinanceOracle" : "MockBinanceOracle",
|
|
91
|
-
from: deployer,
|
|
92
|
-
log: true,
|
|
93
|
-
deterministicDeployment: false,
|
|
94
|
-
proxy: {
|
|
95
|
-
proxyContract: "OptimizedTransparentProxy",
|
|
96
|
-
execute: {
|
|
97
|
-
methodName: "initialize",
|
|
98
|
-
args: [actualBinanceFeedRegistryAddress],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
exports.default = func;
|
|
105
|
-
//# sourceMappingURL=oracles.js.map
|
package/deploy/oracles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oracles.js","sourceRoot":"","sources":["../../deploy/oracles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iCAA+B;AAC/B,uGAA2E;AAC3E,qCAAiC;AAIjC,MAAM,IAAI,GAAmB,UAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAA6B;;QAChH,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;QAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;QAE9C,MAAM,MAAM,CAAC,gBAAgB,EAAE;YAC7B,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,IAAI;YACT,uBAAuB,EAAE,KAAK;YAC9B,KAAK,EAAE;gBACL,aAAa,EAAE,2BAA2B;gBAC1C,OAAO,EAAE;oBACP,UAAU,EAAE,YAAY;oBACxB,IAAI,EAAE,EAAE;iBACT;aACF;SACF,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,gBAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAElE,MAAM,MAAM,CAAC,iBAAiB,EAAE;YAC9B,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,IAAI;YACT,uBAAuB,EAAE,KAAK;YAC9B,KAAK,EAAE;gBACL,aAAa,EAAE,2BAA2B;gBAC1C,OAAO,EAAE;oBACP,UAAU,EAAE,YAAY;oBACxB,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;iBAC/B;aACF;SACF,CAAC,CAAC;QAEH,MAAM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