|
| 1 | +import type { NatValue } from '@agoric/ertp'; |
| 2 | +import type { SupportedChain, YieldProtocol } from '../constants.js'; |
| 3 | +import type { InstrumentId } from '../instruments.js'; |
| 4 | +import type { AssetPlaceRef } from '../types.js'; |
| 5 | + |
| 6 | +// Control and transfer planes |
| 7 | +export type ControlProtocol = 'ibc' | 'axelar' | 'local'; |
| 8 | +export type TransferProtocol = |
| 9 | + | 'ibc' |
| 10 | + | 'fastusdc' |
| 11 | + | 'cctpFromNoble' |
| 12 | + | 'cctpToNoble' // (often to a forwarding address) |
| 13 | + | 'cctpV2' |
| 14 | + | 'local'; |
| 15 | +/** |
| 16 | + * Link to Factory and Wallet contracts: |
| 17 | + * https://github.com/agoric-labs/agoric-to-axelar-local/blob/cd6087fa44de3b019b2cdac6962bb49b6a2bc1ca/packages/axelar-local-dev-cosmos/src/__tests__/contracts/Factory.sol |
| 18 | + * |
| 19 | + * Steps submitted to the contract are expected to include fee/gas payment |
| 20 | + * details which vary by the traversed link. |
| 21 | + * - toUSDN: transferring into USDN transfer reduces the *payload* (e.g., $10k |
| 22 | + * might get reduced to $9995) |
| 23 | + * - makeEvmAccount: the fee for executing the Factory contract to create a new |
| 24 | + * remote wallet |
| 25 | + * - evmToNoble: the fee for running the tx to send tokens from the remote |
| 26 | + * wallet to Noble |
| 27 | + * - evmToPool: the fee for sending and executing a tx on the Wallet contract |
| 28 | + * to supply tokens to a specified pool |
| 29 | + * - poolToEvm: the fee for sending and executing a tx on the Wallet contract |
| 30 | + * to withdraw tokens from a specified pool |
| 31 | + */ |
| 32 | +export type FeeMode = |
| 33 | + | 'toUSDN' |
| 34 | + | 'makeEvmAccount' |
| 35 | + | 'evmToNoble' |
| 36 | + | 'evmToPool' |
| 37 | + | 'poolToEvm' |
| 38 | + | 'evmToEvm'; |
| 39 | + |
| 40 | +// Chains (hubs) |
| 41 | +export interface ChainSpec { |
| 42 | + readonly name: SupportedChain; |
| 43 | + /** how agoric reaches this chain: 'ibc' (noble) or 'axelar' (EVM) or 'local' */ |
| 44 | + readonly control: ControlProtocol; |
| 45 | + /** minimum delta amount for planned moves involving this chain */ |
| 46 | + readonly deltaSoftMin?: NatValue; |
| 47 | +} |
| 48 | + |
| 49 | +// Any reason to block withdrawal is by extension also a reason to block |
| 50 | +// deposit. |
| 51 | +type BlockWithdrawReason = 'LOW_LIQUIDITY'; |
| 52 | +type BlockDepositReason = BlockWithdrawReason | 'AT_CAPACITY'; |
| 53 | + |
| 54 | +export type PoolKey = InstrumentId; |
| 55 | + |
| 56 | +// Pools (leaves) |
| 57 | +export interface PoolSpec { |
| 58 | + readonly pool: PoolKey; |
| 59 | + /** host chain of the corresponding instrument */ |
| 60 | + readonly chain: SupportedChain; |
| 61 | + /** protocol of the corresponding instrument */ |
| 62 | + readonly protocol: YieldProtocol; |
| 63 | + /** when increases are unavailable, the (primary) reason why */ |
| 64 | + readonly blockDepositReason?: BlockDepositReason; |
| 65 | + /** when decreases are unavailable, the (primary) reason why */ |
| 66 | + readonly blockWithdrawReason?: BlockWithdrawReason; |
| 67 | +} |
| 68 | + |
| 69 | +/** |
| 70 | + * A +agoric local account or <Deposit>/<Cash> Agoric blockchain contract seat. |
| 71 | + */ |
| 72 | +export interface LocalPlaceSpec { |
| 73 | + readonly id: '<Deposit>' | '<Cash>' | '+agoric'; |
| 74 | + readonly chain: 'agoric'; |
| 75 | +} |
| 76 | + |
| 77 | +/** |
| 78 | + * A directed edge from one place to another, usually having at least one hub |
| 79 | + * endpoint. |
| 80 | + */ |
| 81 | +export interface LinkSpec { |
| 82 | + readonly src: AssetPlaceRef; |
| 83 | + readonly dest: AssetPlaceRef; |
| 84 | + |
| 85 | + /** |
| 86 | + * variable transfer fee in basis points to be applied against the transferred |
| 87 | + * amount of major units (e.g., USDC) |
| 88 | + */ |
| 89 | + readonly variableFeeBps: number; |
| 90 | + /** flat-rate transfer fee in minor units (e.g., uusdc) */ |
| 91 | + readonly flatFee?: NatValue; |
| 92 | + |
| 93 | + /** expected transfer settlement time in seconds */ |
| 94 | + readonly timeSec: number; |
| 95 | + /** inclusive maximum transfer amount in minor units (e.g., uusdc) */ |
| 96 | + readonly capacity?: NatValue; |
| 97 | + /** inclusive minimum transfer amount in minor units (e.g., uusdc) */ |
| 98 | + readonly min?: NatValue; |
| 99 | + |
| 100 | + /** mechanism by which the transfer occurs */ |
| 101 | + readonly transfer: TransferProtocol; |
| 102 | + /** designator for how fees apply to transactions over this link */ |
| 103 | + readonly feeMode?: FeeMode; |
| 104 | +} |
| 105 | + |
| 106 | +/** Details of how chains/pools/etc. and how they connect. */ |
| 107 | +export interface NetworkSpec { |
| 108 | + readonly debug?: boolean; |
| 109 | + readonly environment?: 'dev' | 'test' | 'prod'; |
| 110 | + |
| 111 | + readonly chains: ChainSpec[]; |
| 112 | + readonly pools: PoolSpec[]; |
| 113 | + readonly localPlaces?: LocalPlaceSpec[]; |
| 114 | + readonly links: LinkSpec[]; |
| 115 | +} |
0 commit comments