SetProtocol/set.js

Are there any examples of this?? [SIM-227]

Opened this issue · 3 comments

Are there any examples of this?? [SIM-227]

@BlockChainScript Could you describe what you're trying to do?

No matter what I do, I always receive some incredible errors. I don’t even know how to initialize a tokenSets instance normally or how to configure a valid SetJSConfig.
There is no example that makes it difficult to use.

My code:

import dotenv from 'dotenv'

import {providers} from 'ethers'
import Web3 from 'web3'
import Set, {SetJSConfig} from 'set.js'

dotenv.config()

const config: SetJSConfig = {
    ethersProvider: new providers.JsonRpcProvider(process.env.POLYGON_PROVIDER_URL!),
    web3Provider: new Web3.providers.HttpProvider(process.env.POLYGON_PROVIDER_URL!),
    basicIssuanceModuleAddress: '',
    controllerAddress: '',
    debtIssuanceModuleAddress: '',
    governanceModuleAddress: '',
    masterOracleAddress: '',
    navIssuanceModuleAddress: '',
    protocolViewerAddress: '',
    setTokenCreatorAddress: '',
    streamingFeeModuleAddress: '',
    tradeModuleAddress: ''
}

const tokenSets = new Set(config)

async function run() {
    console.log(await tokenSets.priceOracle.getPriceAsync('0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'))
    process.exit()
}

run()

Errors like these:
Error: resolver or addr is not configured for ENS name (argument="name", value="", code=INVALID_ARGUMENT, version=contracts/5.5.0)
or
Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.4.5)

Hi @BlockChainScript ! Sorry about that. I have been in a similar position so I can relate. It looks like you're trying to initialize SetJS on Polygon so I think https://github.com/SetProtocol/index-ui/blob/master/src/utils/setjsApi.ts#L149-L164 could be a helpful example.

Also, I think it's a good idea to verify the addresses provided in the SetJSConfig against the addresses listed here