Skip to content

Commit

Permalink
update SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbacoa committed May 27, 2022
1 parent 1499304 commit 7d63065
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/esm/Fuse/addresses/arbitrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
FUSE_POOL_LENS_SECONDARY_CONTRACT_ADDRESS: "0x32ca4E5D75ECb06f33846055652C831f6E7a6924",
// CEther and CERC20
COMPTROLLER_IMPLEMENTATION_CONTRACT_ADDRESS: "0x53cc546053a09431c9d1a2b288471680d15000a4",
CETHER_DELEGATE_CONTRACT_ADDRESS: "0x440253a301b4fc749a24e653fdb11b742e621892",
CETHER_DELEGATE_CONTRACT_ADDRESS: "0xa399432fb9d53a56d60b3732e79afebe6484312c",
CERC20_DELEGATE_CONTRACT_ADDRESS: "0x89971b89e346fc372641a1ae427add6a738df50d",
// Oracles
MASTER_PRICE_ORACLE_IMPLEMENTATION_CONTRACT_ADDRESS: "0x59FA438cD0731EBF5F4cDCaf72D4960EFd13FCe6",
Expand All @@ -16,15 +16,15 @@ export default {
MasterPriceOracle: "0x137a6Bf7D4C866fFd430cDd0107dE6C4828Ce54d",
ChainlinkPriceOracleV2: "0xd1a758149896530a114c7f5e4c4daf093fc184a6",
FixedETHPriceOracle: "0xf826E4fE62c206Ec51B5744b29C71A2245DD540e",
GOhmPriceOracleArbitrum: "0xE18eC050838175eFdc4e878B087D986638a1FFa7",
GOhmPriceOracleArbitrum: "0xA7aC11110F13097a022A6A975BdDc4a3ed6a23bD",
UniswapTwapPriceOracleV2_SushiSwap_ETH: "0x41fa6c04b8a2d1a30200f39b4714c78c81e0e227",
UniswapTwapPriceOracleV2_SushiSwap_GOHM: "0x71bc92b8b848c287f82a56efe1f30a439b1976b2",
},
PRICE_ORACLE_RUNTIME_BYTECODE_HASHES: {
MasterPriceOracle: "0x841c8cee670b29a8e8d2d56b6b1706b0a17beffc57ceeaa730d33821a7193eb8",
ChainlinkPriceOracleV2: "0xe6c58b50e22444dda782858120184cbc86207e51be06e0f747561a8c9eb4c968",
FixedETHPriceOracle: "0x009b75414e3135a12bb0d9ee0a420f96a41b198df7ee9c4a5667a05187860a1d",
GOhmPriceOracleArbitrum: "0xce075a561806260b1d4472b68c07b3784c1f5b2065500f2f217085fcf78e4470",
GOhmPriceOracleArbitrum: "0x1103989d8bf5ce18084976a1bc279c029bc5b5c6c82aa127b57e943e9b3f9670",
UniswapTwapPriceOracleV2_SushiSwap: "0x9fd6d9f10e83d15240e17ade5fbacf6ad30dbffa3b3596ebc985cce96f4aaef2",
},
ORACLES: ["MasterPriceOracle", "ChainlinkPriceOracleV2"],
Expand Down
3 changes: 1 addition & 2 deletions src/esm/Fuse/addresses/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChainID } from "../../utils/networks";
import MAINNET_ADDRESSES from "./mainnet";
import ARBITRUM_ADDRESSES from "./arbitrum";
import ARBITRUM_RINKEBY_ADDRESSES from "./arbitrumRinkeby";
export var CompoundContractVersion;
(function (CompoundContractVersion) {
CompoundContractVersion[CompoundContractVersion["1.0.0"] = 0] = "1.0.0";
Expand Down Expand Up @@ -33,6 +32,6 @@ const addresses = {
[ChainID.HARDHAT]: MAINNET_ADDRESSES,
// Todo - update all these addresses
[ChainID.ARBITRUM]: ARBITRUM_ADDRESSES,
[ChainID.ARBITRUM_TESTNET]: ARBITRUM_RINKEBY_ADDRESSES,
//ChainID.ARBITRUM_TESTNET]: ARBITRUM_RINKEBY_ADDRESSES,
};
export default addresses;
38 changes: 29 additions & 9 deletions src/esm/Fuse/addresses/mainnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
// CEther and CERC20
COMPTROLLER_IMPLEMENTATION_CONTRACT_ADDRESS: "0xe16db319d9da7ce40b666dd2e365a4b8b3c18217",
CERC20_DELEGATE_CONTRACT_ADDRESS: "0x67db14e73c2dce786b5bbbfa4d010deab4bbfcf9",
CETHER_DELEGATE_CONTRACT_ADDRESS: "0xd77e28a1b9a9cfe1fc2eee70e391c05d25853cbf",
CETHER_DELEGATE_CONTRACT_ADDRESS: "0xbDADDC6a1321Ed458b53aB9e51DC0De8dba78D43",
// Oracles
// Implementation for V3
MASTER_PRICE_ORACLE_IMPLEMENTATION_CONTRACT_ADDRESS: "0xb3c8ee7309be658c186f986388c2377da436d8fb",
Expand Down Expand Up @@ -44,7 +44,8 @@ export default {
CurveLiquidityGaugeV2PriceOracle: "0xd9eefdb09d75ca848433079ea72ef609a1c1ea21",
FixedEthPriceOracle: "0xffc9ec4adbf75a537e4d233720f06f0df01fb7f5",
FixedEurPriceOracle: "0x817158553F4391B0d53d242fC332f2eF82463e2a",
WSTEthPriceOracle: "0xb11de4c003c80dc36a810254b433d727ac71c517",
FixedUSDPriceOracle: "0xa7ac11110f13097a022a6a975bddc4a3ed6a23bd",
WSTEthPriceOracle: "0xD007067A6c1877457D179206B628C326600ca36b",
FixedTokenPriceOracle_OHM: "0x71FE48562B816D03Ce9e2bbD5aB28674A8807CC5",
UniswapTwapPriceOracleV2_SushiSwap_DAI: "0x72fd4c801f5845ab672a12bce1b05bdba1fd851a",
UniswapTwapPriceOracleV2_SushiSwap_CRV: "0x552163f2a63f82bb47b686ffc665ddb3ceaca0ea",
Expand All @@ -60,8 +61,17 @@ export default {
GelatoGUniPriceOracle: "0xEa3633b38C747ceA231aDB74b511DC2eD3992B43",
StakedSpellPriceOracle: "0xb544f62045b96a60b398abb5a5c23bf04cb4ed9c",
CurveTriCryptoLpTokenPriceOracle: "0xb2d16916d520d585ee49f08db1436b961b48fe60",
CurveFactoryLpTokenPriceOracle: "0xa9f3faac3b8eDF7b3DCcFDBBf25033D6F5fc02F3",
CurveFactoryLpTokenPriceOracle: "0x4f84a621158CdecBB5e71061127ec7f61418b2F2",
CvxFXSPriceOracle: "0x6104d45971D7E1b0A61Aa5332fC153dcF110D26d",
TribeMasterPriceOracle: "0x4d10BC156FBaD2474a94f792fe0D6c3261469cdd",
BalancerV2TwapPriceOracle: "0x5B643292e3733f5691ac7fd7ce14D2FD3c2dF868",
BalancerStableLpTokenPriceOracle: "0xe058d9dBA5076627639c045d45Cb5d8d24D9A9B4",
XVaultPriceOracle: "0x6503cae60b13b9a563fcd0d7fbe81d9cc5db7e00",
ETHMAXYPriceOracle: "0x745B95bE182A01408bccb1c35ab2927866A5CAd3",
SaddleLpTokenPriceOracle: "0x7cFa667E9c6019683c1210b12647a1370Ee483E2",
GAlcxPriceOracle: "0x819Ef3C70aE87377746af4c83Edd68B396D43d0D",
VoltPriceOracle: "0x316b2a8a2EDD2201238e72FD3fB0df2529C51721",
ZeroPriceOracle: "0xF2c0CFdBA9aF786f94A683BA3b6e21c122A647C1"
},
PRICE_ORACLE_RUNTIME_BYTECODE_HASHES: {
ChainlinkPriceOracle: "0x7a2a5633a99e8abb759f0b52e87875181704b8e29f6567d4a92f12c3f956d313",
Expand All @@ -88,12 +98,11 @@ export default {
// fuse-contracts@v1.2.0
MasterPriceOracleV3: "0xe4199a03b164ca492d19d655b85fdf8cc14cf2da6ddedd236712552b7676b03d",
CurveLpTokenPriceOracle: "0x6742ae836b1f7df0cfd9b858c89d89da3ee814c28c5ee9709a371bcf9dfd2145",
CurveFactoryLpTokenPriceOracleV2: "0x8f69ce5f159abf8255326f7052ace26a2a416d4d553c5bcb92fad4fd8cb8f7e6",
CurveLiquidityGaugeV2PriceOracle: "0xfcf0d93de474152898668c4ebd963e0237bfc46c3d5f0ce51b7045b60c831734",
cvxFXSPriceOracle: "0x6014cac13a95ba888f7087ff476a89c511c1cd2b5b4a95d9ab323d630a269acb",
FixedEthPriceOracle: "0xcb669c93632a1c991adced5f4d97202aa219fab3d5d86ebd28f4f62ad7aa6cb3",
FixedEurPriceOracle: "0x678dbe9f2399a44e89edc934dc17f6d4ee7004d9cbcee83c0fa0ef43de924b84",
WSTEthPriceOracle: "0x11daa8dfb8957304aa7d926ce6876c523c7567b4052962e65e7d6a324ddcb4cc",
FixedUSDPriceOracle: "0x948ac042dcfd530a7918de3d5ade84919c206d076e7cd9caff5e7e2301f9be16",
WSTEthPriceOracle: "0x0cb3d4c32c02641dd8e857355baaa87f6e0b1dad40373f3c139ea9a13b0c1590",
FixedTokenPriceOracle_OHM: "0x136d369f53594c2f10e3ff3f14eaaf0bada4a63964f3cfeda3923e3531e407dc",
UniswapTwapPriceOracleV2_SushiSwap_DAI: "0xb4d279232ab52a2fcaee6dc47db486a733c24a499ade9d7de1b0d417d4730817",
UniswapTwapPriceOracleV2_SushiSwap_CRV: "0x9df749314d6494a785bb5ff7a5fab25adadb772e10d58b7f692028cc23e2cbb3",
Expand All @@ -111,9 +120,19 @@ export default {
MStablePriceOracle: "0x39fc7b2cdac3d401ea91becf897346b2156dbe261162de14082e856103456eb4",
StakedSpellPriceOracle: "0x9fcea6d23c7e2e330e35e303a49f39e0c2c783e6b770ccc2de41fbbfbfc539e7",
CurveTriCryptoLpTokenPriceOracle: "0x92014d914370d8c59082044786d9b056ea188a95891778c555209c210850d5ae",
CurveFactoryLpTokenPriceOracle: "0x90cb470d00fd449254eda43856b1e32b5c9a9bf25a8070c10ed1ff92ca656616",
CurveFactoryLpTokenPriceOracle: "0x8f69ce5f159abf8255326f7052ace26a2a416d4d553c5bcb92fad4fd8cb8f7e6",
CurveFactoryLpTokenPriceOracleV2: "0x8f69ce5f159abf8255326f7052ace26a2a416d4d553c5bcb92fad4fd8cb8f7e6",
GUniLpTokenPriceOracle: "0xbed0eddba7009021dd774a530b53a784fc80217c7bf27c15c9b2487b13fb2863",
TribeMasterPriceOracle: "0xf79f348bef443bef108c446753829e55eb5e4e3028d2064d9edefab2f95fd876",
CvxFXSPriceOracle: "0x6014cac13a95ba888f7087ff476a89c511c1cd2b5b4a95d9ab323d630a269acb",
BalancerV2TwapPriceOracle: "0x0fcca2c7996f4a0e768107f953f6c5fc82d074199a8d3c638ad902772efacd66",
BalancerStableLpTokenPriceOracle: "0x7297a1a7b5cb6dbb1ed2a497bd7ef44cbd3fde7f1cb2be5b843dd7a8383eaaf5",
XVaultPriceOracle: "0x2dda99e1104ca02d17ce20bc9e353046418ca592122ec7c12960c016dcf1d2fe",
ETHMAXYPriceOracle: "0x985ce8d05302c5d4b34c66d64779052011b44d39d50a9f5b1b61383befe3e31c",
SaddleLpTokenPriceOracle: "0x0db5283096540f07fd080cc9b481ed2b808e663243e84ec07a8b3778a1cdf950",
GAlcxPriceOracle: "0x9949f96685e869c90760799819d17bf030b8af377ea1c12746b714993df03fa9",
VoltPriceOracle: "0x1cb6c4e8005963e7fa3e840a6d61c81cb17b00d81770564eaa045b8372b2ad4e",
ZeroPriceOracle: "0x9c59102d4463210f65007140937bd3389c39e0785a091ba0b61629d8137a32e1"
},
// Deployable Oracles
// (Note: In production, you can only deploy `MasterPriceOracle`, `UniswapTwapPriceOracleV2` `UniswapV3TwapPriceOracleV2`)
Expand Down Expand Up @@ -291,8 +310,8 @@ export default {
oldVersions: {},
},
WSTEthPriceOracle: {
address: "0xb11de4c003c80dc36a810254b433d727ac71c517",
bytecodeHash: "0x11daa8dfb8957304aa7d926ce6876c523c7567b4052962e65e7d6a324ddcb4cc",
address: "0xD007067A6c1877457D179206B628C326600ca36b",
bytecodeHash: "0x0cb3d4c32c02641dd8e857355baaa87f6e0b1dad40373f3c139ea9a13b0c1590",
deployable: false,
oldVersions: {},
},
Expand Down Expand Up @@ -424,6 +443,7 @@ export default {
JumpRateModel_Olympus_Majors: "0xe1d35fae219e4d74fe11cb4246990784a4fe6680",
JumpRateModel_Olympus_Majors_New: "0x4EF29407a8dbcA2F37B7107eAb54d6f2a3f2ad60",
JumpRateModel_Flat_3_Percent_Borrow_APY: "0xc8acad405ff67eaee2aca374764883cecbd490ad",
JumpRateModel_Flat_Half_Percent_Borrow_APY: "0x09472B8cdCae7c777d4fBf67e0dA9b58CCfA8870",
Custom_JumpRateModel: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
// Custom_JumpRateModel: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
},
Expand Down
2 changes: 1 addition & 1 deletion src/esm/Fuse/contracts/compound-protocol.min.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/esm/Fuse/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Contract, constants } from "ethers";
import { JsonRpcProvider, Web3Provider } from "@ethersproject/providers";
import { FuseAddresses } from "./addresses/index";
import { ChainID } from "../utils/networks";
import { MulticallProvider } from "@0xsequence/multicall/dist/declarations/src/providers";
declare type MinifiedContracts = {
[key: string]: {
abi?: any;
Expand Down Expand Up @@ -37,6 +36,6 @@ export default class Fuse {
addresses: FuseAddresses;
static COMPTROLLER_ERROR_CODES: string[];
static CTOKEN_ERROR_CODES: string[];
constructor(web3Provider: JsonRpcProvider | Web3Provider | MulticallProvider, chainId: ChainID);
constructor(web3Provider: JsonRpcProvider | Web3Provider, chainId: ChainID);
}
export {};
15 changes: 6 additions & 9 deletions src/esm/Fuse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class Fuse {
priceOracleAddress,
options,
});
let tx = yield contract.deployPool(poolName, comptrollerImplementationAddress, enforceWhitelist, closeFactor, liquidationIncentive, priceOracleAddress);
let tx = yield contract.deployPool(poolName, comptrollerImplementationAddress, enforceWhitelist, closeFactor, liquidationIncentive, priceOracleAddress, options);
receipt = yield tx.wait(1);
// receipt = await contract.deployPool(
// poolName,
Expand Down Expand Up @@ -255,11 +255,11 @@ export default class Fuse {
conf.uniswapV2Factory = this.addresses.UNISWAP_V2_FACTORY_ADDRESS;
// Check for existing oracle
oracleFactoryContract = new Contract(this.addresses.UNISWAP_TWAP_PRICE_ORACLE_V2_FACTORY_CONTRACT_ADDRESS, this.oracleContracts.UniswapTwapPriceOracleV2Factory.abi, this.provider.getSigner());
deployedPriceOracle = yield oracleFactoryContract.oracles(this.addresses.UNISWAP_V2_FACTORY_ADDRESS, conf.baseToken);
deployedPriceOracle = yield oracleFactoryContract.oracles(conf.uniswapV2Factory, conf.baseToken);
// Deploy if oracle does not exist
if (deployedPriceOracle === "0x0000000000000000000000000000000000000000") {
yield oracleFactoryContract.deploy(this.addresses.UNISWAP_V2_FACTORY_ADDRESS, conf.baseToken);
deployedPriceOracle = yield oracleFactoryContract.oracles(this.addresses.UNISWAP_V2_FACTORY_ADDRESS, conf.baseToken);
yield oracleFactoryContract.deploy(conf.uniswapV2Factory, conf.baseToken);
deployedPriceOracle = yield oracleFactoryContract.oracles(conf.uniswapV2Factory, conf.baseToken);
}
break;
case "ChainlinkPriceOracleV2":
Expand Down Expand Up @@ -709,6 +709,7 @@ export default class Fuse {
return __awaiter(this, void 0, void 0, function* () {
// Get price oracle contract name from runtime bytecode hash
const runtimeBytecodeHash = utils.keccak256(yield this.provider.getCode(oracleAddress));
console.log("this.getPriceOracle()", { runtimeBytecodeHash });
for (const model of Object.keys(this.addresses.PRICE_ORACLE_RUNTIME_BYTECODE_HASHES)) {
if (runtimeBytecodeHash ===
this.addresses.PRICE_ORACLE_RUNTIME_BYTECODE_HASHES[model])
Expand All @@ -720,11 +721,7 @@ export default class Fuse {
this.deployRewardsDistributor = function (rewardToken, options) {
return __awaiter(this, void 0, void 0, function* () {
const distributor = new ContractFactory(JSON.parse(this.compoundContracts["contracts/RewardsDistributorDelegator.sol:RewardsDistributorDelegator"].abi), this.compoundContracts["contracts/RewardsDistributorDelegator.sol:RewardsDistributorDelegator"].bin, this.provider.getSigner());
const deployedDistributor = yield distributor.deploy(
options.from,
rewardToken,
this.addresses.REWARDS_DISTRIBUTOR_DELEGATE_CONTRACT_ADDRESS,
);
const deployedDistributor = yield distributor.deploy(options.from, rewardToken, this.addresses.REWARDS_DISTRIBUTOR_DELEGATE_CONTRACT_ADDRESS);
// const rdAddress = distributor.options.address;
return deployedDistributor;
});
Expand Down
2 changes: 1 addition & 1 deletion src/esm/Fuse/irm/JumpRateModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { contracts } from "../contracts/compound-protocol.min.json";
export default class JumpRateModel {
init(interestRateModelAddress, assetAddress, provider) {
return __awaiter(this, void 0, void 0, function* () {
const jumpRateModelContract = createContract(interestRateModelAddress, contracts["contracts/JumpRateModel.sol:JumpRateModel"].abi, provider);
const jumpRateModelContract = createContract(interestRateModelAddress, contracts["contracts/JumpRateModel.sol:JumpRateModel"].abi, provider.getSigner());
this.baseRatePerBlock = toBN(yield jumpRateModelContract.callStatic.baseRatePerBlock());
this.multiplierPerBlock = toBN(yield jumpRateModelContract.callStatic.multiplierPerBlock());
this.jumpMultiplierPerBlock = toBN(yield jumpRateModelContract.callStatic.jumpMultiplierPerBlock());
Expand Down
4 changes: 2 additions & 2 deletions src/esm/utils/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const chainMetadata = {
chainId: ChainID.ARBITRUM_TESTNET,
name: "Arbi Rinkeby",
imageUrl: "/static/networks/arbitrum.svg",
supported: true,
supported: false,
rpcUrl: "https://arb-rinkeby.g.alchemy.com/v2/PkZ7ilUhTBT6tHUsgToel62IOcuyKcwb",
blockExplorerURL: "https://testnet.arbiscan.io",
color: "#28A0EF",
Expand All @@ -80,7 +80,7 @@ export const chainMetadata = {
rpcUrl: "https://mainnet.optimism.io/",
blockExplorerURL: "https://optimistic.etherscan.io",
color: "#FE0521",
}
},
// [ChainID.HARDHAT]: {
// chainId: ChainID.HARDHAT,
// name: "Hardhat",
Expand Down

0 comments on commit 7d63065

Please sign in to comment.