Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(statics): add ofc tokens #5178

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions modules/bitgo/test/v2/unit/coins/ofcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const PRECISION_7 = '10000000';
const PRECISION_8 = '100000000';
const PRECISION_9 = '1000000000';
const PRECISION_18 = '1000000000000000000';
const PRECISION_96 = '9.999999999999999e+95';

describe('OFC:', function () {
let bitgo;
Expand Down Expand Up @@ -419,4 +420,28 @@ describe('OFC:', function () {
});
});
});

describe('check ofc tokens for ripple', function () {
const tokenTest = 'ofctxrp:rlusd';
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('RLUSD');
ofcCoin.getBaseFactor().should.equal(PRECISION_96);
});
});
});

describe('check ofc tokens for opethErc20', function () {
const tokenMain = 'ofcopeth:op';
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('Optimism');
ofcCoin.getBaseFactor().should.equal(PRECISION_18);
});
});
});
});
58 changes: 58 additions & 0 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ import {
tofcsolToken,
tofcStellarToken,
tofcPolygonErc20,
ofcOpethErc20,
tofcXrpToken,
} from './ofc';
import { utxoCoins } from './utxo';
import { lightningCoins } from './lightning';
Expand Down Expand Up @@ -1614,6 +1616,46 @@ export const coins = CoinMap.fromCoins([
UnderlyingAsset['natix'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'abbdcf44-ac44-46be-b4e9-8a760d44b79a',
'ofcsol:mobile',
'Helium Mobile',
6,
UnderlyingAsset['mobile'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'94e55bde-f57f-4817-9984-b461a5d6bcd0',
'ofcsol:jup',
'Jupiter',
6,
UnderlyingAsset['jup'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'989eec31-a0d5-4cdc-b4de-6fca30cde366',
'ofcsol:popcat',
'POPCAT',
9,
UnderlyingAsset['sol:popcat'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'ca2a2bc9-ed79-426f-8378-96f9c9568526',
'ofcsol:wif',
'dogwifhat',
6,
UnderlyingAsset['wif'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'ab833723-8b40-4fc4-8dd1-f5ea9a07c76c',
'ofcsol:goat',
'Goatseus Maximus',
6,
UnderlyingAsset['sol:goat'],
SOL_TOKEN_FEATURES
),
tofcsolToken(
'24d678cf-e0f0-4cde-a338-d754289c5b27',
'ofctsol:slnd',
Expand Down Expand Up @@ -1687,6 +1729,7 @@ export const coins = CoinMap.fromCoins([
UnderlyingAsset['sol:hnt'],
SOL_TOKEN_FEATURES
),
tofcXrpToken('bd406dab-3b55-4ab5-b0a5-74b9f94268a3', 'ofctxrp:rlusd', 'RLUSD', 96, UnderlyingAsset['txrp:rlusd']),
ofc('837f0cab-cad1-4510-a8e4-f2c60e1a8760', 'ofcusd', 'USD', 2, UnderlyingAsset.USD, CoinKind.FIAT),
ofc('798f2a7c-23fd-4e16-9fe5-6bf47ca438a0', 'ofceur', 'Euro', 2, UnderlyingAsset.EUR, CoinKind.FIAT),
ofc('f37bbb72-adfe-4d06-90dc-afd0aa34aadd', 'ofcgbp', 'Pound Sterling', 2, UnderlyingAsset.GBP, CoinKind.FIAT),
Expand Down Expand Up @@ -13039,6 +13082,20 @@ export const coins = CoinMap.fromCoins([
ofcerc20('bbe911d8-c900-401c-8dfb-febd98256e75', 'ofcusdy', 'Ondo U.S. Dollar Yield', 18, UnderlyingAsset.USDY),
ofcerc20('017c87e8-db41-41f6-8382-c61ad8ced64b', 'ofcfold', 'Manifold Finance', 18, UnderlyingAsset.FOLD),
ofcerc20('94fcd19b-6dd6-4a8c-8fea-11c73ba9fa48', 'ofcacx', 'Across Protocol', 18, UnderlyingAsset.ACX),
ofcerc20('b5f3afea-f69a-4a05-87f9-965476ad77de', 'ofclpt', 'Livepeer Token', 18, UnderlyingAsset.LPT),
ofcerc20('567b571f-6f79-40e4-adff-3e0e3c6ba959', 'ofcethfi', 'ether.fi governance token', 18, UnderlyingAsset.ETHFI),
ofcerc20('cba66dc6-31eb-46c4-b73f-8cb77eb7ef5b', 'ofcgal', 'Project Galaxy', 18, UnderlyingAsset.GAL),
ofcerc20('0c6e4b19-d748-477c-9507-6c0f51142b07', 'ofcfdusd', 'First Digital USD', 18, UnderlyingAsset.FDUSD),
ofcerc20('80c3e860-f589-4227-a0f5-2aa6b18293c5', 'ofcrune', 'THORChain ETH.RUNE', 18, UnderlyingAsset.RUNE),
ofcerc20('db35feb4-9cdb-447a-a698-e0e944ca6869', 'ofckcs', 'KuCoin', 6, UnderlyingAsset.KCS),
ofcerc20('519ab013-f634-41f4-9d31-6f9368de5b09', 'ofcbeam', 'Beam', 18, UnderlyingAsset.BEAM),
ofcerc20('4030e0fa-fa80-4e30-8c0f-9168ec65c731', 'ofcmog', 'Mog Coin', 18, UnderlyingAsset.MOG),
ofcerc20('1a7fdcc6-8a6c-4780-b483-c6aaf990e461', 'ofcgt', 'GateChainToken', 18, UnderlyingAsset.GT),
ofcerc20('969180cc-5af9-49c5-ad19-d8e8de755467', 'ofckas', 'Kaspa', 8, UnderlyingAsset.KAS),
ofcerc20('eb54ecb6-7312-42c0-926a-1600d61a50dc', 'ofcbgb', 'Bitget', 18, UnderlyingAsset.BGB),
ofcerc20('a4e0613e-1d1b-477c-9da5-7c553ff787b7', 'ofcmew', 'MEW coin', 18, UnderlyingAsset.MEW),
ofcerc20('ba2c8abb-6375-4207-9262-8b907a1dbf1b', 'ofcusdd', 'USDD', 18, UnderlyingAsset.USDD),
ofcerc20('cbb73d46-ce0d-4045-822b-8aa0d6fb8ad4', 'ofcw', 'Wormhole Token', 18, UnderlyingAsset.W),
ofcArbethErc20(
'df2296e6-366e-4707-bab0-bf16ce592601',
'ofcarbeth:link',
Expand Down Expand Up @@ -13128,6 +13185,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset['avaxc:link']
),
ofcOpethErc20('10259b23-2e2e-4574-b146-b49f1119600f', 'ofcopeth:op', 'Optimism', 18, UnderlyingAsset['opeth:op']),
ofcBscToken('a79933f5-a9d2-4a29-a948-79313a569988', 'ofcbsc:cfx', 'BSC Conflux', 18, UnderlyingAsset['bsc:cfx']),
ofcPolygonErc20(
'547ce68f-cb4c-4618-bef3-9a0ebe9facd2',
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 @@ -1017,3 +1017,105 @@ export function ofcBscToken(
})
);
}

/**
* Factory function for testnet ofc xrp 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 tofcXrpToken(
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 = 'txrp',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return Object.freeze(
new OfcCoin({
id,
name,
fullName,
network,
prefix,
suffix,
features,
decimalPlaces,
isToken,
asset,
kind,
addressCoin,
primaryKeyCurve,
baseUnit: BaseUnit.XRP,
})
);
}

/**
* Factory function for ofc opetherc20 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 ofcOpethErc20(
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 = 'opeth',
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,
})
);
}