Skip to content

Commit

Permalink
Merge pull request #4539 from BitGo/PX-3970-onboard-avax-tokens-on-go…
Browse files Browse the repository at this point in the history
…-account

feat(statics): add ofc token to represent Erc20 token on avalance chain
  • Loading branch information
subavicky committed May 17, 2024
2 parents 2d50f0c + abc09c2 commit 6c4720e
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modules/bitgo/test/v2/unit/coins/ofcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,27 @@ describe('OFC:', function () {
});
});

describe('check ofc tokens for avaxErc20', function () {
const tokenMain = 'ofcavaxc:link';
const tokenTest = 'ofctavaxc:link';
describe('for main network', function () {
it(`should have the correct values for ${tokenMain}`, function () {
const ofcCoin = bitgo.coin(tokenMain);
ofcCoin.getChain().should.equal(tokenMain);
ofcCoin.getFullName().should.equal('Chainlink');
ofcCoin.getBaseFactor().should.equal(PRECISION_18);
});
});
describe('for test network', function () {
it(`should have the correct values for ${tokenTest}`, function () {
const ofcCoin = bitgo.coin(tokenTest);
ofcCoin.getChain().should.equal(tokenTest);
ofcCoin.getFullName().should.equal('Test Chainlink');
ofcCoin.getBaseFactor().should.equal(PRECISION_18);
});
});
});

describe('check ofc tokens for solana', function () {
const tokenMain = 'ofcsol:hnt';
const tokenTest = 'ofctsol:hnt';
Expand Down
56 changes: 56 additions & 0 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
ofcHederaToken,
ofcStellarToken,
ofcArbethErc20,
ofcAvaxErc20,
tofc,
tofcAlgoToken,
ofcsolToken,
Expand All @@ -58,6 +59,7 @@ import {
tofcHederaToken,
tofcStellarToken,
tofcArbethErc20,
tofcAvaxErc20,
} from './ofc';
import { utxoCoins } from './utxo';

Expand Down Expand Up @@ -10600,6 +10602,60 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset['arbeth:arb']
),
ofcAvaxErc20('2bd6201d-c46c-481e-b82d-7cf3601679cb', 'ofcavaxc:aave-e', 'Aave', 18, UnderlyingAsset['avaxc:aave']),
ofcAvaxErc20('515a5a74-54fe-4d73-bb12-8d1130f78692', 'ofcavaxc:btc-b', 'Bitcoin', 8, UnderlyingAsset['avaxc:btc']),
ofcAvaxErc20(
'b8c9ea9d-4be3-4d3c-b1de-a1bb963fc03b',
'ofcavaxc:cai',
'Colony Avalanche Index',
18,
UnderlyingAsset['avaxc:cai']
),
ofcAvaxErc20(
'58d7ae4a-296c-4215-b133-01bf553f8500',
'ofcavaxc:dai-e',
'Dai Stablecoin',
18,
UnderlyingAsset['avaxc:dai']
),
ofcAvaxErc20('ad7a51a1-81fb-483f-b338-9bb236ce9662', 'ofcavaxc:joe', 'Trader Joe', 18, UnderlyingAsset['avaxc:joe']),
ofcAvaxErc20('18d60ded-bc60-48aa-a38a-6f85384ea6cc', 'ofcavaxc:klo', 'Kalao', 18, UnderlyingAsset['avaxc:klo']),
ofcAvaxErc20('4ad0a18d-36b0-42db-ac94-938a0862ef0b', 'ofcavaxc:link', 'Chainlink', 18, UnderlyingAsset['avaxc:link']),
ofcAvaxErc20('cf570f0c-8c17-4ba8-b658-69d38e4f37a9', 'ofcavaxc:png', 'Pangolin', 18, UnderlyingAsset['avaxc:png']),
ofcAvaxErc20('6753faa0-7c76-4c97-ad78-667ff2416c62', 'ofcavaxc:qi', 'BenQi', 18, UnderlyingAsset['avaxc:qi']),
ofcAvaxErc20('786e03a4-c156-48ea-8782-42ea3c63c5a3', 'ofcavaxc:sbc', 'Stable Coin', 18, UnderlyingAsset['avaxc:sbc']),
ofcAvaxErc20('300dbac5-76a3-4ed5-96fb-1d7898da4b4e', 'ofcavaxc:usdc', 'USD Coin', 6, UnderlyingAsset['avaxc:usdc']),
ofcAvaxErc20('974e85e7-d6ad-4a5a-9aea-cae055842f36', 'ofcavaxc:usdc-e', 'USD Coin', 6, UnderlyingAsset['avaxc:usdc']),
ofcAvaxErc20('861e2833-90be-45ec-8c8b-a41b1b86fac3', 'ofcavaxc:usdt', 'Tether USD', 6, UnderlyingAsset['avaxc:usdt']),
ofcAvaxErc20(
'e56e42a8-1566-4b5b-a2f3-5439278b1e8c',
'ofcavaxc:usdt-e',
'Tether USD',
6,
UnderlyingAsset['avaxc:usdt']
),
ofcAvaxErc20(
'3986ecd8-dda6-4b30-8883-b6bf111e4624',
'ofcavaxc:wbtc-e',
'Wrapped BTC',
8,
UnderlyingAsset['avaxc:wbtc']
),
ofcAvaxErc20(
'26281e88-f83a-4b13-b69d-b8a7ce9f4598',
'ofcavaxc:weth-e',
'Wrapped ETH',
18,
UnderlyingAsset['avaxc:weth']
),
ofcAvaxErc20('caeec903-4c42-4d03-8cee-91319ab708c9', 'ofcavaxc:xava', 'Avalaunch', 18, UnderlyingAsset['avaxc:xava']),
tofcAvaxErc20(
'e70417f4-61df-4622-a933-40a43f807923',
'ofctavaxc:link',
'Test Chainlink',
18,
UnderlyingAsset['avaxc:link']
),
ofcerc20(
'baded9c2-d530-4188-b35d-2fd00cf6ee2e',
'ofcustb',
Expand Down
102 changes: 102 additions & 0 deletions modules/statics/src/ofc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,105 @@ export function tofcArbethErc20(
})
);
}

/**
* Factory function for ofc avaxErc20 token instances.
*
* @param id uuid v4
* @param name unique identifier of the coin
* @param fullName Complete human-readable name of the coin
* @param network Network object for this coin
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
* @param prefix? Optional coin prefix. Defaults to empty string
* @param suffix? Optional coin suffix. Defaults to coin name.
* @param isToken? Whether or not this account coin is a token of another coin
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function ofcAvaxErc20(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
asset: UnderlyingAsset,
kind: CoinKind = CoinKind.CRYPTO,
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
network: OfcNetwork = Networks.main.ofc,
isToken = true,
addressCoin = 'avaxc',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return Object.freeze(
new OfcCoin({
id,
name,
fullName,
network,
prefix,
suffix,
features,
decimalPlaces,
isToken,
asset,
kind,
addressCoin,
primaryKeyCurve,
baseUnit: BaseUnit.ETH,
})
);
}

/**
* Factory function for testnet ofc avaxErc20 token instances.
*
* @param id uuid v4
* @param name unique identifier of the coin
* @param fullName Complete human-readable name of the coin
* @param network Network object for this coin
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
* @param prefix? Optional coin prefix. Defaults to empty string
* @param suffix? Optional coin suffix. Defaults to coin name.
* @param isToken? Whether or not this account coin is a token of another coin
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function tofcAvaxErc20(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
asset: UnderlyingAsset,
kind: CoinKind = CoinKind.CRYPTO,
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
network: OfcNetwork = Networks.test.ofc,
isToken = true,
addressCoin = 'tavaxc',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return Object.freeze(
new OfcCoin({
id,
name,
fullName,
network,
prefix,
suffix,
features,
decimalPlaces,
isToken,
asset,
kind,
addressCoin,
primaryKeyCurve,
baseUnit: BaseUnit.ETH,
})
);
}

0 comments on commit 6c4720e

Please sign in to comment.