Proposal to start sunsetting Bancor V3

Appendix

The Mechanism of Adjusting Trading Liquidity on Bancor V3

The design of the Bancor V3 protocol affords the DAO superb control over factors contributing to the systemic risks mentioned in the previous paragraph. Unlike typical AMMs, Bancor V3 can artificially reduce its bonding curve by partitioning the tokens available in its vault between “on-curve” and “off-curve” components. These mechanics are described in the Comprehensive Description of Bancor 3 section of BIP 15, and can be scrutinized in detail via the Bancor V3 simulation resources. Trading liquidity adjustments were expected to be a fairly routine aspect to management of the protocol. To understand what is being proposed, it is important that the arrangement of Bancor V3 be addressed.

The Master Vault

The Master Vault is where all the protocol tokens are stored. These are the “true” token balances; all deposits and withdrawals occur to and from this contract.

The Staking Ledger

The Staking Ledger is a record of the tokens received by the protocol, and is used to measure deficit and surplus resulting from trading via the protocol’s bonding curves, on a per-token basis (i.e. direct measurement of impermanent loss). When the master vault balance of a token is greater than the staking ledger balance, that token is in surplus; when the master vault balance of a token is less than the staking ledger balance, that token is in deficit.

The Liquidity Pools

The Liquidity Pools do not contain any tokens. The organization of Bancor V3 is inspired by Balancer V2, where the liquidity pools are designed to focus solely on the AMM functionality and are separated from the token management and accounting processes.

New function demo (illustrative purposes only)

from tabulate import tabulate

MASTER_VAULT = {
    'DRC' : 16348845,
    'FODL' : 10174584,
    'DAO' : 3375,
    'AUC' : 6338967,
    'DDX' : 6116,
    'KTN' : 37335,
    'SHEESHA' : 789,
    'APW' : 73710,
    'IDLE' : 32074,
    'HEGIC' : 1641375
    }

STAKING_LEDGER = {
    'DRC' : 1,
    'FODL' : 37,
    'DAO' : 0,
    'AUC' : 274,
    'DDX' : 0,
    'KTN' : 3,
    'SHEESHA' : 0,
    'APW' : 9,
    'IDLE' : 5,
    'HEGIC' : 458
    }

TRADING_LIQUIDITY = {
    'DRC' : {'BNT' : 0, 'DRC' : 0},
    'FODL' : {'BNT' : 0, 'FODL' : 0},
    'DAO' : {'BNT' : 0, 'DAO' : 0},
    'AUC' : {'BNT' : 16205, 'AUC' : 4162871},
    'DDX' : {'BNT' : 0, 'DDX' : 0},
    'KTN' : {'BNT' : 14213, 'KTN' : 23336},
    'SHEESHA' : {'BNT' : 11548, 'SHEESHA' : 789},
    'APW' : {'BNT' : 20370, 'APW' : 25936},
    'IDLE' : {'BNT' : 16327, 'IDLE' : 27518},
    'HEGIC' : {'BNT' : 13247, 'HEGIC' : 468402},
    }

CARBON_FEE_BURNER = {
    'DRC' : 0,
    'FODL' : 0,
    'DAO' : 0,
    'AUC' : 0,
    'DDX' : 0,
    'KTN' : 0,
    'SHEESHA' : 0,
    'APW' : 0,
    'IDLE' : 0,
    'HEGIC' : 0
    }

def nonzero_master_vault_balance(token):
    return(MASTER_VAULT[token] > 0)

def nonzero_trading_liquidity(token):
    return(TRADING_LIQUIDITY[token]['BNT'] > 0)

def token_in_surplus(token):
    return(MASTER_VAULT[token] >= STAKING_LEDGER[token])

def set_trading_liquidity_to_zero(token):
    TRADING_LIQUIDITY[token] = {'BNT' : 0, f'{token}' : 0}
    return(None)
    
def measure_token_POL(token):
    return(MASTER_VAULT[token] - STAKING_LEDGER[token])

def nullify_trading_liquidity(token):
    bnt_destroyed = 0
    if nonzero_master_vault_balance(token):
        if nonzero_trading_liquidity(token):
            if token_in_surplus(token):
                bnt_destroyed = TRADING_LIQUIDITY[token]['BNT']
                set_trading_liquidity_to_zero(token)
    return(bnt_destroyed)
                
def move_POL_to_carbon_fee_burner(token):
    if nonzero_master_vault_balance(token):
        if not nonzero_trading_liquidity(token):
            if token_in_surplus(token):
                CARBON_FEE_BURNER[token] = measure_token_POL(token)
                MASTER_VAULT[token] = STAKING_LEDGER[token]
    return(None)

def printer(token):
    data = [['Master vault', MASTER_VAULT[token], token],
            ['Staking ledger', STAKING_LEDGER[token], token],
            [f'Trading liquidity {token}', TRADING_LIQUIDITY[token][token], token],
            ['Trading liquidity BNT', TRADING_LIQUIDITY[token]['BNT'], 'BNT'],
            ['Carbon fee burner', CARBON_FEE_BURNER[token], token]]
    print(tabulate(data, headers = ['Resource', 'Balance', 'Token'], tablefmt = 'pipe'))
    print("\n")
    return(None)

def demo_new_function(token):
    print(f"The current state of {token} is tabulated below: \n")
    printer(token)

    if nonzero_trading_liquidity(token):
        print(f"The trading liquidity for {token} is currently non-zero. The function call cannot proceed until this is nullified.")
        print("Simulating a DAO vote to nullify the trading liquidity...\n")
        bnt_destroyed = nullify_trading_liquidity(token)
        printer(token)
        print(f"A successful DAO decision has nullified the trading liquidity for {token}.")
        print(f"This action destroyed {bnt_destroyed} BNT. We can now proceed with the function call.\n")

    move_POL_to_carbon_fee_burner(token)
    print(f"After the function call, the new state of {token} on Bancor V3 and the balance transferred to the Carbon fee burner is tabulated below: \n")
    printer(token)
    return(None)

demo_new_function('DRC')
demo_new_function('AUC')
7 Likes