Skip to content

Conversation

@mohitkh7
Copy link
Contributor

@mohitkh7 mohitkh7 commented May 2, 2025

Ticket: COIN-3790

Needs Attention! This PR content is auto-generated with scripts. Hence needs extra attention in review.

Description

Onboard batch of 12 arbeth tokens. All of them exibits following properties:

  • Have decimal precision of 18.
  • Needs to be Gated
  • No entity specific configurations

Generation Methodology

Verifying decimal points

In SDK coins.ts we have to specify the token decimal points, the existing approach is to check it from explorer which can go wrong and impact pricing and withdrawals in future.
It is automated with following python script

from web3 import Web3

# Connect to an Arbitrum node
ARBITRUM_RPC = "https://arb1.arbitrum.io/rpc"
w3 = Web3(Web3.HTTPProvider(ARBITRUM_RPC))

# ERC-20 ABI fragment for the decimals function
ERC20_ABI = [
    {
        "constant": True,
        "inputs": [],
        "name": "decimals",
        "outputs": [{"name": "", "type": "uint8"}],
        "type": "function",
    }
]

def get_token_decimals(token_address):
    try:
        contract = w3.eth.contract(address=w3.to_checksum_address(token_address), abi=ERC20_ABI)
        return contract.functions.decimals().call()
    except Exception as e:
        print(f"Failed to fetch decimals for {token_address}: {e}")
        return None


if __name__ == "__main__":
    tokens = [
        {
            "name": "WisdomTree Floating Rate Treasury Digital Fund",
            "symbol": "ARBETH:FLTTX",
            "contract_address": "0x3b9c11cb16b4c9eeb1408dad409afbe800abde3f"
        },
    ]
    for token in tokens:
        symbol = token["symbol"]
        address = token["contract_address"]
        decimals = get_token_decimals(address)
        print(f"{symbol} at address <{address}> has token decimals: {decimals}")

From the script output I confirmed all tokens required 18 decimal precision.

Static Configuration Content

In SDK changes we have to write config for underlying asset, coins and ofccoins which is generated via this script

from uuid import uuid4
from data import tokens

def generate_content_for_coins(name, symbol, address, decimal_point=18):
    unique_id = uuid4()
    content = \
f"""
  arbethErc20(
    '{unique_id}',
    '{symbol}',
    '{name}',
    {decimal_point},
    '{address}',
    UnderlyingAsset['{symbol}']
  ),"""
    return content

def generate_content_for_ofccoins(name, symbol, decimal_point=18):
    unique_id = uuid4()
    content = \
f"""
  ofcArbethErc20(
    '{unique_id}',
    'ofc{symbol}',
    '{name}',
    {decimal_point},
    UnderlyingAsset['{symbol}']
  ),"""
    return content

def asset_content(tokens):
    for token_obj in tokens:
        symbol = token_obj["symbol"].lower()
        print(f"  '{symbol}' = '{symbol}',")

def coins_content(tokens):
    for token_obj in tokens:
        name = token_obj["name"]
        symbol = token_obj["symbol"].lower()
        address = token_obj["contract_address"]
        content = generate_content_for_coins(name, symbol, address)
        print(content,end="")

def ofccoins_content(tokens):
    for token_obj in tokens:
        name = token_obj["name"]
        symbol = token_obj["symbol"].lower()
        content = generate_content_for_ofccoins(name, symbol)
        print(content,end="")

def gatekeep_content(tokens):
    for token_obj in tokens:
        symbol = token_obj["symbol"].lower()
        print(f"  '{symbol}',")

if __name__ == "__main__":
    asset_content(tokens)
    coins_content(tokens)
    ofccoins_content(tokens)
    gatekeep_content(tokens)

@mohitkh7 mohitkh7 requested review from a team as code owners May 2, 2025 10:17
@mohitkh7 mohitkh7 self-assigned this May 2, 2025
@mohitkh7 mohitkh7 force-pushed the COIN-3790-token-ob-1 branch from 03a9177 to 27f3c0b Compare May 2, 2025 10:24
@mohitkh7
Copy link
Contributor Author

mohitkh7 commented May 2, 2025

Did a round of self review, found that 'arbeth:flttx', was missing from gatekeep.ts, which I fixed.

@mohitkh7 mohitkh7 requested review from MohammedRyaan786 and removed request for mohammadalfaiyazbitgo and pengyuc-bitgo May 2, 2025 11:42
Copy link
Contributor

@sampras-saha sampras-saha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@abhishekagrawal080 abhishekagrawal080 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mohitkh7 mohitkh7 merged commit 96c3865 into master May 5, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants