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

chore: devnet config for Fast USDC #10971

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions packages/fast-usdc/src/utils/chain-policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const ChainPolicies = /** @type {const} */ ({
},
Base: {
attenuatedCttpBridgeAddresses: [
// Contract Name: ERC1967Proxy
// Submitted for verification at basescan.org on 2024-06-21
// https://basescan.org/address/0xb6615b2662b35fc3533f8479002e62d0523341de#code
'0xB6615B2662b35fc3533F8479002e62D0523341De',
],
cctpTokenMessengerAddress: '0x1682Ae6375C4E4A97e4B583BC394c861A46D8962',
Expand All @@ -33,6 +36,9 @@ export const ChainPolicies = /** @type {const} */ ({
},
Ethereum: {
attenuatedCttpBridgeAddresses: [
// Contract Name: ERC1967Proxy
// Submitted for verification at Etherscan.io on 2024-06-21
// https://etherscan.io/address/0xbc8552339da68eb65c8b88b414b5854e0e366cfc#code
'0xBC8552339dA68EB65C8b88B414B5854E0E366cFc',
],
cctpTokenMessengerAddress: '0xBd3fa81B58Ba92a82136038B25aDec7066af3155',
Expand Down
193 changes: 152 additions & 41 deletions packages/fast-usdc/src/utils/deploy-config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import { denomHash, withChainCapabilities } from '@agoric/orchestration';
import {
CosmosChainInfoShape,
denomHash,
withChainCapabilities,
} from '@agoric/orchestration';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import { M, mustMatch } from '@endo/patterns';
import { ChainPolicies } from './chain-policies.js';

/**
* @import {FastUSDCConfig} from '@agoric/fast-usdc';
* @import {Passable} from '@endo/marshal';
* @import {CosmosChainInfo, Denom, DenomDetail} from '@agoric/orchestration';
* @import {CosmosChainInfo, Denom, DenomDetail, IBCConnectionInfo} from '@agoric/orchestration';
*/

/** @type {[Denom, DenomDetail & { brandKey?: string}][]} */
export const defaultAssetInfo = [
[
'uusdc',
{
baseName: 'noble',
chainName: 'noble',
baseDenom: 'uusdc',
},
],
[
`ibc/${denomHash({ denom: 'uusdc', channelId: fetchedChainInfo.agoric.connections['noble-1'].transferChannel.channelId })}`,
{
baseName: 'noble',
chainName: 'agoric',
baseDenom: 'uusdc',
brandKey: 'USDC',
},
],
[
`ibc/${denomHash({ denom: 'uusdc', channelId: fetchedChainInfo.osmosis.connections['noble-1'].transferChannel.channelId })}`,
{
baseName: 'noble',
chainName: 'osmosis',
baseDenom: 'uusdc',
},
],
];
/**
* @param {Record<string, IBCConnectionInfo>} connections
* @returns {AssetEntry[]}
* @typedef {[Denom, DenomDetail & { brandKey?: string}]} AssetEntry
*/
const makeUSDCAssets = connections => {
assert('agoric' in connections);
const [baseName, baseDenom] = ['noble', 'uusdc'];
/** @type {AssetEntry} */
const issuer = ['uusdc', { baseName, chainName: 'noble', baseDenom }];
/** @param {string} n */
const brandKeyOf = n => (n === 'agoric' ? { brandKey: 'USDC' } : {});
/** @type {AssetEntry[]} */
const others = Object.entries(connections).map(([chainName, conn]) => [
`ibc/${denomHash({ denom: 'uusdc', channelId: conn.transferChannel.channelId })}`,
{ baseName: 'noble', chainName, baseDenom, ...brandKeyOf(chainName) },
]);
const assetInfo = [issuer, ...others];
return assetInfo;
};

export const defaultAssetInfo = makeUSDCAssets({
agoric: fetchedChainInfo.agoric.connections['noble-1'],
osmosis: fetchedChainInfo.osmosis.connections['noble-1'],
});
harden(defaultAssetInfo);

const agoricAssetInfo = defaultAssetInfo.filter(
Expand All @@ -46,6 +48,116 @@ const agoricAssetInfo = defaultAssetInfo.filter(
const DepositForBurnEvent =
'DepositForBurn(uint64,address,uint256,address,bytes32,uint32,bytes32,bytes32)';

/** @satisfies {Record<string, CosmosChainInfo & Passable>} */
const devnetChainInfo = (() => {
const [idAg, idNoble, idOsmo] = /** @type {const} */ ([
'agoricdev-23',
'grand-1',
'osmo-test-5',
]);
const config = /** @type {const} */ ({
agoric: {
noble: {
channel_id: 'channel-69',
client_id: '07-tendermint-140',
connection_id: 'connection-95',
},
osmosis: {
channel_id: 'channel-61',
client_id: '07-tendermint-127',
connection_id: 'connection-81',
},
},
noble: {
agoric: {
channel_id: 'channel-315',
client_id: '07-tendermint-409',
connection_id: 'connection-367',
},
osmosis: {
connection_id: 'connection-31',
client_id: '07-tendermint-42',
channel_id: 'channel-22',
},
},
osmosis: {
agoric: {
channel_id: 'channel-10041',
client_id: '07-tendermint-4326',
connection_id: 'connection-3786',
},
noble: {
client_id: '07-tendermint-1374',
connection_id: 'connection-1275',
channel_id: 'channel-4280',
},
},
});
const mkConn = (fwd, rev) => {
/** @type {Readonly<IBCConnectionInfo>} */
const conn = {
id: fwd.connection_id,
client_id: fwd.client_id,
counterparty: {
client_id: rev.client_id,
connection_id: rev.connection_id,
},
transferChannel: {
channelId: fwd.channel_id,
counterPartyChannelId: rev.channel_id,
portId: 'transfer',
counterPartyPortId: 'transfer',
state: 3,
ordering: 0,
version: 'ics20-1',
},
state: 3,
};
return conn;
};

const info = {
agoric: {
bech32Prefix: 'agoric',
chainId: idAg,
stakingTokens: [{ denom: 'ubld' }],
icqEnabled: false,
connections: {
[idNoble]: mkConn(config.agoric.noble, config.noble.agoric),
[idOsmo]: mkConn(config.agoric.osmosis, config.osmosis.agoric),
},
},
noble: {
bech32Prefix: 'noble',
chainId: idNoble,
icqEnabled: false,
connections: {
[idAg]: mkConn(config.noble.agoric, config.agoric.noble),
[idOsmo]: mkConn(config.noble.osmosis, config.osmosis.noble),
},
},
osmosis: {
bech32Prefix: 'osmo',
chainId: 'osmo-test-5',
stakingTokens: [{ denom: 'uosmo' }],
icqEnabled: true,
connections: {
[idAg]: mkConn(config.osmosis.agoric, config.agoric.osmosis),
[idNoble]: mkConn(config.osmosis.noble, config.noble.osmosis),
},
},
};
harden(info);
mustMatch(info, M.recordOf(M.string(), CosmosChainInfoShape));
return info;
})();

export const devnetAssetInfo = makeUSDCAssets({
agoric: devnetChainInfo.agoric.connections['grand-1'],
osmosis: devnetChainInfo.osmosis.connections['grand-1'],
});
harden(devnetAssetInfo);

/**
* @type {Record<string, Pick<FastUSDCConfig, 'oracles' | 'feedPolicy' | 'chainInfo' | 'assetInfo' >>}
*
Expand Down Expand Up @@ -98,22 +210,21 @@ export const configurations = {
},
DEVNET: {
oracles: {
DSRV: 'agoric1lw4e4aas9q84tq0q92j85rwjjjapf8dmnllnft',
Stakin: 'agoric1zj6vrrrjq4gsyr9lw7dplv4vyejg3p8j2urm82',
'01node': 'agoric1ra0g6crtsy6r3qnpu7ruvm7qd4wjnznyzg5nu4',
'Simply Staking': 'agoric1qj07c7vfk3knqdral0sej7fa6eavkdn8vd8etf',
P2P: 'agoric10vjkvkmpp9e356xeh6qqlhrny2htyzp8hf88fk',
gov1: 'agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce',
gov2: 'agoric140dmkrz2e42ergjj7gyvejhzmjzurvqeq82ang',
gov3: 'agoric1w8wktaur4zf8qmmtn3n7x3r0jhsjkjntcm3u6h',
// jcv1: 'agoric1f6au5xffuuph97w85zg9qf062gddsnw0sx9xj3',
// jcv2: 'agoric1vxygktgl0zd7aznq9kw2msdx6gfyz0t0wjreag',
},
feedPolicy: {
nobleAgoricChannelId: 'TODO',
// grand-1->agoricdev-23: channel-304
nobleAgoricChannelId: 'channel-304',
nobleDomainId: 4,
chainPolicies: ChainPolicies.TESTNET,
chainPolicies: ChainPolicies.TESTNET, // TODO: devnet chainPolicies
eventFilter: DepositForBurnEvent,
},
chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ (
withChainCapabilities(fetchedChainInfo) // TODO: use devnet values
),
assetInfo: defaultAssetInfo, // TODO: use emerynet values
chainInfo: devnetChainInfo,
assetInfo: devnetAssetInfo,
},
EMERYNET: {
oracles: {
Expand Down
Loading