UNPKG

@f5i23q999d/cow-sdk

Version:

<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>

155 lines 5.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MockBridgeProvider = void 0; /* eslint-disable @typescript-eslint/no-unused-vars */ const types_1 = require("../../types.js"); const order_book_1 = require("../../../order-book/index.js"); const mainnet_1 = require("../../../chains/details/mainnet.js"); const optimism_1 = require("../../../chains/details/optimism.js"); const sepolia_1 = require("../../../chains/details/sepolia.js"); const chains_1 = require("../../../chains/index.js"); const const_1 = require("../../const.js"); const BRIDGING_ID = '123456789asdfg'; const MOCK_CALL = { to: '0x0000000000000000000000000000000000000001', data: '0x0', value: BigInt(0), }; const BUY_TOKENS = [ { chainId: chains_1.SupportedChainId.MAINNET, address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', logoUrl: 'https://swap.cow.fi/assets/network-mainnet-logo-BJe1wK_m.svg', name: 'USD Coin', symbol: 'USDC', decimals: 6, }, { chainId: chains_1.SupportedChainId.MAINNET, address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', logoUrl: 'https://swap.cow.fi/assets/network-gnosis-chain-logo-Do_DEWQv.svg', name: 'Wrapped Ether', symbol: 'WETH', decimals: 18, }, { chainId: chains_1.SupportedChainId.SEPOLIA, address: '0x0625aFB445C3B6B7B929342a04A22599fd5dBB59', logoUrl: 'https://swap.cow.fi/assets/network-mainnet-logo-BJe1wK_m.svg', name: 'CoW Protocol Token', symbol: 'COW', decimals: 18, }, { chainId: chains_1.AdditionalTargetChainId.OPTIMISM, address: '0x4200000000000000000000000000000000000006', logoUrl: 'https://swap.cow.fi/assets/network-mainnet-logo-BJe1wK_m.svg', name: 'Wrapped Ether', symbol: 'WETH', decimals: 18, }, ]; const INTERMEDIATE_TOKENS = { [chains_1.SupportedChainId.MAINNET]: ['0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB'], [chains_1.AdditionalTargetChainId.OPTIMISM]: ['0x68f180fcCe6836688e9084f035309E29Bf0A2095'], [chains_1.SupportedChainId.SEPOLIA]: ['0xB4F1737Af37711e9A5890D9510c9bB60e170CB0D'], }; class MockBridgeProvider { info = { name: 'Mock', logoUrl: `${const_1.RAW_PROVIDERS_FILES_PATH}/mock/mock-logo.png`, }; async getNetworks() { return [mainnet_1.mainnet, optimism_1.optimism, sepolia_1.sepolia]; } async getBuyTokens(targetChainId) { return BUY_TOKENS.filter((token) => token.chainId === targetChainId); } async getIntermediateTokens({ sellTokenChainId }) { return INTERMEDIATE_TOKENS[sellTokenChainId] ?? []; } async getQuote(_request) { return { isSell: true, amountsAndCosts: { costs: { bridgingFee: { feeBps: 10, amountInSellCurrency: 123456n, amountInBuyCurrency: 123456n, }, }, beforeFee: { sellAmount: 123456n, buyAmount: 123456n, }, afterFee: { sellAmount: 123456n, buyAmount: 123456n, }, afterSlippage: { sellAmount: 123456n, buyAmount: 123456n, }, slippageBps: 0, }, quoteTimestamp: Date.now(), expectedFillTimeSeconds: 128, }; } getGasLimitEstimationForHook(_request) { return 110000; } async getUnsignedBridgeCall(_request, _quote) { return MOCK_CALL; } async getSignedHook(_chainId, _unsignedCall, _signer) { return { recipient: '0x0000000000000000000000000000000000000001', postHook: { target: '0x0000000000000000000000000000000000000002', callData: '0x1', gasLimit: '0x2', dappId: 'MockBridgeProvider', }, }; } async decodeBridgeHook(_hook) { return { kind: order_book_1.OrderKind.SELL, provider: this.info, account: '0x0000000000000000000000000000000000000001', sellTokenChainId: 1, sellTokenAddress: '0x0000000000000000000000000000000000000001', sellTokenAmount: '123456', sellTokenDecimals: 18, buyTokenChainId: 1, buyTokenAddress: '0x0000000000000000000000000000000000000002', buyTokenDecimals: 18, minBuyAmount: '123456', receiver: '0x0000000000000000000000000000000000000001', signer: '', appCode: 'MOCK', }; } async getBridgingId(_orderUid, _settlementTx) { return BRIDGING_ID; } getExplorerUrl(bridgingId) { return 'https://www.google.com/search?q=' + bridgingId; } async getStatus(_bridgingId) { return { status: types_1.BridgeStatus.IN_PROGRESS, fillTimeInSeconds: 67, }; } async getCancelBridgingTx(_bridgingId) { return MOCK_CALL; } async getRefundBridgingTx(_bridgingId) { return MOCK_CALL; } } exports.MockBridgeProvider = MockBridgeProvider; //# sourceMappingURL=MockBridgeProvider.js.map