diff --git a/scripts/exchange/FusdUsdtSwapPair/addLiquidity.cdc b/scripts/exchange/FusdUsdtSwapPair/addLiquidity.cdc index b42c19a..5ac5362 100644 --- a/scripts/exchange/FusdUsdtSwapPair/addLiquidity.cdc +++ b/scripts/exchange/FusdUsdtSwapPair/addLiquidity.cdc @@ -2,20 +2,16 @@ import FungibleToken from 0xFUNGIBLETOKENADDRESS import FUSD from 0xFUSDADDRESS import TeleportedTetherToken from 0xTELEPORTEDUSDTADDRESS import FusdUsdtSwapPair from 0xFUSDUSDTSWAPPAIRADDRESS -import FusdUsdtSwapPairProxy from 0xFUSDUSDTSWAPPAIRADDRESS transaction(token1Amount: UFix64, token2Amount: UFix64) { // The Vault references that holds the tokens that are being transferred let fusdVault: &FUSD.Vault let tetherVault: &TeleportedTetherToken.Vault - // The proxy holder reference for access control - let swapProxyRef: &FusdUsdtSwapPairProxy.SwapProxy - // The Vault reference for liquidity tokens let liquidityTokenRef: &FusdUsdtSwapPair.Vault - prepare(signer: AuthAccount, proxyHolder: AuthAccount) { + prepare(signer: AuthAccount) { self.fusdVault = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault) ?? panic("Could not borrow a reference to Vault") @@ -43,9 +39,6 @@ transaction(token1Amount: UFix64, token2Amount: UFix64) { self.liquidityTokenRef = signer.borrow<&FusdUsdtSwapPair.Vault>(from: FusdUsdtSwapPair.TokenStoragePath) ?? panic("Could not borrow a reference to Vault") - - self.swapProxyRef = proxyHolder.borrow<&FusdUsdtSwapPairProxy.SwapProxy>(from: FusdUsdtSwapPairProxy.SwapProxyStoragePath) - ?? panic("Could not borrow a reference to proxy holder") } execute { @@ -55,7 +48,7 @@ transaction(token1Amount: UFix64, token2Amount: UFix64) { // Provide liquidity and get liquidity provider tokens let tokenBundle <- FusdUsdtSwapPair.createTokenBundle(fromToken1: <- token1Vault, fromToken2: <- token2Vault) - let liquidityTokenVault <- self.swapProxyRef.addLiquidity(from: <- tokenBundle) + let liquidityTokenVault <- FusdUsdtSwapPair.addLiquidity(from: <- tokenBundle) // Keep the liquidity provider tokens self.liquidityTokenRef.deposit(from: <- liquidityTokenVault) diff --git a/scripts/exchange/FusdUsdtSwapPair/removeLiquidity.cdc b/scripts/exchange/FusdUsdtSwapPair/removeLiquidity.cdc index 3158dfc..7e19222 100644 --- a/scripts/exchange/FusdUsdtSwapPair/removeLiquidity.cdc +++ b/scripts/exchange/FusdUsdtSwapPair/removeLiquidity.cdc @@ -2,28 +2,21 @@ import FungibleToken from 0xFUNGIBLETOKENADDRESS import FUSD from 0xFUSDADDRESS import TeleportedTetherToken from 0xTELEPORTEDUSDTADDRESS import FusdUsdtSwapPair from 0xFUSDUSDTSWAPPAIRADDRESS -import FusdUsdtSwapPairProxy from 0xFUSDUSDTSWAPPAIRADDRESS transaction(amount: UFix64, token1Amount: UFix64, token2Amount: UFix64) { // The Vault reference for liquidity tokens that are being transferred let liquidityTokenRef: &FusdUsdtSwapPair.Vault - // The proxy holder reference for access control - let swapProxyRef: &FusdUsdtSwapPairProxy.SwapProxy - // The Vault references to receive the liquidity tokens let fusdVaultRef: &FUSD.Vault let tetherVaultRef: &TeleportedTetherToken.Vault - prepare(signer: AuthAccount, proxyHolder: AuthAccount) { + prepare(signer: AuthAccount) { assert(amount == token1Amount + token2Amount: "Incosistent liquidtiy amounts") self.liquidityTokenRef = signer.borrow<&FusdUsdtSwapPair.Vault>(from: FusdUsdtSwapPair.TokenStoragePath) ?? panic("Could not borrow a reference to Vault") - self.swapProxyRef = proxyHolder.borrow<&FusdUsdtSwapPairProxy.SwapProxy>(from: FusdUsdtSwapPairProxy.SwapProxyStoragePath) - ?? panic("Could not borrow a reference to proxy holder") - self.fusdVaultRef = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault) ?? panic("Could not borrow a reference to Vault") @@ -36,7 +29,7 @@ transaction(amount: UFix64, token1Amount: UFix64, token2Amount: UFix64) { let liquidityTokenVault <- self.liquidityTokenRef.withdraw(amount: amount) as! @FusdUsdtSwapPair.Vault // Take back liquidity - let tokenBundle <- self.swapProxyRef.removeLiquidity(from: <-liquidityTokenVault, token1Amount: token1Amount, token2Amount: token2Amount) + let tokenBundle <- FusdUsdtSwapPair.removeLiquidity(from: <-liquidityTokenVault, token1Amount: token1Amount, token2Amount: token2Amount) // Deposit liquidity tokens self.fusdVaultRef.deposit(from: <- tokenBundle.withdrawToken1()) diff --git a/scripts/exchange/FusdUsdtSwapPair/swapFusdForUsdt.cdc b/scripts/exchange/FusdUsdtSwapPair/swapFusdForUsdt.cdc index 08b679a..baff1d0 100644 --- a/scripts/exchange/FusdUsdtSwapPair/swapFusdForUsdt.cdc +++ b/scripts/exchange/FusdUsdtSwapPair/swapFusdForUsdt.cdc @@ -2,17 +2,13 @@ import FungibleToken from 0xFUNGIBLETOKENADDRESS import FUSD from 0xFUSDADDRESS import TeleportedTetherToken from 0xTELEPORTEDUSDTADDRESS import FusdUsdtSwapPair from 0xFUSDUSDTSWAPPAIRADDRESS -import FusdUsdtSwapPairProxy from 0xFUSDUSDTSWAPPAIRADDRESS transaction(amountIn: UFix64) { // The Vault references that holds the tokens that are being transferred let fusdVault: &FUSD.Vault let tetherVault: &TeleportedTetherToken.Vault - // The proxy holder reference for access control - let swapProxyRef: &FusdUsdtSwapPairProxy.SwapProxy - - prepare(signer: AuthAccount, proxyHolder: AuthAccount) { + prepare(signer: AuthAccount) { self.fusdVault = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault) ?? panic("Could not borrow a reference to FUSD Vault") @@ -37,15 +33,12 @@ transaction(amountIn: UFix64) { self.tetherVault = signer.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) ?? panic("Could not borrow a reference to tUSDT Vault") - - self.swapProxyRef = proxyHolder.borrow<&FusdUsdtSwapPairProxy.SwapProxy>(from: FusdUsdtSwapPairProxy.SwapProxyStoragePath) - ?? panic("Could not borrow a reference to proxy holder") } execute { let token1Vault <- self.fusdVault.withdraw(amount: amountIn) as! @FUSD.Vault - let token2Vault <- self.swapProxyRef.swapToken1ForToken2(from: <-token1Vault) + let token2Vault <- FusdUsdtSwapPair.swapToken1ForToken2(from: <-token1Vault) self.tetherVault.deposit(from: <- token2Vault) } diff --git a/scripts/exchange/FusdUsdtSwapPair/swapUsdtForFusd.cdc b/scripts/exchange/FusdUsdtSwapPair/swapUsdtForFusd.cdc index c51ec6b..9b22330 100644 --- a/scripts/exchange/FusdUsdtSwapPair/swapUsdtForFusd.cdc +++ b/scripts/exchange/FusdUsdtSwapPair/swapUsdtForFusd.cdc @@ -2,17 +2,13 @@ import FungibleToken from 0xFUNGIBLETOKENADDRESS import FUSD from 0xFUSDADDRESS import TeleportedTetherToken from 0xTELEPORTEDUSDTADDRESS import FusdUsdtSwapPair from 0xFUSDUSDTSWAPPAIRADDRESS -import FusdUsdtSwapPairProxy from 0xFUSDUSDTSWAPPAIRADDRESS transaction(amountIn: UFix64) { // The Vault references that holds the tokens that are being transferred let fusdVault: &FUSD.Vault let tetherVault: &TeleportedTetherToken.Vault - // The proxy holder reference for access control - let swapProxyRef: &FusdUsdtSwapPairProxy.SwapProxy - - prepare(signer: AuthAccount, proxyHolder: AuthAccount) { + prepare(signer: AuthAccount) { self.tetherVault = signer.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) ?? panic("Could not borrow a reference to tUSDT Vault") @@ -37,15 +33,12 @@ transaction(amountIn: UFix64) { self.fusdVault = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault) ?? panic("Could not borrow a reference to FUSD Vault") - - self.swapProxyRef = proxyHolder.borrow<&FusdUsdtSwapPairProxy.SwapProxy>(from: FusdUsdtSwapPairProxy.SwapProxyStoragePath) - ?? panic("Could not borrow a reference to proxy holder") } execute { let token2Vault <- tetherVault.withdraw(amount: amountIn) as! @TeleportedTetherToken.Vault - let token1Vault <- self.swapProxyRef.swapToken2ForToken1(from: <-token2Vault) + let token1Vault <- FusdUsdtSwapPair.swapToken2ForToken1(from: <-token2Vault) self.fusdVault.deposit(from: <- token1Vault) }