import { TokensService } from '@dequanto/tokens/TokensService';
let service = new TokensService('eth');
let usdc = await service.getKnownToken('USDC');
console.log(usdc);
/* output
{
symbol: 'USDC',
name: 'USD Coin',
platform: 'eth',
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
decimals: 6
}
*/
Ready to use strongly-typed erc20 contract class.
import { TokensService } from '@dequanto/tokens/TokensService';
let service = new TokensService('eth');
let usdc = await service.erc20('USDC');
let balance: bigint = await usdc.balanceOf('0x....')
An article regarding token prices - get-token-price-at-a-specific-block-onchainπ
Paraswap is implemented as the default exchange
import { TokenSwapService } from '@dequanto/tokens/TokenSwapService'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
let client = new EthWeb3Client();
let exchange = new TokenSwapService(client);
let account = { key: '' }
let tx = await exchange.swap(account, {
from: 'USDC',
to: 'WETH',
amount: 1000
});
let receipt = await tx.wait();
import { TokenTransferService} from '@dequanto/tokens/TokenTransferService'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
let client = new EthWeb3Client();
let service = new TokenTransferService(client);
let account = { key: '' }
let tx = await service.transferAll(account, '0x...', 'USDC');
let receipt = await tx.wait();