mento-protocol / mento-sdk

An SDK for integrating applications with the Mento protocol
MIT License
0 stars 3 forks source link

Handle inactive exchanges in the SDK #17

Open bowd opened 1 year ago

bowd commented 1 year ago

Description This ticket is about figuring out and deciding how enabled & disabled pair trading should be handled in the SDK.

Currently, all trading pairs are returned by the SDK, not returning information on whether a pair is currently in a non-full-active trading mode, e.g. from circuit breaker or trading limits.

We are not sure how this would end up in the UX, e.g. if a user attempts a transaction for a currently suspended pair. If the transaction fails, if gas estimation fails.

We need something like CEX APIs, which return a status or error code together with price data, to indicate whether the pair is currently trading live or not.

ref: https://github.com/mento-protocol/mento-sdk/pull/2#discussion_r1086698141

Acceptance Criteria

aaronmgdr commented 5 months ago

would that be why when calling mento.getAmountIn with address for BridgedUSDC i get an error like below but for CELO => cUSD it returns nicely?

I don't actually need BridgedUSDC so i just filtered out pairs from getTradeablePairs first

cEUR BridgedUSDC Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (data="0x", transaction={"to":"0xD3Dff18E465bCa6241A244144765b4421Ac14D09","data":"0x04e456400000000000000000000000009b64e8eabd1a035b148ce970d3319c5c3ad53ec33e6d9109df536ba3f4c166e598bdfe132dca06573a54ca40c2b6f23ac6bd6cc600000000000000000000000010c892a6ec43a53e45d0b916b4b7d383b1b78c0f00000000000000000000000087d61da3d668797786d73bc674f053f87111570d0000000000000000000000000000000000000000000000000de0b6b3a7640000","accessList":null}, error={}, code=CALL_EXCEPTION, version=providers/5.7.2)
    at Logger.makeError (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at checkError (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:66:16)
    at Web3Provider.<anonymous> (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:642:20)
    at step (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.throw (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at rejected (/Users/aaronmgdr/celo/developer-tooling/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  reason: 'missing revert data in call exception; Transaction reverted without a reason string',
  code: 'CALL_EXCEPTION',
  data: '0x',
  transaction: {
    to: '0xD3Dff18E465bCa6241A244144765b4421Ac14D09',
    data: '0x04e456400000000000000000000000009b64e8eabd1a035b148ce970d3319c5c3ad53ec33e6d9109df536ba3f4c166e598bdfe132dca06573a54ca40c2b6f23ac6bd6cc600000000000000000000000010c892a6ec43a53e45d0b916b4b7d383b1b78c0f00000000000000000000000087d61da3d668797786d73bc674f053f87111570d0000000000000000000000000000000000000000000000000de0b6b3a7640000',
    accessList: null
  },
  error: Error: execution reverted: overflow x1y1 * fixed1 detected
      at decoratedCallback (/Users/aaronmgdr/celo/developer-tooling/packages/sdk/connect/src/utils/rpc-caller.ts:117:15)
      at /Users/aaronmgdr/celo/developer-tooling/node_modules/web3-providers-http/lib/index.js:127:13
      at processTicksAndRejections (node:internal/process/task_queues:95:5)