All checks were successful
deploy / deploy (push) Successful in 22s
Proof: The funded NEAR Intents operator path should have a stable configured withdrawal destination for the active assets so exits do not depend on retyping recipient addresses. Assumptions: Active asset withdrawal destinations are long-lived operator settings and can safely live in runtime config; actual withdrawals still require explicit unfreeze and operator action. Still fake: Strategy and executor remain disarmed, no live trade quote has been submitted, and the live withdrawal transaction itself has not been exercised yet.
85 lines
3 KiB
JavaScript
85 lines
3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { buildBridgeWithdrawalPlan } from '../src/core/liquidity-withdrawals.mjs';
|
|
|
|
const config = {
|
|
assetRegistry: new Map([
|
|
['nep141:btc.omft.near', {
|
|
assetId: 'nep141:btc.omft.near',
|
|
chain: 'btc:mainnet',
|
|
withdrawAddress: '',
|
|
}],
|
|
['nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near', {
|
|
assetId: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
chain: 'eth:100',
|
|
withdrawAddress: '0x6C40267e03A97B2132e7a7d3159C88534eBEfdFb',
|
|
}],
|
|
]),
|
|
};
|
|
|
|
test('buildBridgeWithdrawalPlan creates an external-chain EURe withdrawal plan', () => {
|
|
const plan = buildBridgeWithdrawalPlan({
|
|
assetId: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
amount: '5000000000000000000',
|
|
destinationAddress: '0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
|
|
supportedTokens: {
|
|
eure: {
|
|
near_token_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
defuse_asset_identifier: 'eth:100:0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430',
|
|
min_withdrawal_amount: '1',
|
|
withdrawal_fee: '200000000000',
|
|
},
|
|
},
|
|
config,
|
|
});
|
|
|
|
assert.deepEqual(plan, {
|
|
asset_id: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
amount: '5000000000000000000',
|
|
chain: 'eth:100',
|
|
destination_address: '0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
|
|
near_token_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
defuse_asset_identifier: 'eth:100:0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430',
|
|
receiver_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
memo: 'WITHDRAW_TO:0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
|
|
min_withdrawal_amount: '1',
|
|
withdrawal_fee: '200000000000',
|
|
});
|
|
});
|
|
|
|
test('buildBridgeWithdrawalPlan rejects amounts below the bridge minimum', () => {
|
|
assert.throws(() => buildBridgeWithdrawalPlan({
|
|
assetId: 'nep141:btc.omft.near',
|
|
amount: '9999',
|
|
destinationAddress: 'bc1qexample',
|
|
supportedTokens: {
|
|
btc: {
|
|
near_token_id: 'btc.omft.near',
|
|
defuse_asset_identifier: 'btc:mainnet:native',
|
|
min_withdrawal_amount: '10000',
|
|
withdrawal_fee: '1500',
|
|
},
|
|
},
|
|
config,
|
|
}), /amount below minimum withdrawal: 10000/);
|
|
});
|
|
|
|
test('buildBridgeWithdrawalPlan falls back to configured asset withdrawal address', () => {
|
|
const plan = buildBridgeWithdrawalPlan({
|
|
assetId: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
amount: '1000000000000000000',
|
|
destinationAddress: '',
|
|
supportedTokens: {
|
|
eure: {
|
|
near_token_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
|
|
defuse_asset_identifier: 'eth:100:0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430',
|
|
min_withdrawal_amount: '1',
|
|
withdrawal_fee: '200000000000',
|
|
},
|
|
},
|
|
config,
|
|
});
|
|
|
|
assert.equal(plan.destination_address, '0x6C40267e03A97B2132e7a7d3159C88534eBEfdFb');
|
|
});
|