Sub-Adapters 2

Preview and test each sub adapter.

Secret Ethereum Bridge (secret-ethereum)

Secret BSC Bridge (secret-bsc)

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Secret Bridge';
2export const version = '0.1.1';
3export const license = 'MIT';
4
5const secretNativeTokens = ['SSCRT', 'SIENNA', 'SEFI']
6
7export function setup(sdk: Context) {
8  const getBridged = async (chain: 'ethereum' | 'bsc', importedToScrt: boolean) => {
9    const subdomain = chain === 'ethereum' ? 'api-bridge-mainnet' : 'bridge-bsc-mainnet'
10    const data = await sdk.http.get(`https://${subdomain}.azurewebsites.net/tokens/?page=0&size=1000`)
11
12    return data.tokens
13      .filter(token => secretNativeTokens.includes(token.dst_coin) != importedToScrt && token.price !== 'NaN')
14      .reduce((val: number, token) => val + parseFloat(token.totalLockedUSD), 0)
15  }
16
17  const metadata = {
18    name: 'Secret Bridge',
19    icon: sdk.ipfs.getDataURILoader('Qmdpq313DRDLn1mnaEDS3FuZCTNZp1QEmdqNnZpVQ2i1St', 'image/svg+xml'),
20    category: 'multisig',
21    requiredSigners: 3,
22    totalSigners: 5,
23    website: 'https://bridge.scrt.network/',
24    description: 'The Secret Bridge allows assets to be bridged between the Secret Network and both'
25      + 'Ethereum and BSC. The bridge is operated by 5 signers, who are all publicly-known entities.',
26  }
27
28  sdk.registerBundle('secret', metadata)
29
30  sdk.register({
31    id: 'secret-ethereum',
32    bundle: 'secret',
33    queries: {
34      currentValueBridgedAToB: () => getBridged('ethereum', false),
35      currentValueBridgedBToA: () => getBridged('ethereum', true),
36    },
37    metadata: {
38      ...metadata,
39      name: 'Secret Ethereum Bridge',
40      chainA: 'secretnetwork',
41      chainB: 'ethereum',
42    },
43  })
44
45  sdk.register({
46    id: 'secret-bsc',
47    bundle: 'secret',
48    queries: {
49      currentValueBridgedAToB: () => getBridged('bsc', false),
50      currentValueBridgedBToA: () => getBridged('bsc', true),
51    },
52    metadata: {
53      ...metadata,
54      name: 'Secret BSC Bridge',
55      chainA: 'secretnetwork',
56      chainB: 'bsc',
57    },
58  })
59}
60

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.1.1

License

MIT

IPFS CID

QmU3sfFFvvyLQXxeU3fTewDDgtqYFfHnCPr19fWRVu39xk

CID (source)

QmVEhwXhJrvLa8Nbbom8fShxJaSPxZTMcU3MWzyqxec71j

Collections

Author

mihal.eth